private Func <bool> CreateSingleCondition(string conditionString) { var command = CommandModel.Parse(conditionString); if (command.Subject != "Inventory") { throw new GameInitializationException($"Now we only support conditions for inventory. Command: {conditionString}"); } if (command.Action != "Has") { throw new GameInitializationException("Now we only support 'has' conditions"); } EnsureCountOfArguments(command, 1); return(() => playerInventory.HasItem(x => x.Name == command.Arguments[0])); }
private Action CreateSingleAction(string fullCommandString) { var command = CommandModel.Parse(fullCommandString); switch (command.Subject) { case "Inventory": switch (command.Action) { case "Add": EnsureCountOfArguments(command, 1); return(() => { Debug.Log($"Adding {command.Arguments[0]}"); playerInventory.Add(Crutches.Inventory.Items[command.Arguments[0]]); }); case "Remove": EnsureCountOfArguments(command, 1); return(() => { playerInventory.RemoveByName(command.Arguments[0]); }); } break; case "World": switch (command.Action) { case "Add": EnsureCountOfArguments(command, 1); switch (command.Arguments[0]) { case "SceneTransferTwinkieHouse": return(() => Crutches.World.Add.SceneTransfer("SceneTransferToHouse")); case "SceneTransferShoreToPond": return(() => Crutches.World.Add.SceneTransfer("SceneTransferShoreToPond")); case "RecorderForFim": return(Crutches.World.Add.RecorderForFim); } break; case "Change": EnsureCountOfArguments(command, 1); switch (command.Arguments[0]) { case "Nest": return(Crutches.World.Change.Nest); case "RecordPlayer": return(Crutches.World.Change.RecordPlayer); } break; case "Remove": EnsureCountOfArguments(command, 1); switch (command.Arguments[0]) { case "Rupert": return(Crutches.World.Remove.Rupert); case "Hat": return(Crutches.World.Remove.Hat); } break; } break; } throw new GameInitializationException($"Cannot parse command {fullCommandString}"); }