Esempio n. 1
0
int checkSheepDigits(int number)
{
    int maeDigit = 0;
    int tempNumber = number;
    while (number != 0) {
        maeDigit = number%10;
        number = number/10;
        arr[maeDigit] = true;
    }
    if (checkBoolArray()) {
        return tempNumber;
    }
    else {
        return 0;
    }
}
Esempio n. 2
0
void dealerLib::bet()
{


  std::cout<<"enter bet method\n";
  Uint16 currentBet = 0;
  Uint16 oldBet = 0;
  Uint16 playerBet = 0;
  Uint16 playerRaise = 0;
  bool p[m_livePlayers.size()];

  //When all bets are matched the array will all be true
  //Thus breaking out of the while loop
  while(!(checkBoolArray(p)))
  {
      std::cout<<currentBet<<" current bet, "<<oldBet<<" old bet\n";
      for(unsigned int i=0;i<m_livePlayers.size();i++)
      {
          // find max bet
         int maxBet = checkMaxBet() - m_livePlayers[i].getBet();
         if(maxBet==0){p[i]=true;}
         else
         {
             if(!(Comms::receiveBet(m_deviceMap.at(m_livePlayers[i].getID()),playerBet,currentBet,maxBet)))
             {
                 // error, try to receive again
             }

             std::cout<<"player bet received from comms: "<<playerBet<<"\n";

             playerRaise = playerBet;
             playerBet += m_livePlayers[i].getBet();
             m_livePlayers[i].setBet(playerBet);

             // check if player has fold
             if(m_livePlayers[i].isFold())
             {

                 //GUI Stuff
                 //create visual represetation of the cards that get burnt
                 GUI::Hand* burned = m_dealerGui.uniqueHand(m_livePlayers[i].getHole(),m_livePlayers[i].getID());
                 //set their position off-screen
                 burned->setPos(m_dealerGui.getOffScreenPos(m_livePlayers[i].getID()));
                 //flip the cards
                 burned->setFlipped(true,true);
                 //move cards to the centre
                 burned->moveTo(m_dealerGui.getCentre());
                 //burn the cards
                 burned->burn();
                 //add the folded players bet to the pot
                 addBetToPot(playerBet);
                 //transfer the players information to m_table
                 updatePlayer(i);
                 //remove the player from the vector
                 m_livePlayers.erase(m_livePlayers.begin()+i);
                 //set the player to true
                 p[i] = true;
             }
             else
             {
                 //get the current players bet
                 currentBet = m_livePlayers[i].getBet();
                 //GUI runs bet animation
                 m_dealerGui.receiveBetFrom(m_livePlayers[i].getID(),playerRaise);

                 //if the players bet is the same as the previous players bet set the player to true
                 if(currentBet == oldBet)
                 {
                     p[i] = true;
                 }


                 else
                 {
                     //otherwise loop they've raised so loop through the live players
                     for(unsigned int j=0;j<m_livePlayers.size();j++)
                     {
                         //unless they're folded set everyone back to false'
                         if(m_livePlayers[j].isFold()) {p[j] = true;}

                         //otherwise false
                         else                          {p[j] = false;}
                     }
                     //set the current player to true
                     p[i]=true;
                 }
             }
             oldBet = currentBet;
         }
      }
  }
  //loop through live players
  for(unsigned int i=0;i<m_livePlayers.size();i++)
  {
     //get their bet and add it to the pot
      playerBet = m_livePlayers[i].getBet();
      addBetToPot(playerBet);
      //remove bet from their money
      m_livePlayers[i].removeBet();
      //transfer bet from liveplayer to table player
      updatePlayer(i);
  }

}