Add whole-territory Truthtrance force questions
Verify and publish checkpoint container / container (push) Canceled after 0s

This commit is contained in:
Quintine committed 2026-10-29 03:37:52 +11:00
1 parent 7552bb5394
commit f1007a4ea8
9 files changed
+149 -21

No files matched your search

+30 -8
View File
@@ -6,6 +6,7 @@ export type ForceCountFact = {
zone:
| { kind: 'reserves' }
| { kind: 'tanks' }
| { kind: 'territory'; territory: string }
| { kind: 'location'; territory: string; sector: number };
counter: 'total' | 'normal' | 'elite';
compare: 'eq' | 'gte' | 'lte';
@@ -83,6 +84,14 @@ export function parseForceCountFact(
if (!exactKeys(zone, ['kind']))
throw new Error('Reserve and Tanks facts cannot name a board location.');
parsedZone = { kind: zone.kind };
} else if (zone.kind === 'territory') {
if (
!exactKeys(zone, ['kind', 'territory']) ||
typeof zone.territory !== 'string' ||
!validLocations.some(candidate => candidate.territory === zone.territory)
)
throw new Error('Choose a current board territory.');
parsedZone = { kind: 'territory', territory: zone.territory };
} else if (zone.kind === 'location') {
if (
!exactKeys(zone, ['kind', 'territory', 'sector']) ||
@@ -101,7 +110,7 @@ export function parseForceCountFact(
sector: zone.sector as number,
};
} else {
throw new Error('Choose reserves, the Tanks, or a current board location.');
throw new Error('Choose reserves, the Tanks, a current territory, or a board location.');
}
return {
kind: 'forceCount',
@@ -140,13 +149,24 @@ function chosenPool(player: ForceCountPlayer, fact: ForceCountFact) {
} else {
if (!record(player.forces))
throw new Error('The selected board force pool is malformed.');
const key = location(fact.zone.territory, fact.zone.sector);
totalValue = player.forces[key] ?? 0;
if (eliteState !== undefined) {
if (!record(eliteState.forces))
throw new Error('The selected elite board force pool is malformed.');
eliteValue = eliteState.forces[key] ?? 0;
if (eliteState !== undefined && !record(eliteState.forces))
throw new Error('The selected elite board force pool is malformed.');
const sectors = fact.zone.kind === 'territory'
? territory(fact.zone.territory).sectors
: [fact.zone.sector];
let total = 0, elite = 0;
for (const sector of sectors) {
const key = location(fact.zone.territory, sector);
const sectorTotal = count(player.forces[key] === undefined ? 0 : player.forces[key], 'The selected physical force count');
const storedElite = eliteState?.forces[key];
const sectorElite = count(storedElite === undefined ? 0 : storedElite, 'The selected elite force count');
if (sectorElite > sectorTotal)
throw new Error('The selected elite force count exceeds its physical force pool.');
total = count(total + sectorTotal, 'The selected physical force count');
elite = count(elite + sectorElite, 'The selected elite force count');
}
totalValue = total;
eliteValue = elite;
}
const total = count(totalValue, 'The selected physical force count');
const elite = count(eliteValue, 'The selected elite force count');
@@ -197,6 +217,8 @@ export function forceCountFactText(fact: ForceCountFact): string {
? 'in your reserves'
: fact.zone.kind === 'tanks'
? 'in the Tleilaxu Tanks'
: `in ${territory(fact.zone.territory).name}, sector ${fact.zone.sector}`;
: fact.zone.kind === 'territory'
? `in ${territory(fact.zone.territory).name} across all sectors`
: `in ${territory(fact.zone.territory).name}, sector ${fact.zone.sector}`;
return `you currently have ${comparison} ${fact.value} ${counters} ${zone}`;
}