斗地主C++实现


斗地主是一个很流行的游戏,如何编程实现它,这里提供一个难得的有趣的学习C++的实例!
资源截图
代码片段和文件信息
// Client_Game.cpp: implementation of the CClientGame class.
//
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “斗地主.h“

#include “Game.h“

#include “link.h“
#include “My_DirectInput.h“
#include “my_directdraw.h“

#include “Playing_Cards.h“


#include “Draw_Item_Engine.h“
#include “Draw_Cards_Engine.h“

#include “Client_Game.h“

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CClientGame::CClientGame()
{

}

CClientGame::~CClientGame()
{

}
//左边玩家(电脑)思考,并决定要出的牌;
int CClientGame::LeftDoing()
{
if( m_nLordLock == 0 )
{
if( m_nRoundCounter == 3 )  //说明已经出了牌;
{
//把已经出的牌回退;

if(pLeftCards->m_nDiscardingCounter != 0)
pDrawCards->LeftBacking();

if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();

if(pRightCards->m_nDiscardingCounter != 0)
pDrawCards->RightBacking();

m_nRoundCounter = 0;   //新的一圈;
}
m_nRoundCounter++;
return -1;
}

if( pRightCards->m_cDiscardingType.m_nTypeNum == 0 && 
pCenterCards->m_cDiscardingType.m_nTypeNum == 0 )
{
m_nLordLock = -1;
}

//补丁调整出牌显示;
int Temp_Discarding_Counter = 0;  //刚出的牌的数量;
CCard Temp_Discarding[20];         //刚出的牌;

pClientlink->Recv(Temp_Discardingsizeof(CCard)*20);
pClientlink->Recv(&Temp_Discarding_Countersizeof(int));
pClientlink->Recv(&pLeftCards->m_cDiscardingTypesizeof(CCardsType));

if( m_nRoundCounter == 3 )  //说明已经出了牌;
{
//把已经出的牌回退;
if(pLeftCards->m_nDiscardingCounter != 0)
pDrawCards->LeftBacking();

if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();

if(pRightCards->m_nDiscardingCounter != 0)
pDrawCards->RightBacking();

m_nRoundCounter = 0;   //新的一圈;
}
m_nRoundCounter++;

for(int i=0;i<20;i++)
{
pLeftCards->m_cDiscarding[i] = Temp_Discarding[i];
}
pLeftCards->m_nDiscardingCounter = Temp_Discarding_Counter;

//如果出牌数大于0;
if( pLeftCards->m_cDiscardingType.m_nTypeNum == 4 )
{
m_nBombCounter++;//加分;
}

if( pLeftCards->m_cDiscardingType.m_nTypeNum != 0 )
{
pDrawCards->LeftDiscarding();
::RedrawGame();
if( pLeftCards->m_nCardsCounter == 0 )
{
//打印结束信息;
AccountScore(0);
::SetTimer(hWnd00NULL);   //开始游戏;
return 0;
}
}
else
{
//打印左边玩家不要信息;
pDraw->TextGDI(“过牌!-“250200RGB(25500)400“华文新魏“lpddsprimary);
if( m_nCurrentLord == 0 )
{
m_nLordLock = 0;
}
Sleep(300);
}
return 1;
}
//中间(本机)玩家出牌;
int CClientGame::CenterDoing()
{
if( m_nLordLock == 1 )
{
if( m_nRoundCounter == 3 )  //说明已经出了牌;
{
//把已经出的牌回退;
if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();

if(pRightCards->m_nDiscardin

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2004-06-02 15:47  斗地主
     目录           0  2004-06-10 23:41  斗地主mp
     目录           0  2004-06-10 23:41  斗地主mpcards
     文件      112232  2004-04-17 23:04  斗地主mpcards10.bmp
     文件      112232  2004-04-17 23:02  斗地主mpcards2.bmp
     文件      112232  2004-04-17 23:05  斗地主mpcards3.bmp
     文件      112232  2004-04-17 23:21  斗地主mpcards4.bmp
     文件      112232  2004-04-17 23:24  斗地主mpcards5.bmp
     文件      112232  2004-04-17 23:19  斗地主mpcards6.bmp
     文件      112232  2004-04-17 23:34  斗地主mpcards7.bmp
     文件      112232  2004-04-17 23:28  斗地主mpcards8.bmp
     文件      112232  2004-04-17 23:31  斗地主mpcards9.bmp
     文件      112232  2004-04-17 23:03  斗地主mpcardsA.bmp
     文件       28328  2004-06-10 15:06  斗地主mpcardscard_back1.bmp
     文件      112232  2004-04-21 18:02  斗地主mpcardsJ.bmp
     文件       56144  2004-04-22 11:35  斗地主mpcardsJokers.bmp
     文件      112232  2004-04-21 17:54  斗地主mpcardsK.bmp
     文件      112232  2004-04-17 23:08  斗地主mpcardsQ.bmp
     文件      111104  2004-06-10 20:31  斗地主mpcardsThumbs.db
     目录           0  2004-06-10 23:41  斗地主mpfaces
     文件       14896  2004-05-08 19:24  斗地主mpfacesface0.bmp
     文件       14896  2004-05-08 20:18  斗地主mpfacesface1.bmp
     文件       14896  2004-05-08 20:18  斗地主mpfacesface2.bmp
     文件       14896  2004-05-08 20:18  斗地主mpfacesface3.bmp
     文件       24576  2004-05-09 01:27  斗地主mpfacesThumbs.db
     文件     3145784  2004-06-10 23:37  斗地主mpGame_Back.bmp
     目录           0  2004-06-10 23:41  斗地主mpitem
     文件      135056  2004-05-14 19:42  斗地主mpitemring_lord.bmp
     文件       48056  2004-05-16 17:11  斗地主mpitemchoose_lord.bmp
     文件       17384  2004-05-14 19:47  斗地主mpitemlord_frame.bmp
     文件        7256  2004-05-15 02:16  斗地主mpitemOk_Button.bmp
............此处省略75个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)