Beispiel #1
0
        public PlayerVsStatisticBotTakeDrawCommandResult ExecuteCommand(PlayerVsStatisticBotTakeDrawCommand command)
        {
            PlayerVsStatisticBotTakeDrawCommandResult result;

            using (var context = new TicTacToeContext())
            {
                var game  = context.Set <Game>().Include(game1 => game1.Field).FirstOrDefault(game1 => game1.GameId == command.GameId);
                var field = game.Field;

                var fieldCode = GameHelper.GetFieldByNumber(game.FieldNumber, field);
                var gameField = this.fieldStateConverter.StringToGameField(fieldCode);

                GameHelper.RefreshStatistic(game.GameId, GameStatus.Draw, context);

                context.Set <Game>().Remove(game);
                context.SaveChanges();

                result = new PlayerVsStatisticBotTakeDrawCommandResult
                {
                    CellSize  = GameFieldConstants.LineLength,
                    GameField = gameField,
                };
            }

            return(result);
        }
        public ActionResult TakeDraw(PlayerVsStatisticBotTakeDrawCommand command)
        {
            var answer = this.playerVsStatisticBotCommandHandler.ExecuteCommand(command);

            return(this.View(answer));
        }