Exemplo n.º 1
0
        public Player ChangePlayerPiece(LudoGame game, string gameId, int playerId, int pieceId, int numberOfFields)
        {
            var gamestate = game.GetGameState();

            if (gamestate != GameState.Started)
            {
                game.StartGame();
            }
            else if (gamestate != GameState.Ended)
            {
                var player = game.GetPlayers().FirstOrDefault(x => x.PlayerId == playerId);
                game.MovePiece(player, pieceId, numberOfFields);
            }

            var winner = game.GetWinner();

            if (winner is null)
            {
                return(null);
            }

            return(winner);
        }