Example #1
0
void PDUNetworkError::execute(Base::GameState*)
{
#ifdef PSPOT_TABLE_MODULE_

  Base::GameLogic::Instance().setNextState(0);
  Global::Instance().closeConnections();

  CTableView* pView = CTableView::Instance();
  if (pView)
  {
    pView->setCaption();
    pView->resetCards();
    pView->announce("");

    for (int i = 0; i < 10; i++)
      pView->removePlayer(i);
    pView->Invalidate();
  }

  // CONNRESET means server closed connection - it's ok
  if (!Global::CloseConnection())//errorCode_ != WSAECONNRESET)
  {
    CString msg;
    msg.Format(g_szErrFmt, errorCode_);
    if (AfxGetMainWnd())
      AfxGetMainWnd()->MessageBox(msg, NULL, MB_OK|MB_ICONEXCLAMATION);
  }

#else

  Global::Instance().closeConnections();

  CFloorMap* pFM = CFloorMap::Instance();
  if (pFM)
    pFM->disconnect();

  if (!Global::CloseConnection())
  {
    CString msg;
    msg.Format(g_szErrFmt, errorCode_);
    if (AfxGetMainWnd())
      AfxGetMainWnd()->MessageBox(msg, NULL, MB_OK|MB_ICONEXCLAMATION);
  }


#endif

}
Example #2
0
//
// This PDU is always sent at the start of hand.
//
// The dealer is set twice to make sure the old
// blind positions are erased and new positions
// painted correctly.
//
// The player states are reset to sit-in.
//
void PDUButton::execute(Base::GameState* pState)
{
  CTableView* pView = CTableView::Instance();
  if (pView)
  { 
    pView->resetCards(true);
    pView->setDealer(dealerslot_, true);

    static bool is_first_button = true;
    if (!is_first_button)
    {
      for (int i = 0; i < 10; i++)
      {
        Player* pP = pView->getPlayer(i);
        if (pP)
        {
          if (pP->getChips() > 0 &&
              pP->getState() != Base::AllIn)
          {
            pP->setState(Base::SitIn);
            pP->setActionText("", true);
          }
          else
          {
            pP->setState(Base::SitOut);
          }
        }
      }
    }
    else
      is_first_button = true;

    pView->setDealer(dealerslot_, true);
    pView->Invalidate();
  }

  if (GameLogic::Instance().currentState() == NULL)
  { // Set the next state already!
    GameLogic::Instance().setNextState(new StatePromptPostBlind(10, 0, 0));
  }
}