#include "WN_GameLogic.h" #include "PlatformHeader.h" using namespace WNMJ_SPACE; WN_CGameLogic* WN_CGameLogic::s_configInstance = nullptr; ////////////////////////////////////////////////////////////////////////// //静态变量 //扑克数据 const uint8 WN_CGameLogic::m_cbCardDataArray[MAX_REPERTORY]= { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, //万子 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, //万子 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, //万子 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, //万子 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19, //索子 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19, //索子 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19, //索子 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19, //索子 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29, //同子 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29, //同子 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29, //同子 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29, //同子 0x31,0x32,0x33,0x34,0x35,0x36,0x37, //番子 0x31,0x32,0x33,0x34,0x35,0x36,0x37, //番子 0x31,0x32,0x33,0x34,0x35,0x36,0x37, //番子 0x31,0x32,0x33,0x34,0x35,0x36,0x37, //番子 }; ////////////////////////////////////////////////////////////////////////// //构造函数 void WN_CGameLogic::init() { memset(m_cbKingCardIndex, 0xFF, sizeof(m_cbKingCardIndex)); } //析构函数 void WN_CGameLogic::clear() { } //有效判断 bool WN_CGameLogic::IsValidCard(uint8 cbCardData) { uint8 cbValue = (cbCardData&MASK_WN_VALUE); uint8 cbColor = (cbCardData&MASK_WN_COLOR) >> 4; return (((cbValue>=1)&&(cbValue<=9)&&(cbColor<=2))||((cbValue>=1)&&(cbValue<=7)&&(cbColor==3))); } //扑克数目 uint8 WN_CGameLogic::GetCardCount(uint8 cbCardIndex[MAX_INDEX]) { //数目统计 uint8 cbCardCount=0; for (uint8 i=0;i>4)*9+(cbCardData&MASK_WN_VALUE)-1; } //杠牌分析 WORD WN_CGameLogic::AnalyseGangCard(uint8 cbCardIndex[MAX_INDEX], tagWeaveItem WeaveItem[], uint8 cbWeaveCount, tagGangCardResult & GangCardResult) { //设置变量 WORD wActionMask = WIK_WN_NULL; zeromemory(&GangCardResult, sizeof(GangCardResult)); //手上杠牌 for (uint8 i = 0; i < MAX_INDEX - 1; i++) { if (cbCardIndex[i] == 4) { wActionMask |= WIK_WN_GANG; GangCardResult.cbCardData[GangCardResult.cbCardCount++] = SwitchToCardData(i); } } //组合杠牌 for (uint8 i = 0; i < cbWeaveCount; i++) { if (WeaveItem[i].wWeaveKind == WIK_WN_PENG) { if (cbCardIndex[SwitchToCardIndex(WeaveItem[i].cbCenterCard)] == 1) { wActionMask |= WIK_WN_GANG; GangCardResult.cbCardData[GangCardResult.cbCardCount++] = WeaveItem[i].cbCenterCard; } } } return wActionMask; }