fix: make concurrent charging opt-in and show pending charge turns
This commit is contained in:
parent
9f2a6d0dfe
commit
94d125ba2d
10 changed files with 64 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/engine",
|
||||
"version": "4.16.0",
|
||||
"version": "4.16.1",
|
||||
"description": "Javascript engine for project gaia",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.ts",
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export type FactionCustomization = {
|
|||
export type Layout = "standard" | "balanced" | "xshape";
|
||||
|
||||
export interface EngineOptions {
|
||||
/** Let charges be answered independently of other players' decisions. */
|
||||
/** Opt-in: let charges be answered independently while the next player takes their turn. */
|
||||
concurrentCharges?: boolean;
|
||||
/** Allow last player to rotate sector BEFORE faction selection */
|
||||
advancedRules?: boolean;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
automove,
|
||||
canLaunchAnalysisMode,
|
||||
createAnalysis,
|
||||
init,
|
||||
move,
|
||||
moveAI,
|
||||
playerSettings,
|
||||
|
|
@ -18,6 +19,16 @@ import {
|
|||
} from "./wrapper";
|
||||
|
||||
describe("wrapper", () => {
|
||||
it("only enables independent charges when selected in setup", async () => {
|
||||
const standard = await init(4, [], {}, "charge-option-default");
|
||||
const disabled = await init(4, [], { concurrentCharges: false }, "charge-option-off");
|
||||
const enabled = await init(4, [], { concurrentCharges: true }, "charge-option-on");
|
||||
|
||||
expect(standard.options.concurrentCharges).not.to.equal(true);
|
||||
expect(disabled.options.concurrentCharges).to.equal(false);
|
||||
expect(enabled.options.concurrentCharges).to.equal(true);
|
||||
});
|
||||
|
||||
describe("automove", () => {
|
||||
describe("Tinkeroids tile choices", () => {
|
||||
const roundOne = () =>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export async function init(
|
|||
options.lostFleet = true;
|
||||
}
|
||||
|
||||
const engine = new Engine([`init ${nbPlayers} ${seed}`], { concurrentCharges: true, ...options });
|
||||
const engine = new Engine([`init ${nbPlayers} ${seed}`], options);
|
||||
engine.generateAvailableCommandsIfNeeded();
|
||||
|
||||
automove(engine);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/old-ui",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"scripts": {
|
||||
"serve": "vite --port 5193",
|
||||
"build": "vite build",
|
||||
|
|
|
|||
7
scripts/game-options/concurrent-charges.json
Normal file
7
scripts/game-options/concurrent-charges.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "concurrentCharges",
|
||||
"label": "Play while charges are pending",
|
||||
"type": "checkbox",
|
||||
"default": false,
|
||||
"items": null
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/viewer",
|
||||
"version": "5.21.0",
|
||||
"version": "5.21.1",
|
||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||
"contributors": [
|
||||
"coyotte508",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<g>
|
||||
<title v-if="chargePending">Charge power</title>
|
||||
<title v-if="presenceTooltip">{{ presenceTooltip }}</title>
|
||||
<circle :r="1" :style="stroke()" :class="['player-token', 'planet-fill', planet()]" />
|
||||
<defs v-if="portrait && artwork"
|
||||
|
|
@ -51,6 +52,7 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import Engine, { AuctionVariant, Phase, Planet, Player, PlayerEnum } from "@gaia-project/engine";
|
||||
import { chargeDecisionSeats, chargeFor, hasConcurrentCharges } from "@gaia-project/engine/src/pending-charges";
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
import { factionArt } from "../data/faction-art";
|
||||
import { factionPiecePlanet } from "../graphics/utils";
|
||||
|
|
@ -99,11 +101,22 @@ export default class PlayerCircle extends Vue {
|
|||
return this.$store.state.data;
|
||||
}
|
||||
|
||||
get chargePending(): boolean {
|
||||
return !this.chart && hasConcurrentCharges(this.gameData) && !!chargeFor(this.gameData, this.player?.player);
|
||||
}
|
||||
|
||||
stroke() {
|
||||
if (this.chart) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (hasConcurrentCharges(this.gameData)) {
|
||||
const active = this.gameData.newTurn
|
||||
? chargeDecisionSeats(this.gameData).includes(this.player?.player)
|
||||
: this.gameData.playerToMove === this.player?.player;
|
||||
return active ? "stroke-width: 0.22px !important; stroke: #2C4" : "stroke-width: 0.06px !important";
|
||||
}
|
||||
|
||||
if (this.gameData.players[this.gameData.currentPlayer] === this.player) {
|
||||
if (this.gameData.players[this.gameData.playerToMove] === this.player) {
|
||||
return "stroke-width: 0.22px !important; stroke: #2C4";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Engine, { Faction } from "@gaia-project/engine";
|
||||
import Engine, { Faction, Phase } from "@gaia-project/engine";
|
||||
import { render } from "@testing-library/vue";
|
||||
import { expect } from "chai";
|
||||
import { makeStore } from "../store";
|
||||
|
|
@ -70,6 +70,25 @@ describe("TurnOrder presence dots", () => {
|
|||
});
|
||||
|
||||
describe("TurnOrder passedPlayers (docs/lost-fleet/ANALYSIS_MODE_PLAN.md)", () => {
|
||||
it("marks a passed player with a pending charge as active alongside the turn player", () => {
|
||||
const engine = new Engine(["init 2 turn-order-pending-charge"], { concurrentCharges: true });
|
||||
engine.phase = Phase.RoundMove;
|
||||
engine.round = 1;
|
||||
engine.currentPlayer = 0;
|
||||
engine.turnOrder = [0];
|
||||
engine.passedPlayers = [1];
|
||||
engine.pendingCharges = [{ id: 1, player: 1, source: { player: 0, coordinates: "1A0" }, amount: 1 }];
|
||||
const store = makeStore();
|
||||
store.commit("receiveData", engine);
|
||||
const { container } = render(TurnOrder, { store });
|
||||
const circles = container.querySelectorAll<SVGCircleElement>(".player-token");
|
||||
expect(circles.length).to.equal(2);
|
||||
expect(circles[0].style.stroke).to.equal("rgb(34, 204, 68)");
|
||||
expect(circles[1].style.stroke).to.equal("rgb(34, 204, 68)");
|
||||
expect(circles[1].parentElement.style.opacity).to.equal("1");
|
||||
expect(circles[1].parentElement.querySelector("title").textContent).to.equal("Charge power");
|
||||
});
|
||||
|
||||
it("never shows a passed player before round 1, even if passedPlayers is non-empty", () => {
|
||||
// Real games never populate `passedPlayers` before round 1 (only beginRoundStartPhase does,
|
||||
// once per round transition) - this fixture reproduces analysis mode's own setup-phase pre-seed
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
:portrait="true"
|
||||
:index="index"
|
||||
:transform="`translate(${(index + 1 + turnOrder.length) * 2.5})`"
|
||||
style="opacity: 0.5"
|
||||
:style="{ opacity: activePlayers.includes(player.player) ? 1 : 0.5 }"
|
||||
:presence-status="presenceFor(player)"
|
||||
/>
|
||||
</svg>
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import Engine, { Phase, Player, Round } from "@gaia-project/engine";
|
||||
import { chargeDecisionSeats, hasConcurrentCharges } from "@gaia-project/engine/src/pending-charges";
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
import type { PresenceStatus } from "../logic/presence";
|
||||
import { presenceStatus } from "../logic/presence";
|
||||
|
|
@ -45,6 +46,12 @@ export default class TurnOrder extends Vue {
|
|||
return this.$store.state.data;
|
||||
}
|
||||
|
||||
get activePlayers(): number[] {
|
||||
return hasConcurrentCharges(this.gameData) && this.gameData.newTurn
|
||||
? chargeDecisionSeats(this.gameData)
|
||||
: [this.gameData.playerToMove];
|
||||
}
|
||||
|
||||
// Hosted mode only - self-contained/hot-seat play has no "?game=" URL and no accounts to have
|
||||
// presence for, so presenceFor() below returns null (no dot) there, unchanged from before.
|
||||
get gameId(): string | null {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue