Fix repayments that overcharged, and act on the first Frontier playtest

A debt repayment took its whole instalment even when less was owed: four
dollars owed at the store cost twenty. Content could not express "pay what is
owed", so an add effect's amount may now be read from state, with a cap. Five
repayments across both packs use it, and a conformance test holds every pack to
it. The turn record now says which options were hidden, so the analyser stops
counting doors nobody saw, and it reads only feedback logs.

From the same session: wages are labelled as wages, a clamped change says where
it stopped, two unreadable option labels are rewritten, the sale barn no longer
offers what the player already owns, Ward hints at what the promotion waits for,
and the office has five more events. DECISIONS #38-40.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C6UDQ9o6L6Ey173U7XVou6
This commit is contained in:
JesseMarkowitz
2026-09-15 10:23:15 -04:00
co-authored by Claude Opus 5
parent d84ae495f4
commit 112e558dbb
22 changed files with 723 additions and 90 deletions
+31 -1
View File
@@ -11,6 +11,8 @@ import assert from 'node:assert/strict';
import { frontier as pack } from '../content/frontier/index.js';
import { startGame, currentTurn, takeTurn } from '../src/engine/game.js';
import { check } from '../src/engine/conditions.js';
import { applyEffects } from '../src/engine/effects.js';
import { resolveSchema } from '../src/engine/state.js';
import { play, sweep, median } from './fixtures/strategies.js';
/**
@@ -58,7 +60,7 @@ test('the settlement and the room land on the days the pack says', () => {
const turn = currentTurn(pack, state);
const result = takeTurn(pack, state, turn.options.find((o) => o.available).option.id);
for (const change of result.record.upkeep) {
if (change.label === 'Settlement') settlement.push(state.turn);
if (change.label === 'Wages from Vane') settlement.push(state.turn);
if (change.label === 'Room at the Cordwood') room.push(state.turn);
}
state = result.state;
@@ -250,6 +252,34 @@ test('a player who wants a skill does not wait long for the first door', () => {
}
});
test('the horse and the room are each offered only while they can still be bought', () => {
// A real session was shown "Buy the bay" locked after buying it, and offered
// the room under a description about the horse. See DECISIONS #40.
const offered = (lifestyle) => pack.events
.filter((e) => ['the_sale_barn', 'the_ellis_room'].includes(e.id))
.filter((e) => check({ stage: 'deputy', lifestyle }, e.requires).passed)
.map((e) => e.id);
assert.deepEqual(offered(0), ['the_sale_barn']);
assert.deepEqual(offered(1), ['the_ellis_room']);
assert.deepEqual(offered(2), []);
});
test('paying the book down never takes more than is owed', () => {
// Turn 27 of that session: four dollars owed, twenty taken. See DECISIONS #38.
const schema = resolveSchema(pack);
const payDown = pack.events.find((e) => e.id === 'the_store')
.options.find((o) => o.id === 'pay_down');
const base = startGame(pack, { seed: 'the-book' });
const small = applyEffects({ ...base, money: 110, owed: 4 }, payDown.effects, schema).state;
assert.equal(small.money, 106, 'four owed costs four');
assert.equal(small.owed, 0);
const large = applyEffects({ ...base, money: 110, owed: 50 }, payDown.effects, schema).state;
assert.equal(large.money, 90, 'more than twenty owed costs twenty');
assert.equal(large.owed, 30);
});
test('a deliberate player can put Dutch in their debt', () => {
// The deepest relationship gate in the pack: `send_for_dutch` in the
// marshal's office needs a favour banked two rungs earlier.