dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 6af8cca6bb64272a65431633e21b9ea3d0fb1bc9
parent 25c90bc8a0f0c43d77b23a9fcc172380a5baf5f5
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 19 Dec 2023 02:28:11 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 28++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -1813,20 +1813,21 @@ func drawSeatsStyle(authUser *database.User, g *PokerGame) string { func drawAutoActionMsgEvent(evt AutoActionEvent) (html string) { display := utils.Ternary(evt.Message != "", "block", "none") - html += `<style>#autoAction { display: ` + display + `; } #autoAction:before { content: "` + evt.Message + `"; }</style>` + html += fmt.Sprintf(`<style>#autoAction { display: %s; } #autoAction:before { content: "%s"; }</style>`, display, evt.Message) return } func drawErrorMsgEvent(evt ErrorMsgEvent) (html string) { display := utils.Ternary(evt.Message != "", "block", "none") - html += `<style>#errorMsg { display: ` + display + `; } #errorMsg:before { content: "` + evt.Message + `"; }</style>` + html += fmt.Sprintf(`<style>#errorMsg { display: %s; } #errorMsg:before { content: "%s"; }</style>`, display, evt.Message) return } func drawPlayerBetEvent(evt PlayerBetEvent) (html string) { + idxStr := itoa(evt.PlayerSeatIdx + 1) html += `<style>` - html += `#seat` + itoa(evt.PlayerSeatIdx+1) + `Pot:before { content: "` + itoa2(evt.TotalBet) + `"; }` - html += `#seat` + itoa(evt.PlayerSeatIdx+1) + `_cash:before { content: "` + itoa2(evt.Cash) + `"; }` + html += fmt.Sprintf(`#seat%sPot:before { content: "%s"; }`, idxStr, itoa2(evt.TotalBet)) + html += fmt.Sprintf(`#seat%s_cash:before { content: "%s"; }`, idxStr, itoa2(evt.Cash)) html += `</style>` return } @@ -1845,7 +1846,7 @@ func drawGameIsDoneHtml(g *PokerGame, evt GameIsDoneEvent) (html string) { g.Players.RWith(func(gPlayers *[]*seatedPlayer) { for i, p := range *gPlayers { if p != nil { - html += `#seat` + itoa(i+1) + `_cash:before { content: "` + itoa2(p.getCash()) + `"; }` + html += fmt.Sprintf(`#seat%s_cash:before { content: "%s"; }`, itoa(i+1), itoa2(p.getCash())) } } }) @@ -1855,17 +1856,19 @@ func drawGameIsDoneHtml(g *PokerGame, evt GameIsDoneEvent) (html string) { } func drawPlayerFoldEvent(evt PlayerFoldEvent) (html string) { - transition := `transition: 1s ease-in-out; transform: translateX(` + itoa(BurnStackX) + `px) translateY(` + itoa(BurnStackY) + `px) rotateY(` + BackfacingDeg + `);` - html = `<style>#card` + itoa(evt.Card1Idx) + ` { ` + transition + ` } - #card` + itoa(evt.Card2Idx) + ` { ` + transition + ` }</style>` + idxStr := itoa(evt.Card1Idx) + transition := fmt.Sprintf(`transition: 1s ease-in-out; transform: translateX(%spx) translateY(%spx) rotateY(%s);`, itoa(BurnStackX), itoa(BurnStackY), BackfacingDeg) + html = `<style>#card` + idxStr + ` { ` + transition + ` } + #card` + idxStr + ` { ` + transition + ` }</style>` return } func drawResetCardsEvent() (html string) { html += `<style>` for i := 1; i <= 52; i++ { - html += `#card` + itoa(i) + ` { transition: 1s ease-in-out; transform: translateX(` + itoa(DealerStackX) + `px) translateY(` + itoa(DealerStackY) + `px) rotateY(` + BackfacingDeg + `); } - #card` + itoa(i) + ` .card .inner:before { content: ""; }` + idxStr := itoa(i) + html += `#card` + idxStr + ` { transition: 1s ease-in-out; transform: translateX(` + itoa(DealerStackX) + `px) translateY(` + itoa(DealerStackY) + `px) rotateY(` + BackfacingDeg + `); } + #card` + idxStr + ` .card .inner:before { content: ""; }` } html += ` #winner:before { content: ""; } @@ -1887,8 +1890,9 @@ func drawCountDownStyle(evt PokerWaitTurnEvent) string { html += `#seat1, #seat2, #seat3, #seat4, #seat5, #seat6 { background-color: rgba(45, 45, 45, 0.4); }` remainingSecs := int((MaxUserCountdown*time.Second - time.Since(evt.CreatedAt)).Seconds()) if evt.Idx >= 0 && evt.Idx <= 5 { - html += `#seat` + itoa(evt.Idx+1) + ` { background-color: rgba(200, 45, 45, 0.7); }` - html += `#countdown` + itoa(evt.Idx+1) + ` { --duration: ` + itoa(remainingSecs) + `; display: block; animation: time calc(var(--duration) * 1s) steps(1000, start) forwards; }` + idxStr := itoa(evt.Idx + 1) + html += `#seat` + idxStr + ` { background-color: rgba(200, 45, 45, 0.7); }` + html += `#countdown` + idxStr + ` { --duration: ` + itoa(remainingSecs) + `; display: block; animation: time calc(var(--duration) * 1s) steps(1000, start) forwards; }` } html += "</style>" return html