1 Star 0 Fork 0

rock/mahjong-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMJManage.cpp 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
快货运 提交于 2017-01-21 17:00 . update
#include "CMJManage.h"
//构造函数
CMJManage::CMJManage()
{
m_HZPaiNum = 0;
}
//析构函数
CMJManage::~CMJManage()
{
}
//初始化牌
void CMJManage::InitPai(int p_HZPaiNum)
{
m_HZPaiNum = p_HZPaiNum;
m_MJVec.clear();
//中发白
for(UINT i = 1 ; i <= 3 ; i++)
{
stPAI t_Pai;
t_Pai.m_Type = 0;
t_Pai.m_Value = i;
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
}
//东南西北
for(UINT i = 1 ; i <= 4 ; i++)
{
stPAI t_Pai;
t_Pai.m_Type = 1;
t_Pai.m_Value = i;
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
}
//万
for(UINT i = 1 ; i <= 9 ; i++)
{
stPAI t_Pai;
t_Pai.m_Type = 2;
t_Pai.m_Value = i;
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
}
//条
for(UINT i = 1 ; i <= 9 ; i++)
{
stPAI t_Pai;
t_Pai.m_Type = 3;
t_Pai.m_Value = i;
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
}
//饼
for(UINT i = 1 ; i <= 9 ; i++)
{
stPAI t_Pai;
t_Pai.m_Type = 4;
t_Pai.m_Value = i;
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
m_MJVec.push_back(t_Pai);
}
XiPai();
}
//洗牌
void CMJManage::XiPai()
{
srand( GetTickCount() );
random_shuffle(m_MJVec.begin(),m_MJVec.end());
}
//起牌
stPAIEx CMJManage::GetAPai()
{
//如果所有牌都起完了
stPAIEx t_Pai;
t_Pai.m_NewPai.m_Type = m_MJVec.back().m_Type;
t_Pai.m_NewPai.m_Value = m_MJVec.back().m_Value;
t_Pai.m_PaiNum = m_MJVec.size()-1;
if(t_Pai.m_PaiNum ==m_HZPaiNum)
{
t_Pai.m_IsHZ = true;
}
else
{
t_Pai.m_IsHZ = false;
}
//扔去一个
m_MJVec.pop_back();
return t_Pai;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/rock10024/mahjong-test.git
git@gitee.com:rock10024/mahjong-test.git
rock10024
mahjong-test
mahjong-test
master

搜索帮助