Improved code for showing player bets next to name

Also added this functionality to the croupier "player".
This commit is contained in:
greek 2024-06-07 16:30:49 +01:00
parent af6401ddd5
commit 91ea5543a2
2 changed files with 45 additions and 64 deletions

View file

@ -44,6 +44,39 @@ Item {
rightMargin: 5 rightMargin: 5
} }
} }
Text {
id: roll
anchors {
top: parent.top
topMargin: 8
left: parent.right
leftMargin: 5
}
}
Connections {
target: PlayerAreaModel
function onBetChanged(b, n, bet) {
if (PlayerAreaModel.focusedPlayer == 0) {
const betTypes = ["NONE", "Red", "Black", "Odd", "Even", "Low", "High",
"Dozen", "Street", "Single", "Column", "Split"]
if (b < 7) {
roll.text = betTypes[b]
} else {
roll.text = betTypes[b] + " " + (n + 1)
}
}
}
function onBetRemoved(b, n) {
if (PlayerAreaModel.focusedPlayer == 0) {
roll.text = ""
}
}
}
} }
ColumnLayout { ColumnLayout {
@ -140,75 +173,23 @@ Item {
function onBetChanged(b, n, bet) { function onBetChanged(b, n, bet) {
if (PlayerAreaModel.focusedPlayer - 1 == index) { if (PlayerAreaModel.focusedPlayer - 1 == index) {
const betTypes = ["NONE", "Red", "Black", "Odd", "Even", "Low", "High",
"Dozen", "Street", "Single", "Column", "Split"]
if (currentBet1.text == "") { if (currentBet1.text == "") {
currentBet1.betType = b currentBet1.betType = b
currentBet1.n = n currentBet1.n = n
switch(b) { if (b < 7) {
case 1: currentBet1.text = betTypes[b] + ": " + bet + "g"
currentBet1.text = "Red: " + bet + "g" } else {
break; currentBet1.text = betTypes[b] + " " + (n + 1) + ": " + bet + "g"
case 2:
currentBet1.text = "Black: " + bet + "g"
break;
case 3:
currentBet1.text = "Odd: " + bet + "g"
break;
case 4:
currentBet1.text = "Even: " + bet + "g"
break;
case 5:
currentBet1.text = "Low: " + bet + "g"
break;
case 6:
currentBet1.text = "High: " + bet + "g"
break;
case 7:
currentBet1.text = "Dozen " + (n + 1) + ": " + bet + "g"
break;
case 8:
currentBet1.text = "Street " + (n + 1) + ": " + bet + "g"
break;
case 9:
currentBet1.text = "Single " + (n + 1) + ": " + bet + "g"
break;
case 10:
currentBet1.text = "Column " + (n + 1) + ": " + bet + "g"
break;
} }
} else { } else {
currentBet2.betType = b currentBet2.betType = b
currentBet2.n = n currentBet2.n = n
switch(b) { if (b < 7) {
case 1: currentBet2.text = betTypes[b] + ": " + bet + "g"
currentBet2.text = "Red: " + bet + "g" } else {
break; currentBet2.text = betTypes[b] + " " + (n + 1) + ": " + bet + "g"
case 2:
currentBet2.text = "Black: " + bet + "g"
break;
case 3:
currentBet2.text = "Odd: " + bet + "g"
break;
case 4:
currentBet2.text = "Even: " + bet + "g"
break;
case 5:
currentBet2.text = "Low: " + bet + "g"
break;
case 6:
currentBet2.text = "High: " + bet + "g"
break;
case 7:
currentBet2.text = "Dozen " + (n + 1) + ": " + bet + "g"
break;
case 8:
currentBet2.text = "Street " + (n + 1) + ": " + bet + "g"
break;
case 9:
currentBet2.text = "Single " + (n + 1) + ": " + bet + "g"
break;
case 10:
currentBet2.text = "Column " + (n + 1) + ": " + bet + "g"
break;
} }
} }
} }

View file

@ -17,14 +17,14 @@ Item {
topMargin: 68 topMargin: 68
} }
rowSpacing: 0 rowSpacing: 1
columnSpacing: 1.8 columnSpacing: 1.8
Repeater { Repeater {
model: 36 model: 36
Item { Item {
height: 45 height: 44
width: 35 width: 35
BetButton { BetButton {