dkforest

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

commit 103fbc6f0d13f9e85606c486ef368e1e618fa570
parent ecaadee0ca3d0de385a746ae024c121548240921
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 27 Dec 2023 16:38:46 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/events.go | 4++--
Mpkg/web/handlers/poker/poker.go | 30+++++++++++++++---------------
2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/pkg/web/handlers/poker/events.go b/pkg/web/handlers/poker/events.go @@ -6,12 +6,12 @@ import ( ) type PokerEvent struct { - ID string + ID int // ID1 is the ID of the next card in the stack. // We need to pre-set it's z-index because z-index and transform are not working properly together. // And the z-index is actually set once the transform is completed. // So this hack makes it look like the next card from the stack move over the other cards... - ID1 string + ID1 int ZIdx int Name string Top int diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -629,7 +629,7 @@ func (g *Game) unSitPlayer(gPlayers *seatedPlayers, seatedPlayer *seatedPlayer) player.folded.Store(true) player.cards.RWith(func(playerCards []playerCard) { for _, card := range playerCards { - evt := PokerEvent{ID: "card" + itoa(card.idx), Name: "", ZIdx: card.zIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} + evt := PokerEvent{ID: card.idx, Name: "", ZIdx: card.zIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} PubSub.Pub(g.roomID.Topic(), evt) ongoing.events.Append(evt) } @@ -688,8 +688,8 @@ func showCards(g *Game, seats []Seat) { } else if p.seatIdx == 2 { seatData.Top -= 8 } - evt1 := PokerEvent{ID: "card" + itoa(firstCard.idx), Name: firstCard.name, ZIdx: firstCard.zIdx, Top: seatData.Top, Left: seatData.Left, Reveal: true} - evt2 := PokerEvent{ID: "card" + itoa(secondCard.idx), Name: secondCard.name, ZIdx: secondCard.zIdx, Top: seatData.Top, Left: seatData.Left + 53, Reveal: true} + evt1 := PokerEvent{ID: firstCard.idx, Name: firstCard.name, ZIdx: firstCard.zIdx, Top: seatData.Top, Left: seatData.Left, Reveal: true} + evt2 := PokerEvent{ID: secondCard.idx, Name: secondCard.name, ZIdx: secondCard.zIdx, Top: seatData.Top, Left: seatData.Left + 53, Reveal: true} PubSub.Pub(roomTopic, evt1) PubSub.Pub(roomTopic, evt2) ongoing.events.Append(evt1, evt2) @@ -761,8 +761,8 @@ func foldPlayer(g *Game, p *PokerPlayer) { firstCard = pCards[0] secondCard = pCards[1] }) - evt1 := PokerEvent{ID: "card" + itoa(firstCard.idx), Name: "", ZIdx: firstCard.zIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} - evt2 := PokerEvent{ID: "card" + itoa(secondCard.idx), Name: "", ZIdx: secondCard.zIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} + evt1 := PokerEvent{ID: firstCard.idx, Name: "", ZIdx: firstCard.zIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} + evt2 := PokerEvent{ID: secondCard.idx, Name: "", ZIdx: secondCard.zIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} PubSub.Pub(roomTopic, evt1) PubSub.Pub(roomTopic, evt2) g.ongoing.events.Append(evt1, evt2) @@ -1161,8 +1161,8 @@ func burnCard(g *Game, idx, burnIdx *int) { ongoing := g.ongoing *idx++ evt := PokerEvent{ - ID: "card" + itoa(*idx), - ID1: "card" + itoa(*idx+1), + ID: *idx, + ID1: *idx + 1, Name: "", ZIdx: *idx + 53, Top: BurnStackY + (*burnIdx * 2), @@ -1178,8 +1178,8 @@ func dealCard(g *Game, idx *int, dealCardIdx int) { card := ongoing.deck[*idx] *idx++ evt := PokerEvent{ - ID: "card" + itoa(*idx), - ID1: "card" + itoa(*idx+1), + ID: *idx, + ID1: *idx + 1, Name: card, ZIdx: *idx + 53, Top: DealY, @@ -1229,8 +1229,8 @@ func dealPlayersCards(g *Game, seats []Seat, idx *int) { seatData1.Left += 53 } - evt := PokerEvent{ID: "card" + itoa(*idx), ID1: "card" + itoa(*idx+1), Name: "", ZIdx: *idx + 104, Top: top, Left: left, Angle: seatData.Angle} - evt1 := PokerEvent{ID: "card" + itoa(*idx), ID1: "card" + itoa(*idx+1), Name: card, ZIdx: *idx + 104, Top: seatData1.Top, Left: seatData1.Left, Reveal: true, UserID: pUserID} + evt := PokerEvent{ID: *idx, ID1: *idx + 1, Name: "", ZIdx: *idx + 104, Top: top, Left: left, Angle: seatData.Angle} + evt1 := PokerEvent{ID: *idx, ID1: *idx + 1, Name: card, ZIdx: *idx + 104, Top: seatData1.Top, Left: seatData1.Left, Reveal: true, UserID: pUserID} PubSub.Pub(roomTopic, evt) PubSub.Pub(roomUserTopic, evt1) @@ -2069,12 +2069,12 @@ func getPokerEventHtml(payload PokerEvent, animationTime string) string { transform += utils.Ternary(!payload.Reveal, ` rotateY(`+BackfacingDeg+`)`, ``) transform += ";" pokerEvtHtml := `<style>` - if payload.ID1 != "" { - pokerEvtHtml += `#` + payload.ID1 + ` { z-index: ` + itoa(payload.ZIdx+1) + `; }` + if payload.ID1 != 0 { + pokerEvtHtml += `#card` + itoa(payload.ID1) + ` { z-index: ` + itoa(payload.ZIdx+1) + `; }` } pokerEvtHtml += ` -#` + payload.ID + ` { z-index: ` + itoa(payload.ZIdx) + `; transition: ` + animationTime + ` ease-in-out; ` + transform + ` } -#` + payload.ID + ` .card .inner:before { content: "` + payload.Name + `"; color: ` + colorForCard(payload.Name) + `; } +#card` + itoa(payload.ID) + ` { z-index: ` + itoa(payload.ZIdx) + `; transition: ` + animationTime + ` ease-in-out; ` + transform + ` } +#card` + itoa(payload.ID) + ` .card .inner:before { content: "` + payload.Name + `"; color: ` + colorForCard(payload.Name) + `; } </style>` return pokerEvtHtml }