commit 1f7b4fc4b9e1aeed1492381ba44e3aed8fe4ddbb
parent 982be4076c0ade231f9eb0379070ac127213ad28
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 8 Dec 2023 19:58:58 -0500
fix cash labels
Diffstat:
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -97,6 +97,15 @@ type PokerStandingPlayer struct {
Cash int
}
+func (p *PokerStandingPlayer) getDisplayCash(g *PokerGame) int {
+ if g.Ongoing != nil {
+ if op := g.Ongoing.GetPlayer(p.Username); op != nil {
+ return op.Cash
+ }
+ }
+ return p.Cash
+}
+
type PokerPlayer struct {
Username string
RoundTotalBet int
@@ -1184,7 +1193,7 @@ func buildSeatsHtml(g *PokerGame) string {
seats += `<div id="seat` + itoa(i+1) + `Pot"></div>`
if p != nil {
seats += `<style>#seat` + itoa(i+1) + `:before { content: "` + p.Username + `"; }</style>`
- seats += `<style>#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.Cash) + `"; }</style>`
+ seats += `<style>#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.getDisplayCash(g)) + `"; }</style>`
}
}
seats += `
@@ -1216,7 +1225,7 @@ func drawGameIsDoneHtml(g *PokerGame, evt GameIsDoneEvent) (html string) {
html += `<style>`
for i, p := range g.Players {
if p != nil {
- html += `#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.Cash) + `"; }`
+ html += `#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.getDisplayCash(g)) + `"; }`
}
}
html += `#winner:before { content: "Winner: ` + evt.Winner + ` (` + evt.WinnerHand + `)"; }`
@@ -1259,7 +1268,7 @@ func drawSeatsHtml(authUser *database.User, g *PokerGame) string {
}
if p != nil {
html += `#seat` + itoa(i+1) + `:before { content: "` + p.Username + `"; }`
- html += `#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.Cash) + `"; }`
+ html += `#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.getDisplayCash(g)) + `"; }`
} else {
html += `#seat` + itoa(i+1) + `:before { content: ""; }`
html += `#seat` + itoa(i+1) + `_cash:before { content: ""; }`