implement new blinds settings (II)
This commit is contained in:
+86
-5
@@ -18,7 +18,6 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "game.h"
|
||||
#include "gamedata.h"
|
||||
|
||||
#include <enginefactory.h>
|
||||
#include <guiinterface.h>
|
||||
@@ -29,13 +28,13 @@
|
||||
using namespace std;
|
||||
|
||||
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const PlayerDataList &playerDataList, const GameData gameData,
|
||||
const StartData &startData, int gameId)
|
||||
: myFactory(factory), myGui(gui), actualHand(0), actualBoard(0),
|
||||
startQuantityPlayers(startData.numberOfPlayers),
|
||||
startCash(gameData.startMoney), startSmallBlind(gameData.smallBlind),
|
||||
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
||||
myGameID(gameId), actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0)
|
||||
myGameID(gameId), actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData)
|
||||
{
|
||||
// cout << "Create Game Object" << "\n";
|
||||
int i;
|
||||
@@ -107,6 +106,10 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
|
||||
}
|
||||
actualBoard->setPlayerLists(playerArray, seatsList, activePlayerList, runningPlayerList); // delete playerArray
|
||||
|
||||
//start timer
|
||||
blindsTimer.reset();
|
||||
blindsTimer.start();
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
@@ -144,8 +147,8 @@ void Game::initHand()
|
||||
|
||||
actualHandID++;
|
||||
|
||||
// smallBlind alle x Runden erhöhen
|
||||
if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; }
|
||||
// calculate smallBlind
|
||||
raiseBlinds();
|
||||
|
||||
//Spieler Action auf 0 setzen
|
||||
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
@@ -243,3 +246,81 @@ boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
||||
return tmpPlayer;
|
||||
}
|
||||
|
||||
void Game::raiseBlinds() {
|
||||
|
||||
// cout << "timer minutes " << blindsTimer.elapsed().total_seconds()/60 << "\n";
|
||||
// cout << "gameData.raiseIntervallMode " << myGameData.raiseIntervallMode << "\n";
|
||||
// cout << "gameData.raiseMode " << myGameData.raiseMode << "\n";
|
||||
// cout << "gameData.afterManualBlindsMode " << myGameData.afterManualBlindsMode << "\n";
|
||||
|
||||
bool raiseBlinds = false;
|
||||
|
||||
if (myGameData.raiseIntervallMode == RAISE_ON_HANDNUMBER) {
|
||||
|
||||
if (lastHandBlindsRaised + myGameData.raiseSmallBlindEveryHandsValue <= actualHandID) {
|
||||
raiseBlinds = true;
|
||||
lastHandBlindsRaised = actualHandID;
|
||||
|
||||
cout << "raise now on hands \n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (lastTimeBlindsRaised + myGameData.raiseSmallBlindEveryMinutesValue <= blindsTimer.elapsed().total_seconds()/60) {
|
||||
raiseBlinds = true;
|
||||
lastTimeBlindsRaised = blindsTimer.elapsed().total_seconds()/60;
|
||||
|
||||
cout << "raise now on minutes \n";
|
||||
}
|
||||
}
|
||||
|
||||
if (raiseBlinds) {
|
||||
|
||||
// At this point, the blinds must be raised
|
||||
// Now we check how the blinds should be raised
|
||||
|
||||
if (myGameData.raiseMode == DOUBLE_BLINDS) {
|
||||
actualSmallBlind *= 2;
|
||||
cout << "double small blind \n";
|
||||
}
|
||||
else {
|
||||
// Increase the position of the list
|
||||
list<int> blindsList = myGameData.manualBlindsList;
|
||||
list<int>::iterator it;
|
||||
|
||||
if(!blindsList.empty()) {
|
||||
it = find(blindsList.begin(), blindsList.end(), actualSmallBlind);
|
||||
if(it != blindsList.end()) {
|
||||
it++;
|
||||
cout << "increase position in blindslist \n";
|
||||
}
|
||||
else {
|
||||
cout << "blindslist exceeds\n";
|
||||
if(actualSmallBlind == myGameData.firstSmallBlind) {
|
||||
it = blindsList.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
else { cout << "blindslist is empty \n"; }
|
||||
// Check if we can get an element of the list or the position exceeds the lis
|
||||
if (blindsList.empty() || it == blindsList.end()) {
|
||||
|
||||
// The position exceeds the list
|
||||
if (myGameData.afterManualBlindsMode == AFTERMB_DOUBLE_BLINDS) {
|
||||
actualSmallBlind *= 2;
|
||||
cout << "after blindslist double blind\n";
|
||||
}
|
||||
else {
|
||||
if(myGameData.afterManualBlindsMode == AFTERMB_RAISE_ABOUT) {
|
||||
actualSmallBlind += myGameData.afterMBAlwaysRaiseValue;
|
||||
cout << "after blindslist increase about x \n";
|
||||
}
|
||||
else { /* Stay at last blind */ cout << "after blindslist stay at last blind \n"; }
|
||||
}
|
||||
} else {
|
||||
// Grab the blinds amount from the list
|
||||
actualSmallBlind = *it;
|
||||
cout << "set new small blind from blindslist \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -21,11 +21,13 @@
|
||||
#define GAME_H
|
||||
|
||||
#include "game_defs.h"
|
||||
#include "gamedata.h"
|
||||
#include "playerdata.h"
|
||||
#include "configfile.h"
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <core/boost/timers.hpp>
|
||||
|
||||
class GuiInterface;
|
||||
class HandInterface;
|
||||
@@ -43,7 +45,7 @@ class Game {
|
||||
|
||||
public:
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const PlayerDataList &playerDataList, const GameData gameData,
|
||||
const StartData &startData, int gameId);
|
||||
|
||||
~Game();
|
||||
@@ -80,6 +82,8 @@ public:
|
||||
boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id);
|
||||
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
|
||||
|
||||
void raiseBlinds();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<EngineFactory> myFactory;
|
||||
|
||||
@@ -106,6 +110,12 @@ private:
|
||||
int actualSmallBlind;
|
||||
int actualHandID;
|
||||
unsigned dealerPosition;
|
||||
int lastHandBlindsRaised;
|
||||
int lastTimeBlindsRaised;
|
||||
const GameData myGameData;
|
||||
|
||||
//timer
|
||||
boost::timers::portable::second_timer blindsTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -79,9 +79,42 @@ void gameLobbyDialogImpl::createGame()
|
||||
// Set Game Data
|
||||
gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value();
|
||||
gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value();
|
||||
gameData.smallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();
|
||||
gameData.handsBeforeRaise = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
gameData.guiSpeed = myCreateInternetGameDialog->spinBox_gameSpeed->value();
|
||||
gameData.smallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();//TODO remove
|
||||
gameData.firstSmallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();
|
||||
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) {
|
||||
gameData.raiseIntervallMode = RAISE_ON_HANDNUMBER;
|
||||
gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
gameData.handsBeforeRaise = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); //TODO remove
|
||||
}
|
||||
else {
|
||||
gameData.raiseIntervallMode = RAISE_ON_MINUTES;
|
||||
gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
|
||||
}
|
||||
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) {
|
||||
gameData.raiseMode = DOUBLE_BLINDS;
|
||||
}
|
||||
else {
|
||||
gameData.raiseMode = MANUAL_BLINDS_ORDER;
|
||||
std::list<int> tempBlindList;
|
||||
int i;
|
||||
bool ok = TRUE;
|
||||
for(i=0; i<myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) {
|
||||
tempBlindList.push_back(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10));
|
||||
}
|
||||
gameData.manualBlindsList = tempBlindList;
|
||||
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; }
|
||||
else {
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) {
|
||||
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
|
||||
gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value();
|
||||
}
|
||||
else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; }
|
||||
}
|
||||
}
|
||||
|
||||
gameData.guiSpeed = myCreateInternetGameDialog->spinBox_gameSpeed->value();
|
||||
gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value();
|
||||
|
||||
|
||||
@@ -96,10 +96,10 @@ private:
|
||||
ConfigFile *myConfig;
|
||||
Session *mySession;
|
||||
createInternetGameDialogImpl *myCreateInternetGameDialog;
|
||||
LobbyChat *myChat;
|
||||
|
||||
QString currentGameName;
|
||||
bool isAdmin;
|
||||
LobbyChat *myChat;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -723,14 +723,39 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
||||
gameData.startMoney = v->spinBox_startCash->value();
|
||||
gameData.smallBlind = v->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); //TODO remove
|
||||
gameData.firstSmallBlind = v->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();
|
||||
if(v->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) gameData.raiseIntervallMode = RAISE_ON_HANDNUMBER;
|
||||
else gameData.raiseIntervallMode = RAISE_ON_MINUTES;
|
||||
gameData.raiseSmallBlindEveryHandsValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
gameData.handsBeforeRaise = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); //TODO remove
|
||||
gameData.raiseSmallBlindEveryMinutesValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
|
||||
if(v->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) gameData.raiseMode = DOUBLE_BLINDS;
|
||||
else gameData.raiseMode = MANUAL_BLINDS_ORDER;
|
||||
|
||||
|
||||
if(v->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) {
|
||||
gameData.raiseIntervallMode = RAISE_ON_HANDNUMBER;
|
||||
gameData.raiseSmallBlindEveryHandsValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
gameData.handsBeforeRaise = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); //TODO remove
|
||||
}
|
||||
else {
|
||||
gameData.raiseIntervallMode = RAISE_ON_MINUTES;
|
||||
gameData.raiseSmallBlindEveryMinutesValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
|
||||
}
|
||||
|
||||
if(v->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) {
|
||||
gameData.raiseMode = DOUBLE_BLINDS;
|
||||
}
|
||||
else {
|
||||
gameData.raiseMode = MANUAL_BLINDS_ORDER;
|
||||
list<int> tempBlindList;
|
||||
int i;
|
||||
bool ok = TRUE;
|
||||
for(i=0; i<v->getChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) {
|
||||
tempBlindList.push_back(v->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10));
|
||||
}
|
||||
gameData.manualBlindsList = tempBlindList;
|
||||
|
||||
if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; }
|
||||
else {
|
||||
if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) {
|
||||
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
|
||||
gameData.afterMBAlwaysRaiseValue = v->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value();
|
||||
}
|
||||
else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; }
|
||||
}
|
||||
}
|
||||
|
||||
//Speeds
|
||||
gameData.guiSpeed = v->spinBox_gameSpeed->value();
|
||||
@@ -740,8 +765,37 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
||||
// Set Game Data
|
||||
gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers");
|
||||
gameData.startMoney = myConfig->readConfigInt("StartCash");
|
||||
gameData.smallBlind = myConfig->readConfigInt("FirstSmallBlind");
|
||||
gameData.handsBeforeRaise = myConfig->readConfigInt("RaiseSmallBlindEveryHands");
|
||||
gameData.smallBlind = myConfig->readConfigInt("FirstSmallBlind"); //TODO remove
|
||||
gameData.handsBeforeRaise = myConfig->readConfigInt("RaiseSmallBlindEveryHands"); //TODO remove
|
||||
|
||||
gameData.firstSmallBlind = myConfig->readConfigInt("FirstSmallBlind");
|
||||
|
||||
if(myConfig->readConfigInt("RaiseBlindsAtHands")) {
|
||||
gameData.raiseIntervallMode = RAISE_ON_HANDNUMBER;
|
||||
gameData.raiseSmallBlindEveryHandsValue = myConfig->readConfigInt("RaiseSmallBlindEveryHands");
|
||||
gameData.handsBeforeRaise = myConfig->readConfigInt("RaiseSmallBlindEveryHands"); //TODO remove
|
||||
}
|
||||
else {
|
||||
gameData.raiseIntervallMode = RAISE_ON_MINUTES;
|
||||
gameData.raiseSmallBlindEveryMinutesValue = myConfig->readConfigInt("RaiseSmallBlindEveryMinutes");
|
||||
}
|
||||
|
||||
if(myConfig->readConfigInt("AlwaysDoubleBlinds")) {
|
||||
gameData.raiseMode = DOUBLE_BLINDS;
|
||||
}
|
||||
else {
|
||||
gameData.raiseMode = MANUAL_BLINDS_ORDER;
|
||||
gameData.manualBlindsList = myConfig->readConfigIntList("ManualBlindsList");
|
||||
|
||||
if(myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds")) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; }
|
||||
else {
|
||||
if(myConfig->readConfigInt("AfterMBAlwaysRaiseAbout")) {
|
||||
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
|
||||
gameData.afterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue");
|
||||
}
|
||||
else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; }
|
||||
}
|
||||
}
|
||||
//Speeds
|
||||
gameData.guiSpeed = myConfig->readConfigInt("GameSpeed");
|
||||
}
|
||||
@@ -788,9 +842,43 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
|
||||
GameData gameData;
|
||||
gameData.maxNumberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value();
|
||||
gameData.startMoney = myCreateNetworkGameDialog->spinBox_startCash->value();
|
||||
gameData.smallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();
|
||||
gameData.handsBeforeRaise = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value();
|
||||
gameData.smallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();//TODO remove
|
||||
gameData.firstSmallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();
|
||||
|
||||
if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) {
|
||||
gameData.raiseIntervallMode = RAISE_ON_HANDNUMBER;
|
||||
gameData.raiseSmallBlindEveryHandsValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
gameData.handsBeforeRaise = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); //TODO remove
|
||||
}
|
||||
else {
|
||||
gameData.raiseIntervallMode = RAISE_ON_MINUTES;
|
||||
gameData.raiseSmallBlindEveryMinutesValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
|
||||
}
|
||||
|
||||
if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) {
|
||||
gameData.raiseMode = DOUBLE_BLINDS;
|
||||
}
|
||||
else {
|
||||
gameData.raiseMode = MANUAL_BLINDS_ORDER;
|
||||
list<int> tempBlindList;
|
||||
int i;
|
||||
bool ok = TRUE;
|
||||
for(i=0; i<myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) {
|
||||
tempBlindList.push_back(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10));
|
||||
}
|
||||
gameData.manualBlindsList = tempBlindList;
|
||||
|
||||
if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; }
|
||||
else {
|
||||
if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) {
|
||||
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
|
||||
gameData.afterMBAlwaysRaiseValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value();
|
||||
}
|
||||
else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; }
|
||||
}
|
||||
}
|
||||
|
||||
gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value();
|
||||
gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value();
|
||||
|
||||
myGameLobbyDialog->setSession(&getSession());
|
||||
@@ -2856,7 +2944,7 @@ void mainWindowImpl::localGameModification() {
|
||||
}
|
||||
|
||||
//Set the playing mode to "manual"
|
||||
playingMode = 0;
|
||||
playingMode = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user