dkforest

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

commit 8f3d16bbd7ca40ded80abcdd32d28866ba42120e
parent 73b65b237d7d9b8264145441dfee6ef3b8385c59
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat, 16 Dec 2023 05:03:38 -0500

UI

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

diff --git a/pkg/web/handlers/poker/events.go b/pkg/web/handlers/poker/events.go @@ -40,6 +40,10 @@ type LogEvent struct { Message string } +type AutoActionEvent struct { + Message string +} + type ErrorMsgEvent struct { Message string } diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -670,18 +670,18 @@ RoundIsSettledLoop: evt.Call && autoAction == CallAction || evt.Check && autoAction == CheckAction { delete(autoCache, evt.Player) - PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: ""}) + PokerPubSub.Pub(roomUserTopic, AutoActionEvent{Message: ""}) return continueGetPlayerEventLoop } if evt.Fold { autoCache[evt.Player] = FoldAction - PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: "Will auto fold"}) + PokerPubSub.Pub(roomUserTopic, AutoActionEvent{Message: "Will auto fold"}) } else if evt.Call { autoCache[evt.Player] = CallAction - PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: "Will auto call"}) + PokerPubSub.Pub(roomUserTopic, AutoActionEvent{Message: "Will auto call"}) } else if evt.Check { autoCache[evt.Player] = CheckAction - PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: "Will auto check"}) + PokerPubSub.Pub(roomUserTopic, AutoActionEvent{Message: "Will auto check"}) } return continueGetPlayerEventLoop } @@ -776,6 +776,7 @@ RoundIsSettledLoop: RoundIsSettled: + PokerPubSub.Pub(roomTopic, AutoActionEvent{Message: ""}) PokerPubSub.Pub(roomTopic, ErrorMsgEvent{Message: ""}) newLogEvent(g, roomLogsTopic, fmt.Sprintf("--")) setWaitTurn(g, roomTopic, -1) @@ -1517,6 +1518,8 @@ func buildPayloadHtml(g *PokerGame, authUser *database.User, payload any) (html html += drawPlayerBetEvent(evt) case ErrorMsgEvent: html += drawErrorMsgEvent(evt) + case AutoActionEvent: + html += drawAutoActionMsgEvent(evt) case PlayerFoldEvent: html += drawPlayerFoldEvent(evt) case ResetCardsEvent: @@ -1693,17 +1696,30 @@ func buildCountdownsHtml() (html string) { } func buildActionsDiv(roomID RoomID) (html string) { - html += `<div id="actionsDiv">` - html += `<div>` - html += `<iframe src="/poker/` + roomID.String() + `/deal" id="dealBtn"></iframe>` - html += `<iframe src="/poker/` + roomID.String() + `/unsit" id="unSitBtn"></iframe>` - html += `<iframe src="/poker/` + roomID.String() + `/bet" id="betBtn"></iframe>` - html += `<iframe src="/poker/` + roomID.String() + `/call" id="callBtn"></iframe>` - html += `<iframe src="/poker/` + roomID.String() + `/check" id="checkBtn"></iframe>` - html += `<iframe src="/poker/` + roomID.String() + `/fold" id="foldBtn"></iframe>` - html += `</div>` - html += `<div id="errorMsg"></div>` - html += `</div>` + html += ` +<table id="actionsDiv"> + <tr> + <td> + <iframe src="/poker/` + roomID.String() + `/deal" id="dealBtn"></iframe> + <iframe src="/poker/` + roomID.String() + `/unsit" id="unSitBtn"></iframe> + </td> + <td style="vertical-align: top;" rowspan="2"> + <iframe src="/poker/` + roomID.String() + `/bet" id="betBtn"></iframe> + </td> + <td> + <iframe src="/poker/` + roomID.String() + `/call" id="callBtn"></iframe> + <iframe src="/poker/` + roomID.String() + `/check" id="checkBtn"></iframe> + <iframe src="/poker/` + roomID.String() + `/fold" id="foldBtn"></iframe> + </td> + </tr> + <tr> + <td></td> + <td><div id="autoAction"></div></td> + </tr> + <tr> + <td colspan="3"><div id="errorMsg"></div></td> + </tr> +</table>` return } @@ -1759,6 +1775,15 @@ func drawSeatsStyle(authUser *database.User, g *PokerGame) string { return html } +func drawAutoActionMsgEvent(evt AutoActionEvent) (html string) { + if evt.Message != "" { + html += `<style>#autoAction { display: block; } #autoAction:before { content: "` + evt.Message + `"; }</style>` + } else { + html += `<style>#autoAction { display: none; } #autoAction:before { content: ""; }</style>` + } + return +} + func drawErrorMsgEvent(evt ErrorMsgEvent) (html string) { if evt.Message != "" { html += `<style>#errorMsg { display: block; } #errorMsg:before { content: "` + evt.Message + `"; }</style>` @@ -2045,6 +2070,16 @@ body { border-radius: 3px; display: none; } +#autoAction { + color: #072a85; + font-size: 20px; + font-family: Arial,Helvetica,sans-serif; + background-color: #bcd8ff; + border: 1px solid #072a85; + display: none; + padding: 2px 3px; + border-radius: 3px; +} #eventLogs { position: absolute; bottom: 5px; right: 5px; width: 300px; height: 200px; border: 1px solid black; background-color: #ccc; padding: 3px; border-radius: 3px; } #dealerToken { top: 125px; left: 714px; width: 20px; height: 20px; background-color: #ccc; border: 1px solid #333; border-radius: 11px; position: absolute; } #dealerToken .inner { padding: 2px 4px; }