Exemplo n.º 1
0
        public static Changes GetChanges(this Game2.Game game, Game2.Commands.PlayerMoveCommand cmd)
        {
            var affectedCells = game.Attack(cmd);

            return(new Changes
            {
                status = game.Winner,
                valid = affectedCells.Any(),
                nextMove = new Cell {
                },
                nextPlayer = game.NextPlayer,
                cells = affectedCells.Select(cell => new Cell
                {
                    type = cell.Type == Game2.CellType.Destroyed ? CellType.Killed : CellType.Missed,
                    x = cell.X,
                    y = cell.Y
                }).ToList(),
                x = cmd.Move.X,
                y = cmd.Move.Y
            });
        }
Exemplo n.º 2
0
        public static InitData GetInitData(this Game2.Game game, int playerIndex)
        {
            var player1 = game.Player1;
            var player2 = game.Player2;

            if (playerIndex == 1)
            {
                player1 = game.Player2;
                player2 = game.Player1;
            }

            return(new InitData
            {
                name = game.Name,
                player = playerIndex,
                nextPlayer = game.NextPlayer,
                nextMove = new Cell[] { },
                fields = new[]
                {
                    GetCells(GetCellTypeSelf(player1)),
                    GetCells(GetCellTypeEnemy(player2))
                }
            });
        }