dkforest

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

commit b4375545d63acda25a26711c6edce05471d373cb
parent 69bf027af0e821e5d2674760a92bd69bbc392d4d
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat,  9 Dec 2023 05:54:59 -0500

dedup code

Diffstat:
Mpkg/web/handlers/poker/poker.go | 34++++------------------------------
1 file changed, 4 insertions(+), 30 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -1287,37 +1287,11 @@ func buildSeatsHtml(g *PokerGame, authUser *database.User, roomID string) (html html += `</div>` } html += `</div>` - - seated, _ := g.IsSeated(authUser.Username.String()) - html += `<style>` - for i, p := range g.Players { - if p != nil || seated { - html += `.takeSeat` + itoa(i+1) + ` { display: none; }` - } else { - html += `.takeSeat` + itoa(i+1) + ` { display: block; }` - } - if p != nil { - if p.Username == authUser.Username.String() { - html += `#seat` + itoa(i+1) + ` { border: 2px solid #0d1b8f; }` - } - html += `#seat` + itoa(i+1) + ` .inner:before { content: "` + p.Username + `"; }` - html += `#seat` + itoa(i+1) + `_cash:before { content: "` + itoa(p.getDisplayCash(g)) + `"; }` - if g.Ongoing != nil { - if op := g.Ongoing.GetPlayer(p.Username); op != nil && op.Bet > 0 { - html += `#seat` + itoa(i+1) + `Pot:before { content: "` + itoa(op.Bet) + `"; }` - } - } - } else { - html += `#seat` + itoa(i+1) + ` { border: 1px solid #333; }` - html += `#seat` + itoa(i+1) + ` .inner:before { content: ""; }` - html += `#seat` + itoa(i+1) + `_cash:before { content: ""; }` - } - } - html += `</style>` + html += drawSeatsStyle(authUser, g) return html } -func drawSeatsHtml(authUser *database.User, g *PokerGame) string { +func drawSeatsStyle(authUser *database.User, g *PokerGame) string { html := "<style>" seated, _ := g.IsSeated(authUser.Username.String()) g.PlayersMtx.RLock() @@ -1848,9 +1822,9 @@ Loop: case ResetCardsEvent: send(drawResetCardsEvent()) case PokerSeatTakenEvent: - send(drawSeatsHtml(authUser, g)) + send(drawSeatsStyle(authUser, g)) case PokerSeatLeftEvent: - send(drawSeatsHtml(authUser, g)) + send(drawSeatsStyle(authUser, g)) case PokerWaitTurnEvent: send(drawCountDownStyle(evt)) case PokerEvent: