20170226添加:
//胡牌定义
/*
胡牌类型CHK_宏(有且只有11种:抢金、三金倒、单游、双游、三游、自摸、抢杠、七对自摸、七对单游、七对双游、七对三游)
牌型闲/庄番数={4/8,3/6,5/10,10/20,20/40,1/2,4/6,3/6,6/12,12/24,24/48}
以上11种胡牌类型不能再组合了,除此之外,杠(暗杠、回头杠、点杠、花杠)也要参与输赢算番
*/
#define CHK_NULL 0x00000000 //非胡类型
#define CHK_QIANG_JIN 0x00000001 //抢金
#define CHK_SKY_SWIM 0x00000002 //三金倒
#define CHK_SINGLE_SWIM 0x00000004 //单游
#define CHK_DOUBLE_SWIM 0x00000008 //双游
#define CHK_THREE_SWIM 0x00000010 //三游
#define CHK_ZIMO_HU 0x00000020 //自摸
#define CHK_GANG_HU 0x00000040 //抢杠
//#define CHK_QI_DUI 0x00000080 //七对自摸
//#define CHK_QI_DUI1 0x00000100 //七对单游
//#define CHK_QI_DUI2 0x00000200 //七对双游
//#define CHK_QI_DUI3 0x00000400 //七对三游
#define CHK_QI_DUI 0x00000080 //七对
#define CHK_QI_DUI0 (CHK_QI_DUI|CHK_ZIMO_HU) //七对自摸
#define CHK_QI_DUI1 (CHK_QI_DUI|CHK_SINGLE_SWIM) //七对单游
#define CHK_QI_DUI2 (CHK_QI_DUI|CHK_DOUBLE_SWIM) //七对双游
#define CHK_QI_DUI3 (CHK_QI_DUI|CHK_THREE_SWIM) //七对三游
20170122、20170206添加:
//胡牌定义
/*
胡牌类型CHK_宏(有且只有11种:抢金、三金倒、单游、双游、三游、自摸、抢杠、七对自摸、七对单游、七对双游、七对三游)
牌型闲/庄番数={4/8,3/6,5/10,10/20,20/40,1/2,4/6,3/6,6/12,12/24,24/48}
以上11种胡牌类型不能再组合了,除此之外,杠(暗杠、回头杠、点杠、花杠)也要参与输赢算番
*/
#define CHK_NULL 0x00000000 //非胡类型
#define CHK_QIANG_JIN 0x00000001 //抢金
#define CHK_SKY_SWIM 0x00000002 //三金倒
#define CHK_SINGLE_SWIM 0x00000004 //单游
#define CHK_DOUBLE_SWIM 0x00000008 //双游
#define CHK_THREE_SWIM 0x00000010 //三游
#define CHK_ZIMO_HU 0x00000020 //自摸
#define CHK_GANG_HU 0x00000040 //抢杠
//#define CHK_QI_DUI 0x00000080 //七对自摸
//#define CHK_QI_DUI1 0x00000100 //七对单游
//#define CHK_QI_DUI2 0x00000200 //七对双游
//#define CHK_QI_DUI3 0x00000400 //七对三游
#define CHK_QI_DUI 0x00000080 //七对
#define CHK_QI_DUI0 (CHK_QI_DUI|CHK_ZIMO_HU) //七对自摸
#define CHK_QI_DUI1 (CHK_QI_DUI|CHK_SINGLE_SWIM) //七对单游
#define CHK_QI_DUI2 (CHK_QI_DUI|CHK_DOUBLE_SWIM) //七对双游
#define CHK_QI_DUI3 (CHK_QI_DUI|CHK_THREE_SWIM) //七对三游
【 2017-02-06 17:46:46 】i=[0]座,[2][5][5][8][9][9][12][18][18][26][35][36][42][0]
【 2017-02-06 17:46:46 】i=[1]座,[6][8][13][17][19][21][23][29][29][33][34][35][44][0]
6筒,8筒,3万,7万,9万,1条,3条,9条,9条,西风,北风,红中,冬
【 2017-02-06 17:46:46 】i=[2]座,[9][11][13][14][21][21][25][26][27][28][28][31][37][0]
9筒,1万,3万,4万,1条,1条,5条,6条,7条,8条,8条,东风,白板
【 2017-02-06 17:46:46 】i=[3]座,[1][2][3][4][14][14][15][16][17][18][22][25][31][0]
2条(金牌),1筒,2筒,3筒,4筒,4万,4万,5万,6万,7万,8万,5条,东风
麻将网络消息
主码是MDM_GF_GAME=200
1、
define SUB_C_OUT_CARD 1//出牌命令
cbCardData = 49 东风
cbCardData = 53 红中
cbCardData = 54 发财
cbCardData = 34 2条
cbCardData = 20 4万
cbCardData = 1 1筒
cbCardData = 5 5筒
2、
【 2017-02-06 17:46:46 】i=[1]座,[6][8][13][17][19][21][23][29][29][33][34][35][44][0]
6筒,8筒,3万,7万,9万,1条,3条,9条,9条,西风,北风,红中,冬
【 2017-02-06 17:46:46 】i=[2]座,[9][11][13][14][21][21][25][26][27][28][28][31][37][0]
9筒,1万,3万,4万,1条,1条,5条,6条,7条,8条,8条,东风,白板
【 2017-02-06 17:46:46 】i=[3]座,[1][2][3][4][14][14][15][16][17][18][22][25][31][0]
2条(金牌),1筒,2筒,3筒,4筒,4万,4万,5万,6万,7万,8万,5条,东风
麻将网络消息
主码是MDM_GF_GAME=200
1、
define SUB_C_OUT_CARD 1//出牌命令
cbCardData = 49 东风
cbCardData = 53 红中
cbCardData = 54 发财
cbCardData = 34 2条
cbCardData = 20 4万
cbCardData = 1 1筒
cbCardData = 5 5筒
2、
#define SUB_C_OPERATE_CARD 3//操作扑克
#define WIK_PENG 0x08//碰牌类型
cbOperateCode = 8 '\b'
0,0,0
碰西风
#define WIK_PENG 0x08//碰牌类型
cbOperateCode = 8 '\b'
0,0,0
碰西风
#define WIK_LEFT 0x01//左吃类型
1
3,4,5
吃3筒
1
3,4,5
吃3筒
#define WIK_CENTER 0x02//中吃类型
8,7,9
吃8筒
8,7,9
吃8筒
#define WIK_RIGHT 0x04//右吃类型
4
22,21,20
吃6万
4
22,21,20
吃6万
#define WIK_NULL 0x00//没有类型
cbOperateCode = 0 '\0'
0,0,0
弃
cbOperateCode = 0 '\0'
0,0,0
弃
#define WIK_GANG 0x10//杠牌类型
17,17,17
杠1万
17,17,17
杠1万
#define WIK_CHI_HU 0x40//自摸类型
cbOperateCode = 64 '@'
0,0,0
胡
3、
#define SUB_S_GAME_START 100//游戏开始
cbChangeCard = 50 '2'南风
4、
#define SUB_S_OUT_CARD 101//出牌命令
REV- --main command---- 200 -- Sub Command ----101---
HZhMJGameScence::OnSubOutCard
wOutCardUser = 0
cbOutCardData = 50 '2'南风
cbOperateCode = 64 '@'
0,0,0
胡
3、
#define SUB_S_GAME_START 100//游戏开始
cbChangeCard = 50 '2'南风
4、
#define SUB_S_OUT_CARD 101//出牌命令
REV- --main command---- 200 -- Sub Command ----101---
HZhMJGameScence::OnSubOutCard
wOutCardUser = 0
cbOutCardData = 50 '2'南风
wOutCardUser = 0
cbOutCardData = 6 '\x6'6筒
5、
#define SUB_S_SEND_CARD 102//发送扑克
REV- --main command---- 200 -- Sub Command ----102---
HZhMJGameScence::OnSubSendCard
cbOutCardData = 6 '\x6'6筒
5、
#define SUB_S_SEND_CARD 102//发送扑克
REV- --main command---- 200 -- Sub Command ----102---
HZhMJGameScence::OnSubSendCard
C++麻将游戏算法深入解析
http://blog.csdn.net/honghaier/article/details/8604955
// GameLogicTest
//TEST1测试麻将数据和麻将索引的互转
//TEST2测试随机洗牌、随机财神牌、分发麻将的过程
//TEST3测试杠牌分析
int main()
{
CGameLogic m_GameLogic;
QZGameLogic m_QZGameLogic;
// 虚析构空类大小:Win32下为4,x64下为8
cout<<sizeof(m_GameLogic)<<endl;
cout<<sizeof(m_QZGameLogic)<<endl;
// GameLogicTest
//TEST1测试麻将数据和麻将索引的互转
//TEST2测试随机洗牌、随机财神牌、分发麻将的过程
//TEST3测试杠牌分析
int main()
{
CGameLogic m_GameLogic;
QZGameLogic m_QZGameLogic;
// 虚析构空类大小:Win32下为4,x64下为8
cout<<sizeof(m_GameLogic)<<endl;
cout<<sizeof(m_QZGameLogic)<<endl;
#ifdef TEST1
#if 1
srand(time(NULL));
//视图财神
BYTE m_cbChangeCard = CGameLogic::SwitchToCardData_old(rand()%(MAX_INDEX-8));
BYTE m_cbChangeCardIndex=CGameLogic::SwitchToCardIndex_old(m_cbChangeCard);
const char * szCardName=QZGameLogic::GetMJCardName(m_cbChangeCard);
cout<<"m_cbChangeCardIndex="<<(int)m_cbChangeCardIndex<<",m_cbChangeCard="<<(int)m_cbChangeCard<<"("<<szCardName<<"),"<<endl;
m_GameLogic.SetMagicIndex(m_cbChangeCardIndex);
for(int i=0;i<MAX_INDEX;i++)
{
BYTE cbCardData=CGameLogic::SwitchToCardData_old(i);
BYTE cbCardIndex=CGameLogic::SwitchToCardIndex_old(cbCardData);
const char * szCardName=QZGameLogic::GetMJCardName(cbCardData);
cout<<"i="<<i<<",cbCardIndex="<<(int)cbCardIndex<<",cbCardData="<<(int)cbCardData<<"("<<szCardName<<"),"<<endl;
}
#else
for(int i=0;i<MAX_INDEX;i++)
{
BYTE cbCardData=QZGameLogic::SwitchToCardData(i);
BYTE cbCardIndex=QZGameLogic::SwitchToCardIndex(cbCardData);
const char * szCardName=QZGameLogic::GetMJCardName(cbCardData);
cout<<"i="<<i<<",cbCardIndex="<<(int)cbCardIndex<<",cbCardData="<<(int)cbCardData<<"("<<szCardName<<"),"<<endl;
}
#endif
#endif
#if 1
srand(time(NULL));
//视图财神
BYTE m_cbChangeCard = CGameLogic::SwitchToCardData_old(rand()%(MAX_INDEX-8));
BYTE m_cbChangeCardIndex=CGameLogic::SwitchToCardIndex_old(m_cbChangeCard);
const char * szCardName=QZGameLogic::GetMJCardName(m_cbChangeCard);
cout<<"m_cbChangeCardIndex="<<(int)m_cbChangeCardIndex<<",m_cbChangeCard="<<(int)m_cbChangeCard<<"("<<szCardName<<"),"<<endl;
m_GameLogic.SetMagicIndex(m_cbChangeCardIndex);
for(int i=0;i<MAX_INDEX;i++)
{
BYTE cbCardData=CGameLogic::SwitchToCardData_old(i);
BYTE cbCardIndex=CGameLogic::SwitchToCardIndex_old(cbCardData);
const char * szCardName=QZGameLogic::GetMJCardName(cbCardData);
cout<<"i="<<i<<",cbCardIndex="<<(int)cbCardIndex<<",cbCardData="<<(int)cbCardData<<"("<<szCardName<<"),"<<endl;
}
#else
for(int i=0;i<MAX_INDEX;i++)
{
BYTE cbCardData=QZGameLogic::SwitchToCardData(i);
BYTE cbCardIndex=QZGameLogic::SwitchToCardIndex(cbCardData);
const char * szCardName=QZGameLogic::GetMJCardName(cbCardData);
cout<<"i="<<i<<",cbCardIndex="<<(int)cbCardIndex<<",cbCardData="<<(int)cbCardData<<"("<<szCardName<<"),"<<endl;
}
#endif
#endif
#ifdef TEST2
BYTE m_cbRepertoryCard[MAX_REPERTORY]; //库存麻将
BYTE m_cbCardIndex[GAME_PLAYER][MAX_INDEX]; //用户麻将
ZeroMemory(m_cbRepertoryCard,sizeof(m_cbRepertoryCard));
ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex));
BYTE m_cbRepertoryCard[MAX_REPERTORY]; //库存麻将
BYTE m_cbCardIndex[GAME_PLAYER][MAX_INDEX]; //用户麻将
ZeroMemory(m_cbRepertoryCard,sizeof(m_cbRepertoryCard));
ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex));
//随机洗牌
#if 0
CGameLogic::RandCardData(m_cbRepertoryCard,CountArray(m_cbRepertoryCard));
#else
QZGameLogic::RandCardData(m_cbRepertoryCard,CountArray(m_cbRepertoryCard));
#endif
#if 0
CGameLogic::RandCardData(m_cbRepertoryCard,CountArray(m_cbRepertoryCard));
#else
QZGameLogic::RandCardData(m_cbRepertoryCard,CountArray(m_cbRepertoryCard));
#endif
BYTE m_cbLeftCardCount=MAX_REPERTORY;
BYTE m_cbChangeCard = CGameLogic::SwitchToCardData_old(rand()%(MAX_INDEX-8));
BYTE m_cbChangeCardIndex=CGameLogic::SwitchToCardIndex_old(m_cbChangeCard);
const char * szCardName=QZGameLogic::GetMJCardName(m_cbChangeCard);
cout<<"m_cbChangeCardIndex="<<(int)m_cbChangeCardIndex<<",m_cbChangeCard="<<(int)m_cbChangeCard<<"("<<szCardName<<"),"<<endl;
BYTE m_cbChangeCardIndex=CGameLogic::SwitchToCardIndex_old(m_cbChangeCard);
const char * szCardName=QZGameLogic::GetMJCardName(m_cbChangeCard);
cout<<"m_cbChangeCardIndex="<<(int)m_cbChangeCardIndex<<",m_cbChangeCard="<<(int)m_cbChangeCard<<"("<<szCardName<<"),"<<endl;
for (int i=m_cbLeftCardCount-1;i>=0;i--)
{
if (m_cbRepertoryCard[i] == m_cbChangeCard)
{
BYTE temp=m_cbRepertoryCard[i];
m_cbRepertoryCard[i]=m_cbRepertoryCard[m_cbLeftCardCount-1];
m_cbRepertoryCard[m_cbLeftCardCount-1]=temp;
m_cbLeftCardCount--;
break;
}
}
{
if (m_cbRepertoryCard[i] == m_cbChangeCard)
{
BYTE temp=m_cbRepertoryCard[i];
m_cbRepertoryCard[i]=m_cbRepertoryCard[m_cbLeftCardCount-1];
m_cbRepertoryCard[m_cbLeftCardCount-1]=temp;
m_cbLeftCardCount--;
break;
}
}
// 随机出来的财神牌放在数组最后面
for(int i=0;i<MAX_REPERTORY;i++)
{
BYTE cbCardData=m_cbRepertoryCard[i];
BYTE cbCardIndex=CGameLogic::SwitchToCardIndex_old(cbCardData);
const char * szCardName=QZGameLogic::GetMJCardName(cbCardData);
cout<<"i="<<i<<",cbCardIndex="<<(int)cbCardIndex<<",cbCardData="<<(int)cbCardData<<"("<<szCardName<<"),"<<endl;
}
for(int i=0;i<MAX_REPERTORY;i++)
{
BYTE cbCardData=m_cbRepertoryCard[i];
BYTE cbCardIndex=CGameLogic::SwitchToCardIndex_old(cbCardData);
const char * szCardName=QZGameLogic::GetMJCardName(cbCardData);
cout<<"i="<<i<<",cbCardIndex="<<(int)cbCardIndex<<",cbCardData="<<(int)cbCardData<<"("<<szCardName<<"),"<<endl;
}
m_GameLogic.SetMagicIndex(m_cbChangeCardIndex);
//分发麻将
for (WORD i=0;i<GAME_PLAYER;i++)
{
m_cbLeftCardCount-=(MAX_HANDCARD_COUNT-1);
m_GameLogic.SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount],MAX_HANDCARD_COUNT-1,m_cbCardIndex[i]);
BYTE GameStartcbCardData[MAX_HANDCARD_COUNT]={0};
memset(GameStartcbCardData, 0, sizeof(GameStartcbCardData));
m_GameLogic.SwitchToCardData(m_cbCardIndex[i],GameStartcbCardData);
memset(GameStartcbCardData, 0, sizeof(GameStartcbCardData));
m_GameLogic.SwitchToCardData(m_cbCardIndex[i],GameStartcbCardData);
CString strLog;
strLog.Format("i=[%d]座,[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]",i,GameStartcbCardData[0],GameStartcbCardData[1],GameStartcbCardData[2],GameStartcbCardData[3],GameStartcbCardData[4],GameStartcbCardData[5],GameStartcbCardData[6],GameStartcbCardData[0+7],GameStartcbCardData[1+7],GameStartcbCardData[2+7],GameStartcbCardData[3+7],GameStartcbCardData[4+7],GameStartcbCardData[5+7],GameStartcbCardData[6+7]);
cout<<strLog.GetString()<<endl;
strLog.Format("i=[%d]座,[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]",i,QZGameLogic::GetMJCardName(GameStartcbCardData[0]),QZGameLogic::GetMJCardName(GameStartcbCardData[1]),QZGameLogic::GetMJCardName(GameStartcbCardData[2]),QZGameLogic::GetMJCardName(GameStartcbCardData[3]),QZGameLogic::GetMJCardName(GameStartcbCardData[4]),QZGameLogic::GetMJCardName(GameStartcbCardData[5]),QZGameLogic::GetMJCardName(GameStartcbCardData[6]),QZGameLogic::GetMJCardName(GameStartcbCardData[0+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[1+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[2+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[3+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[4+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[5+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[6+7]));
cout<<strLog.GetString()<<endl;
}
strLog.Format("i=[%d]座,[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]",i,GameStartcbCardData[0],GameStartcbCardData[1],GameStartcbCardData[2],GameStartcbCardData[3],GameStartcbCardData[4],GameStartcbCardData[5],GameStartcbCardData[6],GameStartcbCardData[0+7],GameStartcbCardData[1+7],GameStartcbCardData[2+7],GameStartcbCardData[3+7],GameStartcbCardData[4+7],GameStartcbCardData[5+7],GameStartcbCardData[6+7]);
cout<<strLog.GetString()<<endl;
strLog.Format("i=[%d]座,[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]",i,QZGameLogic::GetMJCardName(GameStartcbCardData[0]),QZGameLogic::GetMJCardName(GameStartcbCardData[1]),QZGameLogic::GetMJCardName(GameStartcbCardData[2]),QZGameLogic::GetMJCardName(GameStartcbCardData[3]),QZGameLogic::GetMJCardName(GameStartcbCardData[4]),QZGameLogic::GetMJCardName(GameStartcbCardData[5]),QZGameLogic::GetMJCardName(GameStartcbCardData[6]),QZGameLogic::GetMJCardName(GameStartcbCardData[0+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[1+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[2+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[3+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[4+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[5+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[6+7]));
cout<<strLog.GetString()<<endl;
}
//分发给庄家的第14张牌
WORD m_wBankerUser=0;
BYTE m_cbSendCardData=m_cbRepertoryCard[--m_cbLeftCardCount];
BYTE m_cbSendCardIndex=m_GameLogic.SwitchToCardIndex_old(m_cbSendCardData);
m_cbCardIndex[m_wBankerUser][m_cbSendCardIndex]++;
const char * szSendCardName=QZGameLogic::GetMJCardName(m_cbSendCardData);
cout<<"发牌麻将:m_cbSendCardIndex="<<(int)m_cbSendCardIndex<<",m_cbSendCardData="<<(int)m_cbSendCardData<<"("<<szSendCardName<<"),"<<endl;
cout<<"m_cbLeftCardCount="<<(int)m_cbLeftCardCount<<endl;
#endif
WORD m_wBankerUser=0;
BYTE m_cbSendCardData=m_cbRepertoryCard[--m_cbLeftCardCount];
BYTE m_cbSendCardIndex=m_GameLogic.SwitchToCardIndex_old(m_cbSendCardData);
m_cbCardIndex[m_wBankerUser][m_cbSendCardIndex]++;
const char * szSendCardName=QZGameLogic::GetMJCardName(m_cbSendCardData);
cout<<"发牌麻将:m_cbSendCardIndex="<<(int)m_cbSendCardIndex<<",m_cbSendCardData="<<(int)m_cbSendCardData<<"("<<szSendCardName<<"),"<<endl;
cout<<"m_cbLeftCardCount="<<(int)m_cbLeftCardCount<<endl;
#endif
system("pause");
return 0;
}
return 0;
}
8
4
m_cbChangeCardIndex=19,m_cbChangeCard=34(2条),
i=0,cbCardIndex=14,cbCardData=22(6万),
i=1,cbCardIndex=2,cbCardData=3(3筒),
i=2,cbCardIndex=23,cbCardData=38(6条),
i=3,cbCardIndex=31,cbCardData=53(红中),
i=4,cbCardIndex=27,cbCardData=49(东风),
i=5,cbCardIndex=8,cbCardData=9(9筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=13,cbCardData=21(5万),
i=8,cbCardIndex=7,cbCardData=8(8筒),
i=9,cbCardIndex=2,cbCardData=3(3筒),
i=10,cbCardIndex=23,cbCardData=38(6条),
i=11,cbCardIndex=19,cbCardData=34(2条),
i=12,cbCardIndex=13,cbCardData=21(5万),
i=13,cbCardIndex=14,cbCardData=22(6万),
i=14,cbCardIndex=18,cbCardData=33(1条),
i=15,cbCardIndex=23,cbCardData=38(6条),
i=16,cbCardIndex=15,cbCardData=23(7万),
i=17,cbCardIndex=4,cbCardData=5(5筒),
i=18,cbCardIndex=12,cbCardData=20(4万),
i=19,cbCardIndex=16,cbCardData=24(8万),
i=20,cbCardIndex=0,cbCardData=1(1筒),
i=21,cbCardIndex=18,cbCardData=33(1条),
i=22,cbCardIndex=32,cbCardData=54(发财),
i=23,cbCardIndex=5,cbCardData=6(6筒),
i=24,cbCardIndex=16,cbCardData=24(8万),
i=25,cbCardIndex=6,cbCardData=7(7筒),
i=26,cbCardIndex=21,cbCardData=36(4条),
i=27,cbCardIndex=32,cbCardData=54(发财),
i=28,cbCardIndex=33,cbCardData=55(白板),
i=29,cbCardIndex=0,cbCardData=1(1筒),
i=30,cbCardIndex=26,cbCardData=41(9条),
i=31,cbCardIndex=3,cbCardData=4(4筒),
i=32,cbCardIndex=18,cbCardData=33(1条),
i=33,cbCardIndex=24,cbCardData=39(7条),
i=34,cbCardIndex=28,cbCardData=50(南风),
i=35,cbCardIndex=20,cbCardData=35(3条),
i=36,cbCardIndex=17,cbCardData=25(9万),
i=37,cbCardIndex=21,cbCardData=36(4条),
i=38,cbCardIndex=29,cbCardData=51(西风),
i=39,cbCardIndex=35,cbCardData=66(夏),
i=40,cbCardIndex=22,cbCardData=37(5条),
i=41,cbCardIndex=0,cbCardData=1(1筒),
i=42,cbCardIndex=8,cbCardData=9(9筒),
i=43,cbCardIndex=6,cbCardData=7(7筒),
i=44,cbCardIndex=19,cbCardData=34(2条),
i=45,cbCardIndex=2,cbCardData=3(3筒),
i=46,cbCardIndex=29,cbCardData=51(西风),
i=47,cbCardIndex=12,cbCardData=20(4万),
i=48,cbCardIndex=32,cbCardData=54(发财),
i=49,cbCardIndex=1,cbCardData=2(2筒),
i=50,cbCardIndex=30,cbCardData=52(北风),
i=51,cbCardIndex=5,cbCardData=6(6筒),
i=52,cbCardIndex=2,cbCardData=3(3筒),
i=53,cbCardIndex=25,cbCardData=40(8条),
i=54,cbCardIndex=12,cbCardData=20(4万),
i=55,cbCardIndex=16,cbCardData=24(8万),
i=56,cbCardIndex=26,cbCardData=41(9条),
i=57,cbCardIndex=25,cbCardData=40(8条),
i=58,cbCardIndex=0,cbCardData=1(1筒),
i=59,cbCardIndex=4,cbCardData=5(5筒),
i=60,cbCardIndex=31,cbCardData=53(红中),
i=61,cbCardIndex=11,cbCardData=19(3万),
i=62,cbCardIndex=14,cbCardData=22(6万),
i=63,cbCardIndex=15,cbCardData=23(7万),
i=64,cbCardIndex=24,cbCardData=39(7条),
i=65,cbCardIndex=7,cbCardData=8(8筒),
i=66,cbCardIndex=16,cbCardData=24(8万),
i=67,cbCardIndex=1,cbCardData=2(2筒),
i=68,cbCardIndex=9,cbCardData=17(1万),
i=69,cbCardIndex=21,cbCardData=36(4条),
i=70,cbCardIndex=12,cbCardData=20(4万),
i=71,cbCardIndex=24,cbCardData=39(7条),
i=72,cbCardIndex=37,cbCardData=68(冬),
i=73,cbCardIndex=10,cbCardData=18(2万),
i=74,cbCardIndex=22,cbCardData=37(5条),
i=75,cbCardIndex=33,cbCardData=55(白板),
i=76,cbCardIndex=10,cbCardData=18(2万),
i=77,cbCardIndex=39,cbCardData=70(兰),
i=78,cbCardIndex=30,cbCardData=52(北风),
i=79,cbCardIndex=11,cbCardData=19(3万),
i=80,cbCardIndex=9,cbCardData=17(1万),
i=81,cbCardIndex=20,cbCardData=35(3条),
i=82,cbCardIndex=22,cbCardData=37(5条),
i=83,cbCardIndex=18,cbCardData=33(1条),
i=84,cbCardIndex=29,cbCardData=51(西风),
i=85,cbCardIndex=34,cbCardData=65(春),
i=86,cbCardIndex=28,cbCardData=50(南风),
i=87,cbCardIndex=17,cbCardData=25(9万),
i=88,cbCardIndex=27,cbCardData=49(东风),
i=89,cbCardIndex=21,cbCardData=36(4条),
i=90,cbCardIndex=15,cbCardData=23(7万),
i=91,cbCardIndex=3,cbCardData=4(4筒),
i=92,cbCardIndex=31,cbCardData=53(红中),
i=93,cbCardIndex=1,cbCardData=2(2筒),
i=94,cbCardIndex=10,cbCardData=18(2万),
i=95,cbCardIndex=28,cbCardData=50(南风),
i=96,cbCardIndex=10,cbCardData=18(2万),
i=97,cbCardIndex=5,cbCardData=6(6筒),
i=98,cbCardIndex=3,cbCardData=4(4筒),
i=99,cbCardIndex=8,cbCardData=9(9筒),
i=100,cbCardIndex=25,cbCardData=40(8条),
i=101,cbCardIndex=17,cbCardData=25(9万),
i=102,cbCardIndex=1,cbCardData=2(2筒),
i=103,cbCardIndex=6,cbCardData=7(7筒),
i=104,cbCardIndex=33,cbCardData=55(白板),
i=105,cbCardIndex=11,cbCardData=19(3万),
i=106,cbCardIndex=4,cbCardData=5(5筒),
i=107,cbCardIndex=3,cbCardData=4(4筒),
i=108,cbCardIndex=23,cbCardData=38(6条),
i=109,cbCardIndex=9,cbCardData=17(1万),
i=110,cbCardIndex=11,cbCardData=19(3万),
i=111,cbCardIndex=19,cbCardData=34(2条),
i=112,cbCardIndex=28,cbCardData=50(南风),
i=113,cbCardIndex=26,cbCardData=41(9条),
i=114,cbCardIndex=27,cbCardData=49(东风),
i=115,cbCardIndex=8,cbCardData=9(9筒),
i=116,cbCardIndex=22,cbCardData=37(5条),
i=117,cbCardIndex=33,cbCardData=55(白板),
i=118,cbCardIndex=26,cbCardData=41(9条),
i=119,cbCardIndex=38,cbCardData=69(梅),
i=120,cbCardIndex=15,cbCardData=23(7万),
i=121,cbCardIndex=41,cbCardData=72(竹),
i=122,cbCardIndex=25,cbCardData=40(8条),
i=123,cbCardIndex=17,cbCardData=25(9万),
i=124,cbCardIndex=13,cbCardData=21(5万),
i=125,cbCardIndex=24,cbCardData=39(7条),
i=126,cbCardIndex=20,cbCardData=35(3条),
i=127,cbCardIndex=14,cbCardData=22(6万),
i=128,cbCardIndex=4,cbCardData=5(5筒),
i=129,cbCardIndex=32,cbCardData=54(发财),
i=130,cbCardIndex=20,cbCardData=35(3条),
i=131,cbCardIndex=30,cbCardData=52(北风),
i=132,cbCardIndex=40,cbCardData=71(菊),
i=133,cbCardIndex=9,cbCardData=17(1万),
i=134,cbCardIndex=30,cbCardData=52(北风),
i=135,cbCardIndex=7,cbCardData=8(8筒),
i=136,cbCardIndex=36,cbCardData=67(秋),
i=137,cbCardIndex=29,cbCardData=51(西风),
i=138,cbCardIndex=27,cbCardData=49(东风),
i=139,cbCardIndex=7,cbCardData=8(8筒),
i=140,cbCardIndex=5,cbCardData=6(6筒),
i=141,cbCardIndex=31,cbCardData=53(红中),
i=142,cbCardIndex=13,cbCardData=21(5万),
i=143,cbCardIndex=19,cbCardData=34(2条),
i=[0]座,[6][8][8][11][15][23][31][33][34][34][35][43][47]
i=[0]座,[6筒][8筒][8筒][1万][5万][3条][东风][西风][北风][北风][红中][秋][菊]
i=[1]座,[5][15][16][17][19][23][27][28][29][36][37][45][48]
i=[1]座,[5筒][5万][6万][7万][9万][3条][7条][8条][9条][发财][白板][梅][竹]
i=[2]座,[22][4][5][9][11][13][13][25][26][29][31][32][37]
i=[2]座,[2条][4筒][5筒][9筒][1万][3万][3万][5条][6条][9条][东风][南风][白板]
i=[3]座,[2][2][4][4][6][7][9][12][12][19][28][32][35]
i=[3]座,[2筒][2筒][4筒][4筒][6筒][7筒][9筒][2万][2万][9万][8条][南风][红中]
发牌麻将:m_cbSendCardIndex=15,m_cbSendCardData=23(7万),
m_cbLeftCardCount=90
8
4
i=0,cbCardIndex=0,cbCardData=1(1筒),
i=1,cbCardIndex=1,cbCardData=2(2筒),
i=2,cbCardIndex=2,cbCardData=3(3筒),
i=3,cbCardIndex=3,cbCardData=4(4筒),
i=4,cbCardIndex=4,cbCardData=5(5筒),
i=5,cbCardIndex=5,cbCardData=6(6筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=7,cbCardData=8(8筒),
i=8,cbCardIndex=8,cbCardData=9(9筒),
i=9,cbCardIndex=9,cbCardData=17(1万),
i=10,cbCardIndex=10,cbCardData=18(2万),
i=11,cbCardIndex=11,cbCardData=19(3万),
i=12,cbCardIndex=12,cbCardData=20(4万),
i=13,cbCardIndex=13,cbCardData=21(5万),
i=14,cbCardIndex=14,cbCardData=22(6万),
i=15,cbCardIndex=15,cbCardData=23(7万),
i=16,cbCardIndex=16,cbCardData=24(8万),
i=17,cbCardIndex=17,cbCardData=25(9万),
i=18,cbCardIndex=18,cbCardData=33(1条),
i=19,cbCardIndex=19,cbCardData=34(2条),
i=20,cbCardIndex=20,cbCardData=35(3条),
i=21,cbCardIndex=21,cbCardData=36(4条),
i=22,cbCardIndex=22,cbCardData=37(5条),
i=23,cbCardIndex=23,cbCardData=38(6条),
i=24,cbCardIndex=24,cbCardData=39(7条),
i=25,cbCardIndex=25,cbCardData=40(8条),
i=26,cbCardIndex=26,cbCardData=41(9条),
i=27,cbCardIndex=27,cbCardData=49(东风),
i=28,cbCardIndex=28,cbCardData=50(南风),
i=29,cbCardIndex=29,cbCardData=51(西风),
i=30,cbCardIndex=30,cbCardData=52(北风),
i=31,cbCardIndex=31,cbCardData=53(红中),
i=32,cbCardIndex=32,cbCardData=54(发财),
i=33,cbCardIndex=33,cbCardData=55(白板),
i=34,cbCardIndex=34,cbCardData=65(春),
i=35,cbCardIndex=35,cbCardData=66(夏),
i=36,cbCardIndex=36,cbCardData=67(秋),
i=37,cbCardIndex=37,cbCardData=68(冬),
i=38,cbCardIndex=38,cbCardData=69(梅),
i=39,cbCardIndex=39,cbCardData=70(兰),
i=40,cbCardIndex=40,cbCardData=71(菊),
i=41,cbCardIndex=41,cbCardData=72(竹),
没有花牌数据的牌逻辑代码:
//扑克转换
BYTE CGameLogic::SwitchToCardData_old(BYTE cbCardIndex)
{
#if 1
ASSERT(cbCardIndex<MAX_INDEX);
if( cbCardIndex < 27 )
return ((cbCardIndex/9)<<4)|(cbCardIndex%9+1);
else return (0x30|(cbCardIndex-27+1));
#else
ASSERT(cbCardIndex<MAX_INDEX);
if(cbCardIndex<SPRING_INDEX)
return ((cbCardIndex/9)<<4)|(cbCardIndex%9+1);
else
return (SPRING_DATA+cbCardIndex-SPRING_INDEX);
#endif
}
//扑克转换
BYTE CGameLogic::SwitchToCardIndex_old(BYTE cbCardData)
{
#if 1
ASSERT(IsValidCard(cbCardData));
return ((cbCardData&MASK_COLOR)>>4)*9+(cbCardData&MASK_VALUE)-1;
#else
ASSERT(IsValidCard(cbCardData));
if(cbCardData<SPRING_DATA)
return ((cbCardData&MASK_COLOR)>>4)*9+(cbCardData&MASK_VALUE)-1;
else
return (SPRING_INDEX+(cbCardData&MASK_VALUE)-1);
#endif
}
8
4
m_cbChangeCardIndex=1,m_cbChangeCard=2(2筒),
i=0,cbCardIndex=0,cbCardData=1(1筒),
i=1,cbCardIndex=1,cbCardData=2(2筒),
i=2,cbCardIndex=2,cbCardData=3(3筒),
i=3,cbCardIndex=3,cbCardData=4(4筒),
i=4,cbCardIndex=4,cbCardData=5(5筒),
i=5,cbCardIndex=5,cbCardData=6(6筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=7,cbCardData=8(8筒),
i=8,cbCardIndex=8,cbCardData=9(9筒),
i=9,cbCardIndex=9,cbCardData=17(1万),
i=10,cbCardIndex=10,cbCardData=18(2万),
i=11,cbCardIndex=11,cbCardData=19(3万),
i=12,cbCardIndex=12,cbCardData=20(4万),
i=13,cbCardIndex=13,cbCardData=21(5万),
i=14,cbCardIndex=14,cbCardData=22(6万),
i=15,cbCardIndex=15,cbCardData=23(7万),
i=16,cbCardIndex=16,cbCardData=24(8万),
i=17,cbCardIndex=17,cbCardData=25(9万),
i=18,cbCardIndex=18,cbCardData=33(1条),
i=19,cbCardIndex=19,cbCardData=34(2条),
i=20,cbCardIndex=20,cbCardData=35(3条),
i=21,cbCardIndex=21,cbCardData=36(4条),
i=22,cbCardIndex=22,cbCardData=37(5条),
i=23,cbCardIndex=23,cbCardData=38(6条),
i=24,cbCardIndex=24,cbCardData=39(7条),
i=25,cbCardIndex=25,cbCardData=40(8条),
i=26,cbCardIndex=26,cbCardData=41(9条),
i=27,cbCardIndex=27,cbCardData=49(东风),
i=28,cbCardIndex=28,cbCardData=50(南风),
i=29,cbCardIndex=29,cbCardData=51(西风),
i=30,cbCardIndex=30,cbCardData=52(北风),
i=31,cbCardIndex=31,cbCardData=53(红中),
i=32,cbCardIndex=32,cbCardData=54(发财),
i=33,cbCardIndex=33,cbCardData=55(白板),
i=34,cbCardIndex=34,cbCardData=56(),
i=35,cbCardIndex=35,cbCardData=57(),
i=36,cbCardIndex=36,cbCardData=58(),
i=37,cbCardIndex=37,cbCardData=59(),
i=38,cbCardIndex=38,cbCardData=60(),
i=39,cbCardIndex=39,cbCardData=61(),
i=40,cbCardIndex=40,cbCardData=62(),
i=41,cbCardIndex=41,cbCardData=63(),
分发麻将时,如果分发了财神牌,要处理下
没有处理的情形:
2条是财神牌
8
4
m_cbChangeCardIndex=19,m_cbChangeCard=34(2条),
i=0,cbCardIndex=14,cbCardData=22(6万),
i=1,cbCardIndex=2,cbCardData=3(3筒),
i=2,cbCardIndex=23,cbCardData=38(6条),
i=3,cbCardIndex=31,cbCardData=53(红中),
i=4,cbCardIndex=27,cbCardData=49(东风),
i=5,cbCardIndex=8,cbCardData=9(9筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=13,cbCardData=21(5万),
i=8,cbCardIndex=7,cbCardData=8(8筒),
i=9,cbCardIndex=2,cbCardData=3(3筒),
i=10,cbCardIndex=23,cbCardData=38(6条),
i=11,cbCardIndex=19,cbCardData=34(2条),
i=12,cbCardIndex=13,cbCardData=21(5万),
i=13,cbCardIndex=14,cbCardData=22(6万),
i=14,cbCardIndex=18,cbCardData=33(1条),
i=15,cbCardIndex=23,cbCardData=38(6条),
i=16,cbCardIndex=15,cbCardData=23(7万),
i=17,cbCardIndex=4,cbCardData=5(5筒),
i=18,cbCardIndex=12,cbCardData=20(4万),
i=19,cbCardIndex=16,cbCardData=24(8万),
i=20,cbCardIndex=0,cbCardData=1(1筒),
i=21,cbCardIndex=18,cbCardData=33(1条),
i=22,cbCardIndex=32,cbCardData=54(发财),
i=23,cbCardIndex=5,cbCardData=6(6筒),
i=24,cbCardIndex=16,cbCardData=24(8万),
i=25,cbCardIndex=6,cbCardData=7(7筒),
i=26,cbCardIndex=21,cbCardData=36(4条),
i=27,cbCardIndex=32,cbCardData=54(发财),
i=28,cbCardIndex=33,cbCardData=55(白板),
i=29,cbCardIndex=0,cbCardData=1(1筒),
i=30,cbCardIndex=26,cbCardData=41(9条),
i=31,cbCardIndex=3,cbCardData=4(4筒),
i=32,cbCardIndex=18,cbCardData=33(1条),
i=33,cbCardIndex=24,cbCardData=39(7条),
i=34,cbCardIndex=28,cbCardData=50(南风),
i=35,cbCardIndex=20,cbCardData=35(3条),
i=36,cbCardIndex=17,cbCardData=25(9万),
i=37,cbCardIndex=21,cbCardData=36(4条),
i=38,cbCardIndex=29,cbCardData=51(西风),
i=39,cbCardIndex=35,cbCardData=66(夏),
i=40,cbCardIndex=22,cbCardData=37(5条),
i=41,cbCardIndex=0,cbCardData=1(1筒),
i=42,cbCardIndex=8,cbCardData=9(9筒),
i=43,cbCardIndex=6,cbCardData=7(7筒),
i=44,cbCardIndex=19,cbCardData=34(2条),
i=45,cbCardIndex=2,cbCardData=3(3筒),
i=46,cbCardIndex=29,cbCardData=51(西风),
i=47,cbCardIndex=12,cbCardData=20(4万),
i=48,cbCardIndex=32,cbCardData=54(发财),
i=49,cbCardIndex=1,cbCardData=2(2筒),
i=50,cbCardIndex=30,cbCardData=52(北风),
i=51,cbCardIndex=5,cbCardData=6(6筒),
i=52,cbCardIndex=2,cbCardData=3(3筒),
i=53,cbCardIndex=25,cbCardData=40(8条),
i=54,cbCardIndex=12,cbCardData=20(4万),
i=55,cbCardIndex=16,cbCardData=24(8万),
i=56,cbCardIndex=26,cbCardData=41(9条),
i=57,cbCardIndex=25,cbCardData=40(8条),
i=58,cbCardIndex=0,cbCardData=1(1筒),
i=59,cbCardIndex=4,cbCardData=5(5筒),
i=60,cbCardIndex=31,cbCardData=53(红中),
i=61,cbCardIndex=11,cbCardData=19(3万),
i=62,cbCardIndex=14,cbCardData=22(6万),
i=63,cbCardIndex=15,cbCardData=23(7万),
i=64,cbCardIndex=24,cbCardData=39(7条),
i=65,cbCardIndex=7,cbCardData=8(8筒),
i=66,cbCardIndex=16,cbCardData=24(8万),
i=67,cbCardIndex=1,cbCardData=2(2筒),
i=68,cbCardIndex=9,cbCardData=17(1万),
i=69,cbCardIndex=21,cbCardData=36(4条),
i=70,cbCardIndex=12,cbCardData=20(4万),
i=71,cbCardIndex=24,cbCardData=39(7条),
i=72,cbCardIndex=37,cbCardData=68(冬),
i=73,cbCardIndex=10,cbCardData=18(2万),
i=74,cbCardIndex=22,cbCardData=37(5条),
i=75,cbCardIndex=33,cbCardData=55(白板),
i=76,cbCardIndex=10,cbCardData=18(2万),
i=77,cbCardIndex=39,cbCardData=70(兰),
i=78,cbCardIndex=30,cbCardData=52(北风),
i=79,cbCardIndex=11,cbCardData=19(3万),
i=80,cbCardIndex=9,cbCardData=17(1万),
i=81,cbCardIndex=20,cbCardData=35(3条),
i=82,cbCardIndex=22,cbCardData=37(5条),
i=83,cbCardIndex=18,cbCardData=33(1条),
i=84,cbCardIndex=29,cbCardData=51(西风),
i=85,cbCardIndex=34,cbCardData=65(春),
i=86,cbCardIndex=28,cbCardData=50(南风),
i=87,cbCardIndex=17,cbCardData=25(9万),
i=88,cbCardIndex=27,cbCardData=49(东风),
i=89,cbCardIndex=21,cbCardData=36(4条),
i=90,cbCardIndex=15,cbCardData=23(7万),
i=91,cbCardIndex=3,cbCardData=4(4筒),
i=92,cbCardIndex=31,cbCardData=53(红中),
i=93,cbCardIndex=1,cbCardData=2(2筒),
i=94,cbCardIndex=10,cbCardData=18(2万),
i=95,cbCardIndex=28,cbCardData=50(南风),
i=96,cbCardIndex=10,cbCardData=18(2万),
i=97,cbCardIndex=5,cbCardData=6(6筒),
i=98,cbCardIndex=3,cbCardData=4(4筒),
i=99,cbCardIndex=8,cbCardData=9(9筒),
i=100,cbCardIndex=25,cbCardData=40(8条),
i=101,cbCardIndex=17,cbCardData=25(9万),
i=102,cbCardIndex=1,cbCardData=2(2筒),
i=103,cbCardIndex=6,cbCardData=7(7筒),
i=104,cbCardIndex=33,cbCardData=55(白板),
i=105,cbCardIndex=11,cbCardData=19(3万),
i=106,cbCardIndex=4,cbCardData=5(5筒),
i=107,cbCardIndex=3,cbCardData=4(4筒),
i=108,cbCardIndex=23,cbCardData=38(6条),
i=109,cbCardIndex=9,cbCardData=17(1万),
i=110,cbCardIndex=11,cbCardData=19(3万),
i=111,cbCardIndex=19,cbCardData=34(2条),
i=112,cbCardIndex=28,cbCardData=50(南风),
i=113,cbCardIndex=26,cbCardData=41(9条),
i=114,cbCardIndex=27,cbCardData=49(东风),
i=115,cbCardIndex=8,cbCardData=9(9筒),
i=116,cbCardIndex=22,cbCardData=37(5条),
i=117,cbCardIndex=33,cbCardData=55(白板),
i=118,cbCardIndex=26,cbCardData=41(9条),
i=119,cbCardIndex=38,cbCardData=69(梅),
i=120,cbCardIndex=15,cbCardData=23(7万),
i=121,cbCardIndex=41,cbCardData=72(竹),
i=122,cbCardIndex=25,cbCardData=40(8条),
i=123,cbCardIndex=17,cbCardData=25(9万),
i=124,cbCardIndex=13,cbCardData=21(5万),
i=125,cbCardIndex=24,cbCardData=39(7条),
i=126,cbCardIndex=20,cbCardData=35(3条),
i=127,cbCardIndex=14,cbCardData=22(6万),
i=128,cbCardIndex=4,cbCardData=5(5筒),
i=129,cbCardIndex=32,cbCardData=54(发财),
i=130,cbCardIndex=20,cbCardData=35(3条),
i=131,cbCardIndex=30,cbCardData=52(北风),
i=132,cbCardIndex=40,cbCardData=71(菊),
i=133,cbCardIndex=9,cbCardData=17(1万),
i=134,cbCardIndex=30,cbCardData=52(北风),
i=135,cbCardIndex=7,cbCardData=8(8筒),
i=136,cbCardIndex=36,cbCardData=67(秋),
i=137,cbCardIndex=29,cbCardData=51(西风),
i=138,cbCardIndex=27,cbCardData=49(东风),
i=139,cbCardIndex=7,cbCardData=8(8筒),
i=140,cbCardIndex=5,cbCardData=6(6筒),
i=141,cbCardIndex=31,cbCardData=53(红中),
i=142,cbCardIndex=13,cbCardData=21(5万),
i=143,cbCardIndex=19,cbCardData=34(2条),
i=[0]座,[6][8][8][11][15][23][31][33][34][34][35][43][47]
i=[0]座,[6筒][8筒][8筒][1万][5万][3条][东风][西风][北风][北风][红中][秋][菊]
i=[1]座,[5][15][16][17][19][23][27][28][29][36][37][45][48]
i=[1]座,[5筒][5万][6万][7万][9万][3条][7条][8条][9条][发财][白板][梅][竹]
i=[2]座,[4][5][9][11][13][13][22][25][26][29][31][32][37]
i=[2]座,[4筒][5筒][9筒][1万][3万][3万][2条][5条][6条][9条][东风][南风][白板]
i=[3]座,[2][2][4][4][6][7][9][12][12][19][28][32][35]
i=[3]座,[2筒][2筒][4筒][4筒][6筒][7筒][9筒][2万][2万][9万][8条][南风][红中]
发牌麻将:m_cbSendCardIndex=15,m_cbSendCardData=23(7万),
m_cbLeftCardCount=90
处理的情形:
8
4
m_cbChangeCardIndex=19,m_cbChangeCard=34(2条),
i=0,cbCardIndex=14,cbCardData=22(6万),
i=1,cbCardIndex=2,cbCardData=3(3筒),
i=2,cbCardIndex=23,cbCardData=38(6条),
i=3,cbCardIndex=31,cbCardData=53(红中),
i=4,cbCardIndex=27,cbCardData=49(东风),
i=5,cbCardIndex=8,cbCardData=9(9筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=13,cbCardData=21(5万),
i=8,cbCardIndex=7,cbCardData=8(8筒),
i=9,cbCardIndex=2,cbCardData=3(3筒),
i=10,cbCardIndex=23,cbCardData=38(6条),
i=11,cbCardIndex=19,cbCardData=34(2条),
i=12,cbCardIndex=13,cbCardData=21(5万),
i=13,cbCardIndex=14,cbCardData=22(6万),
i=14,cbCardIndex=18,cbCardData=33(1条),
i=15,cbCardIndex=23,cbCardData=38(6条),
i=16,cbCardIndex=15,cbCardData=23(7万),
i=17,cbCardIndex=4,cbCardData=5(5筒),
i=18,cbCardIndex=12,cbCardData=20(4万),
i=19,cbCardIndex=16,cbCardData=24(8万),
i=20,cbCardIndex=0,cbCardData=1(1筒),
i=21,cbCardIndex=18,cbCardData=33(1条),
i=22,cbCardIndex=32,cbCardData=54(发财),
i=23,cbCardIndex=5,cbCardData=6(6筒),
i=24,cbCardIndex=16,cbCardData=24(8万),
i=25,cbCardIndex=6,cbCardData=7(7筒),
i=26,cbCardIndex=21,cbCardData=36(4条),
i=27,cbCardIndex=32,cbCardData=54(发财),
i=28,cbCardIndex=33,cbCardData=55(白板),
i=29,cbCardIndex=0,cbCardData=1(1筒),
i=30,cbCardIndex=26,cbCardData=41(9条),
i=31,cbCardIndex=3,cbCardData=4(4筒),
i=32,cbCardIndex=18,cbCardData=33(1条),
i=33,cbCardIndex=24,cbCardData=39(7条),
i=34,cbCardIndex=28,cbCardData=50(南风),
i=35,cbCardIndex=20,cbCardData=35(3条),
i=36,cbCardIndex=17,cbCardData=25(9万),
i=37,cbCardIndex=21,cbCardData=36(4条),
i=38,cbCardIndex=29,cbCardData=51(西风),
i=39,cbCardIndex=35,cbCardData=66(夏),
i=40,cbCardIndex=22,cbCardData=37(5条),
i=41,cbCardIndex=0,cbCardData=1(1筒),
i=42,cbCardIndex=8,cbCardData=9(9筒),
i=43,cbCardIndex=6,cbCardData=7(7筒),
i=44,cbCardIndex=19,cbCardData=34(2条),
i=45,cbCardIndex=2,cbCardData=3(3筒),
i=46,cbCardIndex=29,cbCardData=51(西风),
i=47,cbCardIndex=12,cbCardData=20(4万),
i=48,cbCardIndex=32,cbCardData=54(发财),
i=49,cbCardIndex=1,cbCardData=2(2筒),
i=50,cbCardIndex=30,cbCardData=52(北风),
i=51,cbCardIndex=5,cbCardData=6(6筒),
i=52,cbCardIndex=2,cbCardData=3(3筒),
i=53,cbCardIndex=25,cbCardData=40(8条),
i=54,cbCardIndex=12,cbCardData=20(4万),
i=55,cbCardIndex=16,cbCardData=24(8万),
i=56,cbCardIndex=26,cbCardData=41(9条),
i=57,cbCardIndex=25,cbCardData=40(8条),
i=58,cbCardIndex=0,cbCardData=1(1筒),
i=59,cbCardIndex=4,cbCardData=5(5筒),
i=60,cbCardIndex=31,cbCardData=53(红中),
i=61,cbCardIndex=11,cbCardData=19(3万),
i=62,cbCardIndex=14,cbCardData=22(6万),
i=63,cbCardIndex=15,cbCardData=23(7万),
i=64,cbCardIndex=24,cbCardData=39(7条),
i=65,cbCardIndex=7,cbCardData=8(8筒),
i=66,cbCardIndex=16,cbCardData=24(8万),
i=67,cbCardIndex=1,cbCardData=2(2筒),
i=68,cbCardIndex=9,cbCardData=17(1万),
i=69,cbCardIndex=21,cbCardData=36(4条),
i=70,cbCardIndex=12,cbCardData=20(4万),
i=71,cbCardIndex=24,cbCardData=39(7条),
i=72,cbCardIndex=37,cbCardData=68(冬),
i=73,cbCardIndex=10,cbCardData=18(2万),
i=74,cbCardIndex=22,cbCardData=37(5条),
i=75,cbCardIndex=33,cbCardData=55(白板),
i=76,cbCardIndex=10,cbCardData=18(2万),
i=77,cbCardIndex=39,cbCardData=70(兰),
i=78,cbCardIndex=30,cbCardData=52(北风),
i=79,cbCardIndex=11,cbCardData=19(3万),
i=80,cbCardIndex=9,cbCardData=17(1万),
i=81,cbCardIndex=20,cbCardData=35(3条),
i=82,cbCardIndex=22,cbCardData=37(5条),
i=83,cbCardIndex=18,cbCardData=33(1条),
i=84,cbCardIndex=29,cbCardData=51(西风),
i=85,cbCardIndex=34,cbCardData=65(春),
i=86,cbCardIndex=28,cbCardData=50(南风),
i=87,cbCardIndex=17,cbCardData=25(9万),
i=88,cbCardIndex=27,cbCardData=49(东风),
i=89,cbCardIndex=21,cbCardData=36(4条),
i=90,cbCardIndex=15,cbCardData=23(7万),
i=91,cbCardIndex=3,cbCardData=4(4筒),
i=92,cbCardIndex=31,cbCardData=53(红中),
i=93,cbCardIndex=1,cbCardData=2(2筒),
i=94,cbCardIndex=10,cbCardData=18(2万),
i=95,cbCardIndex=28,cbCardData=50(南风),
i=96,cbCardIndex=10,cbCardData=18(2万),
i=97,cbCardIndex=5,cbCardData=6(6筒),
i=98,cbCardIndex=3,cbCardData=4(4筒),
i=99,cbCardIndex=8,cbCardData=9(9筒),
i=100,cbCardIndex=25,cbCardData=40(8条),
i=101,cbCardIndex=17,cbCardData=25(9万),
i=102,cbCardIndex=1,cbCardData=2(2筒),
i=103,cbCardIndex=6,cbCardData=7(7筒),
i=104,cbCardIndex=33,cbCardData=55(白板),
i=105,cbCardIndex=11,cbCardData=19(3万),
i=106,cbCardIndex=4,cbCardData=5(5筒),
i=107,cbCardIndex=3,cbCardData=4(4筒),
i=108,cbCardIndex=23,cbCardData=38(6条),
i=109,cbCardIndex=9,cbCardData=17(1万),
i=110,cbCardIndex=11,cbCardData=19(3万),
i=111,cbCardIndex=19,cbCardData=34(2条),
i=112,cbCardIndex=28,cbCardData=50(南风),
i=113,cbCardIndex=26,cbCardData=41(9条),
i=114,cbCardIndex=27,cbCardData=49(东风),
i=115,cbCardIndex=8,cbCardData=9(9筒),
i=116,cbCardIndex=22,cbCardData=37(5条),
i=117,cbCardIndex=33,cbCardData=55(白板),
i=118,cbCardIndex=26,cbCardData=41(9条),
i=119,cbCardIndex=38,cbCardData=69(梅),
i=120,cbCardIndex=15,cbCardData=23(7万),
i=121,cbCardIndex=41,cbCardData=72(竹),
i=122,cbCardIndex=25,cbCardData=40(8条),
i=123,cbCardIndex=17,cbCardData=25(9万),
i=124,cbCardIndex=13,cbCardData=21(5万),
i=125,cbCardIndex=24,cbCardData=39(7条),
i=126,cbCardIndex=20,cbCardData=35(3条),
i=127,cbCardIndex=14,cbCardData=22(6万),
i=128,cbCardIndex=4,cbCardData=5(5筒),
i=129,cbCardIndex=32,cbCardData=54(发财),
i=130,cbCardIndex=20,cbCardData=35(3条),
i=131,cbCardIndex=30,cbCardData=52(北风),
i=132,cbCardIndex=40,cbCardData=71(菊),
i=133,cbCardIndex=9,cbCardData=17(1万),
i=134,cbCardIndex=30,cbCardData=52(北风),
i=135,cbCardIndex=7,cbCardData=8(8筒),
i=136,cbCardIndex=36,cbCardData=67(秋),
i=137,cbCardIndex=29,cbCardData=51(西风),
i=138,cbCardIndex=27,cbCardData=49(东风),
i=139,cbCardIndex=7,cbCardData=8(8筒),
i=140,cbCardIndex=5,cbCardData=6(6筒),
i=141,cbCardIndex=31,cbCardData=53(红中),
i=142,cbCardIndex=13,cbCardData=21(5万),
i=143,cbCardIndex=19,cbCardData=34(2条),
i=[0]座,[6][8][8][11][15][23][31][33][34][34][35][43][47]
i=[0]座,[6筒][8筒][8筒][1万][5万][3条][东风][西风][北风][北风][红中][秋][菊]
i=[1]座,[5][15][16][17][19][23][27][28][29][36][37][45][48]
i=[1]座,[5筒][5万][6万][7万][9万][3条][7条][8条][9条][发财][白板][梅][竹]
i=[2]座,[22][4][5][9][11][13][13][25][26][29][31][32][37]
i=[2]座,[2条][4筒][5筒][9筒][1万][3万][3万][5条][6条][9条][东风][南风][白板]
i=[3]座,[2][2][4][4][6][7][9][12][12][19][28][32][35]
i=[3]座,[2筒][2筒][4筒][4筒][6筒][7筒][9筒][2万][2万][9万][8条][南风][红中]
发牌麻将:m_cbSendCardIndex=15,m_cbSendCardData=23(7万),
m_cbLeftCardCount=90
20170208添加:
BYTE CGameLogic::SwitchToCardIndex_old(BYTE cbCardData)
{
#if 1
ASSERT(IsValidCard(cbCardData));
return ((cbCardData&MASK_COLOR)>>4)*9+(cbCardData&MASK_VALUE)-1;
#else
ASSERT(IsValidCard(cbCardData));
if(cbCardData<SPRING_DATA)
return ((cbCardData&MASK_COLOR)>>4)*9+(cbCardData&MASK_VALUE)-1;
else
return (SPRING_INDEX+(cbCardData&MASK_VALUE)-1);
#endif
}
8
4
m_cbChangeCardIndex=1,m_cbChangeCard=2(2筒),
i=0,cbCardIndex=0,cbCardData=1(1筒),
i=1,cbCardIndex=1,cbCardData=2(2筒),
i=2,cbCardIndex=2,cbCardData=3(3筒),
i=3,cbCardIndex=3,cbCardData=4(4筒),
i=4,cbCardIndex=4,cbCardData=5(5筒),
i=5,cbCardIndex=5,cbCardData=6(6筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=7,cbCardData=8(8筒),
i=8,cbCardIndex=8,cbCardData=9(9筒),
i=9,cbCardIndex=9,cbCardData=17(1万),
i=10,cbCardIndex=10,cbCardData=18(2万),
i=11,cbCardIndex=11,cbCardData=19(3万),
i=12,cbCardIndex=12,cbCardData=20(4万),
i=13,cbCardIndex=13,cbCardData=21(5万),
i=14,cbCardIndex=14,cbCardData=22(6万),
i=15,cbCardIndex=15,cbCardData=23(7万),
i=16,cbCardIndex=16,cbCardData=24(8万),
i=17,cbCardIndex=17,cbCardData=25(9万),
i=18,cbCardIndex=18,cbCardData=33(1条),
i=19,cbCardIndex=19,cbCardData=34(2条),
i=20,cbCardIndex=20,cbCardData=35(3条),
i=21,cbCardIndex=21,cbCardData=36(4条),
i=22,cbCardIndex=22,cbCardData=37(5条),
i=23,cbCardIndex=23,cbCardData=38(6条),
i=24,cbCardIndex=24,cbCardData=39(7条),
i=25,cbCardIndex=25,cbCardData=40(8条),
i=26,cbCardIndex=26,cbCardData=41(9条),
i=27,cbCardIndex=27,cbCardData=49(东风),
i=28,cbCardIndex=28,cbCardData=50(南风),
i=29,cbCardIndex=29,cbCardData=51(西风),
i=30,cbCardIndex=30,cbCardData=52(北风),
i=31,cbCardIndex=31,cbCardData=53(红中),
i=32,cbCardIndex=32,cbCardData=54(发财),
i=33,cbCardIndex=33,cbCardData=55(白板),
i=34,cbCardIndex=34,cbCardData=56(),
i=35,cbCardIndex=35,cbCardData=57(),
i=36,cbCardIndex=36,cbCardData=58(),
i=37,cbCardIndex=37,cbCardData=59(),
i=38,cbCardIndex=38,cbCardData=60(),
i=39,cbCardIndex=39,cbCardData=61(),
i=40,cbCardIndex=40,cbCardData=62(),
i=41,cbCardIndex=41,cbCardData=63(),
#ifdef TEST3
BYTE m_cbCardIndex[GAME_PLAYER][MAX_INDEX]; //用户麻将
ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex));
BYTE m_cbCardIndex[GAME_PLAYER][MAX_INDEX]; //用户麻将
ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex));
//庄家判断
//杠牌判断
WORD m_wBankerUser=0;
BYTE m_cbChangeCard=0x34;
m_GameLogic.SetMagicIndex(m_GameLogic.SwitchToCardIndex_old(m_cbChangeCard));
BYTE cbTest1[MAX_HANDCARD_COUNT]={0x2,0x6,0x9,0x13,0x13,0x13,0x13,0x22,0x22,0x22,0x23,0x22,0x37,0x47};
m_GameLogic.SwitchToCardIndex(cbTest1,MAX_HANDCARD_COUNT,m_cbCardIndex[m_wBankerUser]);
{
BYTE GameStartcbCardData[MAX_HANDCARD_COUNT]={0};
memset(GameStartcbCardData, 0, sizeof(GameStartcbCardData));
m_GameLogic.SwitchToCardData(m_cbCardIndex[m_wBankerUser],GameStartcbCardData);
//杠牌判断
WORD m_wBankerUser=0;
BYTE m_cbChangeCard=0x34;
m_GameLogic.SetMagicIndex(m_GameLogic.SwitchToCardIndex_old(m_cbChangeCard));
BYTE cbTest1[MAX_HANDCARD_COUNT]={0x2,0x6,0x9,0x13,0x13,0x13,0x13,0x22,0x22,0x22,0x23,0x22,0x37,0x47};
m_GameLogic.SwitchToCardIndex(cbTest1,MAX_HANDCARD_COUNT,m_cbCardIndex[m_wBankerUser]);
{
BYTE GameStartcbCardData[MAX_HANDCARD_COUNT]={0};
memset(GameStartcbCardData, 0, sizeof(GameStartcbCardData));
m_GameLogic.SwitchToCardData(m_cbCardIndex[m_wBankerUser],GameStartcbCardData);
CString strLog;
strLog.Format("财神牌:[%x],当前牌:[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]",m_cbChangeCard,GameStartcbCardData[0],GameStartcbCardData[1],GameStartcbCardData[2],GameStartcbCardData[3],GameStartcbCardData[4],GameStartcbCardData[5],GameStartcbCardData[6],GameStartcbCardData[0+7],GameStartcbCardData[1+7],GameStartcbCardData[2+7],GameStartcbCardData[3+7],GameStartcbCardData[4+7],GameStartcbCardData[5+7],GameStartcbCardData[6+7]);
cout<<strLog.GetString()<<endl;
strLog.Format("财神牌:[%s],当前牌:[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]",QZGameLogic::GetMJCardName(m_cbChangeCard),QZGameLogic::GetMJCardName(GameStartcbCardData[0]),QZGameLogic::GetMJCardName(GameStartcbCardData[1]),QZGameLogic::GetMJCardName(GameStartcbCardData[2]),QZGameLogic::GetMJCardName(GameStartcbCardData[3]),QZGameLogic::GetMJCardName(GameStartcbCardData[4]),QZGameLogic::GetMJCardName(GameStartcbCardData[5]),QZGameLogic::GetMJCardName(GameStartcbCardData[6]),QZGameLogic::GetMJCardName(GameStartcbCardData[0+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[1+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[2+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[3+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[4+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[5+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[6+7]));
cout<<strLog.GetString()<<endl;
}
BYTE m_cbUserAction[GAME_PLAYER];//用户动作
ZeroMemory(m_cbUserAction,sizeof(m_cbUserAction));
#if 0
tagGangCardResult GangCardResult;
tagGangCardResult *pGangCardResult=&GangCardResult;
m_cbUserAction[m_wBankerUser]|=m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wBankerUser],NULL,0,GangCardResult);
#else
QZtagGangCardResult GangCardResult;
tagGangCardResult *pGangCardResult=(tagGangCardResult *)&GangCardResult;
m_cbUserAction[m_wBankerUser]|=QZGameLogic::AnalyseGangCard(m_cbCardIndex[m_wBankerUser],NULL,0,GangCardResult);
#endif
cout<<"有"<<(int)pGangCardResult->cbCardCount<<"个杠:"<<endl;
for(int i=0;i<pGangCardResult->cbCardCount;i++)
{
CString strLog;
strLog.Format("第%d杠:0x%x(%s)",i+1,pGangCardResult->cbCardData[i],QZGameLogic::GetMJCardName(pGangCardResult->cbCardData[i]));
cout<<strLog.GetString()<<endl;
}
#endif
8
4
财神牌:[34],当前牌:[2][6][9][13][13][13][13][22][22][22][22][23][37][47]
财神牌:[北风],当前牌:[2筒][6筒][9筒][3万][3万][3万][3万][2条][2条][2条][2条][3条][白板][菊]
有2个杠:
第1杠:0x13(3万)
第2杠:0x22(2条)
m_GameLogic.SetMagicIndex(m_cbChangeCardIndex);
//分发麻将
for (WORD i=0;i<GAME_PLAYER;i++)
{
m_cbLeftCardCount-=(MAX_HANDCARD_COUNT-1);
#if 1
CGameLogic::SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount],MAX_HANDCARD_COUNT-1,m_cbCardIndex[i]);
#else
QZGameLogic::SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount],MAX_HANDCARD_COUNT-1,m_cbCardIndex[i]);
#endif
BYTE GameStartcbCardData[MAX_HANDCARD_COUNT]={0};
memset(GameStartcbCardData, 0, sizeof(GameStartcbCardData));
#if 1
//分发麻将时,如果分发了财神牌,财神牌放在前面
m_GameLogic.SwitchToCardData(m_cbCardIndex[i],GameStartcbCardData);
#else
//分发麻将时,如果分发了财神牌,财神牌位置没有处理
QZGameLogic::SwitchToCardData(m_cbCardIndex[i],GameStartcbCardData);
#endif
strLog.Format("财神牌:[%x],当前牌:[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]",m_cbChangeCard,GameStartcbCardData[0],GameStartcbCardData[1],GameStartcbCardData[2],GameStartcbCardData[3],GameStartcbCardData[4],GameStartcbCardData[5],GameStartcbCardData[6],GameStartcbCardData[0+7],GameStartcbCardData[1+7],GameStartcbCardData[2+7],GameStartcbCardData[3+7],GameStartcbCardData[4+7],GameStartcbCardData[5+7],GameStartcbCardData[6+7]);
cout<<strLog.GetString()<<endl;
strLog.Format("财神牌:[%s],当前牌:[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]",QZGameLogic::GetMJCardName(m_cbChangeCard),QZGameLogic::GetMJCardName(GameStartcbCardData[0]),QZGameLogic::GetMJCardName(GameStartcbCardData[1]),QZGameLogic::GetMJCardName(GameStartcbCardData[2]),QZGameLogic::GetMJCardName(GameStartcbCardData[3]),QZGameLogic::GetMJCardName(GameStartcbCardData[4]),QZGameLogic::GetMJCardName(GameStartcbCardData[5]),QZGameLogic::GetMJCardName(GameStartcbCardData[6]),QZGameLogic::GetMJCardName(GameStartcbCardData[0+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[1+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[2+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[3+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[4+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[5+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[6+7]));
cout<<strLog.GetString()<<endl;
}
BYTE m_cbUserAction[GAME_PLAYER];//用户动作
ZeroMemory(m_cbUserAction,sizeof(m_cbUserAction));
#if 0
tagGangCardResult GangCardResult;
tagGangCardResult *pGangCardResult=&GangCardResult;
m_cbUserAction[m_wBankerUser]|=m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wBankerUser],NULL,0,GangCardResult);
#else
QZtagGangCardResult GangCardResult;
tagGangCardResult *pGangCardResult=(tagGangCardResult *)&GangCardResult;
m_cbUserAction[m_wBankerUser]|=QZGameLogic::AnalyseGangCard(m_cbCardIndex[m_wBankerUser],NULL,0,GangCardResult);
#endif
cout<<"有"<<(int)pGangCardResult->cbCardCount<<"个杠:"<<endl;
for(int i=0;i<pGangCardResult->cbCardCount;i++)
{
CString strLog;
strLog.Format("第%d杠:0x%x(%s)",i+1,pGangCardResult->cbCardData[i],QZGameLogic::GetMJCardName(pGangCardResult->cbCardData[i]));
cout<<strLog.GetString()<<endl;
}
#endif
8
4
财神牌:[34],当前牌:[2][6][9][13][13][13][13][22][22][22][22][23][37][47]
财神牌:[北风],当前牌:[2筒][6筒][9筒][3万][3万][3万][3万][2条][2条][2条][2条][3条][白板][菊]
有2个杠:
第1杠:0x13(3万)
第2杠:0x22(2条)
m_GameLogic.SetMagicIndex(m_cbChangeCardIndex);
//分发麻将
for (WORD i=0;i<GAME_PLAYER;i++)
{
m_cbLeftCardCount-=(MAX_HANDCARD_COUNT-1);
#if 1
CGameLogic::SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount],MAX_HANDCARD_COUNT-1,m_cbCardIndex[i]);
#else
QZGameLogic::SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount],MAX_HANDCARD_COUNT-1,m_cbCardIndex[i]);
#endif
BYTE GameStartcbCardData[MAX_HANDCARD_COUNT]={0};
memset(GameStartcbCardData, 0, sizeof(GameStartcbCardData));
#if 1
//分发麻将时,如果分发了财神牌,财神牌放在前面
m_GameLogic.SwitchToCardData(m_cbCardIndex[i],GameStartcbCardData);
#else
//分发麻将时,如果分发了财神牌,财神牌位置没有处理
QZGameLogic::SwitchToCardData(m_cbCardIndex[i],GameStartcbCardData);
#endif
CString strLog;
strLog.Format("i=[%d]座,[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]",i,GameStartcbCardData[0],GameStartcbCardData[1],GameStartcbCardData[2],GameStartcbCardData[3],GameStartcbCardData[4],GameStartcbCardData[5],GameStartcbCardData[6],GameStartcbCardData[0+7],GameStartcbCardData[1+7],GameStartcbCardData[2+7],GameStartcbCardData[3+7],GameStartcbCardData[4+7],GameStartcbCardData[5+7],GameStartcbCardData[6+7]);
cout<<strLog.GetString()<<endl;
strLog.Format("i=[%d]座,[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]",i,QZGameLogic::GetMJCardName(GameStartcbCardData[0]),QZGameLogic::GetMJCardName(GameStartcbCardData[1]),QZGameLogic::GetMJCardName(GameStartcbCardData[2]),QZGameLogic::GetMJCardName(GameStartcbCardData[3]),QZGameLogic::GetMJCardName(GameStartcbCardData[4]),QZGameLogic::GetMJCardName(GameStartcbCardData[5]),QZGameLogic::GetMJCardName(GameStartcbCardData[6]),QZGameLogic::GetMJCardName(GameStartcbCardData[0+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[1+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[2+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[3+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[4+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[5+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[6+7]));
cout<<strLog.GetString()<<endl;
}
strLog.Format("i=[%d]座,[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]",i,GameStartcbCardData[0],GameStartcbCardData[1],GameStartcbCardData[2],GameStartcbCardData[3],GameStartcbCardData[4],GameStartcbCardData[5],GameStartcbCardData[6],GameStartcbCardData[0+7],GameStartcbCardData[1+7],GameStartcbCardData[2+7],GameStartcbCardData[3+7],GameStartcbCardData[4+7],GameStartcbCardData[5+7],GameStartcbCardData[6+7]);
cout<<strLog.GetString()<<endl;
strLog.Format("i=[%d]座,[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]",i,QZGameLogic::GetMJCardName(GameStartcbCardData[0]),QZGameLogic::GetMJCardName(GameStartcbCardData[1]),QZGameLogic::GetMJCardName(GameStartcbCardData[2]),QZGameLogic::GetMJCardName(GameStartcbCardData[3]),QZGameLogic::GetMJCardName(GameStartcbCardData[4]),QZGameLogic::GetMJCardName(GameStartcbCardData[5]),QZGameLogic::GetMJCardName(GameStartcbCardData[6]),QZGameLogic::GetMJCardName(GameStartcbCardData[0+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[1+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[2+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[3+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[4+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[5+7]),QZGameLogic::GetMJCardName(GameStartcbCardData[6+7]));
cout<<strLog.GetString()<<endl;
}
分发麻将时,如果分发了财神牌,要处理下
没有处理的情形:
2条是财神牌
8
4
m_cbChangeCardIndex=19,m_cbChangeCard=34(2条),
i=0,cbCardIndex=14,cbCardData=22(6万),
i=1,cbCardIndex=2,cbCardData=3(3筒),
i=2,cbCardIndex=23,cbCardData=38(6条),
i=3,cbCardIndex=31,cbCardData=53(红中),
i=4,cbCardIndex=27,cbCardData=49(东风),
i=5,cbCardIndex=8,cbCardData=9(9筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=13,cbCardData=21(5万),
i=8,cbCardIndex=7,cbCardData=8(8筒),
i=9,cbCardIndex=2,cbCardData=3(3筒),
i=10,cbCardIndex=23,cbCardData=38(6条),
i=11,cbCardIndex=19,cbCardData=34(2条),
i=12,cbCardIndex=13,cbCardData=21(5万),
i=13,cbCardIndex=14,cbCardData=22(6万),
i=14,cbCardIndex=18,cbCardData=33(1条),
i=15,cbCardIndex=23,cbCardData=38(6条),
i=16,cbCardIndex=15,cbCardData=23(7万),
i=17,cbCardIndex=4,cbCardData=5(5筒),
i=18,cbCardIndex=12,cbCardData=20(4万),
i=19,cbCardIndex=16,cbCardData=24(8万),
i=20,cbCardIndex=0,cbCardData=1(1筒),
i=21,cbCardIndex=18,cbCardData=33(1条),
i=22,cbCardIndex=32,cbCardData=54(发财),
i=23,cbCardIndex=5,cbCardData=6(6筒),
i=24,cbCardIndex=16,cbCardData=24(8万),
i=25,cbCardIndex=6,cbCardData=7(7筒),
i=26,cbCardIndex=21,cbCardData=36(4条),
i=27,cbCardIndex=32,cbCardData=54(发财),
i=28,cbCardIndex=33,cbCardData=55(白板),
i=29,cbCardIndex=0,cbCardData=1(1筒),
i=30,cbCardIndex=26,cbCardData=41(9条),
i=31,cbCardIndex=3,cbCardData=4(4筒),
i=32,cbCardIndex=18,cbCardData=33(1条),
i=33,cbCardIndex=24,cbCardData=39(7条),
i=34,cbCardIndex=28,cbCardData=50(南风),
i=35,cbCardIndex=20,cbCardData=35(3条),
i=36,cbCardIndex=17,cbCardData=25(9万),
i=37,cbCardIndex=21,cbCardData=36(4条),
i=38,cbCardIndex=29,cbCardData=51(西风),
i=39,cbCardIndex=35,cbCardData=66(夏),
i=40,cbCardIndex=22,cbCardData=37(5条),
i=41,cbCardIndex=0,cbCardData=1(1筒),
i=42,cbCardIndex=8,cbCardData=9(9筒),
i=43,cbCardIndex=6,cbCardData=7(7筒),
i=44,cbCardIndex=19,cbCardData=34(2条),
i=45,cbCardIndex=2,cbCardData=3(3筒),
i=46,cbCardIndex=29,cbCardData=51(西风),
i=47,cbCardIndex=12,cbCardData=20(4万),
i=48,cbCardIndex=32,cbCardData=54(发财),
i=49,cbCardIndex=1,cbCardData=2(2筒),
i=50,cbCardIndex=30,cbCardData=52(北风),
i=51,cbCardIndex=5,cbCardData=6(6筒),
i=52,cbCardIndex=2,cbCardData=3(3筒),
i=53,cbCardIndex=25,cbCardData=40(8条),
i=54,cbCardIndex=12,cbCardData=20(4万),
i=55,cbCardIndex=16,cbCardData=24(8万),
i=56,cbCardIndex=26,cbCardData=41(9条),
i=57,cbCardIndex=25,cbCardData=40(8条),
i=58,cbCardIndex=0,cbCardData=1(1筒),
i=59,cbCardIndex=4,cbCardData=5(5筒),
i=60,cbCardIndex=31,cbCardData=53(红中),
i=61,cbCardIndex=11,cbCardData=19(3万),
i=62,cbCardIndex=14,cbCardData=22(6万),
i=63,cbCardIndex=15,cbCardData=23(7万),
i=64,cbCardIndex=24,cbCardData=39(7条),
i=65,cbCardIndex=7,cbCardData=8(8筒),
i=66,cbCardIndex=16,cbCardData=24(8万),
i=67,cbCardIndex=1,cbCardData=2(2筒),
i=68,cbCardIndex=9,cbCardData=17(1万),
i=69,cbCardIndex=21,cbCardData=36(4条),
i=70,cbCardIndex=12,cbCardData=20(4万),
i=71,cbCardIndex=24,cbCardData=39(7条),
i=72,cbCardIndex=37,cbCardData=68(冬),
i=73,cbCardIndex=10,cbCardData=18(2万),
i=74,cbCardIndex=22,cbCardData=37(5条),
i=75,cbCardIndex=33,cbCardData=55(白板),
i=76,cbCardIndex=10,cbCardData=18(2万),
i=77,cbCardIndex=39,cbCardData=70(兰),
i=78,cbCardIndex=30,cbCardData=52(北风),
i=79,cbCardIndex=11,cbCardData=19(3万),
i=80,cbCardIndex=9,cbCardData=17(1万),
i=81,cbCardIndex=20,cbCardData=35(3条),
i=82,cbCardIndex=22,cbCardData=37(5条),
i=83,cbCardIndex=18,cbCardData=33(1条),
i=84,cbCardIndex=29,cbCardData=51(西风),
i=85,cbCardIndex=34,cbCardData=65(春),
i=86,cbCardIndex=28,cbCardData=50(南风),
i=87,cbCardIndex=17,cbCardData=25(9万),
i=88,cbCardIndex=27,cbCardData=49(东风),
i=89,cbCardIndex=21,cbCardData=36(4条),
i=90,cbCardIndex=15,cbCardData=23(7万),
i=91,cbCardIndex=3,cbCardData=4(4筒),
i=92,cbCardIndex=31,cbCardData=53(红中),
i=93,cbCardIndex=1,cbCardData=2(2筒),
i=94,cbCardIndex=10,cbCardData=18(2万),
i=95,cbCardIndex=28,cbCardData=50(南风),
i=96,cbCardIndex=10,cbCardData=18(2万),
i=97,cbCardIndex=5,cbCardData=6(6筒),
i=98,cbCardIndex=3,cbCardData=4(4筒),
i=99,cbCardIndex=8,cbCardData=9(9筒),
i=100,cbCardIndex=25,cbCardData=40(8条),
i=101,cbCardIndex=17,cbCardData=25(9万),
i=102,cbCardIndex=1,cbCardData=2(2筒),
i=103,cbCardIndex=6,cbCardData=7(7筒),
i=104,cbCardIndex=33,cbCardData=55(白板),
i=105,cbCardIndex=11,cbCardData=19(3万),
i=106,cbCardIndex=4,cbCardData=5(5筒),
i=107,cbCardIndex=3,cbCardData=4(4筒),
i=108,cbCardIndex=23,cbCardData=38(6条),
i=109,cbCardIndex=9,cbCardData=17(1万),
i=110,cbCardIndex=11,cbCardData=19(3万),
i=111,cbCardIndex=19,cbCardData=34(2条),
i=112,cbCardIndex=28,cbCardData=50(南风),
i=113,cbCardIndex=26,cbCardData=41(9条),
i=114,cbCardIndex=27,cbCardData=49(东风),
i=115,cbCardIndex=8,cbCardData=9(9筒),
i=116,cbCardIndex=22,cbCardData=37(5条),
i=117,cbCardIndex=33,cbCardData=55(白板),
i=118,cbCardIndex=26,cbCardData=41(9条),
i=119,cbCardIndex=38,cbCardData=69(梅),
i=120,cbCardIndex=15,cbCardData=23(7万),
i=121,cbCardIndex=41,cbCardData=72(竹),
i=122,cbCardIndex=25,cbCardData=40(8条),
i=123,cbCardIndex=17,cbCardData=25(9万),
i=124,cbCardIndex=13,cbCardData=21(5万),
i=125,cbCardIndex=24,cbCardData=39(7条),
i=126,cbCardIndex=20,cbCardData=35(3条),
i=127,cbCardIndex=14,cbCardData=22(6万),
i=128,cbCardIndex=4,cbCardData=5(5筒),
i=129,cbCardIndex=32,cbCardData=54(发财),
i=130,cbCardIndex=20,cbCardData=35(3条),
i=131,cbCardIndex=30,cbCardData=52(北风),
i=132,cbCardIndex=40,cbCardData=71(菊),
i=133,cbCardIndex=9,cbCardData=17(1万),
i=134,cbCardIndex=30,cbCardData=52(北风),
i=135,cbCardIndex=7,cbCardData=8(8筒),
i=136,cbCardIndex=36,cbCardData=67(秋),
i=137,cbCardIndex=29,cbCardData=51(西风),
i=138,cbCardIndex=27,cbCardData=49(东风),
i=139,cbCardIndex=7,cbCardData=8(8筒),
i=140,cbCardIndex=5,cbCardData=6(6筒),
i=141,cbCardIndex=31,cbCardData=53(红中),
i=142,cbCardIndex=13,cbCardData=21(5万),
i=143,cbCardIndex=19,cbCardData=34(2条),
i=[0]座,[6][8][8][11][15][23][31][33][34][34][35][43][47]
i=[0]座,[6筒][8筒][8筒][1万][5万][3条][东风][西风][北风][北风][红中][秋][菊]
i=[1]座,[5][15][16][17][19][23][27][28][29][36][37][45][48]
i=[1]座,[5筒][5万][6万][7万][9万][3条][7条][8条][9条][发财][白板][梅][竹]
i=[2]座,[4][5][9][11][13][13][22][25][26][29][31][32][37]
i=[2]座,[4筒][5筒][9筒][1万][3万][3万][2条][5条][6条][9条][东风][南风][白板]
i=[3]座,[2][2][4][4][6][7][9][12][12][19][28][32][35]
i=[3]座,[2筒][2筒][4筒][4筒][6筒][7筒][9筒][2万][2万][9万][8条][南风][红中]
发牌麻将:m_cbSendCardIndex=15,m_cbSendCardData=23(7万),
m_cbLeftCardCount=90
处理的情形:
8
4
m_cbChangeCardIndex=19,m_cbChangeCard=34(2条),
i=0,cbCardIndex=14,cbCardData=22(6万),
i=1,cbCardIndex=2,cbCardData=3(3筒),
i=2,cbCardIndex=23,cbCardData=38(6条),
i=3,cbCardIndex=31,cbCardData=53(红中),
i=4,cbCardIndex=27,cbCardData=49(东风),
i=5,cbCardIndex=8,cbCardData=9(9筒),
i=6,cbCardIndex=6,cbCardData=7(7筒),
i=7,cbCardIndex=13,cbCardData=21(5万),
i=8,cbCardIndex=7,cbCardData=8(8筒),
i=9,cbCardIndex=2,cbCardData=3(3筒),
i=10,cbCardIndex=23,cbCardData=38(6条),
i=11,cbCardIndex=19,cbCardData=34(2条),
i=12,cbCardIndex=13,cbCardData=21(5万),
i=13,cbCardIndex=14,cbCardData=22(6万),
i=14,cbCardIndex=18,cbCardData=33(1条),
i=15,cbCardIndex=23,cbCardData=38(6条),
i=16,cbCardIndex=15,cbCardData=23(7万),
i=17,cbCardIndex=4,cbCardData=5(5筒),
i=18,cbCardIndex=12,cbCardData=20(4万),
i=19,cbCardIndex=16,cbCardData=24(8万),
i=20,cbCardIndex=0,cbCardData=1(1筒),
i=21,cbCardIndex=18,cbCardData=33(1条),
i=22,cbCardIndex=32,cbCardData=54(发财),
i=23,cbCardIndex=5,cbCardData=6(6筒),
i=24,cbCardIndex=16,cbCardData=24(8万),
i=25,cbCardIndex=6,cbCardData=7(7筒),
i=26,cbCardIndex=21,cbCardData=36(4条),
i=27,cbCardIndex=32,cbCardData=54(发财),
i=28,cbCardIndex=33,cbCardData=55(白板),
i=29,cbCardIndex=0,cbCardData=1(1筒),
i=30,cbCardIndex=26,cbCardData=41(9条),
i=31,cbCardIndex=3,cbCardData=4(4筒),
i=32,cbCardIndex=18,cbCardData=33(1条),
i=33,cbCardIndex=24,cbCardData=39(7条),
i=34,cbCardIndex=28,cbCardData=50(南风),
i=35,cbCardIndex=20,cbCardData=35(3条),
i=36,cbCardIndex=17,cbCardData=25(9万),
i=37,cbCardIndex=21,cbCardData=36(4条),
i=38,cbCardIndex=29,cbCardData=51(西风),
i=39,cbCardIndex=35,cbCardData=66(夏),
i=40,cbCardIndex=22,cbCardData=37(5条),
i=41,cbCardIndex=0,cbCardData=1(1筒),
i=42,cbCardIndex=8,cbCardData=9(9筒),
i=43,cbCardIndex=6,cbCardData=7(7筒),
i=44,cbCardIndex=19,cbCardData=34(2条),
i=45,cbCardIndex=2,cbCardData=3(3筒),
i=46,cbCardIndex=29,cbCardData=51(西风),
i=47,cbCardIndex=12,cbCardData=20(4万),
i=48,cbCardIndex=32,cbCardData=54(发财),
i=49,cbCardIndex=1,cbCardData=2(2筒),
i=50,cbCardIndex=30,cbCardData=52(北风),
i=51,cbCardIndex=5,cbCardData=6(6筒),
i=52,cbCardIndex=2,cbCardData=3(3筒),
i=53,cbCardIndex=25,cbCardData=40(8条),
i=54,cbCardIndex=12,cbCardData=20(4万),
i=55,cbCardIndex=16,cbCardData=24(8万),
i=56,cbCardIndex=26,cbCardData=41(9条),
i=57,cbCardIndex=25,cbCardData=40(8条),
i=58,cbCardIndex=0,cbCardData=1(1筒),
i=59,cbCardIndex=4,cbCardData=5(5筒),
i=60,cbCardIndex=31,cbCardData=53(红中),
i=61,cbCardIndex=11,cbCardData=19(3万),
i=62,cbCardIndex=14,cbCardData=22(6万),
i=63,cbCardIndex=15,cbCardData=23(7万),
i=64,cbCardIndex=24,cbCardData=39(7条),
i=65,cbCardIndex=7,cbCardData=8(8筒),
i=66,cbCardIndex=16,cbCardData=24(8万),
i=67,cbCardIndex=1,cbCardData=2(2筒),
i=68,cbCardIndex=9,cbCardData=17(1万),
i=69,cbCardIndex=21,cbCardData=36(4条),
i=70,cbCardIndex=12,cbCardData=20(4万),
i=71,cbCardIndex=24,cbCardData=39(7条),
i=72,cbCardIndex=37,cbCardData=68(冬),
i=73,cbCardIndex=10,cbCardData=18(2万),
i=74,cbCardIndex=22,cbCardData=37(5条),
i=75,cbCardIndex=33,cbCardData=55(白板),
i=76,cbCardIndex=10,cbCardData=18(2万),
i=77,cbCardIndex=39,cbCardData=70(兰),
i=78,cbCardIndex=30,cbCardData=52(北风),
i=79,cbCardIndex=11,cbCardData=19(3万),
i=80,cbCardIndex=9,cbCardData=17(1万),
i=81,cbCardIndex=20,cbCardData=35(3条),
i=82,cbCardIndex=22,cbCardData=37(5条),
i=83,cbCardIndex=18,cbCardData=33(1条),
i=84,cbCardIndex=29,cbCardData=51(西风),
i=85,cbCardIndex=34,cbCardData=65(春),
i=86,cbCardIndex=28,cbCardData=50(南风),
i=87,cbCardIndex=17,cbCardData=25(9万),
i=88,cbCardIndex=27,cbCardData=49(东风),
i=89,cbCardIndex=21,cbCardData=36(4条),
i=90,cbCardIndex=15,cbCardData=23(7万),
i=91,cbCardIndex=3,cbCardData=4(4筒),
i=92,cbCardIndex=31,cbCardData=53(红中),
i=93,cbCardIndex=1,cbCardData=2(2筒),
i=94,cbCardIndex=10,cbCardData=18(2万),
i=95,cbCardIndex=28,cbCardData=50(南风),
i=96,cbCardIndex=10,cbCardData=18(2万),
i=97,cbCardIndex=5,cbCardData=6(6筒),
i=98,cbCardIndex=3,cbCardData=4(4筒),
i=99,cbCardIndex=8,cbCardData=9(9筒),
i=100,cbCardIndex=25,cbCardData=40(8条),
i=101,cbCardIndex=17,cbCardData=25(9万),
i=102,cbCardIndex=1,cbCardData=2(2筒),
i=103,cbCardIndex=6,cbCardData=7(7筒),
i=104,cbCardIndex=33,cbCardData=55(白板),
i=105,cbCardIndex=11,cbCardData=19(3万),
i=106,cbCardIndex=4,cbCardData=5(5筒),
i=107,cbCardIndex=3,cbCardData=4(4筒),
i=108,cbCardIndex=23,cbCardData=38(6条),
i=109,cbCardIndex=9,cbCardData=17(1万),
i=110,cbCardIndex=11,cbCardData=19(3万),
i=111,cbCardIndex=19,cbCardData=34(2条),
i=112,cbCardIndex=28,cbCardData=50(南风),
i=113,cbCardIndex=26,cbCardData=41(9条),
i=114,cbCardIndex=27,cbCardData=49(东风),
i=115,cbCardIndex=8,cbCardData=9(9筒),
i=116,cbCardIndex=22,cbCardData=37(5条),
i=117,cbCardIndex=33,cbCardData=55(白板),
i=118,cbCardIndex=26,cbCardData=41(9条),
i=119,cbCardIndex=38,cbCardData=69(梅),
i=120,cbCardIndex=15,cbCardData=23(7万),
i=121,cbCardIndex=41,cbCardData=72(竹),
i=122,cbCardIndex=25,cbCardData=40(8条),
i=123,cbCardIndex=17,cbCardData=25(9万),
i=124,cbCardIndex=13,cbCardData=21(5万),
i=125,cbCardIndex=24,cbCardData=39(7条),
i=126,cbCardIndex=20,cbCardData=35(3条),
i=127,cbCardIndex=14,cbCardData=22(6万),
i=128,cbCardIndex=4,cbCardData=5(5筒),
i=129,cbCardIndex=32,cbCardData=54(发财),
i=130,cbCardIndex=20,cbCardData=35(3条),
i=131,cbCardIndex=30,cbCardData=52(北风),
i=132,cbCardIndex=40,cbCardData=71(菊),
i=133,cbCardIndex=9,cbCardData=17(1万),
i=134,cbCardIndex=30,cbCardData=52(北风),
i=135,cbCardIndex=7,cbCardData=8(8筒),
i=136,cbCardIndex=36,cbCardData=67(秋),
i=137,cbCardIndex=29,cbCardData=51(西风),
i=138,cbCardIndex=27,cbCardData=49(东风),
i=139,cbCardIndex=7,cbCardData=8(8筒),
i=140,cbCardIndex=5,cbCardData=6(6筒),
i=141,cbCardIndex=31,cbCardData=53(红中),
i=142,cbCardIndex=13,cbCardData=21(5万),
i=143,cbCardIndex=19,cbCardData=34(2条),
i=[0]座,[6][8][8][11][15][23][31][33][34][34][35][43][47]
i=[0]座,[6筒][8筒][8筒][1万][5万][3条][东风][西风][北风][北风][红中][秋][菊]
i=[1]座,[5][15][16][17][19][23][27][28][29][36][37][45][48]
i=[1]座,[5筒][5万][6万][7万][9万][3条][7条][8条][9条][发财][白板][梅][竹]
i=[2]座,[22][4][5][9][11][13][13][25][26][29][31][32][37]
i=[2]座,[2条][4筒][5筒][9筒][1万][3万][3万][5条][6条][9条][东风][南风][白板]
i=[3]座,[2][2][4][4][6][7][9][12][12][19][28][32][35]
i=[3]座,[2筒][2筒][4筒][4筒][6筒][7筒][9筒][2万][2万][9万][8条][南风][红中]
发牌麻将:m_cbSendCardIndex=15,m_cbSendCardData=23(7万),
m_cbLeftCardCount=90
20170208添加:
http://www.52pojie.cn/thread-548527-1-1.html?_t_t_t=0.040788070764392614
湖南房卡麻将后台搭建和客户端编译+微信登录源码程序
https://pan.baidu.com/s/1kVqFbRx
湖南房卡麻将后台搭建和客户端编译+微信登录源码程序
https://pan.baidu.com/s/1kVqFbRx
// 麻将算番,实际上用一个DWORD表示就可以了,处理还更简单,非要建一个类,自找麻烦!!
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<assert.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<assert.h>
#ifndef ASSERT
#define ASSERT(f) assert(f)
#endif
#define ASSERT(f) assert(f)
#endif
#define zeromemory(x,size) memset(x,0,size)
// 数组维数,这个就是计算数组里有几个元素的
#define CountArray(Array) (sizeof(Array)/sizeof(Array[0]))
#define CountArray(Array) (sizeof(Array)/sizeof(Array[0]))
#define MAX_RIGHT_COUNT 3
// "番"类型不能超过28个,#define MASK_CHI_HU_RIGHT 0x0fffffff,MASK_CHI_HU_RIGHT等于2的28次方减1
#define MASK_CHI_HU_RIGHT 0x0fffffff
#define MASK_CHI_HU_RIGHT 0x0fffffff
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned short WORD;
typedef unsigned long DWORD;
/*
// 权位类。
// 注意,在操作仅位时最好只操作单个权位.例如
// CChiHuRight chr;
// chr |= (chr_zi_mo|chr_peng_peng),这样结果是无定义的。
// 只能单个操作:
// chr |= chr_zi_mo;
// chr |= chr_peng_peng;
类功能:麻将
static bool m_bInit 表示静态成员是否被初始化过一次,第二次建立对象就不再初始化了
static DWORD m_dwRightMask[MAX_RIGHT_COUNT] 记录有效位,用一个bit位表示一种"番"类型
DWORD m_dwRight[MAX_RIGHT_COUNT] 实际胡牌位,包含几个dwRightMask中的有效位
这个类仅仅记录胡的牌有哪些番
应该有另一个函数用于计算胡牌得分
*/
class CChiHuRight
{
//静态变量
private:
static bool m_bInit;
static DWORD m_dwRightMask[MAX_RIGHT_COUNT];
// 权位类。
// 注意,在操作仅位时最好只操作单个权位.例如
// CChiHuRight chr;
// chr |= (chr_zi_mo|chr_peng_peng),这样结果是无定义的。
// 只能单个操作:
// chr |= chr_zi_mo;
// chr |= chr_peng_peng;
类功能:麻将
static bool m_bInit 表示静态成员是否被初始化过一次,第二次建立对象就不再初始化了
static DWORD m_dwRightMask[MAX_RIGHT_COUNT] 记录有效位,用一个bit位表示一种"番"类型
DWORD m_dwRight[MAX_RIGHT_COUNT] 实际胡牌位,包含几个dwRightMask中的有效位
这个类仅仅记录胡的牌有哪些番
应该有另一个函数用于计算胡牌得分
*/
class CChiHuRight
{
//静态变量
private:
static bool m_bInit;
static DWORD m_dwRightMask[MAX_RIGHT_COUNT];
//权位变量
private:
DWORD m_dwRight[MAX_RIGHT_COUNT];
private:
DWORD m_dwRight[MAX_RIGHT_COUNT];
public:
//构造函数
CChiHuRight();
//构造函数
CChiHuRight();
//运算符重载
public:
//赋值符
CChiHuRight & operator = ( DWORD dwRight );
public:
//赋值符
CChiHuRight & operator = ( DWORD dwRight );
//与等于
CChiHuRight & operator &= ( DWORD dwRight );
//或等于
CChiHuRight & operator |= ( DWORD dwRight );
CChiHuRight & operator &= ( DWORD dwRight );
//或等于
CChiHuRight & operator |= ( DWORD dwRight );
//与
CChiHuRight operator & ( DWORD dwRight );
CChiHuRight operator & ( DWORD dwRight ) const;
CChiHuRight operator & ( DWORD dwRight );
CChiHuRight operator & ( DWORD dwRight ) const;
//或
CChiHuRight operator | ( DWORD dwRight );
CChiHuRight operator | ( DWORD dwRight ) const;
CChiHuRight operator | ( DWORD dwRight );
CChiHuRight operator | ( DWORD dwRight ) const;
//相等
bool operator == ( DWORD dwRight ) const;
bool operator == ( const CChiHuRight chr ) const;
bool operator == ( DWORD dwRight ) const;
bool operator == ( const CChiHuRight chr ) const;
//不相等
bool operator != ( DWORD dwRight ) const;
bool operator != ( const CChiHuRight chr ) const;
bool operator != ( DWORD dwRight ) const;
bool operator != ( const CChiHuRight chr ) const;
//功能函数
public:
//是否权位为空
bool IsEmpty();
public:
//是否权位为空
bool IsEmpty();
//设置权位为空
void SetEmpty();
void SetEmpty();
//获取权位数值
BYTE GetRightData( DWORD dwRight[], BYTE cbMaxCount );
BYTE GetRightData( DWORD dwRight[], BYTE cbMaxCount );
//设置权位数值
bool SetRightData( const DWORD dwRight[], BYTE cbRightCount );
bool SetRightData( const DWORD dwRight[], BYTE cbRightCount );
private:
//检查权位是否正确
bool IsValidRight( DWORD dwRight );
};
//检查权位是否正确
bool IsValidRight( DWORD dwRight );
};
//静态变量
bool CChiHuRight::m_bInit = false;
bool CChiHuRight::m_bInit = false;
// 这个数组里记录各种“番”是否成立
DWORD CChiHuRight::m_dwRightMask[MAX_RIGHT_COUNT];
DWORD CChiHuRight::m_dwRightMask[MAX_RIGHT_COUNT];
//构造函数
CChiHuRight::CChiHuRight()
{
zeromemory(m_dwRight,sizeof(m_dwRight) );
CChiHuRight::CChiHuRight()
{
zeromemory(m_dwRight,sizeof(m_dwRight) );
if( !m_bInit )
{
m_bInit = true;
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
{
if( 0 == i )
m_dwRightMask[i] = 0;
else
m_dwRightMask[i] = (DWORD(pow((float)2,(float)(i-1))))<<28; //power 幂,乘方 pow(x,y) 表示 x 的 y 次幂
}
}
}
{
m_bInit = true;
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
{
if( 0 == i )
m_dwRightMask[i] = 0;
else
m_dwRightMask[i] = (DWORD(pow((float)2,(float)(i-1))))<<28; //power 幂,乘方 pow(x,y) 表示 x 的 y 次幂
}
}
}
//赋值符重载
CChiHuRight & CChiHuRight::operator = ( DWORD dwRight )
{
DWORD dwOtherRight = 0;
//验证权位
if( !IsValidRight( dwRight ) )
{
//验证取反权位
ASSERT( IsValidRight( ~dwRight ) );
if( !IsValidRight( ~dwRight ) ) return *this;
dwRight = ~dwRight;
dwOtherRight = MASK_CHI_HU_RIGHT;
}
CChiHuRight & CChiHuRight::operator = ( DWORD dwRight )
{
DWORD dwOtherRight = 0;
//验证权位
if( !IsValidRight( dwRight ) )
{
//验证取反权位
ASSERT( IsValidRight( ~dwRight ) );
if( !IsValidRight( ~dwRight ) ) return *this;
dwRight = ~dwRight;
dwOtherRight = MASK_CHI_HU_RIGHT;
}
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
{
if( (dwRight&m_dwRightMask[i]) || (i==0&&dwRight<0x10000000) )
m_dwRight[i] = dwRight&MASK_CHI_HU_RIGHT;
else m_dwRight[i] = dwOtherRight;
}
{
if( (dwRight&m_dwRightMask[i]) || (i==0&&dwRight<0x10000000) )
m_dwRight[i] = dwRight&MASK_CHI_HU_RIGHT;
else m_dwRight[i] = dwOtherRight;
}
return *this;
}
}
//与等于
CChiHuRight & CChiHuRight::operator &= ( DWORD dwRight )
{
bool bNavigate = false;
//验证权位
if( !IsValidRight( dwRight ) )
{
//验证取反权位
ASSERT( IsValidRight( ~dwRight ) );
if( !IsValidRight( ~dwRight ) ) return *this;
//调整权位
DWORD dwHeadRight = (~dwRight)&0xF0000000;
DWORD dwTailRight = dwRight&MASK_CHI_HU_RIGHT;
dwRight = dwHeadRight|dwTailRight;
bNavigate = true;
}
CChiHuRight & CChiHuRight::operator &= ( DWORD dwRight )
{
bool bNavigate = false;
//验证权位
if( !IsValidRight( dwRight ) )
{
//验证取反权位
ASSERT( IsValidRight( ~dwRight ) );
if( !IsValidRight( ~dwRight ) ) return *this;
//调整权位
DWORD dwHeadRight = (~dwRight)&0xF0000000;
DWORD dwTailRight = dwRight&MASK_CHI_HU_RIGHT;
dwRight = dwHeadRight|dwTailRight;
bNavigate = true;
}
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
{
if( (dwRight&m_dwRightMask[i]) || (i==0&&dwRight<0x10000000) )
{
m_dwRight[i] &= (dwRight&MASK_CHI_HU_RIGHT);
}
else if( !bNavigate )
m_dwRight[i] = 0;
}
{
if( (dwRight&m_dwRightMask[i]) || (i==0&&dwRight<0x10000000) )
{
m_dwRight[i] &= (dwRight&MASK_CHI_HU_RIGHT);
}
else if( !bNavigate )
m_dwRight[i] = 0;
}
return *this;
}
}
//或等于
CChiHuRight & CChiHuRight::operator |= ( DWORD dwRight )
{
//验证权位
if( !IsValidRight( dwRight ) ) return *this;
CChiHuRight & CChiHuRight::operator |= ( DWORD dwRight )
{
//验证权位
if( !IsValidRight( dwRight ) ) return *this;
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
{
if( (dwRight&m_dwRightMask[i]) || (i==0&&dwRight<0x10000000) )
{
m_dwRight[i] |= (dwRight&MASK_CHI_HU_RIGHT);
break;
}
}
{
if( (dwRight&m_dwRightMask[i]) || (i==0&&dwRight<0x10000000) )
{
m_dwRight[i] |= (dwRight&MASK_CHI_HU_RIGHT);
break;
}
}
return *this;
}
}
//与
CChiHuRight CChiHuRight::operator & ( DWORD dwRight )
{
CChiHuRight chr = *this;
return (chr &= dwRight);
}
CChiHuRight CChiHuRight::operator & ( DWORD dwRight )
{
CChiHuRight chr = *this;
return (chr &= dwRight);
}
//与
CChiHuRight CChiHuRight::operator & ( DWORD dwRight ) const
{
CChiHuRight chr = *this;
return (chr &= dwRight);
}
CChiHuRight CChiHuRight::operator & ( DWORD dwRight ) const
{
CChiHuRight chr = *this;
return (chr &= dwRight);
}
//或
CChiHuRight CChiHuRight::operator | ( DWORD dwRight )
{
CChiHuRight chr = *this;
return chr |= dwRight;
}
CChiHuRight CChiHuRight::operator | ( DWORD dwRight )
{
CChiHuRight chr = *this;
return chr |= dwRight;
}
//或
CChiHuRight CChiHuRight::operator | ( DWORD dwRight ) const
{
CChiHuRight chr = *this;
return chr |= dwRight;
}
CChiHuRight CChiHuRight::operator | ( DWORD dwRight ) const
{
CChiHuRight chr = *this;
return chr |= dwRight;
}
//相等
bool CChiHuRight::operator == ( DWORD dwRight ) const
{
CChiHuRight chr;
chr = dwRight;
return (*this)==chr;
}
bool CChiHuRight::operator == ( DWORD dwRight ) const
{
CChiHuRight chr;
chr = dwRight;
return (*this)==chr;
}
//相等
bool CChiHuRight::operator == ( const CChiHuRight chr ) const
{
for( WORD i = 0; i < CountArray( m_dwRight ); i++ )
{
if( m_dwRight[i] != chr.m_dwRight[i] ) return false;
}
return true;
}
bool CChiHuRight::operator == ( const CChiHuRight chr ) const
{
for( WORD i = 0; i < CountArray( m_dwRight ); i++ )
{
if( m_dwRight[i] != chr.m_dwRight[i] ) return false;
}
return true;
}
//不相等
bool CChiHuRight::operator != ( DWORD dwRight ) const
{
CChiHuRight chr;
chr = dwRight;
return (*this)!=chr;
}
bool CChiHuRight::operator != ( DWORD dwRight ) const
{
CChiHuRight chr;
chr = dwRight;
return (*this)!=chr;
}
//不相等
bool CChiHuRight::operator != ( const CChiHuRight chr ) const
{
return !((*this)==chr);
}
bool CChiHuRight::operator != ( const CChiHuRight chr ) const
{
return !((*this)==chr);
}
//是否权位为空
bool CChiHuRight::IsEmpty()
{
for( BYTE i = 0; i < CountArray(m_dwRight); i++ )
if( m_dwRight[i] ) return false;
return true;
}
bool CChiHuRight::IsEmpty()
{
for( BYTE i = 0; i < CountArray(m_dwRight); i++ )
if( m_dwRight[i] ) return false;
return true;
}
//设置权位为空
void CChiHuRight::SetEmpty()
{
zeromemory( m_dwRight,sizeof(m_dwRight) );
return;
}
void CChiHuRight::SetEmpty()
{
zeromemory( m_dwRight,sizeof(m_dwRight) );
return;
}
//获取权位数值
BYTE CChiHuRight::GetRightData( DWORD dwRight[], BYTE cbMaxCount )
{
ASSERT( cbMaxCount >= CountArray(m_dwRight) );
if( cbMaxCount < CountArray(m_dwRight) ) return 0;
BYTE CChiHuRight::GetRightData( DWORD dwRight[], BYTE cbMaxCount )
{
ASSERT( cbMaxCount >= CountArray(m_dwRight) );
if( cbMaxCount < CountArray(m_dwRight) ) return 0;
memcpy( dwRight,m_dwRight,sizeof(DWORD)*CountArray(m_dwRight) );
return CountArray(m_dwRight);
}
return CountArray(m_dwRight);
}
//设置权位数值
bool CChiHuRight::SetRightData( const DWORD dwRight[], BYTE cbRightCount )
{
ASSERT( cbRightCount <= CountArray(m_dwRight) );
if( cbRightCount > CountArray(m_dwRight) ) return false;
bool CChiHuRight::SetRightData( const DWORD dwRight[], BYTE cbRightCount )
{
ASSERT( cbRightCount <= CountArray(m_dwRight) );
if( cbRightCount > CountArray(m_dwRight) ) return false;
zeromemory( m_dwRight,sizeof(m_dwRight) );
memcpy( m_dwRight,dwRight,sizeof(DWORD)*cbRightCount );
memcpy( m_dwRight,dwRight,sizeof(DWORD)*cbRightCount );
return true;
}
}
//检查仅位是否正确
bool CChiHuRight::IsValidRight( DWORD dwRight )
{
DWORD dwRightHead = dwRight & 0xF0000000;
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
if( m_dwRightMask[i] == dwRightHead ) return true;
return false;
}
/*
有杠开
有杠暴
没有暴头
有飘花
*/
bool CChiHuRight::IsValidRight( DWORD dwRight )
{
DWORD dwRightHead = dwRight & 0xF0000000;
for( BYTE i = 0; i < CountArray(m_dwRightMask); i++ )
if( m_dwRightMask[i] == dwRightHead ) return true;
return false;
}
/*
有杠开
有杠暴
没有暴头
有飘花
*/
int main()
{
CChiHuRight chr;
chr |= 0x00000001;// 数组中用于表示“杠开”的位置被置位
chr |= 0x00000002;// 数组中用于表示“杠暴”的位置被置位
chr |= 0x00000008;
chr |= 0x00000400;
chr |= 0x00008000;
DWORD dwRight[3];
if(!chr.IsEmpty())
chr.GetRightData(dwRight, 3);
if(dwRight[0] & 0x00000001 )
printf("有杠开\n");
else
printf("没有杠开\n");
if(dwRight[0] & 0x00000002 )
printf("有杠暴\n");
else
printf("没有杠暴\n");
if(dwRight[0] & 0x00000004 )
printf("有暴头\n");
else
printf("没有暴头\n");
if(dwRight[0] & 0x00000008 )
printf("有飘花\n");
else
printf("没有飘花\n");
{
CChiHuRight chr;
chr |= 0x00000001;// 数组中用于表示“杠开”的位置被置位
chr |= 0x00000002;// 数组中用于表示“杠暴”的位置被置位
chr |= 0x00000008;
chr |= 0x00000400;
chr |= 0x00008000;
DWORD dwRight[3];
if(!chr.IsEmpty())
chr.GetRightData(dwRight, 3);
if(dwRight[0] & 0x00000001 )
printf("有杠开\n");
else
printf("没有杠开\n");
if(dwRight[0] & 0x00000002 )
printf("有杠暴\n");
else
printf("没有杠暴\n");
if(dwRight[0] & 0x00000004 )
printf("有暴头\n");
else
printf("没有暴头\n");
if(dwRight[0] & 0x00000008 )
printf("有飘花\n");
else
printf("没有飘花\n");
system("pause");
return 0;
}
return 0;
}