public void ProcessCommand(IBattleManager battleManager, params string[] arguments) { if (battleManager == null) { throw new ArgumentNullException("battleManager"); } if (arguments == null) { throw new ArgumentNullException("arguments"); } if (arguments.Length < 2) { throw new ArgumentException("Invalid number of arguments for attack command"); } var attackerIdentifierString = arguments[0]; var attackerIdentifier = CreatureIdentifier.CreatureIdentifierFromString(attackerIdentifierString); var defenderIdentifierString = arguments[1]; var defenderIdentifier = CreatureIdentifier.CreatureIdentifierFromString(defenderIdentifierString); battleManager.Attack(attackerIdentifier, defenderIdentifier); }
public void ProcessCommand(string commandLine, IBattleManager battleManager) { if (commandLine == null) { throw new ArgumentNullException("commandLine"); } var commandParts = commandLine.Split(' '); var commandName = commandParts[0]; if (!this.commands.ContainsKey(commandName)) { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, "Invalid command name \"{0}\"", commandName)); } var command = this.commands[commandName]; var commandArguments = commandParts.Skip(1).ToArray(); command.ProcessCommand(battleManager, commandArguments); }
public void ProcessCommand(IBattleManager battleManager, params string[] arguments) { if (battleManager == null) { throw new ArgumentNullException("battleManager"); } if (arguments == null) { throw new ArgumentNullException("arguments"); } if (arguments.Length < 1) { throw new ArgumentException("Invalid number of arguments for skip command"); } var creatureIdentifierString = arguments[0]; var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString(creatureIdentifierString); battleManager.Skip(creatureIdentifier); }
public void ProcessCommand(IBattleManager battleManager, params string[] arguments) { if (battleManager == null) { throw new ArgumentNullException("battleManager"); } if (arguments == null) { throw new ArgumentNullException("arguments"); } if (arguments.Length < 2) { throw new ArgumentException("Invalid number of arguments for add command"); } var count = int.Parse(arguments[0], CultureInfo.InvariantCulture); var creatureIdentifierString = arguments[1]; var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString(creatureIdentifierString); battleManager.AddCreatures(creatureIdentifier, count); }
public void ProcessCommand(IBattleManager battleManager, params string[] arguments) { Environment.Exit(0); }