Separate robot ownership from operation and require usable workers to be assigned
This commit is contained in:
parent
bd63371622
commit
6ea0353c02
9 changed files with 114 additions and 69 deletions
|
|
@ -21,8 +21,8 @@ version Stronghold Games adopted as the base rules:
|
|||
- Research factories cost 30 and require a Laboratory; buying a New Chemicals factory
|
||||
requires spending a research card
|
||||
- Over-capacity players discard **before** actions (after production)
|
||||
- Robots don't count against the population limit; robot ownership is capped at
|
||||
(Robots upgrades × population)
|
||||
- Robots don't count against the population limit; robots may be bought in advance, but only
|
||||
(Robots upgrades × current population) may operate factories. All available operators must be assigned where possible
|
||||
- Victory: 75 VP (manned factories + upgrades); ties on VP in purchase order are broken
|
||||
by total credits spent
|
||||
- Market refill via d4 / d10 / d12+1 by game era (leader VP, per the v1.32 setup chart),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
handCapacity,
|
||||
handValue,
|
||||
megaEligible,
|
||||
operators as availableOperators,
|
||||
populationCost,
|
||||
populationMax,
|
||||
upgradeDiscount,
|
||||
|
|
@ -192,7 +193,7 @@ function chooseTurn(player: PlayerState): Move {
|
|||
const cash = handValue(sim);
|
||||
|
||||
// 2. Recruit population while there are factories to man.
|
||||
const unmanned = sim.factories.length - (sim.population + sim.robots);
|
||||
const unmanned = sim.factories.length - availableOperators(sim);
|
||||
if (unmanned > 0 && sim.population < populationMax(sim) && cash >= populationCost(sim)) {
|
||||
const cards = spend(populationCost(sim));
|
||||
buys.push({ buy: "population", count: 1, cards });
|
||||
|
|
@ -220,7 +221,7 @@ function chooseTurn(player: PlayerState): Move {
|
|||
}
|
||||
|
||||
// 4. Man the most valuable factories and end the turn.
|
||||
const operators = sim.population + sim.robots;
|
||||
const operators = availableOperators(sim);
|
||||
const manned = sim.factories
|
||||
.map((factory, index) => ({ index, value: PRODUCTION_DECKS[factory.type].average }))
|
||||
.sort((a, b) => b.value - a.value)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ test("buy factory: water factory costs 20, joins unmanned", () => {
|
|||
];
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "water", cards: [0, 1] }], manned: [] },
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "water", cards: [0, 1] }], manned: [0, 1, 2] },
|
||||
state.activeSeat
|
||||
);
|
||||
assert.equal(player.factories.length, 4);
|
||||
|
|
@ -33,7 +33,7 @@ test("buy factory: titanium requires heavy equipment, research requires laborato
|
|||
const player = activePlayer(state);
|
||||
player.hand = [{ t: "water", v: 40 }];
|
||||
const buyIn = (factory: "titanium" | "research") =>
|
||||
({ action: "endTurn", buys: [{ buy: "factory", factory, cards: [0] }], manned: [] }) as const;
|
||||
({ action: "endTurn", buys: [{ buy: "factory", factory, cards: [0] }], manned: [0, 1, 2] }) as const;
|
||||
assert.throws(() => applyMove(state, buyIn("titanium"), state.activeSeat));
|
||||
assert.throws(() => applyMove(state, buyIn("research"), state.activeSeat));
|
||||
player.upgrades.heavyEquipment = 1;
|
||||
|
|
@ -48,7 +48,7 @@ test("buy factory: new chemicals requires a research card in the payment", () =>
|
|||
assert.throws(() =>
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "newChemicals", cards: [0] }], manned: [] },
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "newChemicals", cards: [0] }], manned: [0, 1, 2] },
|
||||
state.activeSeat
|
||||
)
|
||||
);
|
||||
|
|
@ -58,7 +58,7 @@ test("buy factory: new chemicals requires a research card in the payment", () =>
|
|||
];
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "newChemicals", cards: [0, 1] }], manned: [] },
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "newChemicals", cards: [0, 1] }], manned: [0, 1, 2] },
|
||||
state.activeSeat
|
||||
);
|
||||
assert.equal(player.factories.at(-1)?.type, "newChemicals");
|
||||
|
|
@ -77,7 +77,7 @@ test("population: costs 10 (5 with ecoplants), capped by population max", () =>
|
|||
assert.throws(() =>
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "population", count: 3, cards: [0, 1, 2] }], manned: [] },
|
||||
{ action: "endTurn", buys: [{ buy: "population", count: 3, cards: [0, 1, 2] }], manned: [0, 1, 2] },
|
||||
state.activeSeat
|
||||
)
|
||||
);
|
||||
|
|
@ -95,7 +95,7 @@ test("population: costs 10 (5 with ecoplants), capped by population max", () =>
|
|||
{ buy: "population", count: 2, cards: [0] },
|
||||
{ buy: "population", count: 1, cards: [0] },
|
||||
],
|
||||
manned: [],
|
||||
manned: [0, 1, 2],
|
||||
},
|
||||
state.activeSeat
|
||||
);
|
||||
|
|
@ -103,14 +103,14 @@ test("population: costs 10 (5 with ecoplants), capped by population max", () =>
|
|||
assert.equal(player.hand.length, 1);
|
||||
});
|
||||
|
||||
test("robots: require the upgrade and respect the robot limit", () => {
|
||||
test("robots: require the upgrade and expose the operating limit", () => {
|
||||
const state = initGame(3, {}, "robot-spec");
|
||||
const player = activePlayer(state);
|
||||
player.hand = [
|
||||
{ t: "water", v: 10 },
|
||||
{ t: "water", v: 10 },
|
||||
];
|
||||
const buyRobot = { action: "endTurn", buys: [{ buy: "robots", count: 1, cards: [0] }], manned: [] } as const;
|
||||
const buyRobot = { action: "endTurn", buys: [{ buy: "robots", count: 1, cards: [0] }], manned: [0, 1, 2] } as const;
|
||||
assert.throws(() => applyMove(state, buyRobot, state.activeSeat));
|
||||
player.upgrades.robots = 1;
|
||||
assert.equal(robotMax(player), player.population);
|
||||
|
|
@ -178,6 +178,7 @@ test("end turn: mans the selected factories and passes the action turn on", () =
|
|||
const state = initGame(3, {}, "turn-spec");
|
||||
const first = state.activeSeat;
|
||||
const player = activePlayer(state);
|
||||
player.population = 2;
|
||||
applyMove(state, { action: "endTurn", buys: [], manned: [0, 2] }, first);
|
||||
assert.equal(player.factories[0]?.manned, true);
|
||||
assert.equal(player.factories[1]?.manned, false);
|
||||
|
|
@ -291,3 +292,67 @@ test("bestPayment: exact sums beat overpay, more cards beat fewer at equal total
|
|||
// Without the research constraint the same due is cheaper without one.
|
||||
assert.deepEqual(bestPayment(player, 25, false), [3]);
|
||||
});
|
||||
|
||||
test("robots: excess purchases stay idle and cannot staff factories", () => {
|
||||
const state = initGame(3, {}, "robot-reserves");
|
||||
const player = activePlayer(state);
|
||||
player.upgrades.robots = 1;
|
||||
player.hand = [{ t: "water", v: 60 }];
|
||||
player.factories = Array.from({ length: 10 }, () => ({ type: "ore" as const, manned: false }));
|
||||
const seat = state.activeSeat;
|
||||
const before = JSON.stringify(state);
|
||||
assert.throws(
|
||||
() =>
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "robots", count: 6, cards: [0] }], manned: [0, 1, 2, 3, 4, 5, 6] },
|
||||
seat
|
||||
),
|
||||
/only 6 operators/
|
||||
);
|
||||
assert.equal(JSON.stringify(state), before);
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "robots", count: 6, cards: [0] }], manned: [0, 1, 2, 3, 4, 5] },
|
||||
seat
|
||||
);
|
||||
assert.equal(player.robots, 6);
|
||||
assert.equal(player.factories.filter((f) => f.manned).length, 6);
|
||||
});
|
||||
|
||||
test("staffing: rejects idle usable workers without mutating purchases", () => {
|
||||
const state = initGame(3, {}, "idle-workers");
|
||||
const player = activePlayer(state);
|
||||
player.hand = [{ t: "water", v: 20 }];
|
||||
const before = JSON.stringify(state);
|
||||
assert.throws(
|
||||
() =>
|
||||
applyMove(
|
||||
state,
|
||||
{ action: "endTurn", buys: [{ buy: "factory", factory: "water", cards: [0] }], manned: [0, 1] },
|
||||
state.activeSeat
|
||||
),
|
||||
/assign all available/
|
||||
);
|
||||
assert.equal(JSON.stringify(state), before);
|
||||
});
|
||||
|
||||
test("staffing: multiple Robots upgrades and new colonists unlock reserved robots", () => {
|
||||
const state = initGame(3, {}, "robot-supervision");
|
||||
const player = activePlayer(state);
|
||||
player.upgrades.robots = 2;
|
||||
player.robots = 8;
|
||||
player.factories = Array.from({ length: 12 }, () => ({ type: "ore" as const, manned: false }));
|
||||
player.hand = [{ t: "water", v: 10 }];
|
||||
applyMove(
|
||||
state,
|
||||
{
|
||||
action: "endTurn",
|
||||
buys: [{ buy: "population", count: 1, cards: [0] }],
|
||||
manned: Array.from({ length: 12 }, (_, i) => i),
|
||||
},
|
||||
state.activeSeat
|
||||
);
|
||||
assert.equal(player.population, 4);
|
||||
assert.equal(player.factories.filter((f) => f.manned).length, 12);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {
|
|||
populationCost,
|
||||
populationMax,
|
||||
publicMaxBid,
|
||||
robotMax,
|
||||
operators,
|
||||
scores,
|
||||
setup,
|
||||
upgradeDiscount,
|
||||
|
|
@ -972,9 +972,6 @@ export function applyTurnBuy(state: GameState, player: PlayerState, buy: TurnBuy
|
|||
if (!Number.isInteger(buy.count) || buy.count < 1) {
|
||||
err("invalid robot count");
|
||||
}
|
||||
if (player.robots + buy.count > robotMax(player)) {
|
||||
err(`robot limit is ${robotMax(player)}`);
|
||||
}
|
||||
const indices = sanitizeIndices(buy.cards, player.hand.length, "buy robots");
|
||||
const paid = spendCards(state, player, indices, ROBOT_COST * buy.count);
|
||||
player.robots += buy.count;
|
||||
|
|
@ -1004,8 +1001,12 @@ function runTurn(state: GameState, seat: number, move: Move & { action: "endTurn
|
|||
paid += applyTurnBuy(state, player, buy);
|
||||
}
|
||||
const manned = sanitizeIndices(move.manned, player.factories.length, "endTurn");
|
||||
if (manned.length > player.population + player.robots) {
|
||||
err(`only ${player.population + player.robots} operators available`);
|
||||
const available = operators(player);
|
||||
if (manned.length > available) {
|
||||
err(`only ${available} operators available`);
|
||||
}
|
||||
if (manned.length < Math.min(available, player.factories.length)) {
|
||||
err("assign all available operators before ending your turn");
|
||||
}
|
||||
player.factories.forEach((factory, i) => {
|
||||
factory.manned = manned.includes(i);
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ export function robotMax(player: PlayerState): number {
|
|||
}
|
||||
|
||||
export function operators(player: PlayerState): number {
|
||||
return player.population + player.robots;
|
||||
return player.population + Math.min(player.robots, robotMax(player));
|
||||
}
|
||||
|
||||
/** Number of hand cards that count against hand capacity (a mega card counts as 4). */
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
MIN_CARD_VALUE,
|
||||
UPGRADE_SPECS,
|
||||
auctionCard,
|
||||
operators,
|
||||
} from "outpost-engine";
|
||||
import ResourceIcon from "./ResourceIcon.svelte";
|
||||
import { RESOURCE_LABELS, type ViewerStore } from "./store.svelte";
|
||||
|
|
@ -67,7 +68,7 @@
|
|||
return "";
|
||||
}
|
||||
});
|
||||
const idleOperators = $derived(me ? Math.max(0, me.population + me.robots - store.manningPick.length) : 0);
|
||||
const idleOperators = $derived(me ? Math.max(0, operators(me) - store.manningPick.length) : 0);
|
||||
const idleFactories = $derived(me ? me.factories.length - store.manningPick.length : 0);
|
||||
|
||||
// Preselect sensible cards when a payment or discard is asked of the player
|
||||
|
|
@ -176,14 +177,18 @@
|
|||
<strong>{store.manningPick.length} / {me.factories.length}</strong> factories manned.
|
||||
{#if idleOperators > 0 && idleFactories > 0}
|
||||
<span class="warn">
|
||||
{Math.min(idleOperators, idleFactories)} more could be manned.
|
||||
Assign {Math.min(idleOperators, idleFactories)} more before ending your turn.
|
||||
</span>
|
||||
{/if}
|
||||
{#if staged.length > 0}
|
||||
Also confirms: {staged.join(", ")}.
|
||||
{/if}
|
||||
</span>
|
||||
<button class="confirm" onclick={() => store.confirmEndTurn()}>End turn</button>
|
||||
<button
|
||||
class="confirm"
|
||||
disabled={idleOperators > 0 && idleFactories > 0}
|
||||
onclick={() => store.confirmEndTurn()}>End turn</button
|
||||
>
|
||||
<button class="cancel" onclick={() => store.cancel()}>Back</button>
|
||||
</div>
|
||||
{:else if pending}
|
||||
|
|
@ -249,7 +254,7 @@
|
|||
{#if me.upgrades.robots > 0}
|
||||
<button
|
||||
class="buy"
|
||||
disabled={me.robots >= store.robotMaxOf(store.playerIndex ?? -1) || store.myHandValue < 10}
|
||||
disabled={store.myHandValue < 10}
|
||||
title="Buy a robot: 10 credits"
|
||||
onclick={() => store.startRobotsPayment()}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
handValueExpected,
|
||||
handValueRange,
|
||||
productionRange,
|
||||
operators as availableOperators,
|
||||
type GameState,
|
||||
type Resource,
|
||||
} from "outpost-engine";
|
||||
|
|
@ -75,7 +76,7 @@
|
|||
// Trader / Merchant House. Shown in the hand with an unknown value until the
|
||||
// step ends and they land.
|
||||
const parkedMine = $derived((state.exchange?.parked ?? []).filter((p) => p.seat === index).map((p) => p.card));
|
||||
const operators = $derived(player.population + player.robots);
|
||||
const operators = $derived(availableOperators(player));
|
||||
const pickTotal = $derived(isMe ? store.pickTotal() : 0);
|
||||
const pickRequired = $derived(isMe ? store.pickRequired : null);
|
||||
const pickCount = $derived(isMe ? store.cardPick.length : 0);
|
||||
|
|
@ -142,7 +143,9 @@
|
|||
<div class="row stats">
|
||||
<span title="colonists / population limit">👤 {player.population}/{store.popMaxOf(index)}</span>
|
||||
{#if player.robots > 0 || player.upgrades.robots > 0}
|
||||
<span title="robots / robot limit">🤖 {player.robots}/{store.robotMaxOf(index)}</span>
|
||||
<span title="Robots owned / operating limit. Excess robots remain idle."
|
||||
>🤖 {player.robots}/{store.robotMaxOf(index)}</span
|
||||
>
|
||||
{/if}
|
||||
<span title="hand cards counting toward capacity / hand capacity (research and microbiotics are exempt)">
|
||||
🂠 {store.countingOf(index)}/{store.handCapOf(index)}
|
||||
|
|
|
|||
|
|
@ -323,17 +323,6 @@
|
|||
<ellipse class="crater" cx="1330" cy="104" rx="18" ry="5" />
|
||||
<ellipse class="crater" cx="90" cy="112" rx="20" ry="6" />
|
||||
</g>
|
||||
<g class="outpost" transform="translate(340 0)">
|
||||
<path d="M1152 58 a13 13 0 0 1 26 0 z" />
|
||||
<path d="M1184 60 a9 9 0 0 1 18 0 z" />
|
||||
<rect x="1150" y="57" width="54" height="3" rx="1" />
|
||||
<rect x="1206" y="34" width="2.5" height="26" rx="1" />
|
||||
<circle cx="1207.2" cy="32" r="3" class="beacon" />
|
||||
<rect x="1128" y="52" width="12" height="8" rx="1" />
|
||||
<rect x="1157" y="52" width="3" height="4" rx="0.5" class="win" />
|
||||
<rect x="1164" y="52" width="3" height="4" rx="0.5" class="win" />
|
||||
<rect x="1187" y="55" width="2.5" height="3.5" rx="0.5" class="win" />
|
||||
</g>
|
||||
|
||||
{#each biospheres as dome}
|
||||
<g class="biosphere" style="--bc: {dome.color}">
|
||||
|
|
@ -664,26 +653,6 @@
|
|||
stroke-width: 1.2;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.moon .outpost {
|
||||
fill: #2a2f3a;
|
||||
}
|
||||
.moon .outpost .win {
|
||||
fill: rgba(240, 200, 120, 0.85);
|
||||
}
|
||||
.moon .outpost .beacon {
|
||||
fill: rgba(88, 182, 220, 0.9);
|
||||
animation: beacon 2.6s ease-in-out infinite;
|
||||
}
|
||||
@keyframes beacon {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.25;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Player buildings: factories and upgrades clustered per player.
|
||||
Player color is the outline/accent; unmanned factories are dimmer. */
|
||||
.bldg {
|
||||
|
|
@ -767,8 +736,7 @@
|
|||
@media (prefers-reduced-motion: reduce) {
|
||||
.rock,
|
||||
.station,
|
||||
.comet,
|
||||
.moon .outpost .beacon {
|
||||
.comet {
|
||||
animation: none;
|
||||
}
|
||||
.comet {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
handCapacity,
|
||||
handValue,
|
||||
megaEligible as megaEligibleEngine,
|
||||
operators as availableOperators,
|
||||
populationCost,
|
||||
populationMax,
|
||||
rankings,
|
||||
|
|
@ -135,7 +136,9 @@ export const UPGRADE_EFFECTS: Record<Upgrade, EffectToken[]> = {
|
|||
nodule: ["+3 population limit (per copy)."],
|
||||
scientists: ["Produces a ", { card: "research" }, ` (${cardRange("research")}) each round (per copy).`],
|
||||
orbitalLab: ["Produces a ", { card: "microbiotics" }, ` (${cardRange("microbiotics")}) each round (per copy).`],
|
||||
robots: ["Allows buying robots, operators that ignore the population limit (per copy: up to population)."],
|
||||
robots: [
|
||||
"Buy robots for 10 credits each. Each Robots upgrade lets you operate up to your current colonist count; excess robots stay idle.",
|
||||
],
|
||||
laboratory: ["Allows ", { f: "research", n: 1 }, ` (${cardRange("research")} cards); comes with a free one.`],
|
||||
ecoplants: ["Colonists cost 5 instead of 10. −10 on ", { u: "outpost" }, " bids (per copy)."],
|
||||
outpost: ["Free ", { f: "titanium", n: 1 }, ", +5 hand capacity, +5 population limit."],
|
||||
|
|
@ -827,7 +830,7 @@ export class ViewerStore {
|
|||
if (!this.myActionTurn || !me) {
|
||||
return;
|
||||
}
|
||||
if (me.upgrades.robots === 0 || me.robots >= robotMax(me) || this.myHandValue < 10) {
|
||||
if (me.upgrades.robots === 0 || this.myHandValue < 10) {
|
||||
return;
|
||||
}
|
||||
this.cancel();
|
||||
|
|
@ -849,12 +852,7 @@ export class ViewerStore {
|
|||
: pending.kind === "population"
|
||||
? populationCost(me)
|
||||
: 10;
|
||||
let cap =
|
||||
pending.kind === "population"
|
||||
? populationMax(me) - me.population
|
||||
: pending.kind === "robots"
|
||||
? robotMax(me) - me.robots
|
||||
: Number.MAX_SAFE_INTEGER;
|
||||
let cap = pending.kind === "population" ? populationMax(me) - me.population : Number.MAX_SAFE_INTEGER;
|
||||
if (pending.kind === "factory" && FACTORIES[pending.factory].needsResearchCard) {
|
||||
cap = Math.min(cap, me.hand.filter((c) => c.t === "research").length);
|
||||
}
|
||||
|
|
@ -986,7 +984,7 @@ export class ViewerStore {
|
|||
this.manning = true;
|
||||
// Sensible default: keep last round's assignment, then fill any spare
|
||||
// operators into the most productive unmanned factories (deck average).
|
||||
const operators = me.population + me.robots;
|
||||
const operators = availableOperators(me);
|
||||
const pick = me.factories.flatMap((f, i) => (f.manned ? [i] : [])).slice(0, operators);
|
||||
const spare = me.factories
|
||||
.map((f, index) => ({ index, value: PRODUCTION_DECKS[f.type].average }))
|
||||
|
|
@ -1006,7 +1004,7 @@ export class ViewerStore {
|
|||
if (!this.manning || !me) {
|
||||
return;
|
||||
}
|
||||
const limit = me.population + me.robots;
|
||||
const limit = availableOperators(me);
|
||||
if (this.manningPick.includes(index)) {
|
||||
this.manningPick = this.manningPick.filter((i) => i !== index);
|
||||
} else if (this.manningPick.length < limit) {
|
||||
|
|
@ -1015,7 +1013,11 @@ export class ViewerStore {
|
|||
}
|
||||
|
||||
confirmEndTurn(): void {
|
||||
if (!this.manning) {
|
||||
if (
|
||||
!this.manning ||
|
||||
!this.me ||
|
||||
this.manningPick.length !== Math.min(availableOperators(this.me), this.me.factories.length)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const move: Move = { action: "endTurn", buys: this.turnBuys, manned: this.manningPick };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue