aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/casino.go')
-rw-r--r--internal/game/casino.go47
1 files changed, 25 insertions, 22 deletions
diff --git a/internal/game/casino.go b/internal/game/casino.go
index db5bfad..66c90a1 100644
--- a/internal/game/casino.go
+++ b/internal/game/casino.go
@@ -595,8 +595,8 @@ func (g *Game) emitCasinoEvents(events []casino.Event) {
privateMessage := g.casinoPrivateMessage(sess, category, event.Menu, g.casinoTimeText(text))
privateMessage = g.renderCasinoMessage(sess, category, event.Menu, privateMessage)
rendered := g.renderCasinoSnapshot(sess, event.Snapshot)
- if header, reminder, ok := g.casinoBoardReminder(sess, category, event.Menu, event.Snapshot, g.casinoTimeText(text)); ok {
- privateMessage = composeTableThenReminder(header, rendered, reminder)
+ if reminder, ok := g.casinoBoardReminder(sess, category, event.Menu, event.Snapshot, g.casinoTimeText(text)); ok {
+ privateMessage = composeTableThenReminder(rendered, reminder)
} else if rendered != "" {
privateMessage += "\n" + rendered
}
@@ -635,35 +635,37 @@ func (g *Game) casinoMenuParts(sess *net.Session, menu *casino.MenuView, message
// casinoBoardReminder splits a persistent-board menu (craps, roulette, video
// poker, Pai Gow) so its instructions print under the board they describe.
// Every other game, and compact displays, keep their menu in one block.
-func (g *Game) casinoBoardReminder(sess *net.Session, category string, menu *casino.MenuView, snapshot casino.Snapshot, message string) (header, reminder string, ok bool) {
+func (g *Game) casinoBoardReminder(sess *net.Session, category string, menu *casino.MenuView, snapshot casino.Snapshot, message string) (reminder string, ok bool) {
if category != "casino_menu" || menu == nil || sess.Player == nil {
- return "", "", false
+ return "", false
}
_, isCraps := snapshot.(*casino.CrapsSnapshot)
_, isPoker := snapshot.(*casino.VideoPokerSnapshot)
_, isPaiGow := snapshot.(*casino.PaiGowSnapshot)
s, isRoulette := snapshot.(*casino.RouletteSnapshot)
if !isPoker && !isCraps && !isPaiGow && (!isRoulette || s.Phase == "playing" || s.Phase == "result") {
- return "", "", false
+ return "", false
}
if !isPoker && !isCraps && !isPaiGow && sess.Player.OptionString("casino_display") == "compact" && (menu.Repeat || !menu.ShowBalance) {
// The compact reminder is already a short block; leave it intact.
- return "", "", false
+ return "", false
}
balance, heading, commands := g.casinoMenuParts(sess, menu, message)
- return g.casinoMenuHeader(sess, balance, heading), g.casinoMenuCommands(sess, commands), true
+ // The board replaces the game-name heading, and the balance sits with the
+ // commands underneath it rather than above the graphic.
+ return g.renderCasinoCommands(sess, balance, heading, commands), true
}
-// composeTableThenReminder joins a menu header, the board graphic, and the
-// wager reminder. The board snapshot already leads with a blank line, and the
-// reminder keeps exactly one blank line below the board's last visible row.
-func composeTableThenReminder(header, table, reminder string) string {
- out := header
- if table != "" {
- out += "\n" + strings.TrimRight(table, "\n")
- }
+// composeTableThenReminder joins a board graphic and the wager reminder. The
+// board snapshot already leads with a blank line, and the reminder keeps
+// exactly one blank line below the board's last visible row.
+func composeTableThenReminder(table, reminder string) string {
+ out := strings.TrimRight(table, "\n")
if reminder != "" {
- out += "\n\n" + reminder
+ if out != "" {
+ out += "\n\n"
+ }
+ out += reminder
}
return out
}
@@ -766,18 +768,19 @@ func (g *Game) renderCasinoCommands(sess *net.Session, balance, heading string,
}
// casinoMenuHeader formats the balance and heading that introduce a casino
-// menu. It is split from the command list so the roulette board can be drawn
-// between them.
+// menu. The heading (if any) comes first so the balance always sits directly
+// above the command list. It is split from the command list so the roulette
+// board can be drawn between them.
func (g *Game) casinoMenuHeader(sess *net.Session, balance, heading string) string {
var sb strings.Builder
- if balance != "" {
- sb.WriteString(balance)
- sb.WriteString("\n\n")
- }
if heading != "" {
sb.WriteString(g.colorize(sess, "casino_action", heading))
sb.WriteString("\n\n")
}
+ if balance != "" {
+ sb.WriteString(balance)
+ sb.WriteString("\n\n")
+ }
return strings.TrimRight(sb.String(), "\n")
}