dkforest

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

commit 07088ac5b1f944cd5ebae87e407c8fa45856c31e
parent 439e8846265bd20606217baa0944795a1b59e7a0
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue,  5 Dec 2023 18:16:04 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker.go | 27+++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go @@ -95,6 +95,18 @@ type PokerGame struct { IsGameOver bool } +func (g *Ongoing) GetDeckStr() string { + return g.getDeckStr() +} + +func (g *Ongoing) getDeckStr() string { + return strings.Join(g.Deck, "") +} + +func (g *Ongoing) GetDeckHash() string { + return utils.MD5([]byte(g.getDeckStr())) +} + func (g *Ongoing) GetPlayer(player string) *PokerPlayer { for _, p := range g.Players { if p != nil && p.Username == player { @@ -758,12 +770,6 @@ func PokerHandler(c echo.Context) error { _, _ = c.Response().Write([]byte(s)) } - deckStr := "" - if g.Ongoing != nil { - deckStr = strings.Join(g.Ongoing.Deck, "") - } - deckMd5 := utils.MD5([]byte(deckStr)) - quit := hutils.CloseSignalChan(c) roomTopic := "room_" + roomID roomUserTopic := "room_" + roomID + "_" + authUser.Username.String() @@ -989,7 +995,6 @@ body { actions := `<iframe src="/poker/` + roomID + `/deal" id="dealBtn"></iframe>` actions += `<iframe src="/poker/` + roomID + `/unsit" id="unSitBtn"></iframe>` send(actions) - deckHash := deckMd5 send(`<div id="errorMsg"></div>`) send(`<div id="seat1Pot">BET: 0</div>`) send(buildMainPotHtml(g)) @@ -1003,11 +1008,13 @@ body { drawCountDownStyle(g.Ongoing.WaitTurnEvent) } send(`<div id="deckStr"></div>`) - if g.IsGameDone { - send(`<style>#deckStr:before { content: "` + deckStr + `"; }</style>`) + if g.Ongoing != nil && g.IsGameDone { + send(`<style>#deckStr:before { content: "` + g.Ongoing.GetDeckStr() + `"; }</style>`) } send(`<div id="deckHash"></div>`) - send(`<style>#deckHash:before { content: "` + deckHash + `"; }</style>`) + if g.Ongoing != nil { + send(`<style>#deckHash:before { content: "` + g.Ongoing.GetDeckHash() + `"; }</style>`) + } if g.Ongoing != nil { for _, payload := range g.Ongoing.Events { send(getPokerEventHtml(payload, "0s"))