next steps implementing cardschance

This commit is contained in:
doitux
2008-10-14 20:19:37 +00:00
parent 1962bfe925
commit 01048bd7e9
7 changed files with 129 additions and 7 deletions
+6
View File
@@ -90,3 +90,9 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
}
}
double* Tools::calcCardsChance()
{
double array[10] = { 30.12, 11.11, 100.00, 0.00, 0.00, 99.22, 78.56, 34.22, 67.22, 21.00 };
return array;
}
+1 -1
View File
@@ -24,7 +24,7 @@
class Tools{
public:
static void getRandNumber(int, int, int, int*, bool);
static double* calcCardsChance();
};
#endif
+4 -4
View File
@@ -2571,7 +2571,7 @@
<enum>Qt::NoFocus</enum>
</property>
<property name="currentIndex" >
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab_Log" >
<attribute name="title" >
@@ -2664,7 +2664,7 @@
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="MyChanceLable" name="label" >
<widget class="MyChanceLabel" name="label_chance" >
<property name="text" >
<string/>
</property>
@@ -3144,9 +3144,9 @@
<header>myavatarlabel.h</header>
</customwidget>
<customwidget>
<class>MyChanceLable</class>
<class>MyChanceLabel</class>
<extends>QLabel</extends>
<header>mychancelable.h</header>
<header>mychancelabel.h</header>
</customwidget>
</customwidgets>
<resources/>
+6
View File
@@ -591,6 +591,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
connect(this, SIGNAL(signalStartVoteOnKick(int, int)), this, SLOT(startVoteOnKick(int, int)));
connect(this, SIGNAL(signalEndVoteOnKick()), this, SLOT(endVoteOnKick()));
refreshCardsChance();
}
gameTableImpl::~gameTableImpl() {
@@ -3124,3 +3125,8 @@ void gameTableImpl::refreshVotesMonitor()
label_votesMonitor->setText(tr("Player <b>%1</b> has %2 votes against him.").arg(QString::fromUtf8(info.playerName.c_str())));
}
void gameTableImpl::refreshCardsChance()
{
label_chance->refreshChance(Tools::calcCardsChance());
}
+2
View File
@@ -230,6 +230,8 @@ public slots:
void postRiverRunAnimation5();
void postRiverRunAnimation6();
void refreshCardsChance();
void blinkingStartButtonAnimationAction();
void flipHolecardsAllIn();
+98
View File
@@ -22,3 +22,101 @@ MyChanceLabel::MyChanceLabel(QWidget* parent)
MyChanceLabel::~MyChanceLabel()
{
}
void MyChanceLabel::refreshChance(double *chance)
{
RFChance = chance[9];
SFChance = chance[8];
FOAKChance = chance[7];
FHChance = chance[6];
FLChance = chance[5];
STRChance = chance[4];
TOAKChance = chance[3];
TPChance = chance[2];
OPChance = chance[1];
HCChance = chance[0];
update();
}
void MyChanceLabel::paintEvent(QPaintEvent * event) {
QPainter painter(this);
#ifdef _WIN32
QString font1String = "font-family: \"Arial\";";
#else
#ifdef __APPLE__
QString font1String = "font-family: \"Lucida Grande\";";
#else
QString font1String = "font-family: \"Nimbus Sans L\";";
#endif
#endif
QFont font;
font.setFamily(font1String);
font.setPixelSize(10);
painter.setFont(font);
//Draw Texts
if(RFChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,0), QPointF(76,13)),Qt::AlignRight,"Royal Flush");
painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance, 0, 'f', 2));
if(SFChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,13), QPointF(76,26)),Qt::AlignRight,"Straight Flush");
painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance, 0, 'f', 2));
if(FOAKChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,26), QPointF(76,39)),Qt::AlignRight,"Four of a Kind");
painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance, 0, 'f', 2));
if(FHChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,39), QPointF(76,52)),Qt::AlignRight,"Full House");
painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance, 0, 'f', 2));
if(FLChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,52), QPointF(76,65)),Qt::AlignRight,"Flush");
painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance, 0, 'f', 2));
if(STRChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,65), QPointF(76,78)),Qt::AlignRight,"Straight");
painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance, 0, 'f', 2));
if(TOAKChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,78), QPointF(76,91)),Qt::AlignRight,"Three of a Kind");
painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance, 0, 'f', 2));
if(TPChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,91), QPointF(76,104)),Qt::AlignRight,"Two Pairs");
painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance, 0, 'f', 2));
if(OPChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,104), QPointF(76,117)),Qt::AlignRight,"One Pair");
painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance, 0, 'f', 2));
if(HCChance == 0.00) { painter.setPen(QColor(85,99,47)); }
else { painter.setPen(QColor(156,213,0)); }
painter.drawText(QRectF(QPointF(2,117), QPointF(76,130)),Qt::AlignRight,"Highest Card");
painter.drawText(QRectF(QPointF(196,117), QPointF(236,130)),Qt::AlignRight,QString("%1%").arg(HCChance, 0, 'f', 2));
//Draw gfx
painter.setPen(QColor(0,0,0));
QLinearGradient linearGrad(QPointF(80,3), QPointF(180,10));
linearGrad.setColorAt(0, Qt::blue);
linearGrad.setColorAt(0.5, Qt::yellow);
linearGrad.setColorAt(1, Qt::red);
painter.setBrush(linearGrad);
if(RFChance != 0.00) painter.drawRect(80,3,(107*RFChance)/100,7);
if(SFChance != 0.00) painter.drawRect(80,16,(107*SFChance)/100,7);
if(FOAKChance != 0.00) painter.drawRect(80,29,(107*FOAKChance)/100,7);
if(FHChance != 0.00) painter.drawRect(80,42,(107*FHChance)/100,7);
if(FLChance != 0.00) painter.drawRect(80,55,(107*FLChance)/100,7);
if(STRChance != 0.00) painter.drawRect(80,68,(107*STRChance)/100,7);
if(TOAKChance != 0.00) painter.drawRect(80,81,(107*TOAKChance)/100,7);
if(TPChance != 0.00) painter.drawRect(80,94,(107*TPChance)/100,7);
if(OPChance != 0.00) painter.drawRect(80,107,(107*OPChance)/100,7);
if(HCChance != 0.00) painter.drawRect(80,120,(107*HCChance)/100,7);
}
+12 -2
View File
@@ -28,12 +28,22 @@ public:
~MyChanceLabel();
void setMyW ( gameTableImpl* theValue ) { myW = theValue; }
void paintEvent(QPaintEvent * event);
void refreshChance(double*);
private:
gameTableImpl *myW;
double RFChance;
double SFChance;
double FOAKChance;
double FHChance;
double FLChance;
double STRChance;
double TOAKChance;
double TPChance;
double OPChance;
double HCChance;
};
#endif