Display payout results.
Also fixed problem with some numbers not having enough bits. Fixed indexes on single bets being different from what was expected.
This commit is contained in:
parent
ffcc5f892c
commit
4b19c90450
4 changed files with 95 additions and 79 deletions
|
@ -45,7 +45,7 @@ qt_add_qml_module(roulette-payout
|
|||
RedBlack.qml
|
||||
EvenOdd.qml
|
||||
LowHigh.qml
|
||||
|
||||
Results.qml
|
||||
)
|
||||
|
||||
target_link_libraries(roulette-payout PRIVATE
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "PlayerAreaModel.h"
|
||||
#include <cstdint>
|
||||
|
||||
PlayerAreaModel::PlayerAreaModel(QObject *parent)
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ void PlayerAreaModel::bet(BetType b, int n, int bet)
|
|||
player->bet1.betType = b;
|
||||
player->bet1.betValue = bet;
|
||||
player->bet1.betSpot = n;
|
||||
if (b == 9 && n <= 35) {
|
||||
if (b == SINGLE && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betChanged(b, n, bet);
|
||||
|
@ -51,7 +52,7 @@ void PlayerAreaModel::bet(BetType b, int n, int bet)
|
|||
player->bet2.betType = b;
|
||||
player->bet2.betValue = bet;
|
||||
player->bet2.betSpot = n;
|
||||
if (b == 9 && n <= 35) {
|
||||
if (b == SINGLE && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betChanged(b, n, bet);
|
||||
|
@ -61,15 +62,15 @@ void PlayerAreaModel::bet(BetType b, int n, int bet)
|
|||
void PlayerAreaModel::removeBet(BetType b, int n)
|
||||
{
|
||||
Player *player = &players[focusedPlayer_];
|
||||
if (player->bet1.betType != NONE) {
|
||||
if (player->bet1.betType == b) {
|
||||
player->bet1.betType = NONE;
|
||||
if (b == 9 && n <= 35) {
|
||||
if (b == SINGLE && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betRemoved(b, n);
|
||||
} else {
|
||||
} else if (player->bet2.betType == b) {
|
||||
player->bet2.betType = NONE;
|
||||
if (b == 9 && n <= 35) {
|
||||
if (b == SINGLE && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betRemoved(b, n);
|
||||
|
@ -91,84 +92,93 @@ void PlayerAreaModel::payout()
|
|||
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;
|
||||
if (betType != NONE) {
|
||||
betSpot = players.at(i).bet1.betSpot;
|
||||
if (betType == SINGLE && betSpot <= 35) {
|
||||
betSpot = 36 - betSpot;
|
||||
} else {
|
||||
betSpot += 1;
|
||||
}
|
||||
} 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;
|
||||
|
||||
if (betType == SINGLE && betSpot == rollSpot) {
|
||||
players[i].payout += players.at(i).bet1.betValue * 21;
|
||||
} else if (betType == RED && (((int64_t)1 << (rollSpot - 1)) & redNumbers)) {
|
||||
players[i].payout += players.at(i).bet1.betValue * 2;
|
||||
} else if (betType == BLACK && !(((int64_t)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 && (((int64_t)1 << (rollSpot - 1)) & column1)) {
|
||||
players[i].payout += players.at(i).bet1.betValue * 3;
|
||||
} else if (betSpot == 2 && (((int64_t)1 << (rollSpot - 1)) & column2)) {
|
||||
players[i].payout += players.at(i).bet1.betValue * 3;
|
||||
} else if (betSpot == 3 && (((int64_t)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;
|
||||
|
||||
if (betType != NONE) {
|
||||
betSpot = players.at(i).bet2.betSpot;
|
||||
if (betType == SINGLE && betSpot <= 35) {
|
||||
printf("SINGLLEEE\n");
|
||||
betSpot = 36 - betSpot;
|
||||
} else {
|
||||
betSpot += 1;
|
||||
}
|
||||
} 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;
|
||||
|
||||
if (betType == SINGLE && betSpot == rollSpot) {
|
||||
players[i].payout += players.at(i).bet2.betValue * 21;
|
||||
} else if (betType == RED && (((int64_t)1 << (rollSpot - 1)) & redNumbers)) {
|
||||
players[i].payout += players.at(i).bet2.betValue * 2;
|
||||
} else if (betType == BLACK && !(((int64_t)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 && (((int64_t)1 << (rollSpot - 1)) & column1)) {
|
||||
players[i].payout += players.at(i).bet2.betValue * 3;
|
||||
} else if (betSpot == 2 && (((int64_t)1 << (rollSpot - 1)) & column2)) {
|
||||
players[i].payout += players.at(i).bet2.betValue * 3;
|
||||
} else if (betSpot == 3 && (((int64_t)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);
|
||||
emit results(players.at(i).playerName, i, players.at(i).payout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QQuickView>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <cstdint>
|
||||
#include <qobject.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
@ -42,6 +43,7 @@ signals:
|
|||
void betChanged(BetType b, int n, int bet);
|
||||
void betRemoved(BetType b, int n);
|
||||
void betCanceled(BetType b, uint n);
|
||||
void results(QString name, int n, int payout);
|
||||
|
||||
public slots:
|
||||
void setPlayerName(QString s, int n);
|
||||
|
@ -71,8 +73,8 @@ private:
|
|||
|
||||
int focusedPlayer_;
|
||||
|
||||
long long redNumbers = 45857548629;
|
||||
long long column1 = 9817068105;
|
||||
long long column2 = 19634136210;
|
||||
long long column3 = 39268272420;
|
||||
int64_t redNumbers = 45857548629;
|
||||
int64_t column1 = 9817068105;
|
||||
int64_t column2 = 19634136210;
|
||||
int64_t column3 = 39268272420;
|
||||
};
|
||||
|
|
4
Root.qml
4
Root.qml
|
@ -34,6 +34,7 @@ Window {
|
|||
}
|
||||
|
||||
Button {
|
||||
id: payoutButton
|
||||
text: "Payout"
|
||||
font.pointSize: 15
|
||||
highlighted: false
|
||||
|
@ -61,5 +62,8 @@ Window {
|
|||
border.width: 0
|
||||
}
|
||||
}
|
||||
|
||||
Results {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue