Skip to content

Commit

Permalink
fix: Implement IAliasable in RouteCommand instead of RouteMoonCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Computerdores committed Apr 16, 2024
1 parent 588dd85 commit c5a8c3b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EjectCommand : ICommand, IPredictable {
/// <summary>
/// For the vanilla implementation see: <see cref="Terminal.RunTerminalEvents"/>.
/// </summary>
public CommandResult Execute(string input, ITerminal terminal) { // TODO test
public CommandResult Execute(string input, ITerminal terminal) {
Terminal vT = terminal.GetDriver().VanillaTerminal;

if (!_awaitingConfirmation) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;

namespace Computerdores.AdvancedTerminalAPI.Vanillin.Commands;

public class RouteCommand : ICommand, IPredictable {
public class RouteCommand : ICommand, IPredictable, IAliasable {
private RouteMoonCommand _command;

private bool _awaitingConfirmation;
Expand All @@ -28,6 +29,11 @@ public string PredictInput(string partialInput)

return _command?.Execute(words.Skip(1).Join(delimiter: " "), terminal) ?? CommandResult.IGNORE_INPUT;
}

public IEnumerable<ICommand> GetAll(ITerminal term) {
return from noun in Util.FindKeyword(term, "route").compatibleNouns
select new RouteMoonCommand(noun.noun.word, _vT);
}

public ICommand CloneStateless() => new RouteCommand(_vT);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System.Collections.Generic;
using System.Linq;
namespace Computerdores.AdvancedTerminalAPI.Vanillin.Commands;

namespace Computerdores.AdvancedTerminalAPI.Vanillin.Commands;

public class RouteMoonCommand : ICommand, IAliasable, IPredictable {
public class RouteMoonCommand : ICommand, IPredictable {
private readonly string _moonName;

private bool _awaitingConfirmation;
private CompatibleNoun _moon;

private readonly Terminal _vT;

private RouteMoonCommand(string moonName, Terminal vT) {
public RouteMoonCommand(string moonName, Terminal vT) {
_vT = vT;
_moonName = moonName;
}
Expand Down Expand Up @@ -49,11 +46,6 @@ public class RouteMoonCommand : ICommand, IAliasable, IPredictable {
}

public ICommand CloneStateless() => new RouteMoonCommand(_moonName, _vT);

public IEnumerable<ICommand> GetAll(ITerminal term) {
return from noun in Util.FindKeyword(term, "route").compatibleNouns
select new RouteMoonCommand(noun.noun.word, _vT);
}

public static RouteMoonCommand FromPlayerInput(Terminal term, string input) {
return new RouteMoonCommand(Util.FindKeyword(term, "route").
Expand Down

0 comments on commit c5a8c3b

Please sign in to comment.