Example #1
0
        private FuuroGroup tryGetFuuroGroup(FuuroType type, IEnumerable <Tuple <int, int> > req, params Tile[] tiles)
        {
            var res = new FuuroGroup();

            res.type = type;

            foreach (var reqItem in req)
            {
                var tmp = new List <Tile>();
                tmp.AddRange(player.hand.Where(t => t.GenaralId == reqItem.Item1 && !tiles.Any(t2 => t == t2) && t.isRedDora));
                tmp.AddRange(player.hand.Where(t => t.GenaralId == reqItem.Item1 && !tiles.Any(t2 => t == t2) && !t.isRedDora));
                if (tmp.Count >= reqItem.Item2)
                {
                    res.AddRange(tmp.Take(reqItem.Item2));
                }
                else
                {
                    return(null);
                }
            }

            res.AddRange(tiles);

            return(res);
        }
Example #2
0
        private FuuroGroup HandleAnkan(Player currentPlayer, string tileName)
        {
            tileName = tileName.Replace('0', '5');

            FuuroGroup fuuroGroup = new FuuroGroup();

            fuuroGroup.type = FuuroType.ankan;

            if (currentPlayer == player)
            {
                IEnumerable <Tile> tiles = player.hand.Where(t => t.GeneralName == tileName).ToList();
                fuuroGroup.AddRange(tiles);
                player.hand.RemoveRange(tiles);
            }
            else
            {
                if (tileName[0] == '5' && tileName[1] != 'z') // 暗杠中有红牌
                {
                    fuuroGroup.Add(new Tile(tileName));
                    fuuroGroup.Add(new Tile(tileName));
                    fuuroGroup.Add(new Tile(tileName));
                    fuuroGroup.Add(new Tile("0" + tileName[1]));
                }
                else
                {
                    for (var i = 0; i < 4; i++)
                    {
                        fuuroGroup.Add(new Tile(tileName));
                    }
                }
            }

            currentPlayer.fuuro.Add(fuuroGroup);
            return(fuuroGroup);
        }