Calculate payouts.
This commit is contained in:
parent
f72c5b781f
commit
ffcc5f892c
3 changed files with 96 additions and 3 deletions
|
@ -32,7 +32,7 @@ QString PlayerAreaModel::getPlayerName(int n)
|
||||||
|
|
||||||
void PlayerAreaModel::setPlayerName(QString s, int n)
|
void PlayerAreaModel::setPlayerName(QString s, int n)
|
||||||
{
|
{
|
||||||
this->players[n].playerName = s;
|
players[n].playerName = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerAreaModel::bet(BetType b, int n, int bet)
|
void PlayerAreaModel::bet(BetType b, int n, int bet)
|
||||||
|
@ -83,5 +83,92 @@ void PlayerAreaModel::cancelBet(BetType b, int n)
|
||||||
|
|
||||||
void PlayerAreaModel::payout()
|
void PlayerAreaModel::payout()
|
||||||
{
|
{
|
||||||
printf("payout\n");
|
if (players.at(0).bet1.betType == NONE) {
|
||||||
|
printf("Select where the ball landed\n");
|
||||||
|
} else {
|
||||||
|
int rollSpot = 36 - players.at(0).bet1.betSpot;
|
||||||
|
|
||||||
|
for (int i = 1; i < 8; i++) {
|
||||||
|
int betType = players.at(i).bet1.betType;
|
||||||
|
int betSpot;
|
||||||
|
if (betType == SINGLE) {
|
||||||
|
betSpot = 36 - players.at(i).bet1.betSpot;
|
||||||
|
} else {
|
||||||
|
betSpot = players.at(i).bet1.betSpot + 1;
|
||||||
|
}
|
||||||
|
players[i].payout = 0;
|
||||||
|
printf("%d %d\n", betSpot, rollSpot);
|
||||||
|
|
||||||
|
if (betType == SINGLE && betSpot == rollSpot) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 21;
|
||||||
|
} else if (betType == RED && ((1 << (rollSpot - 1)) & redNumbers)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||||
|
} else if (betType == BLACK && !((1 << (rollSpot - 1)) & redNumbers)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||||
|
} else if (betType == ODD && (rollSpot % 2)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||||
|
} else if (betType == EVEN && !(rollSpot % 2)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||||
|
} else if (betType == LOW && rollSpot <= 18 ) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||||
|
} else if (betType == HIGH && rollSpot >= 19 && rollSpot < 37) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||||
|
} else if (betType == DOZEN) {
|
||||||
|
if (rollSpot <= 12 * betSpot && rollSpot >= (12 * (betSpot - 1)) + 1) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 3;
|
||||||
|
}
|
||||||
|
} else if (betType == STREET) {
|
||||||
|
if (rollSpot <= 3 * betSpot && rollSpot >= (3 * (betSpot - 1)) + 1) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 6;
|
||||||
|
}
|
||||||
|
} else if (betType == COLUMN) {
|
||||||
|
if (betSpot == 1 && ((1 << (rollSpot - 1)) & column1)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 3;
|
||||||
|
} else if (betSpot == 2 && ((1 << (rollSpot - 1)) & column2)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 3;
|
||||||
|
} else if (betSpot == 3 && ((1 << (rollSpot - 1)) & column3)) {
|
||||||
|
players[i].payout += players.at(i).bet1.betValue * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
betType = players.at(i).bet2.betType;
|
||||||
|
if (betType == SINGLE) {
|
||||||
|
betSpot = 36 - players.at(i).bet1.betSpot;
|
||||||
|
} else {
|
||||||
|
betSpot = players.at(i).bet1.betSpot + 1;
|
||||||
|
}
|
||||||
|
if (betType == SINGLE && betSpot == rollSpot) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 21;
|
||||||
|
} else if (betType == RED && ((1 << (rollSpot - 1)) & redNumbers)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||||
|
} else if (betType == BLACK && !((1 << (rollSpot - 1)) & redNumbers)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||||
|
} else if (betType == ODD && (rollSpot % 2)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||||
|
} else if (betType == EVEN && !(rollSpot % 2)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||||
|
} else if (betType == LOW && rollSpot <= 18 ) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||||
|
} else if (betType == HIGH && rollSpot >= 19 && rollSpot < 37) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||||
|
} else if (betType == DOZEN) {
|
||||||
|
if (rollSpot <= 12 * betSpot && rollSpot >= (12 * (betSpot - 1)) + 1) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 3;
|
||||||
|
}
|
||||||
|
} else if (betType == STREET) {
|
||||||
|
if (rollSpot <= 3 * betSpot && rollSpot >= (3 * (betSpot - 1)) + 1) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 6;
|
||||||
|
}
|
||||||
|
} else if (betType == COLUMN) {
|
||||||
|
if (betSpot == 1 && ((1 << (rollSpot - 1)) & column1)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 3;
|
||||||
|
} else if (betSpot == 2 && ((1 << (rollSpot - 1)) & column2)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 3;
|
||||||
|
} else if (betSpot == 3 && ((1 << (rollSpot - 1)) & column3)) {
|
||||||
|
players[i].payout += players.at(i).bet2.betValue * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("Player %s got %d gil\n", players.at(i).playerName.toLocal8Bit().data(), players.at(i).payout);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,15 @@ private:
|
||||||
QString playerName = "";
|
QString playerName = "";
|
||||||
Bet bet1;
|
Bet bet1;
|
||||||
Bet bet2;
|
Bet bet2;
|
||||||
|
int payout;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<Player> players;
|
QList<Player> players;
|
||||||
|
|
||||||
int focusedPlayer_;
|
int focusedPlayer_;
|
||||||
|
|
||||||
|
long long redNumbers = 45857548629;
|
||||||
|
long long column1 = 9817068105;
|
||||||
|
long long column2 = 19634136210;
|
||||||
|
long long column3 = 39268272420;
|
||||||
};
|
};
|
||||||
|
|
|
@ -129,7 +129,7 @@ Item {
|
||||||
topMargin: 6
|
topMargin: 6
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextEdited: PlayerAreaModel.setPlayerName(text, index)
|
onTextEdited: PlayerAreaModel.setPlayerName(text, index + 1)
|
||||||
onActiveFocusChanged: {
|
onActiveFocusChanged: {
|
||||||
/* focusReason 0, 1 and 2 are mouse, tab forward, and tab backward, respectively */
|
/* focusReason 0, 1 and 2 are mouse, tab forward, and tab backward, respectively */
|
||||||
if (activeFocus && (focusReason == 0 || focusReason == 1 || focusReason == 2)) {
|
if (activeFocus && (focusReason == 0 || focusReason == 1 || focusReason == 2)) {
|
||||||
|
|
Loading…
Reference in a new issue