資源簡介
doudizhu_shffule_src.zip
代碼片段和文件信息
#include?“GameUtil.h“
#include?
#include???
void?CGameUtil::?ShuffleData?(long*?cbCardBuffer?long?dataCount?SHUFFLETYPE?shuffleType/*?=?ST_NORMAL*/)
{
ShuffleImpl1?(cbCardBuffer?dataCount);
}
void?CGameUtil::?ShuffleImpl1?(long*?cbCardBuffer?long?dataCount)
{
std::vector?testV;
????for?(long?i?=?0;?i?????{
????????testV.push_back(i);
????}
????
????std::random_device?rd;
????std::mt19937?g(rd());
????std::shuffle(testV.begin()?testV.end()?g);
????
????for?(long?i?=?0;?i?????{
????????cbCardBuffer[i]?=?testV[i];
????}
}
void?CGameUtil::Deal
{
/*
arr?[0]?--?給玩家0發的牌
arr?[1]?--?給玩家1發的牌
arr?[2]?--?給玩家2發的牌
arr?[3]?--?底牌
*/
long?arr[4]?[TOTAL_CUSTOMER_CARDS]?=?{0};
CRandomGenerator?rg;
std::mt19937::result_type?seed?=?time(0);
auto?dice_rand?=?std::bind(std::uniform_int_distribution(5?12)?std::mt19937(seed));
int?firstCount?=?dice_rand?();
assert(firstCount?>=?5?&&?firstCount?<=?12);
long?index?=?0;
long?client?=?0;
for?(index=0;?index {
if?(index?>=?TOTAL_PlayerS*firstCount)
{
break;
}
client?=?index/firstCount;
arr[client][index%firstCount]?=?m_data?[index];
}
for?(long?j=0;?j<3;?j++)
{
arr[3][j]?=?m_data?[index];
index++;
}
client?=?0;
long?dataIndex?=?0;
for?(long?nextIndex?=?index;?nextIndex {
for?(client?=?0;?client?yerS;?client++)
{
arr[client][firstCount?+?dataIndex]?=?m_data?[nextIndex++];
}
dataIndex++;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????14948498??2015-05-13?15:07??iLandlord.apk
?????文件????????1638??2015-05-13?13:43??GameUtil.cpp
?????文件?????????223??2015-05-13?13:41??GameUtil.h
- 上一篇:基于STM32的倒立擺程序
- 下一篇:TwinCAT 2 PLC入門教程V2.3
評論
共有 條評論