feat(viewer): program planned moves up to a chosen step
This commit is contained in:
parent
a8ace70a2e
commit
296a8a0a38
29 changed files with 682 additions and 62 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/old-ui",
|
||||
"version": "1.2.22",
|
||||
"version": "1.2.23",
|
||||
"scripts": {
|
||||
"serve": "vite --port 5193",
|
||||
"build": "vite build",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/viewer",
|
||||
"version": "5.22.22",
|
||||
"version": "5.22.23",
|
||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||
"contributors": [
|
||||
"coyotte508",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { Phase } from "@gaia-project/engine";
|
||||
import { mount, Wrapper } from "@vue/test-utils";
|
||||
import BootstrapVue from "bootstrap-vue";
|
||||
import { expect } from "chai";
|
||||
|
|
@ -25,8 +26,8 @@ describe("AnalysisCommitConfirm", () => {
|
|||
for (const wrapper of mounted.splice(0)) wrapper.destroy();
|
||||
});
|
||||
|
||||
const open = async (p: AnalysisCommitPlan): Promise<Wrapper<Vue>> => {
|
||||
const wrapper = mount(AnalysisCommitConfirm, { propsData: { plan: p }, attachTo: document.body });
|
||||
const open = async (p: AnalysisCommitPlan, initialLimit: number | null = null): Promise<Wrapper<Vue>> => {
|
||||
const wrapper = mount(AnalysisCommitConfirm, { propsData: { plan: p, initialLimit }, attachTo: document.body });
|
||||
mounted.push(wrapper);
|
||||
wrapper.vm.$bvModal.show("analysis-commit-confirm");
|
||||
await Vue.nextTick();
|
||||
|
|
@ -43,6 +44,81 @@ describe("AnalysisCommitConfirm", () => {
|
|||
(b.textContent ?? "").includes(label)
|
||||
) as HTMLButtonElement | undefined;
|
||||
|
||||
it("lets the player queue a prefix and clearly keeps the rest for later", async () => {
|
||||
const original = plan({ queued: ["terrans up nav.", "terrans up gaia.", "terrans up eco."] });
|
||||
const wrapper = await open(original, 2);
|
||||
|
||||
const queued = document.body.querySelectorAll(".analysis-commit__row--queued");
|
||||
expect(Array.from(queued).map((row) => row.querySelector(".analysis-commit__move").textContent)).to.deep.equal([
|
||||
"terrans up nav.",
|
||||
"terrans up gaia.",
|
||||
]);
|
||||
expect(document.body.querySelector(".analysis-commit__deferred").textContent).to.contain("terrans up eco.");
|
||||
expect(dialogText()).to.contain("Kept for later");
|
||||
expect(dialogText()).not.to.contain("These moves stay saved");
|
||||
expect(footerButton("Queue 2 moves")).not.to.equal(undefined);
|
||||
expect(wrapper.emitted("confirm")).to.equal(undefined);
|
||||
footerButton("Queue 2 moves").click();
|
||||
await Vue.nextTick();
|
||||
expect(wrapper.emitted("confirm")).to.deep.equal([[2]]);
|
||||
expect(original.queued).to.have.length(3);
|
||||
});
|
||||
|
||||
it("includes the move that plays now in the chosen limit", async () => {
|
||||
const wrapper = await open(plan({ live: "terrans up nav.", queued: ["terrans up gaia.", "terrans up eco."] }), 1);
|
||||
|
||||
expect(document.body.querySelectorAll(".analysis-commit__row--live")).to.have.length(1);
|
||||
expect(document.body.querySelectorAll(".analysis-commit__row--queued")).to.have.length(0);
|
||||
expect(document.body.querySelectorAll(".analysis-commit__deferred li")).to.have.length(2);
|
||||
footerButton("Play 1 move").click();
|
||||
await Vue.nextTick();
|
||||
expect(wrapper.emitted("confirm")).to.deep.equal([[1]]);
|
||||
});
|
||||
|
||||
it("keeps a deliberately deferred move separate from an unavailable tail", async () => {
|
||||
await open(plan({ queued: ["a", "b"], dropped: ["c"], cut: "overdrawn" }), 1);
|
||||
|
||||
expect(document.body.querySelector(".analysis-commit__deferred .analysis-commit__move").textContent).to.equal("b");
|
||||
expect(document.body.querySelector(".modal .analysis-commit__badge")).to.equal(null);
|
||||
expect(dialogText()).not.to.contain("not programmed");
|
||||
expect(dialogText()).not.to.contain("not committed");
|
||||
expect(dialogText()).to.contain("spend more than you actually have");
|
||||
expect(document.body.querySelector(".analysis-commit__dropped-head").textContent).to.contain("1 more");
|
||||
});
|
||||
|
||||
it("resets the selection each time the confirmation opens", async () => {
|
||||
const wrapper = await open(plan({ queued: ["a", "b", "c"] }), 1);
|
||||
await wrapper.setProps({ initialLimit: null });
|
||||
wrapper.findComponent({ name: "BModal" }).vm.$emit("show");
|
||||
await Vue.nextTick();
|
||||
await Vue.nextTick();
|
||||
expect(footerButton("Queue 3 moves")).not.to.equal(undefined);
|
||||
expect(document.body.querySelector(".analysis-commit__deferred")).to.equal(null);
|
||||
expect(wrapper.emitted("confirm")).to.equal(undefined);
|
||||
});
|
||||
|
||||
it("invalidates an open confirmation if real progress changes the proposed moves", async () => {
|
||||
const wrapper = await open(plan({ queued: ["a", "b", "c"] }), 2);
|
||||
await wrapper.setProps({ plan: plan({ queued: ["b", "c"] }) });
|
||||
// A queued modal OK event must not turn the old stopping point after b into one after c.
|
||||
wrapper.findComponent({ name: "BModal" }).vm.$emit("ok");
|
||||
await Vue.nextTick();
|
||||
expect(wrapper.emitted("confirm")).to.equal(undefined);
|
||||
});
|
||||
|
||||
it("cancels a selected prefix without submitting", async () => {
|
||||
const wrapper = await open(plan({ queued: ["a", "b", "c"] }), 2);
|
||||
footerButton("Keep planning").click();
|
||||
await Vue.nextTick();
|
||||
expect(wrapper.emitted("confirm")).to.equal(undefined);
|
||||
});
|
||||
|
||||
it("never offers a numeric selector", async () => {
|
||||
await open(plan({ live: "a", queued: ["b", "c"] }));
|
||||
expect(document.body.querySelector("select")).to.equal(null);
|
||||
expect(footerButton("Play 3 moves")).not.to.equal(undefined);
|
||||
});
|
||||
|
||||
it("lists every move that is about to be played, saying which one goes live", async () => {
|
||||
const wrapper = await open(
|
||||
plan({ live: "terrans up nav.", queued: ["terrans build m 1A2.", "terrans pass booster3"] })
|
||||
|
|
@ -53,15 +129,20 @@ describe("AnalysisCommitConfirm", () => {
|
|||
expect(text).to.contain("terrans build m 1A2.");
|
||||
expect(text).to.contain("terrans pass booster3");
|
||||
expect(text).to.contain("plays now");
|
||||
expect(text).to.contain("premove 1");
|
||||
expect(text).to.contain("premove 2");
|
||||
expect(document.body.querySelectorAll(".analysis-commit__row--queued")).to.have.length(2);
|
||||
expect(document.body.querySelector(".analysis-commit__row--queued .analysis-commit__badge")).to.equal(null);
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it("says nothing plays immediately when the commit happens off turn", async () => {
|
||||
const wrapper = await open(plan({ live: null, queued: ["terrans up nav."] }));
|
||||
const wrapper = await open(
|
||||
plan({ live: null, queued: ["terrans up nav."], timings: [{ round: 1, phase: Phase.RoundMove }] })
|
||||
);
|
||||
|
||||
expect(dialogText()).to.contain("Queue these premoves?");
|
||||
expect(dialogText()).not.to.contain("Round 1");
|
||||
expect(document.body.querySelector(".analysis-commit__row--queued .small.text-muted")).to.equal(null);
|
||||
expect(document.body.querySelector(".analysis-commit__row--queued .analysis-commit__badge")).to.equal(null);
|
||||
expect(dialogText()).to.not.contain("plays now");
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
|
@ -85,7 +166,7 @@ describe("AnalysisCommitConfirm", () => {
|
|||
it("confirms a longer queue without a move-limit warning", async () => {
|
||||
const wrapper = await open(plan({ live: "a", queued: ["b", "c", "d", "e"] }));
|
||||
|
||||
expect(dialogText()).to.contain("premove 4");
|
||||
expect(document.body.querySelectorAll(".analysis-commit__row--queued")).to.have.length(4);
|
||||
expect(dialogText()).to.not.contain("stay behind");
|
||||
expect(footerButton("Play 5 moves")).to.not.equal(undefined);
|
||||
wrapper.destroy();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
cancel-title="Keep planning"
|
||||
:ok-disabled="total === 0"
|
||||
dialog-class="gaia-viewer-modal"
|
||||
@ok="$emit('confirm')"
|
||||
@show="resetSelection"
|
||||
@ok="confirm"
|
||||
>
|
||||
<ol class="analysis-commit__list">
|
||||
<li v-if="view.live" class="analysis-commit__row analysis-commit__row--live">
|
||||
|
|
@ -18,19 +19,22 @@
|
|||
<MoveCost :cost="view.costs && view.costs[0]" />
|
||||
</li>
|
||||
<li v-for="(move, i) in view.queued" :key="`q${i}`" class="analysis-commit__row analysis-commit__row--queued">
|
||||
<span class="analysis-commit__badge analysis-commit__badge--queued">premove {{ i + 1 }}</span>
|
||||
<span v-if="view.timings" class="small text-muted">{{
|
||||
view.timings[i + (view.live ? 1 : 0)].round === 0
|
||||
? "Setup"
|
||||
: `Round ${view.timings[i + (view.live ? 1 : 0)].round}`
|
||||
}}</span>
|
||||
<span class="analysis-commit__move">{{ move }}</span>
|
||||
<MoveCost :cost="view.costs && view.costs[i + (view.live ? 1 : 0)]" />
|
||||
<span v-if="isCheapAnalysisBuild(move)" class="small">3c only</span>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<!-- Show the unsent tail; it stays in the local plan. -->
|
||||
<section v-if="view.deferred && view.deferred.length" class="analysis-commit__deferred">
|
||||
<h6>Kept for later</h6>
|
||||
<ol class="analysis-commit__list analysis-commit__list--dropped">
|
||||
<li v-for="(move, i) in view.deferred" :key="`later${i}`" class="analysis-commit__row">
|
||||
<span class="analysis-commit__move">{{ move }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<!-- Show the unavailable tail separately from moves deliberately kept for later. -->
|
||||
<template v-if="view.dropped.length > 0">
|
||||
<p class="analysis-commit__dropped-head">
|
||||
{{ view.dropped.length }} more {{ view.dropped.length === 1 ? "move stays" : "moves stay" }} behind —
|
||||
|
|
@ -38,7 +42,6 @@
|
|||
</p>
|
||||
<ol class="analysis-commit__list analysis-commit__list--dropped">
|
||||
<li v-for="(move, i) in view.dropped" :key="`d${i}`" class="analysis-commit__row">
|
||||
<span class="analysis-commit__badge analysis-commit__badge--dropped">not committed</span>
|
||||
<span class="analysis-commit__move">{{ move }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
|
|
@ -49,7 +52,7 @@
|
|||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import type { AnalysisCommitCut, AnalysisCommitPlan } from "../logic/analysis";
|
||||
import { isCheapAnalysisBuild } from "../logic/analysis";
|
||||
import { isCheapAnalysisBuild, limitAnalysisCommit } from "../logic/analysis";
|
||||
|
||||
import MoveCost from "./MoveCost.vue";
|
||||
|
||||
|
|
@ -70,17 +73,49 @@ const CUT_TEXT: Record<AnalysisCommitCut, string> = {
|
|||
export default Vue.extend({
|
||||
name: "AnalysisCommitConfirm",
|
||||
components: { MoveCost },
|
||||
methods: { isCheapAnalysisBuild },
|
||||
data() {
|
||||
return { selectedCount: null as number | null, proposalChanged: false };
|
||||
},
|
||||
methods: {
|
||||
isCheapAnalysisBuild,
|
||||
resetSelection() {
|
||||
this.selectedCount = this.initialLimit ?? this.availableTotal;
|
||||
this.proposalChanged = false;
|
||||
},
|
||||
confirm() {
|
||||
if (!this.proposalChanged && this.total > 0) this.$emit("confirm", this.total);
|
||||
},
|
||||
},
|
||||
props: {
|
||||
/** Nullable rather than defaulted: Vue substitutes a prop default only for `undefined`, and
|
||||
* Commands.vue holds `null` whenever Game.vue has no plan to give (outside sandbox mode, or a
|
||||
* line with nothing committable in it) - which would otherwise render this as `null.live`. */
|
||||
plan: { type: Object as () => AnalysisCommitPlan | null, default: null },
|
||||
initialLimit: { type: Number, default: null },
|
||||
},
|
||||
watch: {
|
||||
proposalKey() {
|
||||
// Real moves can retire the beginning of the draft while this dialog is open. Do not
|
||||
// silently shift a chosen stopping point to later moves; ask the player to reopen it.
|
||||
this.proposalChanged = true;
|
||||
this.$bvModal.hide("analysis-commit-confirm");
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
view(): AnalysisCommitPlan {
|
||||
availablePlan(): AnalysisCommitPlan {
|
||||
return (this.plan as AnalysisCommitPlan | null) ?? EMPTY_PLAN;
|
||||
},
|
||||
availableTotal(): number {
|
||||
return (this.availablePlan.live ? 1 : 0) + this.availablePlan.queued.length;
|
||||
},
|
||||
proposalKey(): string {
|
||||
const plan = this.availablePlan as AnalysisCommitPlan;
|
||||
return JSON.stringify([plan.live, plan.queued, plan.timings]);
|
||||
},
|
||||
|
||||
view(): AnalysisCommitPlan {
|
||||
return limitAnalysisCommit(this.availablePlan, this.selectedCount ?? this.availableTotal);
|
||||
},
|
||||
total(): number {
|
||||
const view = this.view as AnalysisCommitPlan;
|
||||
return (view.live ? 1 : 0) + view.queued.length;
|
||||
|
|
@ -100,8 +135,9 @@ export default Vue.extend({
|
|||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.analysis-commit__lede {
|
||||
margin-bottom: 0.75rem;
|
||||
.analysis-commit__deferred {
|
||||
border-top: 1px solid var(--ui-border-strong);
|
||||
padding-top: 0.75rem;
|
||||
}
|
||||
|
||||
.analysis-commit__list {
|
||||
|
|
@ -138,14 +174,6 @@ export default Vue.extend({
|
|||
color: var(--ui-success);
|
||||
}
|
||||
|
||||
.analysis-commit__badge--queued {
|
||||
color: var(--ui-text-muted);
|
||||
}
|
||||
|
||||
.analysis-commit__badge--dropped {
|
||||
color: var(--ui-text-subtle);
|
||||
}
|
||||
|
||||
// The move string itself, in the same raw form the premove bar lists a queued row in - so the entry
|
||||
// confirmed here and the row that shows up in the queue afterwards read identically.
|
||||
.analysis-commit__move {
|
||||
|
|
@ -162,9 +190,4 @@ export default Vue.extend({
|
|||
margin-bottom: 0.4rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.analysis-commit__foot {
|
||||
font-size: 0.85rem;
|
||||
color: var(--ui-text-muted);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
46
viewer/src/components/AnalysisMoves.spec.ts
Normal file
46
viewer/src/components/AnalysisMoves.spec.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import { mount } from "@vue/test-utils";
|
||||
import { expect } from "chai";
|
||||
import AnalysisMoves from "./AnalysisMoves.vue";
|
||||
|
||||
describe("AnalysisMoves prefix programming", () => {
|
||||
const propsData = {
|
||||
entries: [
|
||||
{ kind: "move", move: "a" },
|
||||
{ kind: "adjust", charge: 2 },
|
||||
{ kind: "move", move: "b" },
|
||||
{ kind: "move", move: "blocked" },
|
||||
{ kind: "move", move: "suffix" },
|
||||
],
|
||||
played: [{ move: "already played" }],
|
||||
appliedCount: 3,
|
||||
committableMoves: 2,
|
||||
};
|
||||
|
||||
it("counts only remaining moves, with no programming control on played or adjustment rows", async () => {
|
||||
const wrapper = mount(AnalysisMoves, { propsData });
|
||||
const buttons = wrapper.findAll(".analysis-moves__program");
|
||||
expect(buttons.length).to.equal(4);
|
||||
expect(buttons.at(1).attributes("aria-label")).to.equal("Program up to move 3");
|
||||
expect(wrapper.find(".analysis-moves__past button").exists()).to.equal(false);
|
||||
await buttons.at(1).trigger("click");
|
||||
expect(wrapper.emitted("commit")).to.deep.equal([[2]]);
|
||||
await buttons.at(2).trigger("click");
|
||||
await buttons.at(3).trigger("click");
|
||||
expect(wrapper.emitted("commit")).to.have.length(1);
|
||||
// Existing edit and delete events still carry entry indices, not move counts.
|
||||
await wrapper.findAll(".analysis-moves__move").at(1).trigger("click");
|
||||
await wrapper.findAll(".analysis-moves__remove").at(2).trigger("click");
|
||||
expect(wrapper.emitted("edit")).to.deep.equal([[2]]);
|
||||
expect(wrapper.emitted("remove")).to.deep.equal([[2]]);
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it("disables simulated but uncommittable endpoints and all controls during an unfinished move", async () => {
|
||||
const wrapper = mount(AnalysisMoves, { propsData: { ...propsData, appliedCount: 5, committableMoves: 1 } });
|
||||
expect(wrapper.findAll(".analysis-moves__program").at(1).attributes("disabled")).to.equal("disabled");
|
||||
await wrapper.setProps({ disabled: true });
|
||||
await wrapper.find(".analysis-moves__program").trigger("click");
|
||||
expect(wrapper.emitted("commit")).to.equal(undefined);
|
||||
wrapper.destroy();
|
||||
});
|
||||
});
|
||||
|
|
@ -50,6 +50,20 @@
|
|||
<span v-else class="analysis-moves__adjustment">{{
|
||||
entry.kind === "adjust" ? `Assume ${entry.charge} power charged` : `Faction setup: ${entry.lineup.join(", ")}`
|
||||
}}</span>
|
||||
<button
|
||||
v-if="entry.kind === 'move'"
|
||||
type="button"
|
||||
class="analysis-moves__program"
|
||||
:disabled="disabled || index >= appliedCount || moveNumber(index) - played.length > committableMoves"
|
||||
:title="`Program up to move ${moveNumber(index)}`"
|
||||
:aria-label="`Program up to move ${moveNumber(index)}`"
|
||||
@click="$emit('commit', moveNumber(index) - played.length)"
|
||||
@keydown.stop
|
||||
>
|
||||
<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
|
||||
<path d="M2 2.5v11L10 8ZM12 2.5h2v11h-2Z" />
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
v-if="entry.kind !== 'faction'"
|
||||
type="button"
|
||||
|
|
@ -110,6 +124,7 @@ export default Vue.extend({
|
|||
blockedReason: { type: String, default: "" },
|
||||
costs: { type: Array as PropType<MoveCostData[]>, default: () => [] },
|
||||
appliedCount: { type: Number, default: 0 },
|
||||
committableMoves: { type: Number, default: 0 },
|
||||
disabled: Boolean,
|
||||
canAppend: { type: Boolean, default: true },
|
||||
},
|
||||
|
|
@ -183,6 +198,7 @@ export default Vue.extend({
|
|||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
.analysis-moves__program,
|
||||
.analysis-moves__remove {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
|
@ -207,6 +223,15 @@ export default Vue.extend({
|
|||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
.analysis-moves__program {
|
||||
flex-basis: 2.5rem;
|
||||
min-height: 2.5rem;
|
||||
color: var(--ui-success);
|
||||
&:hover:enabled,
|
||||
&:focus-visible {
|
||||
color: var(--ui-success);
|
||||
}
|
||||
}
|
||||
.analysis-moves__move {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -869,6 +869,48 @@ describe("Commands", () => {
|
|||
expect(container.querySelectorAll("#analysis-commit-confirm").length).to.be.at.most(1);
|
||||
});
|
||||
|
||||
it("opens a row prefix without submitting, and the header restores the full proposal", async () => {
|
||||
const store = makeStore();
|
||||
store.commit("receiveData", createLostFleetRoundMoveEngine());
|
||||
const wrapper = mount(Commands, {
|
||||
store,
|
||||
propsData: {
|
||||
currentMove: "",
|
||||
analysisMode: true,
|
||||
analysisMoveCount: 3,
|
||||
analysisAppliedCount: 4,
|
||||
analysisCommittableMoves: 3,
|
||||
analysisPlayed: [{ move: "played" }],
|
||||
analysisEntries: [
|
||||
{ kind: "move", move: "a" },
|
||||
{ kind: "adjust", charge: 2 },
|
||||
{ kind: "move", move: "b" },
|
||||
{ kind: "move", move: "c" },
|
||||
],
|
||||
analysisCommitPlan: { live: null, queued: ["a", "b", "c"], dropped: [], cut: null, limit: "line" },
|
||||
},
|
||||
});
|
||||
await wrapper.findAll(".analysis-moves__program").at(1).trigger("click");
|
||||
await Vue.nextTick();
|
||||
await Vue.nextTick();
|
||||
const confirmation = wrapper.findComponent({ name: "AnalysisCommitConfirm" });
|
||||
expect(confirmation.props("initialLimit")).to.equal(2);
|
||||
expect((confirmation.vm as any).view.queued).to.deep.equal(["a", "b"]);
|
||||
expect((confirmation.vm as any).view.deferred).to.deep.equal(["c"]);
|
||||
expect(wrapper.emitted("analysis-commit")).to.equal(undefined);
|
||||
confirmation.findComponent({ name: "BModal" }).vm.$emit("cancel");
|
||||
expect(wrapper.emitted("analysis-commit")).to.equal(undefined);
|
||||
await wrapper.find(".analysis-controls__btn").trigger("click");
|
||||
expect(confirmation.props("initialLimit")).to.equal(null);
|
||||
// BootstrapVue's show event snapshots the limit on each fresh opening.
|
||||
confirmation.findComponent({ name: "BModal" }).vm.$emit("show");
|
||||
await Vue.nextTick();
|
||||
expect((confirmation.vm as any).view.queued).to.deep.equal(["a", "b", "c"]);
|
||||
confirmation.findComponent({ name: "BModal" }).vm.$emit("ok");
|
||||
expect(wrapper.emitted("analysis-commit")).to.deep.equal([[3]]);
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it("asks before committing instead of firing the moves off the button press (§6)", async () => {
|
||||
const engine = createLostFleetRoundMoveEngine();
|
||||
const store = makeStore();
|
||||
|
|
@ -900,6 +942,13 @@ describe("Commands", () => {
|
|||
expect((document.body.querySelector(".modal")?.textContent ?? "").replace(/\s+/g, " ")).to.contain(
|
||||
"terrans up nav."
|
||||
);
|
||||
expect(document.body.querySelector("#analysis-commit-count")).to.equal(null);
|
||||
const confirm = Array.from(document.body.querySelectorAll(".modal-footer button")).find(
|
||||
(button) => button.textContent.trim() === "Play 2 moves"
|
||||
);
|
||||
expect(confirm).not.to.equal(undefined);
|
||||
await fireEvent.click(confirm);
|
||||
expect(emitted()["analysis-commit"]).to.deep.equal([[2]]);
|
||||
});
|
||||
|
||||
it("stripes both headers and reads SANDBOX during sandbox mode, without exiting when tapped (§5.1/§12)", async () => {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@
|
|||
:blocked-reason="analysisBlockedReason"
|
||||
:costs="analysisMoveCosts"
|
||||
:applied-count="analysisAppliedCount"
|
||||
:committable-moves="analysisCommittableMoves"
|
||||
@commit="requestAnalysisCommit($event)"
|
||||
:can-append="!engine.ended"
|
||||
:disabled="analysisEditingIndex < 0 && !!currentMove"
|
||||
@edit="$emit('analysis-edit-move', $event)"
|
||||
|
|
@ -83,7 +85,12 @@
|
|||
<AnalysisModeInfo v-if="analysisMode" />
|
||||
<!-- Commit's confirmation step, rendered here for the same once-per-page reason as the info modal
|
||||
above. The Commit button only opens it; nothing leaves the sandbox until this is confirmed. -->
|
||||
<AnalysisCommitConfirm v-if="analysisMode" :plan="analysisCommitPlan" @confirm="$emit('analysis-commit')" />
|
||||
<AnalysisCommitConfirm
|
||||
v-if="analysisMode"
|
||||
:plan="analysisCommitPlan"
|
||||
:initial-limit="analysisCommitLimit"
|
||||
@confirm="$emit('analysis-commit', $event)"
|
||||
/>
|
||||
<div
|
||||
id="move-buttons"
|
||||
data-tutorial="game-controls"
|
||||
|
|
@ -806,10 +813,13 @@ export default class Commands extends Vue implements CommandController {
|
|||
return !!this.silentBidCommand && !!this.$store.state.sealedBidBackend && isLegacySequentialBidRound(this.engine);
|
||||
}
|
||||
|
||||
/** Commit asks first (ANALYSIS_MODE_PLAN.md §6) - it is the only sandbox control whose effect
|
||||
* reaches the real game, where the sandbox's own Undo does not follow, and it clears the line on
|
||||
* the way out. The modal is what emits `analysis-commit`; this only opens it. */
|
||||
requestAnalysisCommit() {
|
||||
analysisCommitLimit: number | null = null;
|
||||
|
||||
/** A row chooses a stopping point; the header proposes every eligible move.
|
||||
* Only confirmation emits `analysis-commit`; the full draft stays saved for later review. */
|
||||
async requestAnalysisCommit(count?: number) {
|
||||
this.analysisCommitLimit = typeof count === "number" ? count : null;
|
||||
await this.$nextTick();
|
||||
this.$bvModal.show("analysis-commit-confirm");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { fireEvent } from "@testing-library/vue";
|
|||
import BootstrapVue from "bootstrap-vue";
|
||||
import { expect } from "chai";
|
||||
import Vue from "vue";
|
||||
import { MAX_ANALYSIS_LINES } from "../logic/analysis";
|
||||
import { loadAnalysisLines, MAX_ANALYSIS_LINES } from "../logic/analysis";
|
||||
import { makeStore } from "../store";
|
||||
import { passedChargeGame } from "../testing/passed-charge";
|
||||
import Game from "./Game.vue";
|
||||
|
|
@ -2601,6 +2601,207 @@ describe("Game", () => {
|
|||
vm.$destroy();
|
||||
});
|
||||
|
||||
describe("programming only a prefix", () => {
|
||||
for (const [seat, count] of [
|
||||
[0, 1],
|
||||
[0, 2],
|
||||
[1, 2],
|
||||
[1, 100],
|
||||
[1, undefined],
|
||||
]) {
|
||||
it(`submits ${count ?? "all"} moves for seat ${seat}, counting any live move and matching timings`, () => {
|
||||
const vm = mountAsSeat(seat, Engine.fromData(stripSecret(researchGame(), seat)));
|
||||
vm.$store.commit("hosted", true);
|
||||
vm.enterAnalysisMode();
|
||||
const faction = seat === 0 ? "terrans" : "nevlas";
|
||||
const moves = ["nav", "gaia", "terra"].map((field) => `${faction} up ${field}.`);
|
||||
for (const move of moves) vm.applyAnalysisMove(move);
|
||||
const plan = vm.analysisCommitPlan;
|
||||
const draft = loadAnalysisLines(seat, vm.analysisStorageScope);
|
||||
expect(plan.live).to.equal(seat === 0 ? moves[0] : null);
|
||||
expect(plan.timings).to.have.length(3);
|
||||
const dispatched = spyDispatch(vm);
|
||||
|
||||
vm.commitAnalysisLine(count);
|
||||
|
||||
expect(dispatched).to.have.length(1);
|
||||
expect(dispatched[0].type).to.equal("submitPlan");
|
||||
const payload = dispatched[0].payload;
|
||||
const selected = Math.min(count ?? moves.length, moves.length);
|
||||
expect(payload.moves).to.deep.equal(moves.slice(0, selected));
|
||||
expect(payload.timings).to.deep.equal(plan.timings.slice(0, selected));
|
||||
expect(payload.timings).to.have.length(payload.moves.length);
|
||||
expect(vm.analysisCommitPlan).to.deep.equal(plan);
|
||||
expect(loadAnalysisLines(seat, vm.analysisStorageScope)).to.deep.equal(draft);
|
||||
expect(vm.analysisMode).to.equal(true);
|
||||
vm.$el.remove();
|
||||
vm.$destroy();
|
||||
});
|
||||
}
|
||||
|
||||
it("does not dispatch, leave planning or change the saved draft for invalid counts", () => {
|
||||
const vm = mountAsSeat(0, Engine.fromData(stripSecret(researchGame(), 0)));
|
||||
vm.$store.commit("hosted", true);
|
||||
vm.enterAnalysisMode();
|
||||
vm.applyAnalysisMove("terrans up nav.");
|
||||
vm.applyAnalysisMove("terrans up gaia.");
|
||||
const draft = loadAnalysisLines(0, vm.analysisStorageScope);
|
||||
const dispatched = spyDispatch(vm);
|
||||
for (const count of [NaN, Infinity, -Infinity, -1, 1.5, 0, null, "1", true, { type: "click" }]) {
|
||||
vm.commitAnalysisLine(count);
|
||||
expect(dispatched, `count ${count}`).to.deep.equal([]);
|
||||
expect(vm.analysisMode).to.equal(true);
|
||||
expect(vm.analysisSubmission).to.equal(null);
|
||||
expect(loadAnalysisLines(0, vm.analysisStorageScope)).to.deep.equal(draft);
|
||||
}
|
||||
vm.$el.remove();
|
||||
vm.$destroy();
|
||||
});
|
||||
|
||||
it("still submits at most one live move offline and keeps the entire saved draft", () => {
|
||||
const vm = mountAsSeat(0, researchGame());
|
||||
vm.enterAnalysisMode();
|
||||
vm.applyAnalysisMove("terrans up nav.");
|
||||
vm.applyAnalysisMove("terrans up gaia.");
|
||||
vm.applyAnalysisMove("terrans up terra.");
|
||||
const draft = loadAnalysisLines(0, vm.analysisStorageScope);
|
||||
const dispatched = spyDispatch(vm);
|
||||
vm.commitAnalysisLine(100);
|
||||
expect(dispatched).to.deep.equal([{ type: "move", payload: "terrans up nav." }]);
|
||||
expect(vm.analysisMode).to.equal(false);
|
||||
expect(loadAnalysisLines(0, vm.analysisStorageScope)).to.deep.equal(draft);
|
||||
vm.$el.remove();
|
||||
vm.$destroy();
|
||||
});
|
||||
|
||||
it("replaces an existing server queue with the selected prefix, never appending either tail", () => {
|
||||
const real = bgsMove(
|
||||
JSON.parse(JSON.stringify(researchGame())),
|
||||
{
|
||||
type: "premoves",
|
||||
requestId: "old-queue",
|
||||
moves: ["nevlas up nav.", "nevlas up gaia."],
|
||||
revision: 0,
|
||||
turn: 0,
|
||||
round: 1,
|
||||
},
|
||||
1
|
||||
);
|
||||
const vm = mountAsSeat(1, Engine.fromData(stripSecret(real, 1)));
|
||||
vm.$store.commit("hosted", true);
|
||||
vm.enterAnalysisMode();
|
||||
vm.applyAnalysisMove("nevlas up terra.");
|
||||
vm.applyAnalysisMove("nevlas up nav.");
|
||||
const draft = loadAnalysisLines(1, vm.analysisStorageScope);
|
||||
const dispatched = spyDispatch(vm);
|
||||
// Invalid selections must not send an empty replacement and cancel an existing queue.
|
||||
for (const count of [0, NaN, Infinity, -1, 1.5, null, "1", { type: "click" }]) vm.commitAnalysisLine(count);
|
||||
expect(dispatched).to.deep.equal([]);
|
||||
expect(vm.myPremovePlan.moves).to.deep.equal(["nevlas up nav.", "nevlas up gaia."]);
|
||||
expect(loadAnalysisLines(1, vm.analysisStorageScope)).to.deep.equal(draft);
|
||||
vm.commitAnalysisLine(1);
|
||||
expect(dispatched[0].payload.moves).to.deep.equal(["nevlas up terra."]);
|
||||
expect(dispatched[0].payload.timings).to.have.length(1);
|
||||
expect(dispatched[0].payload.revision).to.equal(real.automation.plans[1].revision);
|
||||
const saved = bgsMove(real, dispatched[0].payload, 1);
|
||||
expect(saved.automation.plans[1].moves).to.deep.equal(["nevlas up terra."]);
|
||||
expect(saved.automation.plans[1].runs[1].status).to.equal("replaced");
|
||||
expect(loadAnalysisLines(1, vm.analysisStorageScope)).to.deep.equal(draft);
|
||||
vm.$el.remove();
|
||||
vm.$destroy();
|
||||
});
|
||||
|
||||
it("keeps the full draft across acknowledgement/reload, then stops after the prefix until another commit", async () => {
|
||||
const real = researchGame();
|
||||
const first = mountAsSeat(1, Engine.fromData(stripSecret(real, 1)));
|
||||
first.$store.commit("hosted", true);
|
||||
first.enterAnalysisMode();
|
||||
for (const field of ["nav", "gaia", "terra"]) first.applyAnalysisMove(`nevlas up ${field}.`);
|
||||
first.addAnalysisLine();
|
||||
first.startAnalysisMoveEdit(2);
|
||||
first.applyAnalysisMove("nevlas up eco.");
|
||||
first.selectAnalysisLine(0);
|
||||
const draft = loadAnalysisLines(1, first.analysisStorageScope);
|
||||
const submitted = spyDispatch(first);
|
||||
first.commitAnalysisLine(2);
|
||||
expect(submitted[0].payload.moves).to.deep.equal(["nevlas up nav.", "nevlas up gaia."]);
|
||||
expect(submitted[0].payload.timings).to.have.length(2);
|
||||
first.$store.commit("submittingPlan", submitted[0].payload);
|
||||
const saved = bgsMove(JSON.parse(JSON.stringify(real)), submitted[0].payload, 1);
|
||||
await first.$store.dispatch("externalData", stripSecret(saved, 1));
|
||||
expect(first.analysisMode).to.equal(false);
|
||||
expect(loadAnalysisLines(1, first.analysisStorageScope)).to.deep.equal(draft);
|
||||
first.$el.remove();
|
||||
first.$destroy();
|
||||
|
||||
const vm = mountAsSeat(1, Engine.fromData(stripSecret(saved, 1)));
|
||||
vm.$store.commit("hosted", true);
|
||||
vm.enterAnalysisMode();
|
||||
expect(vm.analysisPendingRestore).to.equal(null);
|
||||
expect(vm.analysisLines).to.deep.equal(draft.lines);
|
||||
expect(vm.analysisPlayed).to.deep.equal(draft.played);
|
||||
expect(vm.analysisActiveLine).to.equal(draft.active);
|
||||
expect(vm.myPremovePlan.moves).to.deep.equal(["nevlas up nav.", "nevlas up gaia."]);
|
||||
const dispatched = spyDispatch(vm);
|
||||
const submissions = () => dispatched.filter(({ type }) => type === "submitPlan");
|
||||
|
||||
const firstPlayed = bgsMove(saved, "terrans up nav.", 0);
|
||||
await vm.$store.dispatch("externalData", stripSecret(firstPlayed, 1));
|
||||
expect(vm.analysisMode).to.equal(true);
|
||||
expect(vm.analysisLines).to.deep.equal(draft.lines.map((line) => line.slice(1)));
|
||||
expect(vm.analysisPlayed.map((line) => line.length)).to.deep.equal([1, 1]);
|
||||
expect(vm.myPremovePlan.moves).to.deep.equal(["nevlas up gaia."]);
|
||||
expect(vm.myPremovePlan.timings).to.have.length(1);
|
||||
|
||||
const prefixPlayed = bgsMove(firstPlayed, "terrans up gaia.", 0);
|
||||
await vm.$store.dispatch("externalData", stripSecret(prefixPlayed, 1));
|
||||
const remaining = draft.lines.map((line) => line.slice(2));
|
||||
expect(vm.analysisLines).to.deep.equal(remaining);
|
||||
expect(vm.analysisPlayed.map((line) => line.length)).to.deep.equal([2, 2]);
|
||||
expect(vm.myPremovePlan.moves).to.deep.equal([]);
|
||||
expect(vm.myPremovePlan.timings).to.deep.equal([]);
|
||||
expect(vm.myPremovePlan.runs[0].status).to.equal("completed");
|
||||
expect(vm.myPremovePlan.runs[0].steps).to.have.length(2);
|
||||
const played = JSON.parse(JSON.stringify(vm.analysisPlayed));
|
||||
const persisted = loadAnalysisLines(1, vm.analysisStorageScope);
|
||||
expect(persisted.lines).to.deep.equal(remaining);
|
||||
expect(persisted.played).to.deep.equal(played);
|
||||
vm.exitAnalysisMode();
|
||||
vm.enterAnalysisMode();
|
||||
expect(vm.analysisLines).to.deep.equal(remaining);
|
||||
expect(vm.analysisPlayed).to.deep.equal(played);
|
||||
|
||||
// It is now our turn again, but the local third move is not a server premove.
|
||||
const waiting = bgsMove(prefixPlayed, "terrans up terra.", 0);
|
||||
await vm.$store.dispatch("externalData", stripSecret(waiting, 1));
|
||||
expect(waiting.playerToMove).to.equal(1);
|
||||
expect(vm.myPremovePlan.moves).to.deep.equal([]);
|
||||
expect(vm.analysisLines).to.deep.equal(remaining);
|
||||
expect(vm.analysisPlayed).to.deep.equal(played);
|
||||
vm.startAnalysisMoveEdit(0);
|
||||
expect(vm.analysisEdit).to.include({ index: 0, mode: "replace" });
|
||||
vm.applyAnalysisMove("nevlas up nav.");
|
||||
expect(vm.analysisEntries).to.deep.equal([{ kind: "move", move: "nevlas up nav." }]);
|
||||
expect(vm.analysisLines[1]).to.deep.equal(remaining[1]);
|
||||
expect(vm.analysisPlayed).to.deep.equal(played);
|
||||
expect(submissions()).to.deep.equal([]);
|
||||
|
||||
const edited = loadAnalysisLines(1, vm.analysisStorageScope);
|
||||
vm.commitAnalysisLine(1);
|
||||
expect(submissions()).to.have.length(1);
|
||||
const next = submissions()[0].payload;
|
||||
expect(next.moves).to.deep.equal(["nevlas up nav."]);
|
||||
expect(next.timings).to.have.length(1);
|
||||
expect(loadAnalysisLines(1, vm.analysisStorageScope)).to.deep.equal(edited);
|
||||
expect(vm.analysisPlayed).to.deep.equal(played);
|
||||
const resumed = bgsMove(waiting, next, 1);
|
||||
expect(resumed.moveHistory[resumed.moveHistory.length - 1]).to.match(/^nevlas up nav/);
|
||||
expect(resumed.automation.plans[1].moves).to.deep.equal([]);
|
||||
vm.$el.remove();
|
||||
vm.$destroy();
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the sandbox and a partial turn open across this seat's automatic leech", async () => {
|
||||
const real = new Engine(SETUP_MOVES);
|
||||
const vm = mountAsSeat(1, real);
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ import {
|
|||
dropPlayedAnalysisPrefix,
|
||||
emptyAnalysisLineSet,
|
||||
factionSeedAvailable,
|
||||
limitAnalysisCommit,
|
||||
loadAnalysisLines,
|
||||
markAnalysisSeat,
|
||||
MAX_ANALYSIS_LINES,
|
||||
|
|
@ -1277,11 +1278,12 @@ export default class Game extends Vue {
|
|||
);
|
||||
}
|
||||
|
||||
commitAnalysisLine() {
|
||||
commitAnalysisLine(moveCount?: number) {
|
||||
if (!this.analysisMode) {
|
||||
return;
|
||||
}
|
||||
const { live, queued, timings } = this.analysisCommitPlan;
|
||||
const plan = this.analysisCommitPlan;
|
||||
const { live, queued, timings } = moveCount === undefined ? plan : limitAnalysisCommit(plan, moveCount);
|
||||
if (live === null && queued.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Bedøm en åbning ud fra runde-2-indkomst, energi, viden/teknologiadgang, rækkevidde og en mulig næste produktiv handling – ikke kun sejrspoint i runde 1.",
|
||||
"Keep a green token for the top level": "Gem en grøn brik til øverste niveau",
|
||||
"Keep access to several ships": "Behold adgang til flere skibe",
|
||||
"Keep planning": "Fortsæt planlægningen",
|
||||
"Keep your income tile": "Behold din indkomstbrik",
|
||||
"Knowledge": "Viden",
|
||||
"Knowledge + Ore": "Viden + Malm",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Fortsæt",
|
||||
"Wait for charges": "Vent på opladninger",
|
||||
"New plan": "Ny plan",
|
||||
"✓ Income resolved": "✓ Indkomst afviklet"
|
||||
"✓ Income resolved": "✓ Indkomst afviklet",
|
||||
"Program up to move {p0}": "Programmér til og med træk {p0}",
|
||||
"Kept for later": "Gemt til senere"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Beurteile eine Eröffnung nach Runde-2-Einnahmen, Macht, Wissens-/Tech-Zugang, Reichweite und einer machbaren nächsten produktiven Aktion – nicht allein nach Runde-1-SP.",
|
||||
"Keep a green token for the top level": "Behalte ein grünes Plättchen für die oberste Stufe",
|
||||
"Keep access to several ships": "Behalte Zugang zu mehreren Schiffen",
|
||||
"Keep planning": "Weiterplanen",
|
||||
"Keep your income tile": "Behalte dein Einnahmeplättchen",
|
||||
"Knowledge": "Wissen",
|
||||
"Knowledge + Ore": "Wissen + Erz",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Fortsetzen",
|
||||
"Wait for charges": "Auf Machtentscheidungen warten",
|
||||
"New plan": "Neuer Plan",
|
||||
"✓ Income resolved": "✓ Einkommen abgehandelt"
|
||||
"✓ Income resolved": "✓ Einkommen abgehandelt",
|
||||
"Program up to move {p0}": "Bis zu Zug {p0} programmieren",
|
||||
"Kept for later": "Für später gespeichert"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Κρίνε ένα άνοιγμα από το εισόδημα του Γύρου 2, την ενέργεια, την πρόσβαση σε γνώση/τεχνολογία, την εμβέλεια και μια εφικτή επόμενη παραγωγική ενέργεια—όχι μόνο από τους ΠΝ του Γύρου 1.",
|
||||
"Keep a green token for the top level": "Κράτησε μια πράσινη μάρκα για το ανώτατο επίπεδο",
|
||||
"Keep access to several ships": "Διατήρησε πρόσβαση σε πολλά πλοία",
|
||||
"Keep planning": "Συνέχεια σχεδιασμού",
|
||||
"Keep your income tile": "Κράτησε το πλακίδιο εισοδήματός σου",
|
||||
"Knowledge": "Γνώση",
|
||||
"Knowledge + Ore": "Γνώση + Μετάλλευμα",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Συνέχεια",
|
||||
"Wait for charges": "Αναμονή για φορτίσεις",
|
||||
"New plan": "Νέο σχέδιο",
|
||||
"✓ Income resolved": "✓ Το εισόδημα διευθετήθηκε"
|
||||
"✓ Income resolved": "✓ Το εισόδημα διευθετήθηκε",
|
||||
"Program up to move {p0}": "Προγραμματισμός έως την κίνηση {p0}",
|
||||
"Kept for later": "Αποθηκευμένες για αργότερα"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.",
|
||||
"Keep a green token for the top level": "Keep a green token for the top level",
|
||||
"Keep access to several ships": "Keep access to several ships",
|
||||
"Keep planning": "Keep planning",
|
||||
"Keep your income tile": "Keep your income tile",
|
||||
"Knowledge": "Knowledge",
|
||||
"Knowledge + Ore": "Knowledge + Ore",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Resume",
|
||||
"Wait for charges": "Wait for charges",
|
||||
"New plan": "New plan",
|
||||
"✓ Income resolved": "✓ Income resolved"
|
||||
"✓ Income resolved": "✓ Income resolved",
|
||||
"Program up to move {p0}": "Program up to move {p0}",
|
||||
"Kept for later": "Kept for later"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "شروع را با درآمد دور ۲، نیرو، دسترسی به دانش و فناوری، برد و عمل مفید بعدی بسنجید؛ نه فقط امتیاز دور اول.",
|
||||
"Keep a green token for the top level": "یک نشان سبز برای بالاترین سطح نگه دارید",
|
||||
"Keep access to several ships": "دسترسی به چند سفینه را حفظ کنید",
|
||||
"Keep planning": "ادامهٔ برنامهریزی",
|
||||
"Keep your income tile": "کاشی درآمد خود را نگه دارید",
|
||||
"Knowledge": "دانش",
|
||||
"Knowledge + Ore": "دانش + سنگ معدن",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "ادامه",
|
||||
"Wait for charges": "انتظار برای شارژها",
|
||||
"New plan": "برنامهٔ جدید",
|
||||
"✓ Income resolved": "✓ درآمد دریافت شد"
|
||||
"✓ Income resolved": "✓ درآمد دریافت شد",
|
||||
"Program up to move {p0}": "برنامهریزی تا حرکت {p0}",
|
||||
"Kept for later": "نگهداشتهشده برای بعد"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Évaluez une ouverture selon vos revenus de deuxième manche, votre puissance, votre accès à la recherche, votre portée et votre prochaine action utile, plutôt que les seuls PV de première manche.",
|
||||
"Keep a green token for the top level": "Gardez un jeton vert pour le niveau supérieur",
|
||||
"Keep access to several ships": "Gardez l'accès à plusieurs vaisseaux",
|
||||
"Keep planning": "Continuer la planification",
|
||||
"Keep your income tile": "Gardez votre tuile de revenu",
|
||||
"Knowledge": "Connaissance",
|
||||
"Knowledge + Ore": "Connaissance + Minerai",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Reprendre",
|
||||
"Wait for charges": "Attendre les charges",
|
||||
"New plan": "Nouveau plan",
|
||||
"✓ Income resolved": "✓ Revenus résolus"
|
||||
"✓ Income resolved": "✓ Revenus résolus",
|
||||
"Program up to move {p0}": "Programmer jusqu’au coup {p0}",
|
||||
"Kept for later": "Conservés pour plus tard"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "किसी शुरुआत का मूल्यांकन दौर-2 की आय, ऊर्जा, ज्ञान/तकनीक पहुँच, पहुँच और एक व्यवहार्य अगली उत्पादक क्रिया से करें—न कि केवल दौर-1 के वीपी से।",
|
||||
"Keep a green token for the top level": "शीर्ष स्तर के लिए एक हरा टोकन रखें",
|
||||
"Keep access to several ships": "कई जहाजों तक पहुँच रखें",
|
||||
"Keep planning": "योजना बनाना जारी रखें",
|
||||
"Keep your income tile": "अपनी आय टाइल रखें",
|
||||
"Knowledge": "ज्ञान",
|
||||
"Knowledge + Ore": "ज्ञान + अयस्क",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "जारी रखें",
|
||||
"Wait for charges": "शक्ति चार्ज का इंतज़ार करें",
|
||||
"New plan": "नई योजना",
|
||||
"✓ Income resolved": "✓ आय प्राप्त हो गई"
|
||||
"✓ Income resolved": "✓ आय प्राप्त हो गई",
|
||||
"Program up to move {p0}": "चाल {p0} तक प्रोग्राम करें",
|
||||
"Kept for later": "बाद के लिए सुरक्षित"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Giudica un'apertura dal reddito del Round 2, potere, accesso a conoscenza/tecnologia, portata e una prossima azione produttiva fattibile—non solo dai PV del Round 1.",
|
||||
"Keep a green token for the top level": "Tieni un segnalino verde per il livello superiore",
|
||||
"Keep access to several ships": "Mantieni l'accesso a diverse navi",
|
||||
"Keep planning": "Continua a pianificare",
|
||||
"Keep your income tile": "Tieni la tua tessera reddito",
|
||||
"Knowledge": "Conoscenza",
|
||||
"Knowledge + Ore": "Conoscenza + Minerale",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Riprendi",
|
||||
"Wait for charges": "Attendi le ricariche",
|
||||
"New plan": "Nuovo piano",
|
||||
"✓ Income resolved": "✓ Reddito risolto"
|
||||
"✓ Income resolved": "✓ Reddito risolto",
|
||||
"Program up to move {p0}": "Programma fino alla mossa {p0}",
|
||||
"Kept for later": "Conservate per dopo"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "오프닝을 판단할 때 라운드 2 수입, 파워, 지식/기술 접근성, 도달 범위, 그리고 실행 가능한 다음 생산적 행동을 기준으로 하세요. 라운드 1 VP만으로 판단하지 마세요.",
|
||||
"Keep a green token for the top level": "최상위 레벨을 위해 녹색 토큰을 유지하세요",
|
||||
"Keep access to several ships": "여러 우주선에 접근할 수 있게 유지하세요",
|
||||
"Keep planning": "계속 계획하기",
|
||||
"Keep your income tile": "수입 타일을 유지하세요",
|
||||
"Knowledge": "지식",
|
||||
"Knowledge + Ore": "지식 + 광석",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "계속하기",
|
||||
"Wait for charges": "파워 충전 기다리기",
|
||||
"New plan": "새 계획",
|
||||
"✓ Income resolved": "✓ 수입 처리 완료"
|
||||
"✓ Income resolved": "✓ 수입 처리 완료",
|
||||
"Program up to move {p0}": "{p0}번째 수까지 예약",
|
||||
"Kept for later": "나중을 위해 보관됨"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Beoordeel een opening op ronde-2-inkomen, macht, kennis/tech-toegang, bereik en een haalbare volgende productieve actie—niet alleen op ronde-1-VP.",
|
||||
"Keep a green token for the top level": "Bewaar een groen fiche voor het hoogste niveau",
|
||||
"Keep access to several ships": "Houd toegang tot meerdere schepen",
|
||||
"Keep planning": "Verder plannen",
|
||||
"Keep your income tile": "Houd je inkomenstegel",
|
||||
"Knowledge": "Kennis",
|
||||
"Knowledge + Ore": "Kennis + Erts",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Hervatten",
|
||||
"Wait for charges": "Wacht op laadkeuzes",
|
||||
"New plan": "Nieuw plan",
|
||||
"✓ Income resolved": "✓ Inkomsten afgehandeld"
|
||||
"✓ Income resolved": "✓ Inkomsten afgehandeld",
|
||||
"Program up to move {p0}": "Programmeer tot en met zet {p0}",
|
||||
"Kept for later": "Bewaard voor later"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Oceń otwarcie po dochodzie z rundy 2, mocy, dostępie do wiedzy/technologii, zasięgu i wykonalnej kolejnej produktywnej akcji — nie tylko po PZ z rundy 1.",
|
||||
"Keep a green token for the top level": "Zachowaj zielony żeton na najwyższy poziom",
|
||||
"Keep access to several ships": "Zachowaj dostęp do kilku statków",
|
||||
"Keep planning": "Kontynuuj planowanie",
|
||||
"Keep your income tile": "Zachowaj swoją płytkę dochodu",
|
||||
"Knowledge": "Wiedza",
|
||||
"Knowledge + Ore": "Wiedza + Ruda",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Wznów",
|
||||
"Wait for charges": "Czekaj na ładowania",
|
||||
"New plan": "Nowy plan",
|
||||
"✓ Income resolved": "✓ Dochód rozliczony"
|
||||
"✓ Income resolved": "✓ Dochód rozliczony",
|
||||
"Program up to move {p0}": "Zaprogramuj do ruchu {p0}",
|
||||
"Kept for later": "Zachowane na później"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Julgue uma abertura pela renda da Rodada 2, poder, acesso a conhecimento/tecnologia, alcance e uma próxima ação produtiva viável—não apenas pelos PV da Rodada 1.",
|
||||
"Keep a green token for the top level": "Guarde uma ficha verde para o nível superior",
|
||||
"Keep access to several ships": "Mantenha acesso a várias naves",
|
||||
"Keep planning": "Continuar planejando",
|
||||
"Keep your income tile": "Mantenha sua ficha de renda",
|
||||
"Knowledge": "Conhecimento",
|
||||
"Knowledge + Ore": "Conhecimento + Minério",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Continuar",
|
||||
"Wait for charges": "Aguardar cargas",
|
||||
"New plan": "Novo plano",
|
||||
"✓ Income resolved": "✓ Renda resolvida"
|
||||
"✓ Income resolved": "✓ Renda resolvida",
|
||||
"Program up to move {p0}": "Programar até a jogada {p0}",
|
||||
"Kept for later": "Guardados para depois"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Evaluează o deschidere după venitul din Runda 2, putere, acces la cunoaștere/tehnologie, rază și o următoare acțiune productivă fezabilă—nu doar VP din Runda 1.",
|
||||
"Keep a green token for the top level": "Păstrează un jeton verde pentru nivelul superior",
|
||||
"Keep access to several ships": "Păstrează accesul la mai multe nave",
|
||||
"Keep planning": "Continuă planificarea",
|
||||
"Keep your income tile": "Păstrează-ți cartonașul de venit",
|
||||
"Knowledge": "Cunoaștere",
|
||||
"Knowledge + Ore": "Cunoaștere + Minereu",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Continuă",
|
||||
"Wait for charges": "Așteaptă încărcările",
|
||||
"New plan": "Plan nou",
|
||||
"✓ Income resolved": "✓ Venit rezolvat"
|
||||
"✓ Income resolved": "✓ Venit rezolvat",
|
||||
"Program up to move {p0}": "Programează până la mutarea {p0}",
|
||||
"Kept for later": "Păstrate pentru mai târziu"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Оценивай дебют по доходу 2-го раунда, энергии, доступу к знаниям/технологиям, досягаемости и осуществимому следующему продуктивному действию — а не только по ПО 1-го раунда.",
|
||||
"Keep a green token for the top level": "Сохрани зелёный жетон для верхнего уровня",
|
||||
"Keep access to several ships": "Сохрани доступ к нескольким кораблям",
|
||||
"Keep planning": "Продолжить планирование",
|
||||
"Keep your income tile": "Сохрани свой жетон дохода",
|
||||
"Knowledge": "Знания",
|
||||
"Knowledge + Ore": "Знания + Руда",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Продолжить",
|
||||
"Wait for charges": "Ждать зарядки",
|
||||
"New plan": "Новый план",
|
||||
"✓ Income resolved": "✓ Доход получен"
|
||||
"✓ Income resolved": "✓ Доход получен",
|
||||
"Program up to move {p0}": "Запрограммировать до хода {p0}",
|
||||
"Kept for later": "Сохранены на потом"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "Đánh giá khai cuộc bằng thu nhập Vòng 2, năng lượng, khả năng tiếp cận tri thức/công nghệ, tầm với và một hành động sản xuất khả thi tiếp theo—không chỉ riêng VP Vòng 1.",
|
||||
"Keep a green token for the top level": "Giữ một token xanh cho cấp cao nhất",
|
||||
"Keep access to several ships": "Giữ quyền tiếp cận nhiều tàu",
|
||||
"Keep planning": "Tiếp tục lên kế hoạch",
|
||||
"Keep your income tile": "Giữ ô thu nhập của bạn",
|
||||
"Knowledge": "Tri thức",
|
||||
"Knowledge + Ore": "Tri thức + Quặng",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "Tiếp tục",
|
||||
"Wait for charges": "Chờ nạp năng lượng",
|
||||
"New plan": "Kế hoạch mới",
|
||||
"✓ Income resolved": "✓ Đã xử lý thu nhập"
|
||||
"✓ Income resolved": "✓ Đã xử lý thu nhập",
|
||||
"Program up to move {p0}": "Lập trình đến nước đi {p0}",
|
||||
"Kept for later": "Giữ lại để dùng sau"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "评价开局应看第二轮的收入、能量、知识及科技获取、航程和后续有效行动的可行性,而不只看第一轮的胜利点。",
|
||||
"Keep a green token for the top level": "为最高等级保留一个绿色标记",
|
||||
"Keep access to several ships": "保持对多艘飞船的访问",
|
||||
"Keep planning": "继续规划",
|
||||
"Keep your income tile": "保留你的收入板块",
|
||||
"Knowledge": "知识",
|
||||
"Knowledge + Ore": "知识 + 矿石",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "继续",
|
||||
"Wait for charges": "等待能量充能",
|
||||
"New plan": "新计划",
|
||||
"✓ Income resolved": "✓ 收入已结算"
|
||||
"✓ Income resolved": "✓ 收入已结算",
|
||||
"Program up to move {p0}": "编排至第 {p0} 步",
|
||||
"Kept for later": "保留供以后使用"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,7 @@
|
|||
"Judge an opening by Round-2 income, power, knowledge/tech access, reach, and a feasible next productive action—not Round-1 VP alone.": "評估開局應看第2輪的收入、能量、知識/科技取得、航程,以及下一個可行的有效行動——而非僅看第1輪的VP。",
|
||||
"Keep a green token for the top level": "保留一個綠色標記給最高等級",
|
||||
"Keep access to several ships": "保留多艘太空船的使用權",
|
||||
"Keep planning": "繼續規劃",
|
||||
"Keep your income tile": "保留你的收入板塊",
|
||||
"Knowledge": "知識",
|
||||
"Knowledge + Ore": "知識+礦石",
|
||||
|
|
@ -4137,5 +4138,7 @@
|
|||
"Resume": "繼續",
|
||||
"Wait for charges": "等待能量充能",
|
||||
"New plan": "新計畫",
|
||||
"✓ Income resolved": "✓ 收入已結算"
|
||||
"✓ Income resolved": "✓ 收入已結算",
|
||||
"Program up to move {p0}": "編排至第 {p0} 步",
|
||||
"Kept for later": "保留供之後使用"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import Engine, {
|
|||
} from "@gaia-project/engine";
|
||||
import { expect } from "chai";
|
||||
import { passedChargeGame } from "../testing/passed-charge";
|
||||
import type { AnalysisEntry, AnalysisLineSet, MoveCost } from "./analysis";
|
||||
import type { AnalysisCommitPlan, AnalysisEntry, AnalysisLineSet, MoveCost } from "./analysis";
|
||||
import {
|
||||
advancePastOwnPass,
|
||||
analysisCommitPrefix,
|
||||
|
|
@ -28,6 +28,7 @@ import {
|
|||
emptyAnalysisLineSet,
|
||||
factionSeedAvailable,
|
||||
isCheapAnalysisBuild,
|
||||
limitAnalysisCommit,
|
||||
loadAnalysisLines,
|
||||
markAnalysisSeat,
|
||||
MAX_ANALYSIS_LINES,
|
||||
|
|
@ -1377,6 +1378,117 @@ describe("planAnalysisCommit - what the Commit confirmation shows (§6)", () =>
|
|||
});
|
||||
});
|
||||
|
||||
describe("limitAnalysisCommit - program only the selected eligible prefix", () => {
|
||||
const moves = ["terrans up nav.", "terrans up gaia.", "terrans build ts -1x2 cheap."];
|
||||
const makePlan = (onTurn = true): AnalysisCommitPlan => ({
|
||||
...planAnalysisCommit({
|
||||
committable: moves,
|
||||
lineMoves: [...moves, "terrans unavailable"],
|
||||
cut: "illegal",
|
||||
onTurn,
|
||||
hosted: true,
|
||||
}),
|
||||
timings: [
|
||||
{ round: 1, phase: Phase.RoundMove },
|
||||
{ round: 2, phase: Phase.RoundMove },
|
||||
{ round: 3, phase: Phase.RoundMove },
|
||||
],
|
||||
costs: [
|
||||
[{ type: Resource.Knowledge, count: 4 }],
|
||||
[{ type: Resource.Knowledge, count: 4 }],
|
||||
[{ type: Resource.Credit, count: 3 }],
|
||||
],
|
||||
});
|
||||
|
||||
for (const onTurn of [true, false]) {
|
||||
it(`selects a prefix ${onTurn ? "including the live move" : "entirely from the off-turn queue"}`, () => {
|
||||
const plan = makePlan(onTurn);
|
||||
const before = JSON.parse(JSON.stringify(plan));
|
||||
const limited = limitAnalysisCommit(plan, 2);
|
||||
expect(limited.live).to.equal(onTurn ? moves[0] : null);
|
||||
expect(limited.queued).to.deep.equal(onTurn ? [moves[1]] : moves.slice(0, 2));
|
||||
expect(limited.deferred).to.deep.equal([moves[2]]);
|
||||
expect(limited.dropped).to.deep.equal(plan.dropped);
|
||||
expect(limited.cut).to.equal("illegal");
|
||||
expect(limited.limit).to.equal("line");
|
||||
expect(limited.timings).to.deep.equal(plan.timings.slice(0, 2));
|
||||
expect(limited.costs).to.deep.equal(plan.costs.slice(0, 2));
|
||||
expect(limited.simulatedNeighbour).to.equal(false);
|
||||
expect(limited.queued).not.to.equal(plan.queued);
|
||||
expect(limited.timings).not.to.equal(plan.timings);
|
||||
expect(limited.costs).not.to.equal(plan.costs);
|
||||
expect(plan).to.deep.equal(before);
|
||||
});
|
||||
}
|
||||
|
||||
it("counts an immediate move as the first selected move, not as an extra queue slot", () => {
|
||||
const plan = makePlan();
|
||||
const limited = limitAnalysisCommit(plan, 1);
|
||||
expect(limited.live).to.equal(moves[0]);
|
||||
expect(limited.queued).to.deep.equal([]);
|
||||
expect(limited.timings).to.deep.equal(plan.timings.slice(0, 1));
|
||||
expect(limited.costs).to.deep.equal(plan.costs.slice(0, 1));
|
||||
expect(limited.deferred).to.deep.equal(moves.slice(1));
|
||||
});
|
||||
|
||||
for (const count of [NaN, Infinity, -Infinity, -1, 1.5, 0]) {
|
||||
it(`selects nothing for invalid count ${count}`, () => {
|
||||
const plan = makePlan();
|
||||
const limited = limitAnalysisCommit(plan, count);
|
||||
expect(limited.live).to.equal(null);
|
||||
expect(limited.queued).to.deep.equal([]);
|
||||
expect(limited.timings).to.deep.equal([]);
|
||||
expect(limited.costs).to.deep.equal([]);
|
||||
expect(limited.deferred).to.deep.equal(moves);
|
||||
expect(limited.dropped).to.deep.equal(plan.dropped);
|
||||
expect(limited.cut).to.equal(plan.cut);
|
||||
expect(limited.limit).to.equal(plan.limit);
|
||||
expect(limited.simulatedNeighbour).to.equal(false);
|
||||
});
|
||||
}
|
||||
|
||||
for (const count of [3, 100]) {
|
||||
it(`keeps the full eligible prefix for count ${count}, including its neighbour requirement`, () => {
|
||||
const plan = makePlan();
|
||||
const limited = limitAnalysisCommit(plan, count);
|
||||
expect(limited.live).to.equal(plan.live);
|
||||
expect(limited.queued).to.deep.equal(plan.queued);
|
||||
expect(limited.timings).to.deep.equal(plan.timings);
|
||||
expect(limited.costs).to.deep.equal(plan.costs);
|
||||
expect(limited.deferred).to.deep.equal([]);
|
||||
expect(limited.dropped).to.deep.equal(plan.dropped);
|
||||
expect(limited.simulatedNeighbour).to.equal(true);
|
||||
});
|
||||
}
|
||||
|
||||
it("preserves optional metadata when absent and never expands offline eligibility", () => {
|
||||
for (const onTurn of [true, false]) {
|
||||
const plan = planAnalysisCommit({ committable: moves, lineMoves: moves, cut: null, onTurn, hosted: false });
|
||||
const limited = limitAnalysisCommit(plan, 100);
|
||||
expect(limited.live).to.equal(onTurn ? moves[0] : null);
|
||||
expect(limited.queued).to.deep.equal([]);
|
||||
expect(limited.deferred).to.deep.equal([]);
|
||||
expect(limited.dropped).to.deep.equal(onTurn ? moves.slice(1) : moves);
|
||||
expect(limited.limit).to.equal("no-premoves");
|
||||
expect(limited.cut).to.equal(null);
|
||||
expect(limited.timings).to.equal(undefined);
|
||||
expect(limited.costs).to.equal(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
it("can narrow a plan repeatedly without reviving deferred moves or losing their order", () => {
|
||||
const plan = makePlan();
|
||||
const first = limitAnalysisCommit(plan, 2);
|
||||
const second = limitAnalysisCommit(first, 1);
|
||||
const expanded = limitAnalysisCommit(second, 100);
|
||||
expect(first.deferred).to.deep.equal([moves[2]]);
|
||||
expect(second.deferred).to.deep.equal(moves.slice(1));
|
||||
expect(expanded).to.deep.equal(second);
|
||||
expect(expanded.dropped).to.deep.equal(plan.dropped);
|
||||
expect(limitAnalysisCommit(second, 0).deferred).to.deep.equal(moves);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the round-0 faction seed (§11)", () => {
|
||||
const freshGame = () => new Engine(["init 2 randomSeed"]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1143,14 +1143,34 @@ export interface AnalysisCommitPlan {
|
|||
live: string | null;
|
||||
/** Queued as Sequential premoves, in line order, behind `live`. */
|
||||
queued: string[];
|
||||
/** Everything in the line that stays behind. Never committed, and cleared with the line. */
|
||||
/** Ineligible or unavailable moves left in the saved draft, never submitted by this plan. */
|
||||
dropped: string[];
|
||||
/** Eligible moves deliberately left in the saved draft for a later explicit commit. */
|
||||
deferred?: string[];
|
||||
/** Why the line itself stops where it does - null when the line was not the limit. */
|
||||
cut: AnalysisCommitCut | null;
|
||||
/** Whether the line's feasibility or the absence of premoves prevents submitting the rest. */
|
||||
limit: "line" | "no-premoves";
|
||||
}
|
||||
|
||||
/** Select only an already-eligible prefix, counting the live move first when present.
|
||||
* Invalid counts select nothing; limiting a plan again can never restore deferred/dropped moves. */
|
||||
export function limitAnalysisCommit(plan: AnalysisCommitPlan, count: number): AnalysisCommitPlan {
|
||||
const eligible = plan.live === null ? plan.queued : [plan.live, ...plan.queued];
|
||||
const selectedCount = Number.isInteger(count) && count > 0 ? Math.min(count, eligible.length) : 0;
|
||||
const selected = eligible.slice(0, selectedCount);
|
||||
const live = selectedCount > 0 ? plan.live : null;
|
||||
return {
|
||||
...plan,
|
||||
live,
|
||||
queued: live === null ? selected : selected.slice(1),
|
||||
...(plan.timings ? { timings: plan.timings.slice(0, selectedCount) } : {}),
|
||||
...(plan.costs ? { costs: plan.costs.slice(0, selectedCount) } : {}),
|
||||
simulatedNeighbour: selected.some(isCheapAnalysisBuild),
|
||||
deferred: [...eligible.slice(selectedCount), ...(plan.deferred ?? [])],
|
||||
};
|
||||
}
|
||||
|
||||
/** Submit the full valid prefix in hosted play; offline play can only commit the current move. */
|
||||
export function planAnalysisCommit(args: {
|
||||
/** The committable prefix - `analysisCommitPrefix().moves`. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue