fix(viewer): remove redundant setup status banner

This commit is contained in:
coyotte508 2026-10-30 23:02:35 +01:00
commit 3eb863b78c
5 changed files with 52 additions and 482 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/old-ui",
"version": "1.2.15",
"version": "1.2.16",
"scripts": {
"serve": "vite --port 5193",
"build": "vite build",

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/viewer",
"version": "5.22.15",
"version": "5.22.16",
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
"contributors": [
"coyotte508",

View file

@ -45,14 +45,7 @@
</b-modal>
<div v-if="$store.state.planError" class="alert alert-warning" role="status">{{ $store.state.planError }}</div>
<template v-if="uiMode === 'graphical'">
<!-- Round 0 only (ban/pick/bid/starting buildings/booster): says whose turn it is and what
they have to do, plus the auction/ban explainer buttons. Deliberately above the map
rather than down in the commands column - during setup the board matters least and
"whose turn, doing what" matters most, and the commands column is both below the whole
map+research row on mobile AND only rendered for the player on turn (`canPlay`), so
everyone else used to have nothing but a green ring on a turn-order circle to go on.
Rendered here (inside the viewer) so hosted and self-contained/hot-seat play get the
same strip. -->
<!-- Setup rules and simultaneous-bid forms are available to every seat. -->
<div class="row" v-if="!ended">
<div class="col-12">
<SilentAuctionSummary />
@ -65,7 +58,7 @@
<PreferenceSplitBid @command="handleCommand" />
<SilentAuctionBid @command="handleCommand" />
<!-- Mobile only (`setupActionsAtTop`): during round 0 the pick/ban buttons move up here,
directly under the status strip, instead of sitting below the whole map+research row
alongside the setup forms, instead of sitting below the whole map+research row
where they normally live. Desktop keeps them in the commands column, unchanged. The
matching `v-if` on the commands column's own <Commands> keeps exactly one of the two
mounted - never both, which would duplicate its element ids and modals. -->

View file

@ -23,59 +23,6 @@ describe("SetupStatus", () => {
return new Engine(["init 3 setup-status", ...moves], { auction: AuctionVariant.Silent });
}
it("names the player on turn and what they have to do", () => {
const engine = silentAuctionEngine();
engine.players[0].name = "Mark";
expect(engine.phase).to.equal(Phase.SetupFactionBan);
const wrapper = mountFor(engine);
expect(wrapper.text()).to.contain("Mark's turn");
expect(wrapper.text()).to.contain("to ban a faction");
wrapper.destroy();
});
it("addresses the player whose seat is being viewed in the second person", () => {
const engine = silentAuctionEngine();
engine.players[0].name = "Mark";
const wrapper = mountFor(engine, 0);
expect(wrapper.text()).to.contain("Your turn");
expect(wrapper.text()).to.not.contain("Mark's turn");
wrapper.destroy();
});
it("keeps showing whose turn it is for a player who cannot act (the case Commands.vue never covered)", () => {
const engine = silentAuctionEngine();
engine.players[0].name = "Mark";
// Seat 2 is watching while seat 0 bans - the action panel isn't rendered for them at all.
const wrapper = mountFor(engine, 2);
expect(wrapper.text()).to.contain("Mark's turn");
expect(wrapper.text()).to.contain("to ban a faction");
wrapper.destroy();
});
it("follows the phase through pick and silent bid", () => {
const picking = silentAuctionEngine(["p1 banFaction terrans", "p2 banFaction lantids", "p3 banFaction gleens"]);
expect(picking.phase).to.equal(Phase.SetupFaction);
let wrapper = mountFor(picking);
expect(wrapper.text()).to.contain("to pick a faction");
wrapper.destroy();
const bidding = silentAuctionEngine([
"p1 banFaction terrans",
"p2 banFaction lantids",
"p3 banFaction gleens",
"p1 faction itars",
"p2 faction taklons",
"p3 faction xenos",
]);
expect(bidding.phase).to.equal(Phase.SetupSilentBid);
wrapper = mountFor(bidding);
expect(wrapper.text()).to.contain("to submit their secret bids");
wrapper.destroy();
});
it("shows compact ban and auction links during an auction's ban phase, and opens the auction explainer", async () => {
const wrapper = mountFor(silentAuctionEngine());
@ -99,7 +46,6 @@ describe("SetupStatus", () => {
expect(engine.phase).to.equal(Phase.SetupFactionBan);
const wrapper = mountFor(engine);
expect(wrapper.text()).to.contain("to ban a faction");
expect(wrapper.find(".setup-status__info--ban").text()).to.contain("Ban phase");
expect(wrapper.find(".setup-status__info--auction").exists()).to.equal(false);
wrapper.destroy();
@ -128,74 +74,16 @@ describe("SetupStatus", () => {
});
}
it("offers no explainer at all for a plain faction pick", () => {
it("renders no banner for a plain faction pick", () => {
const engine = new Engine(["init 2 setup-status-plain"]);
expect(engine.phase).to.equal(Phase.SetupFaction);
const wrapper = mountFor(engine);
expect(wrapper.text()).to.contain("to pick a faction");
expect(wrapper.find(".setup-status").exists()).to.equal(false);
expect(wrapper.find(".setup-status__info").exists()).to.equal(false);
wrapper.destroy();
});
/** One "mark name" chip per seat, in seat order. */
function roster(wrapper: ReturnType<typeof mount>): string[] {
return wrapper.findAll(".setup-status__chip").wrappers.map((chip) => chip.text().replace(/\s+/g, " ").trim());
}
it("does not repeat ban turn order in a second roster beneath the status line", () => {
const engine = silentAuctionEngine(["p1 banFaction terrans"]);
engine.players[0].name = "Mark";
engine.players[1].name = "Ada";
engine.players[2].name = "Bo";
const wrapper = mountFor(engine);
expect(wrapper.text()).to.contain("Ada's turn");
expect(roster(wrapper)).to.deep.equal([]);
expect(wrapper.find(".setup-status__roster").exists()).to.equal(false);
wrapper.destroy();
});
it("tracks who has picked a faction", () => {
const engine = silentAuctionEngine([
"p1 banFaction terrans",
"p2 banFaction lantids",
"p3 banFaction gleens",
"p1 faction itars",
]);
expect(engine.phase).to.equal(Phase.SetupFaction);
const wrapper = mountFor(engine);
// A player with a faction is named by it once they have one, which is also the "done" signal.
expect(roster(wrapper)).to.deep.equal(["✔ Itars", "▸ Player 2", "· Player 3"]);
expect(wrapper.text()).to.contain("Picks");
expect(wrapper.text()).to.contain("1 of 3 in");
wrapper.destroy();
});
it("leaves the Silent Auction's secret-bid round to its own panel, which already has a roster", () => {
// Both simultaneous bid rounds behave the same way here (see the Preference Split's own case
// below). Hot-seat: the strip itself still shows, because the device really is passed around,
// but the roster belongs to SilentAuctionBid.vue - two on one screen would just be noise.
const engine = silentAuctionEngine([
"p1 banFaction terrans",
"p2 banFaction lantids",
"p3 banFaction gleens",
"p1 faction itars",
"p2 faction taklons",
"p3 faction xenos",
"p1 silentBid itars 17 taklons 4 xenos 0",
]);
expect(engine.phase).to.equal(Phase.SetupSilentBid);
const wrapper = mountFor(engine);
expect(wrapper.text()).to.contain("to submit their secret bids");
expect(roster(wrapper)).to.deep.equal([]);
// The one thing this must never leak.
expect(wrapper.text()).to.not.contain("17");
wrapper.destroy();
});
it("says nothing at all while a hosted sealed auction is open, where nobody is 'on turn'", () => {
// Every seat bids at once, so naming one of them would be actively wrong - and the bid panel
// right below reports what is really happening (n of 3 in).
@ -217,67 +105,13 @@ describe("SetupStatus", () => {
wrapper.destroy();
});
it("marks the viewer's own seat and explains each remaining roster chip for a screen reader", () => {
const engine = silentAuctionEngine([
"p1 banFaction terrans",
"p2 banFaction lantids",
"p3 banFaction gleens",
"p1 faction itars",
]);
engine.players[1].name = "Ada";
const wrapper = mountFor(engine, 1);
const chips = wrapper.findAll(".setup-status__chip");
expect(chips.at(0).classes()).to.contain("setup-status__chip--done");
expect(chips.at(0).attributes("aria-label")).to.equal("Itars has picked a faction");
expect(chips.at(1).classes()).to.contain("setup-status__chip--mine");
expect(chips.at(1).attributes("aria-label")).to.equal("Ada has not picked yet");
wrapper.destroy();
});
it("offers no roster where 'done' is not a state: the ascending auction and the booster round", () => {
// Choose-Then-Bid: a player bids, gets outbid, bids again - there is nothing to tick off.
const auction = new Engine(["init 2 setup-status-cb", "p1 faction terrans", "p2 faction xenos"], {
auction: AuctionVariant.ChooseBid,
});
expect(auction.phase).to.equal(Phase.SetupAuction);
let wrapper = mountFor(auction);
expect(wrapper.text()).to.contain("to bid on a faction");
expect(roster(wrapper)).to.deep.equal([]);
wrapper.destroy();
// And the starting-building round, where a player owes two placements rather than one.
const buildings = new Engine(["init 2 setup-status-build", "p1 faction terrans", "p2 faction xenos"]);
expect(buildings.phase).to.equal(Phase.SetupBuilding);
wrapper = mountFor(buildings);
expect(wrapper.text()).to.contain("starting buildings");
expect(roster(wrapper)).to.deep.equal([]);
wrapper.destroy();
});
it("leaves the Preference Split bid phase to its own panel, which already has a roster", () => {
const engine = new Engine(
["init 3 setup-status-ps", "p1 faction itars", "p2 faction taklons", "p3 faction xenos"],
{ auction: AuctionVariant.PreferenceSplit, auctionBudget: 60 }
);
expect(engine.phase).to.equal(Phase.SetupPreferenceBid);
// Hot-seat: the strip itself still shows (the device really is passed around), but the roster
// belongs to PreferenceSplitBid.vue - two on one screen would just be noise.
const wrapper = mountFor(engine);
expect(wrapper.text()).to.contain("to split their bid points");
expect(roster(wrapper)).to.deep.equal([]);
wrapper.destroy();
});
it("renders nothing once round 1 has started", () => {
const setup = mountFor(new Engine(["init 2 setup-status-round1"]));
const setup = mountFor(silentAuctionEngine());
expect(setup.find(".setup-status").exists()).to.equal(true);
setup.destroy();
// The strip is a round-0 thing only - from round 1 on, Commands.vue's own status line and the
// mobile sticky bar take over.
const engine = new Engine(["init 2 setup-status-round1"]);
// Contextual setup rules are not shown once play begins.
const engine = silentAuctionEngine();
(engine as any).round = 1;
const wrapper = mountFor(engine);

View file

@ -1,239 +1,62 @@
<template>
<!-- Round 0 status strip, shown to everyone (see Game.vue). The action panel below only renders
for whoever is on turn, so before this existed an off-turn player had nothing but a green
ring on a turn-order circle to tell them what was happening - and the "how does the auction
work?" button lived inside that same on-turn-only panel. -->
<div v-if="visible" class="setup-status" :class="mine ? 'setup-status--mine' : 'setup-status--theirs'">
<div class="setup-status__main">
<span class="setup-status__text">
<b>{{ who }}</b>
{{ assignment }}
</span>
<span v-if="showBanPhaseInfo || auctionInfoModalId" class="setup-status__links">
<b-btn
v-if="showBanPhaseInfo"
v-b-modal.ban-phase-info
variant="link"
size="sm"
class="setup-status__info setup-status__info--ban"
aria-label="Read about the ban phase"
title="Read about the ban phase"
>
Ban phase <b-badge variant="info" pill>i</b-badge>
</b-btn>
<b-btn
v-if="auctionInfoModalId"
variant="link"
size="sm"
class="setup-status__info setup-status__info--auction"
:aria-label="`Read about ${auctionTypeName}`"
:title="`Read about ${auctionTypeName}`"
@click="$bvModal.show(auctionInfoModalId)"
>
Auction type <b-badge variant="info" pill>i</b-badge>
</b-btn>
</span>
<SilentAuctionInfo v-if="showSilentAuctionInfo" />
<PreferenceSplitInfo v-if="showPreferenceSplitInfo" :budget="gameData.preferenceSplitBudget" />
<BanPhaseInfo v-if="showBanPhaseInfo" />
<b-modal
v-if="showClassicAuctionInfo"
id="classic-auction-info"
size="lg"
:title="`How ${auctionTypeName} works`"
ok-only
dialog-class="gaia-viewer-modal"
<div v-if="visible" class="setup-status">
<span class="setup-status__links">
<b-btn
v-if="showBanPhaseInfo"
v-b-modal.ban-phase-info
variant="link"
size="sm"
class="setup-status__info setup-status__info--ban"
aria-label="Read about the ban phase"
title="Read about the ban phase"
>
<p class="mb-0">{{ classicAuctionDescription }}</p>
</b-modal>
</div>
<!-- Who is done and who is not, for the round-0 phases where that adds information beyond the
turn-order avatars and `who` above. Never carries what anybody picked or bid - only whether
they have. The ban phase deliberately has no roster: it is sequential, and repeating the
same active player directly below the turn text and highlighted avatar was redundant. -->
<div v-if="roster.length > 0" class="setup-status__roster">
<span class="setup-status__roster-label">{{ rosterLabel }}</span>
<span
v-for="row in roster"
:key="row.seat"
class="setup-status__chip"
:class="{
'setup-status__chip--done': row.done,
'setup-status__chip--turn': row.onTurn,
'setup-status__chip--mine': row.mine,
}"
:aria-label="row.label"
:title="row.label"
Ban phase <b-badge variant="info" pill>i</b-badge>
</b-btn>
<b-btn
v-if="auctionInfoModalId"
variant="link"
size="sm"
class="setup-status__info setup-status__info--auction"
:aria-label="`Read about ${auctionTypeName}`"
:title="`Read about ${auctionTypeName}`"
@click="$bvModal.show(auctionInfoModalId)"
>
<span class="setup-status__chip-mark" aria-hidden="true">{{ row.done ? "✔" : row.onTurn ? "▸" : "·" }}</span>
{{ row.name }}
</span>
<span class="setup-status__roster-count">{{ doneCount }} of {{ roster.length }} in</span>
</div>
Auction type <b-badge variant="info" pill>i</b-badge>
</b-btn>
</span>
<SilentAuctionInfo v-if="showSilentAuctionInfo" />
<PreferenceSplitInfo v-if="showPreferenceSplitInfo" :budget="gameData.preferenceSplitBudget" />
<BanPhaseInfo v-if="showBanPhaseInfo" />
<b-modal
v-if="showClassicAuctionInfo"
id="classic-auction-info"
size="lg"
:title="`How ${auctionTypeName} works`"
ok-only
dialog-class="gaia-viewer-modal"
>
<p class="mb-0">{{ classicAuctionDescription }}</p>
</b-modal>
</div>
</template>
<script lang="ts">
import Engine, { AuctionVariant, Phase, Player, PlayerEnum } from "@gaia-project/engine";
import Engine, { AuctionVariant, Phase } from "@gaia-project/engine";
import { Component, Vue } from "vue-property-decorator";
import { factionName } from "../data/factions";
import { isLegacySequentialBidRound, sealedBidPhase } from "../logic/sealed-bid";
import { isBeforeRound1 } from "../logic/utils";
import BanPhaseInfo from "./BanPhaseInfo.vue";
import PreferenceSplitInfo from "./PreferenceSplitInfo.vue";
import SilentAuctionInfo from "./SilentAuctionInfo.vue";
/** What the player on turn has to do, in the second person and in the third person. */
const assignments: { [phase: string]: [string, string] } = {
[Phase.SetupFactionBan]: ["to ban a faction", "to ban a faction"],
[Phase.SetupFaction]: ["to pick a faction", "to pick a faction"],
[Phase.SetupAuction]: ["to bid on a faction", "to bid on a faction"],
[Phase.SetupSilentBid]: ["to submit your secret bids", "to submit their secret bids"],
// The Preference Split Auction is simultaneous, so "whose turn" is really "who is still missing";
// the engine's turn pointer only decides the order the submissions are recorded in.
[Phase.SetupPreferenceBid]: ["to split your bid points", "to split their bid points"],
[Phase.SetupBuilding]: ["to place your starting buildings", "to place their starting buildings"],
[Phase.SetupBooster]: ["to choose your round booster", "to choose their round booster"],
};
/**
* The round-0 phases that get a per-player done/waiting roster, and what to call it.
*
* Only phases where every player owes **exactly one** thing qualify, so "done" is a real state:
*
* - the sequential ban phase is deliberately absent because the turn-order avatar and status line
* already identify the only player who can act;
* - `SetupAuction` (the Choose-Then-Bid and Bid-While-Choosing variants) is deliberately absent.
* There a player bids repeatedly and can be outbid again afterwards, so a done/waiting mark would
* be actively wrong - what matters there is who currently leads which faction at what price,
* which the turn-order circles and the auction's own buttons already show.
* - both simultaneous bid rounds (`SetupPreferenceBid`, `SetupSilentBid`) are absent too, but for
* the opposite reason: their submissions all happen at once, and each variant's bid panel
* (`PreferenceSplitBid.vue` / `SilentAuctionBid.vue`) already carries the same roster inside the
* form itself, fed by the server's sealed-bid status in hosted play. Rendering it here as well
* would put two of them on one screen.
*/
const rosterLabels: { [phase: string]: string } = {
[Phase.SetupFaction]: "Picks",
};
/** The state each roster phase reports, in the third person, for the chip's tooltip/aria-label. */
const rosterStates: { [phase: string]: [string, string] } = {
[Phase.SetupFaction]: ["has picked a faction", "has not picked yet"],
};
@Component({ components: { BanPhaseInfo, PreferenceSplitInfo, SilentAuctionInfo } })
export default class SetupStatus extends Vue {
get gameData(): Engine {
return this.$store.state.data;
}
get onTurn(): Player | null {
const index = this.gameData?.playerToMove;
return index === undefined || index === null ? null : (this.gameData.players[index] ?? null);
}
/** True only when the viewer is locked to the seat on turn - hot-seat/self-contained play has no
* locked seat, and there "your turn" would be meaningless since every seat is the viewer's. */
get mine(): boolean {
const seat: PlayerEnum | undefined = this.$store.state.player?.index;
return seat !== undefined && seat !== null && seat >= 0 && seat === this.gameData?.playerToMove;
}
get visible(): boolean {
const data = this.gameData;
// Hosted sealed bidding (either variant) is simultaneous: naming one seat as "on turn" there
// would be actively wrong, and the bid panel right below says what is actually happening
// (n of 4 in). Hot-seat play keeps the line, because there the device really is passed around,
// and so does a legacy sequential Silent Auction, which genuinely still bids one seat at a time.
if (sealedBidPhase(data) && this.$store.state.sealedBidBackend && !isLegacySequentialBidRound(data)) {
return false;
}
return (
!!data &&
data.players?.length > 0 &&
isBeforeRound1(data) &&
data.phase in assignments &&
this.onTurn !== null &&
!!this.assignment
);
}
get assignment(): string {
return assignments[this.gameData?.phase]?.[this.mine ? 0 : 1] ?? "";
}
get who(): string {
if (this.mine) {
return "Your turn";
}
const name = this.playerName;
return `${name}${name.endsWith("s") ? "'" : "'s"} turn`;
}
private get playerName(): string {
return this.onTurn ? this.seatName(this.onTurn.player as PlayerEnum) : "?";
}
private seatName(seat: PlayerEnum): string {
const pl = this.gameData?.players?.[seat as number];
if (!pl) {
return "?";
}
// The account name first: during setup a faction is only provisional (the Silent Auction can
// still reassign it), and in the ban phase nobody has one at all.
return pl.name || (pl.faction ? factionName(pl.faction) : `Player ${(seat as number) + 1}`);
}
get rosterLabel(): string {
return rosterLabels[this.gameData?.phase] ?? "";
}
/**
* One entry per seat: has this player done their one thing for this phase yet?
*
* Each phase is read from the state that phase actually writes, rather than from a shared
* "how many moves have been made" counter:
*
* - a pick sets `player.faction`, which is order-independent - Bid-While-Choosing interleaves
* picks with bids, so a positional rule would be wrong there.
*/
get roster(): { seat: number; name: string; done: boolean; onTurn: boolean; mine: boolean; label: string }[] {
const data = this.gameData;
if (!this.rosterLabel || !data?.players?.length) {
return [];
}
const mySeat = this.$store.state.player?.index;
const [doneState, waitingState] = rosterStates[data.phase];
return data.players.map((_, seat: number) => {
const done = this.hasActed(seat);
const name = this.seatName(seat as PlayerEnum);
return {
seat,
name,
done,
onTurn: seat === data.playerToMove,
mine: typeof mySeat === "number" && mySeat === seat,
label: `${name} ${done ? doneState : waitingState}`,
};
});
}
get doneCount(): number {
return this.roster.filter((row) => row.done).length;
}
private hasActed(seat: number): boolean {
const data = this.gameData;
switch (data.phase) {
case Phase.SetupFaction:
// Truthiness, not `!== undefined`: an unpicked seat's faction is `null` (Player's own
// initializer), and the Silent Auction resets it to `undefined` when it reassigns.
return !!data.players[seat]?.faction;
default:
return false;
}
return !!data && isBeforeRound1(data) && (this.showBanPhaseInfo || !!this.auctionInfoModalId);
}
// Deliberately NOT during `SetupSilentBid`: SilentAuctionBid.vue renders this very modal there,
@ -317,33 +140,15 @@ export default class SetupStatus extends Vue {
<style lang="scss" scoped>
.setup-status {
padding: 0.25rem 0.75rem;
margin-bottom: 0.5rem;
border-radius: 0.25rem;
border: 1px solid transparent;
font-size: 0.95rem;
}
.setup-status__main {
display: flex;
justify-content: flex-end;
margin-bottom: 0.5rem;
}
.setup-status__links {
display: inline-flex;
align-items: center;
flex-wrap: nowrap;
gap: 0.25rem 0.5rem;
}
.setup-status__text {
flex: 1 1 auto;
min-width: 0;
}
.setup-status--mine {
border-color: rgba(40, 167, 69, 0.5);
background: rgba(40, 167, 69, 0.12);
}
.setup-status--theirs {
border-color: rgba(128, 128, 128, 0.35);
background: rgba(128, 128, 128, 0.1);
gap: 0.1rem;
}
.setup-status__info {
@ -355,66 +160,4 @@ export default class SetupStatus extends Vue {
margin-left: 0.25rem;
}
}
.setup-status__links {
display: inline-flex;
flex: 0 0 auto;
align-items: center;
gap: 0.1rem;
margin-left: auto;
}
.setup-status__roster {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.2rem 0.4rem;
margin-top: 0.2rem;
font-size: 0.8rem;
}
.setup-status__roster-label {
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.03em;
color: #6c757d;
}
.setup-status__roster-count {
margin-left: auto;
color: #6c757d;
white-space: nowrap;
}
.setup-status__chip {
display: inline-flex;
align-items: baseline;
gap: 0.2rem;
padding: 0 0.35rem;
border-radius: 0.75rem;
border: 1px solid currentColor;
max-width: 10rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
// Waiting is the default state; done and on-turn each override it below.
color: #8a8a8a;
}
.setup-status__chip--done {
color: #2b7a2b;
}
.setup-status__chip--turn {
color: #b36b00;
font-weight: 600;
}
.setup-status__chip--mine {
text-decoration: underline;
}
.setup-status__chip-mark {
flex: 0 0 auto;
}
</style>