public List <int> GetMoreThanCardVal(ref CardVector vec, CardSize minVal, int minCount, int maxCount = 0) { List <CardSize> arr = new List <CardSize>(); List <int> resultCards = new List <int>(); List <CardSize> keys = vec.GetKeys(); for (int i = 0; i < keys.Count; ++i) { CardSize key = keys[i]; if (0 == i && key > minVal && key < mC2) { arr.Add(key); } else if (key > minVal) { CardSize preKey = keys[i - 1]; if (preKey == key - 1 && key < mC2) { arr.Add(key); if (0 == maxCount && arr.Count == minCount) { break; } } else { if (arr.Count >= minCount) { break; } else { arr = new List <CardSize>(); arr.Add(key); } } } } int length = arr.Count; if (length >= minCount) { for (int i = 0; i < length; ++i) { if ((0 == maxCount && i == minCount) || (0 < maxCount && i >= maxCount - 1)) { break; } CopyList(vec.Get(arr[i]), ref resultCards); } } return(resultCards); }
//检查单牌是否可加到顺子中,返回剩余牌 public List <int> CheckSingleAsShun(List <int> handCard, ref CardVector vec) { CardVector shunVec = vec; List <CardSize> keys = shunVec.GetKeys(); if (0 == keys.Count) { return(handCard); } List <int> lastCards = new List <int>(); foreach (int card in handCard) { bool suc = false; foreach (CardSize key in keys) { List <int> items = shunVec.Get(key); if (0 == items.Count) { continue; } CardSize min = GetCardSize(items[0]); CardSize max = GetCardSize(items[items.Count - 1]); CardSize val = GetCardSize(card); if (val == min - 1) { items.Insert(0, (int)val); suc = true; break; } else if (val == max + 1) { items.Add((int)val); suc = true; break; } } if (!suc) { lastCards.Add(card); } } return(lastCards); }
//去除对子至Vector对象,返回剩余牌 public List <int> GetTwoCard(List <int> handCard, ref CardVector vec, bool matchThree = false) { List <int> lastCards = GetSameCard(handCard, 2, ref vec); if (matchThree) { CardVector threeVec = new CardVector(DeckType.Three); lastCards = GetSameCard(handCard, 3, ref threeVec); if (0 < threeVec.GetCount()) { List <CardSize> keys = threeVec.GetKeys(); foreach (CardSize key in keys) { List <int> val = threeVec.Get(key); List <int> arr = new List <int>(); CopyList(val, ref arr, 0, 2); vec.Add(key, arr); } } } return(lastCards); }