Exemplo n.º 1
0
        public DrawResponse OnDraw(VisibleBoard board, Tile tile, DrawActions suggestedActions)
        {
            if (suggestedActions.HasFlag(DrawActions.Tsumo))
            {
                return(DrawResponse.Tsumo());
            }

            if (suggestedActions.HasFlag(DrawActions.Riichi))
            {
                var tileTypeId = board.Watashi.Hand.GetHighestUkeIreDiscard();
                var discard    = board.Watashi.ConcealedTiles.First(i => i.TileType.TileTypeId == tileTypeId);
                return(DrawResponse.Riichi(discard));
            }

            if (suggestedActions.HasFlag(DrawActions.KyuushuKyuuhai) && (board.Watashi.Hand.Shanten > 2 || board.Seats.Any(s => s.DeclaredRiichi)))
            {
                return(DrawResponse.KyuushuKyuuhai());
            }

            {
                var tileTypeId = board.Watashi.Hand.GetHighestUkeIreDiscard();
                // Prefer tsumogiri
                if (tile.TileType.TileTypeId == tileTypeId)
                {
                    return(DrawResponse.Discard(tile));
                }

                var discard = board.Watashi.ConcealedTiles.First(i => i.TileType.TileTypeId == tileTypeId);
                return(DrawResponse.Discard(discard));
            }
        }
Exemplo n.º 2
0
        public DrawResponse OnDraw(VisibleBoard board, Tile tile, DrawActions suggestedActions)
        {
            if ((suggestedActions & DrawActions.Tsumo) != 0)
            {
                return(DrawResponse.Tsumo());
            }

            if ((suggestedActions & DrawActions.KyuushuKyuuhai) != 0)
            {
                return(DrawResponse.KyuushuKyuuhai());
            }

            if ((suggestedActions & DrawActions.Kan) != 0)
            {
                var ankanTileType = board.Watashi.ConcealedTiles.GroupBy(t => t.TileType).FirstOrDefault(t => t.Count() == 4)?.Key;
                if (ankanTileType != null)
                {
                    return(DrawResponse.Ankan(ankanTileType));
                }

                var shouminkanTile = board.Watashi.ConcealedTiles.FirstOrDefault(t => board.Watashi.Melds.Any(m => m.MeldType == MeldType.Koutsu && m.LowestTile.TileType == t.TileType));
                if (shouminkanTile != null)
                {
                    return(DrawResponse.Shouminkan(tile));
                }
            }

            return(DrawResponse.Discard(FindDiscard(board)));
        }