判断一手牌中的牌是否可以胡牌,思路是选出将手牌中的对子,将手牌中的对子牌“去掉”后(将这个牌添加到一个叫DUIZI的list里),将去掉对子的手牌进行连牌与同牌判断
,将“连牌与同牌”的list进行M选N操作,如果选出的种类不等于0那么可以判定出是普通胡牌,对于自摸与非自摸的区分在于传入的是在“接牌”后形成的胡牌,还是其他玩家
“出完”牌后形成的胡牌。
static List<int> ReconsCards(int[] cbCardIndex, List<FrontageItem> Frontage)
{
List<int> DuiZi = new List<int>();
List<int> DuiZi1 = new List<int>();
DuiZi.Clear();
DuiZi1.Clear();
for (int i = 0; i < cbCardIndex.Length; i++)
{
if (cbCardIndex[i] == 2)
{
DuiZi1.Add(i);
}
}
int[] DuiZi2 = new int[DuiZi1.Count];
for (int a = 0; a < DuiZi2.Length; a++)
{
DuiZi2[a] = DuiZi1[a];
}
for (int b = 1; b < DuiZi2.Length; b++)
{
if (DuiZi2[b - 1] != (DuiZi2[b] - 1) && cbCardIndex[DuiZi2[b] - 1] == 0)
{
cbCardIndex[DuiZi2[b]] = 0;
DuiZi.Add(DuiZi2[b]);
break;
}
else
{
cbCardIndex[DuiZi2[b - 1]] = 0;
DuiZi.Add(DuiZi2[b - 1]);
break;
}
}
for (int b = 0; b < DuiZi2.Length; b++)
{
if(DuiZi.Count==0)
{
int value = IndexSwitchToCard(DuiZi2[b]);
if ((value & MASK_VALUE) == 9 || (value & MASK_VALUE) == 1)
{
cbCardIndex[DuiZi2[b]] = 0;
DuiZi.Add(DuiZi2[b]);
DuiZi2[b] = 0;
break;
}
}
}
if (DuiZi2.Length == 1)
{
if (DuiZi2[0] != 0)
{
cbCardIndex[DuiZi2[0]] = 0;
DuiZi.Add(DuiZi2[0]);
}
}
if (DuiZi.Count==0)
{
for (int i = 0; i < cbCardIndex.Length; i++)
{
if (cbCardIndex[i] >= 3)
{
if ((i % 9) < 7)
{
if (cbCardIndex[i] + cbCardIndex[i + 1] + cbCardIndex[i + 2] >= 3 && cbCardIndex[i + 1] == 1 && cbCardIndex[i + 2] == 1)
{
cbCardIndex[i] = cbCardIndex[i] - 2;
DuiZi.Add(i);
break;
}
}
if ((i % 9) > 1 && (i % 9) < 7)
{
if ((cbCardIndex[i] + cbCardIndex[i - 1] + cbCardIndex[i + 1] >= 3 && cbCardIndex[i + 1] == 1 && cbCardIndex[i - 1] == 1 && cbCardIndex[i + 2] != 3) ||( cbCardIndex[i] + cbCardIndex[i - 1] + cbCardIndex[i + 1] >= 3 && cbCardIndex[i + 1] == 1 && cbCardIndex[i - 1] == 1 && cbCardIndex[i + 2] == 3 && cbCardIndex[i - 2] == 3))
{
cbCardIndex[i] = cbCardIndex[i] - 2;
DuiZi.Add(i);
break;
}
}
if ((i % 9) > 1)
{
if (cbCardIndex[i] + cbCardIndex[i - 1] + cbCardIndex[i -2] >= 3 && cbCardIndex[i-1] == 1 && cbCardIndex[i -2] == 1 )
{
cbCardIndex[i] = cbCardIndex[i] - 2;
DuiZi.Add(i);
break;
}
}
}
}
}
return DuiZi;
}
下一章胡牌之整体比较