//增加到vector集合以及wang,bomb,three,two,one分类 public void AddVector(ref CardVector vec, CardSize val, List <int> list) { int len = list.Count; if (0 < len && val >= mCW1) { vec.GetChild(DeckType.WangBomb).Add(val, list); } else if (4 == len) { vec.GetChild(DeckType.Bomb).Add(val, list); } else if (3 == len) { vec.GetChild(DeckType.Three).Add(val, list); } else if (2 == len) { vec.GetChild(DeckType.Double).Add(val, list); } else if (1 == len) { vec.GetChild(DeckType.Single).Add(val, list); } }
//计算出牌手数 public int GetVectorHandleTimes(CardVector vec) { int times = 0; if (0 < vec.GetChild(DeckType.WangBomb).GetCount()) { times += 1; } int bombLen = vec.GetChild(DeckType.Bomb).GetCount(); if (0 < bombLen) { times += bombLen; } times += vec.GetChild(DeckType.Shunzi).GetCount(); int threeLen = vec.GetChild(DeckType.Three).GetCount(); if (0 < threeLen) { times += threeLen; } int twoLen = vec.GetChild(DeckType.Double).GetCount(); if (0 < twoLen) { times += twoLen; } int oneLen = vec.GetChild(DeckType.Single).GetCount(); if (0 < oneLen) { times += oneLen; } times -= threeLen * 1; return(times); }
//计算对牌数 public int GetTwoCount(CardVector vec) { return(vec.GetChild(DeckType.Double).GetCount()); }
//计算单牌数 public int GetSingleCount(CardVector vec) { return(vec.GetChild(DeckType.Single).GetCount()); }
//取出无关联的牌,返回剩余的关联牌 public List <int> GetUnrelatedCard(List <int> handCard, ref CardVector vec) { List <int> arr = new List <int>(); List <int> lastCards = new List <int>(); CardSize eqVal = 0; int count = handCard.Count; if (count < 2) { return(handCard); } for (int i = 0; i < count; ++i) { int card = handCard[i]; CardSize val = GetCardSize(card); if (0 == i) { arr.Add(card); continue; } int preCard = handCard[i - 1]; CardSize preVal = GetCardSize(preCard); if (val == preVal) { arr.Add(card); } else { if ((preVal >= mC2) || (((0 == eqVal) || (eqVal != preVal - 1)) && ((val == mC2) || preVal < val - 1))) { AddVector(ref vec, preVal, arr); } else { lastCards.AddRange(arr); } arr = new List <int>(); eqVal = preVal; arr.Add(card); } if (i == count - 1) { if (val >= mC2 || eqVal < val - 1) { if (val == mCW1 || (preVal < mCW1 && val == mCW2)) { vec.GetChild(DeckType.Single).Add(val, new List <int>(card)); } else { lastCards.AddRange(arr); } } } } return(lastCards); }