//适合自动流程的棋牌游戏桌子类
class MyXXTable
{
public:
MyXXTable()
{
//绑定回调数据
mMyStatus[ eGS_1 ] = MyStatus( &MyXXTable::OnStatus1, eGS_2, 2000 );
mMyStatus[ eGS_2 ] = MyStatus( &MyXXTable::OnStatus2, eGS_3, 3000 );
mMyStatus[ eGS_3 ] = MyStatus( &MyXXTable::OnStatus3, eGS_4, 4000 );
mMyStatus[ eGS_4 ] = MyStatus( &MyXXTable::OnStatus4, eGS_1, 5000 );
//第一次启动或者也可以认为是上一次结束
const auto &Status = mMyStatus[ eGS_4 ];
mGameStatus = Status.mNextStatus;
SetTimer( 0, Status.mNextTime );
}
//游戏状态
enum eGameStatus
{
eGS_1,
eGS_2,
eGS_3,
eGS_4,
eGS_MAX,
};
//定时器管理流程
void OnTimerOut()
{
assert( mGameStatus < eGS_MAX );
const auto &Status = mMyStatus[ mGameStatus ];
(this->*Status.mpNextMethod)();
mGameStatus = Status.mNextStatus;
KillTimer( 0 );
SetTimer( 0, Status.mNextTime );
//下面是传统做法,代码冗余费劲
//switch( mGameStatus )
//{
// case eGS_1:
// {
/
C++下适合系统自动流程的棋牌游戏服务器桌子类
最新推荐文章于 2020-09-20 18:32:05 发布