Ejemplo n.º 1
0
        public bool IsAllSameSuitType(List <Poker> pokers)
        {
            int suitType = PokerSuitType.NULL;

            foreach (var p in pokers)
            {
                if (_value.IsHeartHost(p))
                {
                    continue;
                }

                if (suitType != PokerSuitType.NULL)
                {
                    if (p.SuitType != suitType)
                    {
                        return(false);
                    }
                }
                else
                {
                    suitType = p.SuitType;
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public void BuildPokerPool()
        {
            _pokerPool.Clear();
            _pilePool.Clear();
            _xxdd = null;
            _heartHosts.Clear();

            if (_myPokers.Count <= 0)
            {
                return;
            }

            var piles = new Dictionary <int, PokerPile>();

            foreach (var p in _myPokers)
            {
                if (_value.IsHeartHost(p))
                {
                    _heartHosts.Add(p);
                }
                else
                {
                    List <Poker> list = null;
                    if (_pokerPool.ContainsKey(p.NumType))
                    {
                        list = _pokerPool[p.NumType];
                    }

                    if (list == null)
                    {
                        list = new List <Poker>();
                        _pokerPool[p.NumType] = list;
                    }

                    list.Add(p);

                    PokerPile pile = null;
                    if (piles.ContainsKey(p.NumType))
                    {
                        pile = piles[p.NumType];
                    }

                    if (pile == null)
                    {
                        pile             = new PokerPile(p.NumType);
                        piles[p.NumType] = pile;
                    }

                    pile.AddPoker(1);
                }
            }

            foreach (var pp in piles.Values)
            {
                List <PokerPile> list = null;
                if (_pilePool.ContainsKey(pp.Count))
                {
                    list = _pilePool[pp.Count];
                }

                if (list == null)
                {
                    list = new List <PokerPile>();
                    _pilePool[pp.Count] = list;
                }

                var added = false;
                for (int i = 0; i < list.Count; i++)
                {
                    if (_value.ValueOf(pp.NumType) < _value.ValueOf(list[i].NumType))
                    {
                        list.Insert(i, pp);
                        added = true;
                        break;
                    }
                }

                if (!added)
                {
                    list.Add(pp);
                }
            }

            List <PokerPile> piles2 = null;

            if (_pilePool.ContainsKey(2))
            {
                piles2 = _pilePool[2];
            }

            if (piles2 != null && piles2.Count >= 2)
            {
                var pd = piles2[piles2.Count - 1];
                var px = piles2[piles2.Count - 2];

                if (px.NumType == PokerNumType.PX &&
                    pd.NumType == PokerNumType.PD)
                {
                    var pw = new List <PokerPile>();
                    pw.Add(px);
                    pw.Add(pd);
                    px.Next = pd;
                    _xxdd   = px;
                    piles2.Remove(px);
                    piles2.Remove(pd);

                    if (piles2.Count <= 0)
                    {
                        _pilePool.Remove(2);
                    }
                }
            }
        }