diff --git a/web/src/components/BattlePhase.tsx b/web/src/components/BattlePhase.tsx index 00cf400..75a1c4f 100644 --- a/web/src/components/BattlePhase.tsx +++ b/web/src/components/BattlePhase.tsx @@ -289,7 +289,11 @@ function unitPop(ev: BattleEvent | null, seat: number, events: BattleEvent[], st export function BattlePhase({ view, send, step, setStep }: Props) { const battle = view.battle! const events = battle.events ?? [] + // acked = the player committed to the next round (waiting on the opponent). const [acked, setAcked] = useState(false) + // The result dialog pops when the replay ends. "Not yet" dismisses it so the + // battle can be rewatched; a toolbar button then remains to advance the round. + const [resultDismissed, setResultDismissed] = useState(false) // The deck-peek popover lives inside .battlefield, which sets overflow-x // (and thus overflow-y) to auto — so an absolutely-positioned popover gets // clipped to the battlefield. We anchor it to the hovered stack's viewport @@ -358,6 +362,17 @@ export function BattlePhase({ view, send, step, setStep }: Props) { const won = battle.winnerSeat === youSeat const draw = battle.winnerSeat < 0 + // Commit to the next round: ack and hand off to the server. + const proceed = () => { + setAcked(true) + send({ type: 'ready' }) + } + const nextLabel = battle.round >= view.maxRounds ? 'See final results' : 'Next round →' + // Show the result dialog when the replay finishes — unless the player chose + // "Not yet" to rewatch (then only the toolbar button remains). Once they've + // committed, the dialog reappears to show the "waiting" state. + const showResult = done && (acked || !resultDismissed) + // Dice for the rock event currently on screen. renderSide draws them under // the throwing side's deck; `step` keys the tray so the scramble replays for // every rock event. @@ -603,6 +618,17 @@ export function BattlePhase({ view, send, step, setStep }: Props) { > ⏱ {speed}× + {/* Once the replay ends, a persistent way to advance the round — the + path forward after the result dialog is dismissed to rewatch. */} + {done && !acked && ( + + )} @@ -658,33 +684,39 @@ export function BattlePhase({ view, send, step, setStep }: Props) { ) })()} - {done && ( -
-
- {draw ? 'Draw!' : won ? 'Victory!' : 'Defeat…'} -
- {!draw && ( -
- {view.players[battle.winnerSeat]?.name} wins{' '} - {'🏆'.repeat(battle.trophies)} + {/* The result lands as a centered dialog — always fully on screen, even on + a phone where the arena fills the viewport. "Not yet" dismisses it so + the battle can be rewatched; the toolbar keeps a way to advance. */} + {showResult && + createPortal( +
+
+
+ {draw ? 'Draw!' : won ? 'Victory!' : 'Defeat…'} +
+ {!draw ? ( +
+ {view.players[battle.winnerSeat]?.name} wins {'🏆'.repeat(battle.trophies)} +
+ ) : ( +
No trophies awarded
+ )} + {acked ? ( +

Waiting for opponent…

+ ) : ( +
+ + +
+ )}
- )} - {draw &&
No trophies awarded
} - {acked ? ( -

Waiting for opponent…

- ) : ( - - )} -
- )} +
, + document.body, + )}
) } diff --git a/web/src/components/CardView.tsx b/web/src/components/CardView.tsx index e5f3b69..77f409d 100644 --- a/web/src/components/CardView.tsx +++ b/web/src/components/CardView.tsx @@ -13,10 +13,12 @@ const DIE_PIPS: Record = { 6: [[9, 9], [21, 9], [9, 15], [21, 15], [9, 21], [21, 21]], } -function TierDie({ tier }: { tier: number }) { - const pips = DIE_PIPS[tier] ?? DIE_PIPS[1] +// DieFace renders a value 1–6 as a pipped die, like the real game's markers. +// Shared by the card's tier corner and the topbar's round indicator. +export function DieFace({ value, className }: { value: number; className?: string }) { + const pips = DIE_PIPS[value] ?? DIE_PIPS[1] return ( - + {pips.map(([cx, cy], i) => ( @@ -25,6 +27,10 @@ function TierDie({ tier }: { tier: number }) { ) } +function TierDie({ tier }: { tier: number }) { + return +} + // useFitText shrinks text until it fits its box, so long abilities (and the // smaller battle cards) render in full instead of being clipped by the fixed // card height, and long single-line names shrink instead of wrapping. It diff --git a/web/src/components/Table.tsx b/web/src/components/Table.tsx index c788769..40c6b24 100644 --- a/web/src/components/Table.tsx +++ b/web/src/components/Table.tsx @@ -3,7 +3,7 @@ import type { Dispatch, SetStateAction } from 'react' import { createPortal } from 'react-dom' import { useGame } from '../useGame' import { useCatalog } from '../useCatalog' -import { CardView } from './CardView' +import { CardView, DieFace } from './CardView' import type { Card, Session } from '../types' import { Lobby } from './Lobby' import { ShopPhase } from './ShopPhase' @@ -44,6 +44,10 @@ export function Table({ session, onLeave }: { session: Session; onLeave: () => v // this open flag is simply ignored. const [logOpen, setLogOpen] = useState(false) + // The room code and Leave button live behind a "⋯" menu in the topbar rail, + // keeping the rail short enough for one row on a phone. + const [menuOpen, setMenuOpen] = useState(false) + // The battle outcome is known before the replay plays out, so we hold its // "result" log entry back: it's dropped from the persistent list during the // battle and appended as the final battle line only once the replay reaches @@ -132,8 +136,12 @@ export function Table({ session, onLeave }: { session: Session; onLeave: () => v 🐾 SAP {view.phase !== 'gameover' && view.phase !== 'lobby' && ( -
- Round {view.round} / {view.maxRounds} +
+
)}
@@ -179,12 +187,41 @@ export function Table({ session, onLeave }: { session: Session; onLeave: () => v
))}
-
- {view.code} +
+ + {menuOpen && ( + <> +
setMenuOpen(false)} /> +
+
+ Room code + + {view.code} + +
+ +
+ + )}
-
diff --git a/web/src/styles.css b/web/src/styles.css index 6a44ff5..d1a6f5e 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -422,14 +422,17 @@ h3 { letter-spacing: 0.04em; } +/* The round shows as a die face — 1–6 pips, like the real game's round marker. */ .topbar-round { - font-size: 0.95rem; - font-weight: 700; - color: rgba(255, 245, 225, 0.9); + display: flex; + align-items: center; } -.topbar-round strong { - color: var(--gold); +.topbar-die { + width: 26px; + height: 26px; + display: block; + filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4)); } .topbar-players { @@ -514,7 +517,7 @@ h3 { line-height: 1; } -/* The room code, stamped like a label on a card tray. */ +/* The room code, stamped like a label on a card tray. Lives inside the ⋯ menu. */ .topbar-code { font-family: var(--font-display); letter-spacing: 0.28em; @@ -525,6 +528,54 @@ h3 { border-radius: 8px; } +/* The ⋯ menu holds the room code and Leave, pushed to the right of the rail so + the middle is just the players and their stats. */ +.topbar-menu { + position: relative; + margin-left: auto; +} + +.topbar-menu-btn { + font-size: 1.15rem; + line-height: 1; + padding: 5px 12px; +} + +/* A full-viewport catcher so a click anywhere off the menu closes it. */ +.topbar-menu-backdrop { + position: fixed; + inset: 0; + z-index: 20; +} + +.topbar-menu-pop { + position: absolute; + right: 0; + top: calc(100% + 8px); + z-index: 21; + min-width: 190px; + display: flex; + flex-direction: column; + gap: 12px; + padding: 14px; + background: + repeating-linear-gradient(92deg, rgba(0, 0, 0, 0.05) 0 3px, transparent 3px 7px), + linear-gradient(180deg, var(--wood-light), var(--wood) 70%, var(--wood-dark)); + border: 2px solid var(--wood-dark); + border-radius: 12px; + box-shadow: + inset 0 1px 0 rgba(255, 220, 170, 0.25), + 0 14px 30px rgba(0, 0, 0, 0.55); +} + +.topbar-menu-code { + display: flex; + flex-direction: column; + gap: 5px; + align-items: flex-start; + font-size: 0.78rem; +} + .table-body { flex: 1; display: flex; @@ -2666,14 +2717,11 @@ h3 { z-index: 5; } -.battle-result { - text-align: center; - display: flex; - flex-direction: column; - gap: 12px; - align-items: center; - padding: 8px 0; - animation: result-in 400ms ease; +/* The end-of-battle result dialog: a centered modal so it's always fully on + screen (even on a phone where the arena fills the viewport). */ +.battle-result-modal { + gap: 14px; + min-width: min(320px, 86vw); } @keyframes result-in { @@ -2693,15 +2741,15 @@ h3 { text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), 0 6px 14px rgba(0, 0, 0, 0.4); } -.battle-result.is-win .battle-result-title { +.battle-result-modal.is-win .battle-result-title { color: var(--gold); } -.battle-result.is-loss .battle-result-title { +.battle-result-modal.is-loss .battle-result-title { color: #ff8f7a; } -.battle-result.is-draw .battle-result-title { +.battle-result-modal.is-draw .battle-result-title { color: #6fd6c2; } @@ -2710,6 +2758,11 @@ h3 { font-weight: 700; } +/* The toolbar's "advance the round" button stands out from the ghost controls. */ +.battle-next { + margin-left: 2px; +} + /* ---------- game over ---------- */ .gameover { @@ -2856,19 +2909,23 @@ h3 { gap: 5px 8px; padding: 5px 9px; } + /* Drop the wordmark entirely on a phone — the die, the player tags, and the + ⋯ menu are all that's needed, and losing it helps the rail stay one row. */ .topbar-brand { - font-size: 1.05rem; - } - /* The wordmark is redundant next to the paw on a phone — drop it to buy width - so the rail packs onto fewer rows. */ - .topbar-brand span { display: none; } - /* Let the tags pack tight instead of stretching across a whole row. */ + .topbar-die { + width: 23px; + height: 23px; + } + /* Let the tags pack tight; the ⋯ menu is pushed to the right by margin-auto. */ .topbar-players { flex: 0 1 auto; gap: 6px; } + .topbar-menu-btn { + padding: 4px 10px; + } .topbar-round { font-size: 0.82rem; } @@ -3065,6 +3122,30 @@ h3 { min-width: 72px; min-height: 112px; } + /* A battle card is small and glanced at, not read — so on a phone strip it to + the essentials: big art, the power badge and any damage marker, and the + name. No suit dot, tier die, or ability text (the magnified view still shows + the full card). The scene grows to fill the space the panel gives up. */ + .battle-unit .card-scene { + flex: 1 1 auto; + } + .battle-unit .card-panel { + flex: 0 0 auto; + } + .battle-unit .card-effect, + .battle-unit .card-suit, + .battle-unit .card-die, + .battle-unit .card-panel-slot { + display: none; + } + .battle-unit .card-panel-head { + grid-template-columns: 1fr; + border-bottom: none; + padding-bottom: 0; + } + .battle-unit .card-art { + font-size: 2.1rem; + } .card-back { width: 56px; height: 78px; @@ -3078,13 +3159,10 @@ h3 { .food-fan-card:not(:first-child) { margin-left: -50px; } - .battle-result { - gap: 8px; - } .battle-result-title { font-size: 1.7rem; } - .battle-result .btn-big { + .battle-result-modal .btn-big { font-size: 1.05rem; padding: 11px 22px; }