Ejemplo n.º 1
0
        public ICommand CreatePlayerCommand(string commandName)
        {
            ICommand resultCommand;

             if (this.commands.ContainsKey(commandName))
             {
                 return this.commands[commandName];
             }

             var commandNameLowerCase = commandName.ToLower();
             switch (commandNameLowerCase)
             {
                 case "kdl":
                     resultCommand = new KingDownLeftCommand();
                     break;
                 case "kdr":
                     resultCommand = new KingDownRightCommand();
                     break;
                 case "kul":
                     resultCommand = new KingUpLeftCommand();
                     break;
                 case "kur":
                     resultCommand = new KingUpRightCommand();
                     break;
                 case "adl":
                     resultCommand = new PawnADownLeftCommand();
                     break;
                 case "adr":
                     resultCommand = new PawnADownRightCommand();
                     break;
                 case "bdl":
                     resultCommand = new PawnBDownLeftCommand();
                     break;
                 case "bdr":
                     resultCommand = new PawnBDownRightCommand();
                     break;
                 case "cdl":
                     resultCommand = new PawnCDownLeftCommand();
                     break;
                 case "cdr":
                     resultCommand = new PawnCDownRightCommand();
                     break;
                 case "ddl":
                     resultCommand = new PawnDDownLeftCommand();
                     break;
                 case "ddr":
                     resultCommand = new PawnDDownRightCommand();
                     break;
                 case "undo":
                     resultCommand = new UndoCommand();
                     break;
                 default:
                     throw new ArgumentException("Incorrect command " + commandName);
             }

             this.commands.Add(commandName, resultCommand);
             return resultCommand;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method for creting player command depend on the command name
        /// </summary>
        /// <param name="commandName">Name od the command</param>
        /// <returns></returns>
        public ICommand CreatePlayerCommand(string commandName)
        {
            ICommand resultCommand;

             if (this.commands.ContainsKey(commandName))
             {
                 return this.commands[commandName];
             }

             var commandNameLowerCase = commandName.ToLower();
             switch (commandNameLowerCase)
             {
                 case Constants.KingDownLeftCommand:
                     resultCommand = new KingDownLeftCommand();
                     break;
                 case Constants.KingDownRightCommand:
                     resultCommand = new KingDownRightCommand();
                     break;
                 case Constants.KingUpLeftCommand:
                     resultCommand = new KingUpLeftCommand();
                     break;
                 case Constants.KingUpRightCommand:
                     resultCommand = new KingUpRightCommand();
                     break;
                 case Constants.AdlCommand:
                     resultCommand = new PawnADownLeftCommand();
                     break;
                 case Constants.AdrCommand:
                     resultCommand = new PawnADownRightCommand();
                     break;
                 case Constants.BdlCommand:
                     resultCommand = new PawnBDownLeftCommand();
                     break;
                 case Constants.BdrCommand:
                     resultCommand = new PawnBDownRightCommand();
                     break;
                 case Constants.CdlCommand:
                     resultCommand = new PawnCDownLeftCommand();
                     break;
                 case Constants.CdrCommand:
                     resultCommand = new PawnCDownRightCommand();
                     break;
                 case Constants.DdlCommand:
                     resultCommand = new PawnDDownLeftCommand();
                     break;
                 case Constants.DdrCommand:
                     resultCommand = new PawnDDownRightCommand();
                     break;
                 case Constants.UndoCommand:
                     resultCommand = new UndoCommand();
                     break;
                 default:
                     throw new InvalidCommandException("Invalid command " + commandName);
             }

             this.commands.Add(commandName, resultCommand);
             return resultCommand;
        }