implement #79 - show cards chances also after fold

This commit is contained in:
doitux
2011-10-29 19:02:15 +00:00
parent 23b247c90f
commit fb6edc997f
3 changed files with 28 additions and 15 deletions
+7 -2
View File
@@ -3527,14 +3527,19 @@ void gameTableImpl::refreshCardsChance(GameState bero)
if(myConfig->readConfigInt("ShowCardsChanceMonitor")) { if(myConfig->readConfigInt("ShowCardsChanceMonitor")) {
boost::shared_ptr<PlayerInterface> humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); boost::shared_ptr<PlayerInterface> humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front();
if(humanPlayer->getMyActiveStatus() && humanPlayer->getMyAction() != PLAYER_ACTION_FOLD) { if(humanPlayer->getMyActiveStatus()) {
int boardCards[5]; int boardCards[5];
int holeCards[2]; int holeCards[2];
humanPlayer->getMyCards(holeCards); humanPlayer->getMyCards(holeCards);
myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards); myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards);
label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards)); if(humanPlayer->getMyAction() == PLAYER_ACTION_FOLD) {
label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards), true);
}
else {
label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards), false);
}
} else { } else {
label_chance->resetChance(); label_chance->resetChance();
} }
+18 -12
View File
@@ -22,7 +22,7 @@
using namespace std; using namespace std;
MyChanceLabel::MyChanceLabel(QWidget* parent) MyChanceLabel::MyChanceLabel(QWidget* parent)
: QLabel(parent), myW(0), myStyle(0) : QLabel(parent), myW(0), myStyle(0), myFoldState(false)
{ {
RFChance[0] = 0; RFChance[0] = 0;
SFChance[0] = 0; SFChance[0] = 0;
@@ -51,7 +51,7 @@ MyChanceLabel::~MyChanceLabel()
{ {
} }
void MyChanceLabel::refreshChance(vector< vector<int> > chance) void MyChanceLabel::refreshChance(vector< vector<int> > chance, bool fold)
{ {
RFChance[0] = chance[0][9]; RFChance[0] = chance[0][9];
SFChance[0] = chance[0][8]; SFChance[0] = chance[0][8];
@@ -75,6 +75,8 @@ void MyChanceLabel::refreshChance(vector< vector<int> > chance)
OPChance[1] = chance[1][1]; OPChance[1] = chance[1][1];
HCChance[1] = chance[1][0]; HCChance[1] = chance[1][0];
myFoldState = fold;
update(); update();
} }
@@ -102,70 +104,70 @@ void MyChanceLabel::paintEvent(QPaintEvent * /*event*/)
QColor possible("#"+myStyle->getChanceLabelPossibleColor()); QColor possible("#"+myStyle->getChanceLabelPossibleColor());
QColor impossible("#"+myStyle->getChanceLabelImpossibleColor()); QColor impossible("#"+myStyle->getChanceLabelImpossibleColor());
if(RFChance[1] == 0) { if(RFChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,0), QPointF(85,13)),Qt::AlignRight,"Royal Flush"); painter.drawText(QRectF(QPointF(2,0), QPointF(85,13)),Qt::AlignRight,"Royal Flush");
painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance[0])); painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance[0]));
if(SFChance[1] == 0) { if(SFChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,13), QPointF(85,26)),Qt::AlignRight,"Straight Flush"); painter.drawText(QRectF(QPointF(2,13), QPointF(85,26)),Qt::AlignRight,"Straight Flush");
painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance[0])); painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance[0]));
if(FOAKChance[1] == 0) { if(FOAKChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,26), QPointF(85,39)),Qt::AlignRight,"Four of a Kind"); painter.drawText(QRectF(QPointF(2,26), QPointF(85,39)),Qt::AlignRight,"Four of a Kind");
painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance[0])); painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance[0]));
if(FHChance[1] == 0) { if(FHChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,39), QPointF(85,52)),Qt::AlignRight,"Full House"); painter.drawText(QRectF(QPointF(2,39), QPointF(85,52)),Qt::AlignRight,"Full House");
painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance[0])); painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance[0]));
if(FLChance[1] == 0) { if(FLChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,52), QPointF(85,65)),Qt::AlignRight,"Flush"); painter.drawText(QRectF(QPointF(2,52), QPointF(85,65)),Qt::AlignRight,"Flush");
painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance[0])); painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance[0]));
if(STRChance[1] == 0) { if(STRChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,65), QPointF(85,78)),Qt::AlignRight,"Straight"); painter.drawText(QRectF(QPointF(2,65), QPointF(85,78)),Qt::AlignRight,"Straight");
painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance[0])); painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance[0]));
if(TOAKChance[1] == 0) { if(TOAKChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,78), QPointF(85,91)),Qt::AlignRight,"Three of a Kind"); painter.drawText(QRectF(QPointF(2,78), QPointF(85,91)),Qt::AlignRight,"Three of a Kind");
painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance[0])); painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance[0]));
if(TPChance[1] == 0) { if(TPChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,91), QPointF(85,104)),Qt::AlignRight,"Two Pairs"); painter.drawText(QRectF(QPointF(2,91), QPointF(85,104)),Qt::AlignRight,"Two Pairs");
painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance[0])); painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance[0]));
if(OPChance[1] == 0) { if(OPChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
} }
painter.drawText(QRectF(QPointF(2,104), QPointF(85,117)),Qt::AlignRight,"One Pair"); painter.drawText(QRectF(QPointF(2,104), QPointF(85,117)),Qt::AlignRight,"One Pair");
painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance[0])); painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance[0]));
if(HCChance[1] == 0) { if(HCChance[1] == 0 || myFoldState) {
painter.setPen(impossible); painter.setPen(impossible);
} else { } else {
painter.setPen(possible); painter.setPen(possible);
@@ -182,6 +184,9 @@ void MyChanceLabel::paintEvent(QPaintEvent * /*event*/)
linearGrad.setColorAt(1, Qt::red); linearGrad.setColorAt(1, Qt::red);
painter.setBrush(linearGrad); painter.setBrush(linearGrad);
if(myFoldState) { painter.setOpacity(0.4); }
else { painter.setOpacity(1.0); }
if(RFChance[1] != 0) painter.drawRect(89,3,(108*RFChance[0])/100,7); if(RFChance[1] != 0) painter.drawRect(89,3,(108*RFChance[0])/100,7);
if(SFChance[1] != 0) painter.drawRect(89,16,(108*SFChance[0])/100,7); if(SFChance[1] != 0) painter.drawRect(89,16,(108*SFChance[0])/100,7);
if(FOAKChance[1] != 0) painter.drawRect(89,29,(108*FOAKChance[0])/100,7); if(FOAKChance[1] != 0) painter.drawRect(89,29,(108*FOAKChance[0])/100,7);
@@ -219,5 +224,6 @@ void MyChanceLabel::resetChance()
OPChance[1] = 0; OPChance[1] = 0;
HCChance[1] = 0; HCChance[1] = 0;
myFoldState = false;
update(); update();
} }
+3 -1
View File
@@ -41,7 +41,7 @@ public:
myStyle = theValue; myStyle = theValue;
} }
void paintEvent(QPaintEvent * event); void paintEvent(QPaintEvent * event);
void refreshChance(std::vector< std::vector<int> >); void refreshChance(std::vector< std::vector<int> >, bool);
void resetChance(); void resetChance();
private: private:
@@ -58,6 +58,8 @@ private:
int TPChance[2]; int TPChance[2];
int OPChance[2]; int OPChance[2];
int HCChance[2]; int HCChance[2];
bool myFoldState;
}; };
#endif #endif