?? draw_cards_engine.cpp
字號:
pLeftCards->m_nCardsTable[pLeftCards->m_cCards[17].m_nValue]++;
pLeftCards->m_nCardsTable[pLeftCards->m_cCards[18].m_nValue]++;
pLeftCards->m_nCardsTable[pLeftCards->m_cCards[19].m_nValue]++;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
::RedrawGame();
}
else if(bLord == 1)
{
//發地主牌給中間玩家;
//第一張;
pCenterCards->m_cCards[17] = g_cAllCards[51]; //第十八張牌;
MoveCard(pCardsMap->Center0[17].m_nX,
Center_y0,
Lord_Card1_x,
Lord_Card1_y,
pCenterCards->m_cCards[17].m_nColor,
pCenterCards->m_cCards[17].m_nValue,
80);
pCenterCards->m_nCardsCounter++; //m_nCardsCounter =18
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
// ::Redraw_Game();
//第二張;
pCenterCards->m_cCards[18] = g_cAllCards[52];
MoveCard(pCardsMap->Center0[18].m_nX,
Center_y0,
Lord_Card2_x,
Lord_Card2_y,
pCenterCards->m_cCards[18].m_nColor,
pCenterCards->m_cCards[18].m_nValue,
80);
pCenterCards->m_nCardsCounter++; //m_nCardsCounter =19
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
// ::Redraw_Game();
//第三張;
pCenterCards->m_cCards[19] = g_cAllCards[53];
MoveCard(pCardsMap->Center0[19].m_nX,
Center_y0,
Lord_Card3_x,
Lord_Card3_y,
pCenterCards->m_cCards[19].m_nColor,
pCenterCards->m_cCards[19].m_nValue,
80);
pCenterCards->m_nCardsCounter++; //m_nCardsCounter =20
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
::RedrawGame();
//拿到地主牌后再整理一次;
DrawCleanUp();
}
else if(bLord == 2)
{
//發地主牌給右邊玩家;
//第一張;
pRightCards->m_cCards[17] = g_cAllCards[51]; //第十八張牌;
MoveCard(Right_x0,
pCardsMap->Right0[17].m_nY,
Lord_Card1_x,
Lord_Card1_y,
pRightCards->m_cCards[17].m_nColor,
pRightCards->m_cCards[17].m_nValue,
80);
pRightCards->m_nCardsCounter++; //m_nCardsCounter =18
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
// ::Redraw_Game();
//第二張;
pRightCards->m_cCards[18] = g_cAllCards[52];
MoveCard(Right_x0,
pCardsMap->Right0[18].m_nY,
Lord_Card2_x,
Lord_Card2_y,
pRightCards->m_cCards[18].m_nColor,
pRightCards->m_cCards[18].m_nValue,
80);
pRightCards->m_nCardsCounter++; //m_nCardsCounter =19
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
// ::Redraw_Game();
//第三張;
pRightCards->m_cCards[19] = g_cAllCards[53];
MoveCard(Right_x0,
pCardsMap->Right0[19].m_nY,
Lord_Card3_x,
Lord_Card3_y,
pRightCards->m_cCards[19].m_nColor,
pRightCards->m_cCards[19].m_nValue,
80);
pRightCards->m_nCardsCounter++; //m_nCardsCounter =20
pRightCards->m_nCardsTable[pRightCards->m_cCards[17].m_nValue]++;
pRightCards->m_nCardsTable[pRightCards->m_cCards[18].m_nValue]++;
pRightCards->m_nCardsTable[pRightCards->m_cCards[19].m_nValue]++;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
::RedrawGame();
}
pLeftCards->CleanUp();
pRightCards->CleanUp();
::RedrawGame();
return 1;
}
//中間(本機)玩家出牌;
int CDrawCardsEngine::CenterDiscarding()
{
///檢查出牌的合法性,調用CPlaying_Cards的方法;
int counter = 0;
pCenterCards->m_nDiscardingCounter = 0;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
for(int i=0;i<pCenterCards->m_nCardsCounter;i++)
{
if(pCardsMap->Center0[i].m_nY == Center_y0 - Card_Up)
{
//移動提起的牌到剛出牌區;
pCardsMap->Center0[i].m_bVisual = 0;
MoveCard(pCardsMap->Center2[pCenterCards->m_nDiscardingCounter].m_nX,
pCardsMap->Center2[pCenterCards->m_nDiscardingCounter].m_nY,
pCardsMap->Center0[i].m_nX,
pCardsMap->Center0[i].m_nY,
pCenterCards->m_cCards[i].m_nColor,
pCenterCards->m_cCards[i].m_nValue,
80);
pCardsMap->Center0[i].m_nY += Card_Up;
pCenterCards->m_cCards[i].m_nColor = 4; //花色為4表示已經出過牌;
pCenterCards->m_cCards[i].m_nValue = 17; //值為17表示已經出過牌;
counter++;
pCenterCards->m_nDiscardingCounter++;
}
}
//將中間(本機)的牌置為可見;
for(int j=0;j<pCenterCards->m_nCardsCounter;j++)
{
pCardsMap->Center0[j].m_bVisual = 1;
}
DrawCleanUp();
pCenterCards->m_nCardsCounter -= counter;
// pCenterCards->m_nDiscardingCounter = 0;
pCardsMap->m_nUpCounter = 0; //提起牌數為0;
return 1;
}
//本機玩家剛出的牌從剛出牌區移動到已經出牌區;
int CDrawCardsEngine::CenterBacking()
{
int temp_counter = pCenterCards->m_nDiscardingCounter ;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_RESOURCE|SND_NODEFAULT ); //
for(int i=0;i<temp_counter;i++)
{
//移動提起的牌到剛出牌區;
MoveCard(pCardsMap->Center1[pCenterCards->m_nDiscardedCounter].m_nX,
pCardsMap->Center1[pCenterCards->m_nDiscardedCounter].m_nY,
pCardsMap->Center2[i].m_nX,
pCardsMap->Center2[i].m_nY,
pCenterCards->m_cDiscarding[i].m_nColor,
pCenterCards->m_cDiscarding[i].m_nValue,
100);
pCenterCards->m_nDiscardingCounter--;
pCenterCards->m_cDiscarded[pCenterCards->m_nDiscardedCounter] = pCenterCards->m_cDiscarding[i];
pCenterCards->m_nDiscardedCounter++;
}
::RedrawGame();
return 1;
}
//左邊玩家出牌;
int CDrawCardsEngine::LeftDiscarding()
{
int temp_counter = pLeftCards->m_nDiscardingCounter;
pLeftCards->m_nDiscardingCounter = 0;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
for(int i=0;i<temp_counter;i++)
{
//移動提起的牌到剛出牌區;
MoveCard(pCardsMap->Left2[i].m_nX,
pCardsMap->Left2[i].m_nY,
pCardsMap->Left0[pLeftCards->m_nCardsCounter - 1].m_nX,
pCardsMap->Left0[pLeftCards->m_nCardsCounter - 1].m_nY,
pLeftCards->m_cDiscarding[i].m_nColor,
pLeftCards->m_cDiscarding[i].m_nValue,
100);
pLeftCards->m_nDiscardingCounter++;
pLeftCards->m_nCardsCounter--;
}
// ::Redraw_Game();
return 1;
}
//左邊玩家剛出的牌從剛出牌區移動到已經出牌區;
int CDrawCardsEngine::LeftBacking()
{
int temp_counter = pLeftCards->m_nDiscardingCounter ;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
for(int i=0;i<temp_counter;i++)
{
//移動提起的牌到剛出牌區;
MoveCard(pCardsMap->Left1[pLeftCards->m_nDiscardedCounter].m_nX,
pCardsMap->Left1[pLeftCards->m_nDiscardedCounter].m_nY,
pCardsMap->Left2[i].m_nX,
pCardsMap->Left2[i].m_nY,
pLeftCards->m_cDiscarding[i].m_nColor,
pLeftCards->m_cDiscarding[i].m_nValue,
140);
pLeftCards->m_nDiscardingCounter--;
pLeftCards->m_cDiscarded[pLeftCards->m_nDiscardedCounter] = pLeftCards->m_cDiscarding[i];
pLeftCards->m_nDiscardedCounter++;
}
::RedrawGame();
return 1;
}
//右邊玩家出牌;
int CDrawCardsEngine::RightDiscarding()
{
int temp_counter = pRightCards->m_nDiscardingCounter;
pRightCards->m_nDiscardingCounter = 0;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
for(int i=0;i<temp_counter;i++)
{
//移動提起的牌到剛出牌區;
MoveCard(pCardsMap->Right2[i].m_nX,
pCardsMap->Right2[i].m_nY,
pCardsMap->Right0[pRightCards->m_nCardsCounter - 1].m_nX,
pCardsMap->Right0[pRightCards->m_nCardsCounter - 1].m_nY,
pRightCards->m_cDiscarding[i].m_nColor,
pRightCards->m_cDiscarding[i].m_nValue,
100);
pRightCards->m_nDiscardingCounter++;
pRightCards->m_nCardsCounter--;
}
return 1;
}
//右邊玩家剛出的牌從剛出牌區移動到已經出牌區;
int CDrawCardsEngine::RightBacking()
{
int temp_counter = pRightCards->m_nDiscardingCounter ;
PlaySound(MAKEINTRESOURCE(IDR_GIVE),AfxGetResourceHandle(),
SND_ASYNC|SND_RESOURCE|SND_NODEFAULT ); //
for(int i=0;i<temp_counter;i++)
{
//移動提起的牌到剛出牌區;
MoveCard(pCardsMap->Right1[pLeftCards->m_nDiscardedCounter].m_nX,
pCardsMap->Right1[pLeftCards->m_nDiscardedCounter].m_nY,
pCardsMap->Right2[i].m_nX,
pCardsMap->Right2[i].m_nY,
pRightCards->m_cDiscarding[i].m_nColor,
pRightCards->m_cDiscarding[i].m_nValue,
140);
pRightCards->m_nDiscardingCounter--;
pRightCards->m_cDiscarded[pRightCards->m_nDiscardedCounter] = pRightCards->m_cDiscarding[i];
pRightCards->m_nDiscardedCounter++;
}
::RedrawGame();
return 1;
}
//重畫;
void CDrawCardsEngine::Redraw(LPDIRECTDRAWSURFACE7 pSurface)
{
//左邊未出的牌;
int i;
if( m_bVisual )
{
for(i=0;i<pLeftCards->m_nCardsCounter;i++)
{
if(pCardsMap->Left0[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Left0[i].m_nX,
pCardsMap->Left0[i].m_nY,
pLeftCards->m_cCards[i].m_nColor,
pLeftCards->m_cCards[i].m_nValue);
}
}
}
else//
{
for(i=0;i<pLeftCards->m_nCardsCounter;i++)
{
if(pCardsMap->Left0[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Left0[i].m_nX,
pCardsMap->Left0[i].m_nY,
0,
17);
}
}
}
//左邊已經出的牌;
for(i=0;i<pLeftCards->m_nDiscardedCounter;i++)
{
if(pCardsMap->Left1[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Left1[i].m_nX,
pCardsMap->Left1[i].m_nY,
pLeftCards->m_cDiscarded[i].m_nColor,
pLeftCards->m_cDiscarded[i].m_nValue);
}
}
//左邊剛出的牌;
for(i=0;i<pLeftCards->m_nDiscardingCounter;i++)
{
if(pCardsMap->Left2[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Left2[i].m_nX,
pCardsMap->Left2[i].m_nY,
pLeftCards->m_cDiscarding[i].m_nColor,
pLeftCards->m_cDiscarding[i].m_nValue);
}
}
//中間未出的牌;
for(i=0;i<pCenterCards->m_nCardsCounter;i++)
{
if(pCardsMap->Center0[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Center0[i].m_nX,
pCardsMap->Center0[i].m_nY,
pCenterCards->m_cCards[i].m_nColor,
pCenterCards->m_cCards[i].m_nValue);
}
}
//中間已經出的牌;
for(i=0;i<pCenterCards->m_nDiscardedCounter;i++)
{
if(pCardsMap->Center1[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Center1[i].m_nX,
pCardsMap->Center1[i].m_nY,
pCenterCards->m_cDiscarded[i].m_nColor,
pCenterCards->m_cDiscarded[i].m_nValue);
}
}
//中間剛出的牌;
for(i=0;i<pCenterCards->m_nDiscardingCounter;i++)
{
if(pCardsMap->Center2[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Center2[i].m_nX,
pCardsMap->Center2[i].m_nY,
pCenterCards->m_cDiscarding[i].m_nColor,
pCenterCards->m_cDiscarding[i].m_nValue);
}
}
//右邊未出的牌;
if( m_bVisual )
{
for(i=0;i<pRightCards->m_nCardsCounter;i++)
{
if(pCardsMap->Right0[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Right0[i].m_nX,
pCardsMap->Right0[i].m_nY,
pRightCards->m_cCards[i].m_nColor,
pRightCards->m_cCards[i].m_nValue);
}
}
}
else
{
for(i=0;i<pRightCards->m_nCardsCounter;i++)
{
if(pCardsMap->Right0[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Right0[i].m_nX,
pCardsMap->Right0[i].m_nY,
0,
17);
}
}
}
//右邊已經出的牌;
for(i=0;i<pRightCards->m_nDiscardedCounter;i++)
{
if(pCardsMap->Right1[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Right1[i].m_nX,
pCardsMap->Right1[i].m_nY,
pRightCards->m_cDiscarded[i].m_nColor,
pRightCards->m_cDiscarded[i].m_nValue);
}
}
//右邊剛出的牌;
for(i=0;i<pRightCards->m_nDiscardingCounter;i++)
{
if(pCardsMap->Right2[i].m_bVisual == 1)
{
DrawCard(pCardsMap->Right2[i].m_nX,
pCardsMap->Right2[i].m_nY,
pRightCards->m_cDiscarding[i].m_nColor,
pRightCards->m_cDiscarding[i].m_nValue);
}
}
//正在發的牌;
if(pCardsMap->m_cDistributeCard.m_bVisual == 1)
{
DrawCard(pCardsMap->m_cDistributeCard.m_nX,
pCardsMap->m_cDistributeCard.m_nY,
0,
17);
}
//陳列的三張地主牌;
if(pCardsMap->m_nLordCards == 1)
{
for(i=0;i<3;i++)
{
if(pCardsMap->m_cLordCards[i].m_bVisual == 1)
{
DrawCard(pCardsMap->m_cLordCards[i].m_nX,
pCardsMap->m_cLordCards[i].m_nY,
0,
17);
}
}//end for
}
else if(pCardsMap->m_nLordCards == 2)
{
for(i=0;i<3;i++)
{
if(pCardsMap->m_cLordCards[i].m_bVisual == 1)
{
DrawCard(pCardsMap->m_cLordCards[i].m_nX,
pCardsMap->m_cLordCards[i].m_nY,
::g_cAllCards[51+i].m_nColor,
::g_cAllCards[51+i].m_nValue);
}
}//end for
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -