📄 single_game.cpp
字号:
{
PlaySound(MAKEINTRESOURCE(IDR_WIN),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
else
{
PlaySound(MAKEINTRESOURCE(IDR_LOSE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
pDrawCards->m_bVisual = TRUE;
AccountScore(0);
::SetTimer(hWnd,0,0,NULL); //开始游戏;
return 0;
}
}
else
{
if( m_nCurrentLord == 0 )
{
m_nLordLock = 0;
}
//不要;
pLeftCards->m_cDiscardingType.m_nTypeNum = 0;
pDraw->TextGDI("-过牌!",250,200,RGB(255,0,0),400,"华文新魏",lpddsprimary);
Sleep(300);
}
}
return 1;
}
//本机(中间)玩家的出牌处理;
int CSingleGame::CenterDoing()
{
if( m_nLordLock == 1 )
{
if( m_nRoundCounter == 3 ) //说明已经出了牌;
{
//把已经出的牌回退;
if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();
if(pRightCards->m_nDiscardingCounter != 0)
pDrawCards->RightBacking();
if(pLeftCards->m_nDiscardingCounter != 0)
pDrawCards->LeftBacking();
m_nRoundCounter = 0; //新的一圈;
}
m_nRoundCounter++;
return -1; //表示当前是地主,上次轮过牌,现在则不能出牌;
}
//如果没有选择牌;
if( pCardsMap->m_nUpCounter == 0 )
{
//当不是第一个出牌的时候才可以过牌;
if( pLeftCards->m_cDiscardingType.m_nTypeNum != 0 ||
pRightCards->m_cDiscardingType.m_nTypeNum != 0 )
{
pDraw->TextGDI("过牌!",470,400,RGB(255,0,0),400,"华文新魏",lpddsprimary);
Sleep(500);
if( m_nRoundCounter == 3 ) //说明已经出了牌;
{
//把已经出的牌回退;
if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();
if(pRightCards->m_nDiscardingCounter != 0)
pDrawCards->RightBacking();
if(pLeftCards->m_nDiscardingCounter != 0)
pDrawCards->LeftBacking();
m_nRoundCounter = 0; //新的一圈;
}
m_nRoundCounter++;
pCenterCards->m_cDiscardingType.m_nTypeNum = 0; //将出的牌值设为空;
if( m_nCurrentLord == 1 )
{
m_nLordLock = 1;
}
return 1;
}
else
{
return 0;
}
}
pCenterCards->m_nChoosingCardsCounter = 0;
//将要出的牌加入到m_cDiscarding[20]数组中,m_nDiscardingCounter计数增加;
for(int i=0;i<pCenterCards->m_nCardsCounter;i++)
{
if(pCardsMap->Center0[i].m_nY== Center_y0 - Card_Up)
{
pCenterCards->m_cChoosingCards[pCenterCards->m_nChoosingCardsCounter] = pCenterCards->m_cCards[i];
pCenterCards->m_nChoosingCardsCounter++;
}
}
//判断出牌的合法性,
if( pCenterCards->CheckChoosing() )
{
//大小判断;
if( CompareCards() == 0 )
{
for(int j=0;j<pCenterCards->m_nCardsCounter;j++)
{
if(pCardsMap->Center0[j].m_nY== Center_y0 - Card_Up)
{
pCardsMap->Center0[j].m_nY+= Card_Up;
}
}
pCardsMap->m_nUpCounter = 0; //提起牌数为0;
::RedrawGame();
m_bButton = 0; //延时锁;
Sleep(400);
m_bButton = 1; //延时锁;
return 0;
}
if( m_nRoundCounter == 3 ) //说明已经出了牌;
{
//把已经出的牌回退;
if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();
if(pRightCards->m_nDiscardingCounter != 0)
pDrawCards->RightBacking();
if(pLeftCards->m_nDiscardingCounter != 0)
pDrawCards->LeftBacking();
m_nRoundCounter = 0; //新的一圈;
}
m_nRoundCounter++;
//将要出的牌加入到m_cDiscarding[20]数组中,m_nDiscardingCounter计数增加;
for(int i=0;i<pCenterCards->m_nCardsCounter;i++)
{
if(pCardsMap->Center0[i].m_nY== Center_y0 - Card_Up)
{
pCenterCards->m_cDiscarding[pCenterCards->m_nDiscardingCounter] = pCenterCards->m_cCards[i];
pCenterCards->m_nDiscardingCounter++;
}
}
if( pCenterCards->m_cDiscardingType.m_nTypeNum == 4 )
{
m_nBombCounter++;//加分;
}
pDrawCards->CenterDiscarding(); //本机玩家出牌;
if( pCenterCards->m_nCardsCounter == 0 )
{
//打印结束信息;
PlaySound(MAKEINTRESOURCE(IDR_WIN),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
pDrawCards->m_bVisual = TRUE;
AccountScore(1);
::SetTimer(hWnd,0,0,NULL); //开始游戏;
return 2;
}
}
else
{
for(int j=0;j<pCenterCards->m_nCardsCounter;j++)
{
if(pCardsMap->Center0[j].m_nY== Center_y0 - Card_Up)
{
pCardsMap->Center0[j].m_nY+= Card_Up;
}
}
pCardsMap->m_nUpCounter = 0; //提起牌数为0;
::RedrawGame();
m_bButton = 0; //延时锁;
Sleep(400);
m_bButton = 1; //延时锁;
return 0;
}
return 1;
}
//右边电脑思考,并决定要出的牌;
int CSingleGame::RightDoing()
{
if( m_nRoundCounter == 3 ) //说明已经出了牌;
{
//把已经出的牌回退;
if(pRightCards->m_nDiscardingCounter != 0)
pDrawCards->RightBacking();
if(pCenterCards->m_nDiscardingCounter != 0)
pDrawCards->CenterBacking();
if(pLeftCards->m_nDiscardingCounter != 0)
pDrawCards->LeftBacking();
m_nRoundCounter = 0; //新的一圈;
}
m_nRoundCounter++;
if( m_nLordLock == 2 )
{
return -1;
}
if(pCenterCards->m_cDiscardingType.m_nTypeNum == 0 &&
pLeftCards->m_cDiscardingType.m_nTypeNum == 0)
{
m_nLordLock = -1;
//开始新的一回合,选择一种牌型出;
pRightCards->DirectChoose();
if( pRightCards->m_cDiscardingType.m_nTypeNum == 4 )
{
m_nBombCounter++;//加分;
}
pRightCards->CleanUp();
pDrawCards->RightDiscarding();
::RedrawGame();
if( pRightCards->m_nCardsCounter == 0 )
{
//打印结束信息;
if( m_nCurrentLord == 0 )
{
PlaySound(MAKEINTRESOURCE(IDR_WIN),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
else
{
PlaySound(MAKEINTRESOURCE(IDR_LOSE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
pDrawCards->m_bVisual = TRUE;
AccountScore(2);
::SetTimer(hWnd,0,0,NULL); //开始游戏;
return 0;
}
return 1;
}
//1.两者都不能大牌,我是最大;
//2.新的一回合开始,我先出;
if(pCenterCards->m_cDiscardingType.m_nTypeNum != 0)
{
//如果上家出了牌,则根据上家决定出牌;
if( m_nCurrentLord == 0 &&
m_nLordLock == 0 &&
pCenterCards->m_cDiscardingType.m_nTypeValue > 13 )
{
//不要;
pRightCards->m_cDiscardingType.m_nTypeNum = 0;
pDraw->TextGDI("过牌!-",600,200,RGB(255,0,0),400,"华文新魏",lpddsprimary);
Sleep(300);
return 1;
}
//如果上家出了牌,则根据上家决定出牌;
if( pRightCards->CompareChoose(pCenterCards->m_cDiscardingType) )
{
if( pRightCards->m_cDiscardingType.m_nTypeNum == 4 )
{
m_nBombCounter++;//加分;
}
pRightCards->CleanUp();
pDrawCards->RightDiscarding();
::RedrawGame();
if( pRightCards->m_nCardsCounter == 0 )
{
//打印结束信息;
if(m_nCurrentLord == 0 )
{
PlaySound(MAKEINTRESOURCE(IDR_WIN),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
else
{
PlaySound(MAKEINTRESOURCE(IDR_LOSE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
pDrawCards->m_bVisual = TRUE;
AccountScore(2);
::SetTimer(hWnd,0,0,NULL); //开始游戏;
return 0;
}
}
else
{
//不要;
pRightCards->m_cDiscardingType.m_nTypeNum = 0;
pDraw->TextGDI("过牌!-",600,200,RGB(255,0,0),400,"华文新魏",lpddsprimary);
if( m_nCurrentLord == 2 )
{
m_nLordLock = 2;
}
Sleep(300);
}
}
else
{
//如果上家出了牌,则根据上家决定出牌;
if( m_nCurrentLord == 1 &&
m_nLordLock == 1 &&
pLeftCards->m_cDiscardingType.m_nTypeValue > 13 )
{
//不要;
pRightCards->m_cDiscardingType.m_nTypeNum = 0;
pDraw->TextGDI("过牌!-",600,200,RGB(255,0,0),400,"华文新魏",lpddsprimary);
//补丁:地主一旦过牌,本轮内都不能再出牌;
Sleep(300);
return 1;
}
//如果上家没出牌,则根据上上家决定出牌;
if( pRightCards->CompareChoose(pLeftCards->m_cDiscardingType) )
{
if( pRightCards->m_cDiscardingType.m_nTypeNum == 4 )
{
m_nBombCounter++;//加分;
}
pRightCards->CleanUp();
pDrawCards->RightDiscarding();
::RedrawGame();
if( pRightCards->m_nCardsCounter == 0 )
{
//打印结束信息;
if(m_nCurrentLord == 0 )
{
PlaySound(MAKEINTRESOURCE(IDR_WIN),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
else
{
PlaySound(MAKEINTRESOURCE(IDR_LOSE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
}
pDrawCards->m_bVisual = TRUE;
AccountScore(2);
::SetTimer(hWnd,0,0,NULL); //开始游戏;
return 0;
}
}
else
{
//不要;
pRightCards->m_cDiscardingType.m_nTypeNum = 0;
pDraw->TextGDI("过牌!-",600,200,RGB(255,0,0),400,"华文新魏",lpddsprimary);
if( m_nCurrentLord == 2 )
{
m_nLordLock = 2;
}
Sleep(300);
}
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -