void PDUCommunityCard::execute(Base::GameState*) { // Note: the StateDealCommunity is not used since // if a new community card pdu is received while a // StateDealCommunity is active then the previous // community card is lost. Instead, this PDU puts // the card directly to the community player. CTableView* pView = CTableView::Instance(); ASSERT_VALID(pView); if (pView) { // Tell the current state to quit animations if any GameState* state = GameLogic::Instance().currentState(); if (state) state->onCommand(MAKEWPARAM(ID_STOPANIMATION, 0), 0); pView->endBettingRound(); // Update the screen now to make sure whatever we // were doing becomes visible pView->UpdateWindow(); Player* pCommunity = pView->getCommunity(); ASSERT(pCommunity); if (pCommunity) { // Add card directly to community's deck Card card(suit_, card_); pCommunity->addCard(card); SndMan::Instance()->playSound(SndMan::SM_Card2); if (msecs_ > 0) { // Do the "flip" animation to show the card CPoint pos = pCommunity->getCardPos(Player::LastCard); Cards::Instance().startFlip(card, pos); CDC* pDC = pView->GetDC(); if (pDC) { Cards::Instance().flip(pDC, card, pos); pView->ReleaseDC(pDC); } } else { // Just repaint it once pView->InvalidateRect(pCommunity->getCardPaintArea(Player::LastCard)); } ShowCommunityCardMessage(pCommunity); } } }
void PDUShowdown::execute(Base::GameState*) { CTableView* pView = CTableView::Instance(); if (pView) { Player* pPlayer = pView->getPlayer(player_); if (pPlayer) { if (num_cards_ == 0) { // // Player mucks hand - do muck hand animation // unless its the local player // if (!pView->isLocalPlayer(player_)) { pView->InvalidateRect(pPlayer->getCardPaintArea(Player::AllCards)); pPlayer->empty(); GameLogic::Instance().setNextState( new StateShowdown(player_, pPlayer->numCards())); } } else { // // Show player's cards // pView->InvalidateRect(pPlayer->getCardPaintArea(Player::AllCards)); CardEntry* pC = pCards_; for (int i = 0; i < num_cards_; i++, pC++) pPlayer->setCard(i, Card((Base::Suit)pC->suit_, pC->value_)); pPlayer->setShowAll(TRUE); } pView->InvalidateRect( pPlayer->getCardPaintArea(Player::AllCards)); if (message_) pPlayer->setActionText(message_); else pPlayer->setActionText(""); } } }
void PDUPlayerInfo::execute(GameState*) { CString msg; CTableView* pTable = CTableView::Instance(); ASSERT(pTable); CChatView* pChat = CChatView::Instance(); int num_players_b4_pdu = pTable->numPlayers(); if (pTable) { int num_players = num_players_b4_pdu; PlayerInfo* pP = pPlayers_; if (pP != NULL) { for (int i = 0; i < num_players_; i++) { CString namesz = MakeString(pP->username_); Player* p = pTable->getPlayer(pP->slot_); bool wasThere = false; if (p && p->getName() == namesz) wasThere = true; pTable->addPlayer(namesz, CChips_n(pP->chips_).ntohl(), pP->slot_); // Set initial player state if (pP->state_ & PLAYER_STATE_ACTIVE) pTable->setState(pP->slot_, Base::SitIn); else pTable->setState(pP->slot_, Base::SitOut); Player* pPlayer = pTable->getPlayer(pP->slot_); ASSERT(pPlayer); if (pPlayer) { if (pP->state_ & PLAYER_STATE_ZOMBIE) pPlayer->setState(Base::Zombie); CString citysz = MakeString(pP->city_); pPlayer->setHomeCity(citysz); pTable->InvalidateRect(&pPlayer->getArea()); } if (pChat && !wasThere) { CString msg; msg.Format(g_szPlayerJoined, (LPCSTR)namesz, pP->slot_ + 1); pChat->addDealerMessage(msg, CChatView::CF_GameNormal); } pP++; } } // make a full redraw if original player // count was 0 if (num_players == 0) pTable->Invalidate(); } if (num_players_b4_pdu == 0) { // Send initial sit in status BOOL b = GameLogic::SitOut(); if (Global::TableServer()) { if (b) Global::TableServer()->sendPlaySitOutPDU(); else Global::TableServer()->sendPlaySitInPDU(); } // Send initial muck hand status b = GameLogic::HideHand(); if (Global::TableServer()) { if (b) Global::TableServer()->sendPlayHideCardsPDU(); else Global::TableServer()->sendPlayShowCardsPDU(); } // Done, start waiting for new hand to start GameLogic::Instance().setNextState(new StateWait()); } }