public override void CheckWinner() { SicboInfo tableInfo = (SicboInfo)_GameTable.GetTableInfo(); // 查看是否需要控制 E_CARD_TYPE[] enCardType = new E_CARD_TYPE[SicboDefine.COUNT_AZIMUTH]; int iCardTypeCount = 0; int i = 0; for (i = 0; i < SicboDefine.COUNT_AZIMUTH; ++i) { enCardType[i] = E_CARD_TYPE.enCardType_Illegal; } int[] cards = tableInfo.m_enCards; do { Random random = new Random(); cards[0] = (random.Next() % 6 + 1); cards[1] = (random.Next() % 6 + 1); cards[2] = (random.Next() % 6 + 1); int iCountNum = cards[0] + cards[1] + cards[2]; if (((cards[0] == cards[1]) && (cards[1] == cards[2])) || // 三个相同 ((int)E_CARD_TYPE.enCardType_NumberFour == iCountNum) || ((int)E_CARD_TYPE.enCardType_NumberSeventeen == iCountNum)) { ++tableInfo.m_iSameCount; if (tableInfo.m_iSameCount < 30) { System.Threading.Thread.Sleep(10); continue; } tableInfo.m_iSameCount = 0; } } while (false); _GameLogic.GetCardType(cards, enCardType, ref iCardTypeCount); for (i = 0; i < iCardTypeCount; ++i) { if (E_CARD_TYPE.enCardType_Illegal != enCardType[i]) { tableInfo.m_bWinner[(int)enCardType[i]] = 1; } } }
// 获取牌型 public bool GetCardType(int[] enCardsBuffer, E_CARD_TYPE[] enCardType, ref int iCardTypeCount) { iCardTypeCount = 0; // 先要找出围骰 // 获取点数个数 int i = 0; for (i = 0; i < SicboDefine.MAX_SICBO_NUMBER; ++i) { int iCount = GetSicboCountByNumber(enCardsBuffer, m_enSicboData[i]); if (SicboDefine.MAX_COUNT_SICBO == iCount) { enCardType[iCardTypeCount] = E_CARD_TYPE.enCardType_SicboThreeSame; ++iCardTypeCount; enCardType[iCardTypeCount] = (E_CARD_TYPE)(E_CARD_TYPE.enCardType_SicboThreeOne + i); ++iCardTypeCount; enCardType[iCardTypeCount] = (E_CARD_TYPE)(E_CARD_TYPE.enCardType_SicboOne + i); ++iCardTypeCount; return(true); // 不会有其他的牌型了 } else if (iCount > 0) // 不存在围骰 { break; } } // 获取点数 E_CARD_TYPE enCardTypeTemp = IsSicboNumber(enCardsBuffer); if (E_CARD_TYPE.enCardType_Illegal != enCardTypeTemp) { enCardType[iCardTypeCount] = enCardTypeTemp; ++iCardTypeCount; // 获取大小 if (enCardTypeTemp > E_CARD_TYPE.enCardType_NumberTen) { enCardType[iCardTypeCount] = E_CARD_TYPE.enCardType_Big; } else { enCardType[iCardTypeCount] = E_CARD_TYPE.enCardType_Small; } ++iCardTypeCount; } // 获取单双 enCardTypeTemp = IsSicboSingleDouble(enCardsBuffer); if (E_CARD_TYPE.enCardType_Illegal != enCardTypeTemp) { enCardType[iCardTypeCount] = enCardTypeTemp; ++iCardTypeCount; } // 获取点数个数 for (i = 0; i < SicboDefine.MAX_SICBO_NUMBER; ++i) { int iCount = GetSicboCountByNumber(enCardsBuffer, m_enSicboData[i]); if (iCount > 0) { enCardType[iCardTypeCount] = (E_CARD_TYPE)(E_CARD_TYPE.enCardType_SicboOne + i); ++iCardTypeCount; // 有一个才有两个 if (iCount > 1) { enCardType[iCardTypeCount] = (E_CARD_TYPE)(E_CARD_TYPE.enCardType_SicboDoubleOne + i); ++iCardTypeCount; } // 散牌 for (int j = (i + 1); j < SicboDefine.MAX_SICBO_NUMBER; ++j) { int iCount2 = GetSicboCountByNumber(enCardsBuffer, m_enSicboData[j]); if (iCount2 > 0) { enCardType[iCardTypeCount] = (E_CARD_TYPE)(E_CARD_TYPE.enCardType_SicboOneAndTwo + (i * SicboDefine.MAX_SICBO_NUMBER + j) - (((i + 1) * (i + 2)) / 2)); ++iCardTypeCount; } } } } return(true); }