コード例 #1
0
            internal override void MakeMove(
                PlayerEntity player,
                long tileId,
                ITrain train)
            {
                var tile = player
                           .Hand
                           .First(t => t.Id == tileId);

                var openDoubleIds = Games
                                    .Get(player.gameId)
                                    .GetOpenDoubleTileIds()
                                    .ToArray();

                if (openDoubleIds.Any() &&
                    !Games
                    .Get(player.gameId)
                    .GetPlayedTile(openDoubleIds.First())
                    .IsMatch(tile))
                {
                    throw new ApplicationException($"Illegal move. Must play on first present open double which is '{Games.Get(player.gameId).GetPlayedTile(openDoubleIds.First())}'. The played tile '{tile}' is not a match.");
                }

                train.AddTile(
                    tile,
                    player.Id);
                player.Hand =
                    new HashSet <DominoTileEntity>(
                        player.Hand.Where(t => t.Id != tile.Id));
            }