@chrischall/warapp-mcp 0.13.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -6
- package/dist/analysis/airlift-plan.js +288 -0
- package/dist/analysis/blockade-plan.js +178 -0
- package/dist/analysis/bomb-plan.js +72 -0
- package/dist/analysis/card-threats.js +10 -9
- package/dist/analysis/cards-in-effect.js +20 -0
- package/dist/analysis/combat.js +5 -0
- package/dist/analysis/coordination.js +47 -0
- package/dist/analysis/income-calibration.js +280 -0
- package/dist/analysis/intel.js +1 -1
- package/dist/analysis/lookahead.js +4 -0
- package/dist/analysis/opponents.js +52 -3
- package/dist/analysis/plan/deploy-estimates.js +1 -1
- package/dist/analysis/plan/estimates.js +40 -6
- package/dist/analysis/plan/relations.js +57 -8
- package/dist/analysis/plan/threats.js +1 -1
- package/dist/analysis/player-record.js +1 -0
- package/dist/analysis/relations.js +40 -0
- package/dist/analysis/stress.js +42 -2
- package/dist/analysis/turn-sim.js +62 -0
- package/dist/bundle.js +24486 -21811
- package/dist/card-state.js +157 -0
- package/dist/decision-log.js +44 -5
- package/dist/local-time.js +142 -0
- package/dist/relations-store.js +30 -5
- package/dist/tools/airlift-readback.js +87 -0
- package/dist/tools/alternative-orders.js +21 -0
- package/dist/tools/begin-turn.js +19 -5
- package/dist/tools/calibration-harness.js +102 -0
- package/dist/tools/calibration.js +110 -0
- package/dist/tools/card-advice.js +5 -4
- package/dist/tools/card-plays.js +32 -20
- package/dist/tools/card-state-view.js +26 -0
- package/dist/tools/card-support-advice.js +25 -8
- package/dist/tools/chat-inbox.js +1 -1
- package/dist/tools/chat.js +1 -1
- package/dist/tools/check-plan.js +113 -9
- package/dist/tools/common.js +14 -0
- package/dist/tools/decision-capture.js +14 -1
- package/dist/tools/game.js +11 -2
- package/dist/tools/index.js +13 -1
- package/dist/tools/notifications.js +1 -1
- package/dist/tools/opponents.js +2 -0
- package/dist/tools/player-card-readback.js +45 -0
- package/dist/tools/relations.js +146 -14
- package/dist/tools/sanctions-played.js +51 -0
- package/dist/tools/stress-opponents.js +8 -4
- package/dist/tools/turn-history.js +214 -0
- package/dist/tools/turn.js +504 -20
- package/dist/turn-orders.js +64 -0
- package/dist/version.js +1 -1
- package/manifest.json +17 -2
- package/mint.yaml +7 -0
- package/package.json +1 -1
- package/server.json +8 -2
- package/skills/warapp-mcp/SKILL.md +9 -1
package/dist/analysis/intel.js
CHANGED
|
@@ -56,7 +56,7 @@ export function resolveIntel(stored, turn, args) {
|
|
|
56
56
|
}
|
|
57
57
|
report.applied.knownIncome = fresh.map((i) => ({ player: i.player, income: i.income, statedTurn: i.turn }));
|
|
58
58
|
if (fresh.length)
|
|
59
|
-
out.knownIncome = fresh.map((i) => ({ player: i.player, income: i.income }));
|
|
59
|
+
out.knownIncome = fresh.map((i) => ({ player: i.player, income: i.income, source: 'chat' }));
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
for (const st of report.stale)
|
|
@@ -26,6 +26,10 @@ export function twoStepReaches(input) {
|
|
|
26
26
|
graph,
|
|
27
27
|
board,
|
|
28
28
|
deploys: [...myDeploys, ...deploys],
|
|
29
|
+
...(input.bombs?.length ? { bombs: input.bombs.map((target) => ({ player: me, target })) } : {}),
|
|
30
|
+
...(input.abandons?.length ? { abandons: input.abandons.map((w) => ({ ...w, player: me })) } : {}),
|
|
31
|
+
...(input.blockades?.length ? { blockades: input.blockades.map((w) => ({ ...w, player: me })) } : {}),
|
|
32
|
+
...(input.airlifts?.length ? { airlifts: input.airlifts.map((a) => ({ ...a, player: me })) } : {}),
|
|
29
33
|
orders: [{ player: me, orders: myOrders }, ...(theirs ? [theirs] : [])],
|
|
30
34
|
moveOrder,
|
|
31
35
|
...(input.settings ? { settings: input.settings } : {}),
|
|
@@ -138,6 +138,13 @@ const byNum = (a, b) => a - b;
|
|
|
138
138
|
* calibration run.
|
|
139
139
|
*/
|
|
140
140
|
export const RISE_CAP = 1.3;
|
|
141
|
+
/**
|
|
142
|
+
* #567 (owner decision 2026-11-25): a turn read from at least this share of its frontier
|
|
143
|
+
* ({@link ObservedTurn.coverage}) is evidence enough that its low end (every ambiguous army read as a move,
|
|
144
|
+
* at most its could-earn cap) was deployed: the {@link RISE_CAP} hold never stays below it. Offline, on the
|
|
145
|
+
* calibration records, no turn read at 60% or more had a low end above the truth.
|
|
146
|
+
*/
|
|
147
|
+
export const RISE_LOW_COVERAGE = 0.6;
|
|
141
148
|
/** #418: my armies in view against its own, at or above which I lead it on the board ({@link ObservedTurn.leadIncome}). */
|
|
142
149
|
export const LEAD_ARMIES = 3;
|
|
143
150
|
/**
|
|
@@ -194,7 +201,9 @@ export function incomeBasis(t) {
|
|
|
194
201
|
return t.incomeRise
|
|
195
202
|
? t.incomeRise.proven !== undefined
|
|
196
203
|
? `max observed over ${span}, ${range}, held at the +${t.incomeRise.proven} a capture with every source in view proved (above ${RISE_CAP}× the ~${t.incomeRise.before} before it): no turn read in full reached ${t.incomeRise.read}`
|
|
197
|
-
:
|
|
204
|
+
: t.incomeRise.low !== undefined
|
|
205
|
+
? `max observed over ${span}, ${range}, held at the +${t.incomeRise.low} a turn read from ${Math.round(RISE_LOW_COVERAGE * 100)}% or more of its frontier surely deployed (above ${RISE_CAP}× the ~${t.incomeRise.before} before it): no turn read in full reached ${t.incomeRise.read}`
|
|
206
|
+
: `max observed over ${span}, ${range}, held to ${RISE_CAP}× the ~${t.incomeRise.before} before it: no turn read in full reached ${t.incomeRise.read}`
|
|
198
207
|
: `max observed over ${span}, ${range}, a rise held to ${RISE_CAP}× a turn`;
|
|
199
208
|
if (t.incomeMethod === 'tripped')
|
|
200
209
|
return t.incomeTrip
|
|
@@ -539,6 +548,32 @@ function fogCapturePattern(observed) {
|
|
|
539
548
|
const income = Math.min(last.cap, Math.ceil(armies / (last.from - hits[0].from + 1)));
|
|
540
549
|
return { turns: hits.map((x) => x.from), armies, income };
|
|
541
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* #567: the turn of `window` whose low end (at most its could-earn cap) is highest, the newest on a tie,
|
|
553
|
+
* when that low end is above `income`; else `null`. Pure.
|
|
554
|
+
*/
|
|
555
|
+
export function observedLowOf(window, income) {
|
|
556
|
+
if (income === null)
|
|
557
|
+
return null;
|
|
558
|
+
let top = null;
|
|
559
|
+
for (const x of window)
|
|
560
|
+
if (!top || Math.min(x.low, x.cap) >= Math.min(top.low, top.cap))
|
|
561
|
+
top = x;
|
|
562
|
+
if (!top || Math.min(top.low, top.cap) <= income)
|
|
563
|
+
return null;
|
|
564
|
+
return { low: Math.min(top.low, top.cap), high: Math.min(top.high, top.cap), turn: top.from, coverage: top.coverage?.share ?? null };
|
|
565
|
+
}
|
|
566
|
+
/** #567: the warning that a tracked income is held below what a turn of its window surely read. */
|
|
567
|
+
export function observedLowWarning(player, income, o, method) {
|
|
568
|
+
const read = o.coverage !== null ? `, from ${Math.round(o.coverage * 100)}% of its frontier` : '';
|
|
569
|
+
const range = o.high > o.low ? `, up to +${o.high}` : '';
|
|
570
|
+
const why = method === 'tripped'
|
|
571
|
+
? 'the over-read tripwire keeps the readings before its step at most the stepped figure (#418)'
|
|
572
|
+
: `a rise no turn read in full confirmed is held to ${RISE_CAP}× a turn (#418)`;
|
|
573
|
+
return (`Player ${player}'s income is held at ~${income}, but turn ${o.turn} read it deploying at least +${o.low}${range}${read} (#567): ` +
|
|
574
|
+
`${why}, so the plan sizes its borders for ~${income}. To test the low end, pass known_income ${o.low} for it to ` +
|
|
575
|
+
'warapp_check_plan (a board figure: it moves no other opponent, #567).');
|
|
576
|
+
}
|
|
542
577
|
/**
|
|
543
578
|
* #418: {@link trackedIncome} with the tripwire's ceiling on the readings of the turns it covers: those
|
|
544
579
|
* count at most its value, the later ones whole; method `tripped` when that lowers the figure.
|
|
@@ -686,12 +721,21 @@ function carryIncome(observed) {
|
|
|
686
721
|
const before = Math.max(prev.income, x.visibleIncome);
|
|
687
722
|
// #418: proof may always raise an estimate: the hold never goes below a capture floor in the window.
|
|
688
723
|
const proof = Math.max(0, ...window.map((w) => w.captureFloor ?? 0));
|
|
689
|
-
|
|
724
|
+
// #567: nor below the low end of a turn read from RISE_LOW_COVERAGE or more of its frontier.
|
|
725
|
+
const low = disproved
|
|
726
|
+
? 0
|
|
727
|
+
: Math.max(0, ...window.filter((w) => (w.coverage?.share ?? 0) >= RISE_LOW_COVERAGE).map((w) => Math.min(w.low, w.cap)));
|
|
728
|
+
const limit = Math.max(disproved ? prev.income : Math.ceil(before * RISE_CAP - 1e-9), proof, low);
|
|
690
729
|
// #418 review: the lead is judged against the carry before the rise (or its visible income), never
|
|
691
730
|
// against the reading being judged: an over-read above my income must not switch its own cap off.
|
|
692
731
|
carry =
|
|
693
732
|
(x.leadIncome ?? 0) > before && !fresh.confirmed && fresh.income > limit
|
|
694
|
-
? {
|
|
733
|
+
? {
|
|
734
|
+
...fresh,
|
|
735
|
+
income: limit,
|
|
736
|
+
set: limit,
|
|
737
|
+
rise: { read: fresh.income, before, ...(proof >= limit ? { proven: proof } : low >= limit ? { low } : {}) },
|
|
738
|
+
}
|
|
695
739
|
: fresh;
|
|
696
740
|
}
|
|
697
741
|
}
|
|
@@ -1203,6 +1247,10 @@ export function trackOpponents(g, boards, me, settings = {}, game) {
|
|
|
1203
1247
|
if (earnedAtLeast.exceedsTotal)
|
|
1204
1248
|
warnings.push(`${head}; it could be banking more than your total visible armies (${visibleArmies}).`);
|
|
1205
1249
|
}
|
|
1250
|
+
// #567: a turn of the window surely read more than the income held: said, never applied.
|
|
1251
|
+
const observedLow = observed.length >= TRACKED_MIN_TURNS ? observedLowOf(incomeWindow, income) : null;
|
|
1252
|
+
if (observedLow)
|
|
1253
|
+
warnings.push(observedLowWarning(nameOf(playerId), income, observedLow, estimate.method));
|
|
1206
1254
|
if (jump)
|
|
1207
1255
|
warnings.push(`Player ${nameOf(playerId)}'s ${incomeJumpText(jump, income, observed.filter((x) => x.from >= jump.since && x.from < jump.turn))}`);
|
|
1208
1256
|
if (firstSeen === null) {
|
|
@@ -1464,6 +1512,7 @@ export function trackOpponents(g, boards, me, settings = {}, game) {
|
|
|
1464
1512
|
incomeLowered: carried ? carried.set - carried.income : 0,
|
|
1465
1513
|
...(incomeRise ? { incomeRise } : {}),
|
|
1466
1514
|
...(incomeTrip ? { incomeTrip } : {}),
|
|
1515
|
+
...(observedLow ? { observedLow } : {}),
|
|
1467
1516
|
unexplained,
|
|
1468
1517
|
inferred,
|
|
1469
1518
|
topUp: observed.reduce((n, x) => (x.topUp === undefined ? n : Math.max(n ?? 0, x.topUp)), null),
|
|
@@ -199,7 +199,7 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
|
|
|
199
199
|
: null;
|
|
200
200
|
const priorFull = prior && fogBeside ? Math.min(Math.max(0, Math.floor(priorBase)), priorCap ?? couldEarn) : null;
|
|
201
201
|
// #444: incomes other players stated scale this one's prior down by their ratio to mine (never up).
|
|
202
|
-
const statedRatio = prior?.stated && !prior.stated.players.some((x) => x.id === playerId) ? prior.stated.
|
|
202
|
+
const statedRatio = prior?.stated && !prior.stated.players.some((x) => x.id === playerId) ? prior.stated.scale : null;
|
|
203
203
|
const priorFigure = priorFull !== null && statedRatio !== null ? Math.min(priorFull, Math.ceil(priorFull * statedRatio - 1e-9)) : priorFull;
|
|
204
204
|
// #419: the past winners' pace, as the prior is figured (capped, scaled, only beside the fog), when above it.
|
|
205
205
|
const paceIncome = prior?.winnerPace ? fogPaceIncome(prior.winnerPace, prior.myIncome) : null;
|
|
@@ -102,21 +102,32 @@ export function planEnemyEstimates(input) {
|
|
|
102
102
|
const priced = applyKnown(applyArmyPrice(applySanctions(estimates, input.sanctions ?? [], turn), input.settings?.armyCostMultiplier ?? 0), input.known ?? []);
|
|
103
103
|
return { estimates: priced, prior, ...(skipped ? { priorSkipped: skipped } : {}) };
|
|
104
104
|
}
|
|
105
|
+
/** #567: the fewest players in view with an income stated in chat before #444's scale applies. */
|
|
106
|
+
export const MIN_STATED_PLAYERS = 2;
|
|
105
107
|
/**
|
|
106
|
-
* #
|
|
107
|
-
*
|
|
108
|
+
* #567: the scale is (mean stated ÷ my income) to this power: the square root, so a stated mean half mine
|
|
109
|
+
* scales the others' prior to ~0.71 of it, not 0.5. Offline evidence (13 finished FFAs, true incomes): the
|
|
110
|
+
* full ratio set the others' prior far below their truth.
|
|
111
|
+
*/
|
|
112
|
+
export const STATED_DAMPING = 0.5;
|
|
113
|
+
/**
|
|
114
|
+
* #444: the incomes stated in chat (`known` with `source: 'chat'`, #567) for players in view (not me) scale
|
|
115
|
+
* the prior of every other opponent when their mean is below my income: `EnemyIncomePrior.stated`. #567: only
|
|
116
|
+
* from {@link MIN_STATED_PLAYERS} such players, and by the mean's ratio to mine to the {@link STATED_DAMPING}
|
|
117
|
+
* power (`scale`; `ratio` keeps the ratio itself). A `board` income (the default) never scales anyone. The prior
|
|
118
|
+
* unchanged otherwise.
|
|
108
119
|
*/
|
|
109
120
|
function statedScale(prior, board, me, known) {
|
|
110
121
|
if (!prior || !known.length || prior.myIncome <= 0)
|
|
111
122
|
return prior;
|
|
112
123
|
const inView = new Set(board.territories.flatMap((t) => (t.owner.kind === 'player' ? [t.owner.playerId] : [])));
|
|
113
124
|
const players = known
|
|
114
|
-
.filter((k) => k.player !== me && inView.has(k.player))
|
|
125
|
+
.filter((k) => k.source === 'chat' && k.player !== me && inView.has(k.player))
|
|
115
126
|
.map((k) => ({ id: k.player, income: Math.max(0, Math.floor(k.income)) }));
|
|
116
|
-
if (
|
|
127
|
+
if (players.length < MIN_STATED_PLAYERS)
|
|
117
128
|
return prior;
|
|
118
|
-
const
|
|
119
|
-
return
|
|
129
|
+
const raw = players.reduce((n, x) => n + x.income, 0) / players.length / prior.myIncome;
|
|
130
|
+
return raw < 1 ? { ...prior, stated: { players, mine: prior.myIncome, ratio: raw, scale: raw ** STATED_DAMPING } } : prior;
|
|
120
131
|
}
|
|
121
132
|
/**
|
|
122
133
|
* #368: each estimate whose player the user gave a known income for (what it said in chat, say): that
|
|
@@ -135,6 +146,29 @@ export function applyKnown(estimates, known) {
|
|
|
135
146
|
return { ...e, estimate: income + card, known: { income, was: e.estimate - card } };
|
|
136
147
|
});
|
|
137
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* #567: the opponents whose estimate the #444 scale moved: each in `scaled` (estimates made with the known
|
|
151
|
+
* incomes) whose fog prior was scaled (`stated`) and whose estimate differs from `plain` (made without them).
|
|
152
|
+
* A player whose own income was given (`known`) is left out: its figure is the one supplied. Ascending ids. Pure.
|
|
153
|
+
*/
|
|
154
|
+
export function statedShifts(plain, scaled, prior) {
|
|
155
|
+
if (!prior?.stated)
|
|
156
|
+
return [];
|
|
157
|
+
const before = new Map(plain.map((e) => [e.playerId, e.estimate]));
|
|
158
|
+
return scaled
|
|
159
|
+
.filter((e) => e.stated && !e.known && before.has(e.playerId) && before.get(e.playerId) !== e.estimate)
|
|
160
|
+
.map((e) => ({ player: e.playerId, was: before.get(e.playerId), now: e.estimate, by: prior.stated.players }))
|
|
161
|
+
.sort((a, b) => a.player - b.player);
|
|
162
|
+
}
|
|
163
|
+
/** #567: the warning naming each opponent a known income moved (#444), and by how much; `null` with none. */
|
|
164
|
+
export function statedShiftWarning(shifts, name = String) {
|
|
165
|
+
if (!shifts.length)
|
|
166
|
+
return null;
|
|
167
|
+
const by = shifts[0].by.map((x) => `player ${name(x.id)}'s ${x.income}`).join(', ');
|
|
168
|
+
const moved = shifts.map((x) => `player ${name(x.player)} ~${x.was} → ~${x.now}`).join(', ');
|
|
169
|
+
return (`The known income${shifts[0].by.length === 1 ? '' : 's'} given (${by}) moved ${shifts.length === 1 ? 'another opponent\'s estimate' : 'other opponents\' estimates'}: ${moved} (#444: ` +
|
|
170
|
+
'incomes stated in chat scale the fog prior of every opponent who stated none). To size them without it, give those incomes source "board" or leave them out.');
|
|
171
|
+
}
|
|
138
172
|
/**
|
|
139
173
|
* #332: in a commerce game with a rising army price (multiplier m > 0), what each estimate read off the board
|
|
140
174
|
* (`visible`, `exact`: its base and bonuses, in gold) buys in armies, its Reinforcement card's armies kept on top.
|
|
@@ -334,6 +334,7 @@ function capsOf(pc) {
|
|
|
334
334
|
const { truce } = pc;
|
|
335
335
|
const capped = new Map();
|
|
336
336
|
const borderOf = new Map();
|
|
337
|
+
const promised = new Set();
|
|
337
338
|
truce.given.forEach((r, i) => {
|
|
338
339
|
if (!truce.binds[i] || r.borderCap === undefined || truce.enforced.has(r.player))
|
|
339
340
|
return;
|
|
@@ -342,7 +343,26 @@ function capsOf(pc) {
|
|
|
342
343
|
for (const t of ts)
|
|
343
344
|
capped.set(t, Math.min(capped.get(t) ?? Infinity, Math.max(0, Math.floor(r.borderCap))));
|
|
344
345
|
});
|
|
345
|
-
|
|
346
|
+
// A territory cap I promised binds while the truce does, on a territory of mine, like a border cap.
|
|
347
|
+
truce.given.forEach((r, i) => {
|
|
348
|
+
if (!truce.binds[i] || !r.territoryCaps?.length)
|
|
349
|
+
return;
|
|
350
|
+
const ts = borderOf.get(i) ?? [];
|
|
351
|
+
for (const c of r.territoryCaps) {
|
|
352
|
+
if (!pc.mineSet.has(c.territory))
|
|
353
|
+
continue;
|
|
354
|
+
const max = Math.max(0, Math.floor(c.max));
|
|
355
|
+
if (max < (capped.get(c.territory) ?? Infinity)) {
|
|
356
|
+
capped.set(c.territory, max);
|
|
357
|
+
promised.add(c.territory);
|
|
358
|
+
}
|
|
359
|
+
if (!ts.includes(c.territory))
|
|
360
|
+
ts.push(c.territory);
|
|
361
|
+
}
|
|
362
|
+
if (ts.length)
|
|
363
|
+
borderOf.set(i, ts.sort(byNum));
|
|
364
|
+
});
|
|
365
|
+
const caps = { borderOf, capped, promised };
|
|
346
366
|
capsMemo.set(pc, caps);
|
|
347
367
|
return caps;
|
|
348
368
|
}
|
|
@@ -399,7 +419,7 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
399
419
|
if (!tp)
|
|
400
420
|
return;
|
|
401
421
|
const { deployed, avail, moves, warnings, rationale, incoming } = ps;
|
|
402
|
-
const { capped, borderOf } = capsOf(pc);
|
|
422
|
+
const { capped, borderOf, promised } = capsOf(pc);
|
|
403
423
|
if (!capped.size)
|
|
404
424
|
return;
|
|
405
425
|
// Another front: a foe's territory no truce covers, else any territory not mine no truce covers.
|
|
@@ -415,6 +435,9 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
415
435
|
truce.given.forEach((r, i) => {
|
|
416
436
|
for (const t of borderOf.get(i) ?? []) {
|
|
417
437
|
const cap = capped.get(t);
|
|
438
|
+
// How the lines name it: a territory cap I promised, or the truce's border cap.
|
|
439
|
+
const capIs = promised.has(t) ? `cap of ${cap} on ${label(t)}` : `border cap ${cap}`;
|
|
440
|
+
const capWord = promised.has(t) ? 'cap' : 'border cap';
|
|
418
441
|
const before = endsAt(pc, ps, t);
|
|
419
442
|
let excess = before - cap;
|
|
420
443
|
if (excess <= 0)
|
|
@@ -486,7 +509,7 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
486
509
|
to: step,
|
|
487
510
|
armies: k,
|
|
488
511
|
kind: 'transfer',
|
|
489
|
-
reason: `keeps the truce's
|
|
512
|
+
reason: `keeps the truce's ${capWord} of ${cap} with player ${r.player} on ${label(t)}`,
|
|
490
513
|
});
|
|
491
514
|
hd.arrived.set(step, (hd.arrived.get(step) ?? 0) + k);
|
|
492
515
|
moved.push({ from: t, to: step, armies: k });
|
|
@@ -497,7 +520,7 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
497
520
|
if (moved.length)
|
|
498
521
|
tp.capMoved.set(i, moved);
|
|
499
522
|
if (said.length || trimmed.length)
|
|
500
|
-
rationale.push(`Truce with player ${r.player} (
|
|
523
|
+
rationale.push(`Truce with player ${r.player} (${capIs}): ${already ? `${label(t)} already stands above the cap with ${armiesOf(t)}, so` : `my orders would leave more than ${cap} on ${label(t)}, so`} ${[...trimmed, ...said].join(' and ')}${said.length && !facesOther ? ', toward another front' : ''} (T5).`);
|
|
501
524
|
if (excess > 0) {
|
|
502
525
|
const dep = deployed.get(t) ?? 0;
|
|
503
526
|
const why = step === undefined && dep > 0
|
|
@@ -510,8 +533,8 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
510
533
|
? ` (Local Deployment: the pools had room for only ${noRoom.shift} of the ${noRoom.off} deployed there on ${label(step)}, and the armies there cannot move again this turn)`
|
|
511
534
|
: ' (the armies there cannot move again this turn)';
|
|
512
535
|
warnings.push(why.endsWith('.')
|
|
513
|
-
? `Truce with player ${r.player}: my orders leave ${excess} above the agreed
|
|
514
|
-
: `Truce with player ${r.player}: my orders leave ${excess} above the agreed
|
|
536
|
+
? `Truce with player ${r.player}: my orders leave ${excess} above the agreed ${capWord} of ${cap} on ${label(t)}${why}`
|
|
537
|
+
: `Truce with player ${r.player}: my orders leave ${excess} above the agreed ${capWord} of ${cap} on ${label(t)}${why}: that breaks a term of the truce.`);
|
|
515
538
|
}
|
|
516
539
|
if (facesOther) {
|
|
517
540
|
// The cap's cost: what it leaves no longer holds the border against another opponent.
|
|
@@ -522,7 +545,7 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
522
545
|
const need = f && !truce.partners.has(f.player) ? Math.max(0, threats.holdArmies(f.threat) - unitsAt(t)) : 0;
|
|
523
546
|
const left = endsAt(pc, ps, t);
|
|
524
547
|
if (f && need > 0 && left < need && before >= need)
|
|
525
|
-
warnings.push(`Truce with player ${r.player} (
|
|
548
|
+
warnings.push(`Truce with player ${r.player} (${capIs}): ${label(t)} also faces player ${f.player}, and the ${left} the cap leaves there do not hold it — its hold needs ${need} against player ${f.player}'s ~${f.threat}. Keep the term, or give notice (notice-by-me) and ask the owner before exceeding the cap; never break it silently.`);
|
|
526
549
|
}
|
|
527
550
|
if (pc.myCommanders.has(t)) {
|
|
528
551
|
// T3 keeps my commander's full hold against the partner; the cap may still thin it below that.
|
|
@@ -533,7 +556,7 @@ export function applyBorderCaps(pc, ps, book, hd, tp, threats) {
|
|
|
533
556
|
const need = f ? Math.max(0, threats.holdArmies(f.threat) - unitsAt(t)) : 0;
|
|
534
557
|
const left = endsAt(pc, ps, t);
|
|
535
558
|
if (f && need > 0 && left < need && before >= need)
|
|
536
|
-
warnings.push(`Truce with player ${r.player} (
|
|
559
|
+
warnings.push(`Truce with player ${r.player} (${capIs}): my commander stands on ${label(t)}, and the ${left} the cap leaves there do not hold it against player ${r.player}'s full attack — its hold needs ${need} against ~${f.threat}. Keep the term, or give notice (notice-by-me) and ask the owner before exceeding the cap; never break it silently.`);
|
|
537
560
|
}
|
|
538
561
|
}
|
|
539
562
|
});
|
|
@@ -848,3 +871,29 @@ export function reportBreakLosses(pc, views, plan) {
|
|
|
848
871
|
plan.rationale.push(`${name}: if it broke this turn — its ~${loss.deploy} deploy on ${label(loss.from)} and an attack on ${label(loss.to)} with ${loss.attackers} — I would lose ${lost}${when} (T6).`);
|
|
849
872
|
});
|
|
850
873
|
}
|
|
874
|
+
/**
|
|
875
|
+
* The territory caps I promised (each binding relation's `territoryCaps`) that `deploys` and `moves`
|
|
876
|
+
* go over: per capped territory of mine, its armies now, plus the deploys there, less the armies moved
|
|
877
|
+
* out, plus those moved in from territories of mine (transfers). For warapp_check_plan's warning.
|
|
878
|
+
*/
|
|
879
|
+
export function territoryCapOverruns(relations, o) {
|
|
880
|
+
const out = [];
|
|
881
|
+
for (const r of relations)
|
|
882
|
+
for (const c of r.territoryCaps ?? []) {
|
|
883
|
+
if (!o.mine.has(c.territory))
|
|
884
|
+
continue;
|
|
885
|
+
let n = o.armiesOf(c.territory);
|
|
886
|
+
for (const d of o.deploys)
|
|
887
|
+
if (d.territoryId === c.territory)
|
|
888
|
+
n += d.armies;
|
|
889
|
+
for (const m of o.moves) {
|
|
890
|
+
if (m.from === c.territory)
|
|
891
|
+
n -= m.armies;
|
|
892
|
+
if (m.to === c.territory && o.mine.has(m.from))
|
|
893
|
+
n += m.armies;
|
|
894
|
+
}
|
|
895
|
+
if (n > c.max)
|
|
896
|
+
out.push({ player: r.player, ...(r.agreement ? { agreement: r.agreement } : {}), territory: c.territory, max: c.max, armies: n });
|
|
897
|
+
}
|
|
898
|
+
return out.sort((a, b) => a.territory - b.territory || a.player - b.player);
|
|
899
|
+
}
|
|
@@ -1105,7 +1105,7 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
1105
1105
|
const st = incomePrior.stated;
|
|
1106
1106
|
const said = st.players.map((x) => `player ${x.id} states ${x.income}`).join(', ');
|
|
1107
1107
|
const mid = e.stated.midpoint;
|
|
1108
|
-
warnings.push(`Player ${p}'s fog prior is scaled by the incomes stated in chat (known_income: ${said}), ${Math.round(st.
|
|
1108
|
+
warnings.push(`Player ${p}'s fog prior is scaled by the incomes stated in chat (known_income: ${said}), ${Math.round(st.scale * 100) / 100}× my ${st.mine} (the square root of their mean's ${Math.round(st.ratio * 100) / 100}× mine, #567): ~${e.stated.scaled} in place of ~${e.stated.full}, never below what is in view or tracked${mid !== null ? `; with no track it is sized at the midpoint ~${mid} between ~${e.stated.lower} and ~${e.stated.scaled} (#368)` : ''}.`);
|
|
1109
1109
|
}
|
|
1110
1110
|
// #368: an income the user supplied replaces the estimate.
|
|
1111
1111
|
if (e.known) {
|
|
@@ -55,6 +55,7 @@ export function recordEntryFor(a, input, previous) {
|
|
|
55
55
|
scopeSize: scope === 'all' ? null : 'territories' in scope ? scope.territories.length : scope.bonuses.length,
|
|
56
56
|
noticeTurns: a.terms.noticeTurns,
|
|
57
57
|
cap: a.terms.borderCap ?? null,
|
|
58
|
+
...(a.caps?.length ? { caps: a.caps.length } : {}),
|
|
58
59
|
endCondition: endCondition(a.terms),
|
|
59
60
|
against: a.terms.against !== undefined,
|
|
60
61
|
},
|
|
@@ -44,6 +44,15 @@ export const TACIT_QUIET_TURNS = 3;
|
|
|
44
44
|
* and the partner's. The partner no longer needs me from there on.
|
|
45
45
|
*/
|
|
46
46
|
export const TRUCE_ENDGAME_RATIO = 0.5;
|
|
47
|
+
/** Territory caps kept per agreement. */
|
|
48
|
+
export const MAX_CAPS = 20;
|
|
49
|
+
/** `a` with `caps` set (one per territory: a new one replaces the old) and `remove` lifted; `caps` absent when none is left. */
|
|
50
|
+
export function withCaps(a, caps, remove = []) {
|
|
51
|
+
const gone = new Set([...remove, ...caps.map((c) => c.territory)]);
|
|
52
|
+
const next = [...(a.caps ?? []).filter((c) => !gone.has(c.territory)), ...caps].slice(-MAX_CAPS);
|
|
53
|
+
const { caps: _old, ...rest } = a;
|
|
54
|
+
return next.length ? { ...rest, caps: next } : rest;
|
|
55
|
+
}
|
|
47
56
|
/**
|
|
48
57
|
* Who an exception lets attack: `mine` — the partner agreed I may attack its covered territories;
|
|
49
58
|
* `theirs` — I agreed the partner may attack (or take) covered territories of mine.
|
|
@@ -250,6 +259,36 @@ function fedByHitSource(t, orders, mine, was, now, me) {
|
|
|
250
259
|
return nowArmies < expectedArmies(m.from, before, orders, mine);
|
|
251
260
|
});
|
|
252
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* A self-check of the territory caps I promised on `a` (its `caps`): on the newest board, each territory
|
|
264
|
+
* of mine holding more than its cap is one `cap-exceeded` flag `by: 'me'` — my breach, not the
|
|
265
|
+
* partner's, so it never feeds {@link trust}. Nothing for a proposal never agreed, or with no caps.
|
|
266
|
+
*/
|
|
267
|
+
export function capSelfCheck(a, boards, me) {
|
|
268
|
+
if (!a.caps?.length || a.agreedTurn === undefined)
|
|
269
|
+
return [];
|
|
270
|
+
const newest = [...boards].sort((x, y) => x.turn - y.turn).at(-1);
|
|
271
|
+
if (!newest)
|
|
272
|
+
return [];
|
|
273
|
+
const at = territoryMap(newest.board);
|
|
274
|
+
const flags = [];
|
|
275
|
+
for (const c of [...a.caps].sort((x, y) => x.territory - y.territory)) {
|
|
276
|
+
const t = visibleState(at.get(c.territory));
|
|
277
|
+
const armies = t?.armies ?? 0;
|
|
278
|
+
if (!t || ownerOn(t) !== me || armies <= c.max)
|
|
279
|
+
continue;
|
|
280
|
+
flags.push({
|
|
281
|
+
kind: 'cap-exceeded',
|
|
282
|
+
by: 'me',
|
|
283
|
+
turn: newest.turn,
|
|
284
|
+
territories: [c.territory],
|
|
285
|
+
armies,
|
|
286
|
+
cap: c.max,
|
|
287
|
+
evidence: `my territory ${c.territory} holds ${armies}, over the cap of ${c.max} I agreed`,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
return flags;
|
|
291
|
+
}
|
|
253
292
|
/**
|
|
254
293
|
* What my boards say about the partner keeping `agreement`, over the consecutive turns from the
|
|
255
294
|
* one it was agreed (and before it ended), as flags with their turn and evidence:
|
|
@@ -622,6 +661,7 @@ export function planRelationsFrom(input) {
|
|
|
622
661
|
state: broke ? 'broken' : state.phase,
|
|
623
662
|
...(state.endsTurn !== undefined ? { endsTurn: state.endsTurn } : {}),
|
|
624
663
|
...(a.terms.borderCap !== undefined ? { borderCap: a.terms.borderCap } : {}),
|
|
664
|
+
...(a.caps?.length ? { territoryCaps: a.caps.map((c) => ({ territory: c.territory, max: c.max })) } : {}),
|
|
625
665
|
trust: verdict.level,
|
|
626
666
|
...(watch.length ? { watch } : {}),
|
|
627
667
|
// T9: `a.enforced` is never read in. No tool writes it, and only a Diplomacy card the decoder is
|
package/dist/analysis/stress.js
CHANGED
|
@@ -79,7 +79,7 @@ import { couldHoldBonusPools, enemyDeployReaching, freeIncome } from './local-de
|
|
|
79
79
|
import { twoStepReaches } from './lookahead.js';
|
|
80
80
|
import { DEFAULT_BASE_INCOME } from './player.js';
|
|
81
81
|
import { ownerShown } from './plan/shared.js';
|
|
82
|
-
import { simTerritories, simulateTurn, } from './turn-sim.js';
|
|
82
|
+
import { roundHalfDown, simTerritories, simulateTurn, } from './turn-sim.js';
|
|
83
83
|
const DEFAULT_MAX_REPLIES = 8;
|
|
84
84
|
/** The chain search's caps (#180), shared with the planner (chains.ts, #199). */
|
|
85
85
|
export { CHAIN_MAX_NODES, CHAIN_MAX_STEPS } from './chains.js';
|
|
@@ -95,10 +95,15 @@ export function stressPlan(input) {
|
|
|
95
95
|
const guard = input.settings?.oneArmyStandsGuard === false ? 0 : 1;
|
|
96
96
|
const myDeploys = input.deploys.map((d) => ({ player: me, territoryId: d.territoryId, armies: d.armies }));
|
|
97
97
|
const myOrders = input.moves.map((m) => ({ ...m }));
|
|
98
|
+
const myAirlifts = (input.airlifts ?? []).map((a) => ({ ...a, player: me }));
|
|
98
99
|
const simulate = (sides, moveOrder) => simulateTurn({
|
|
99
100
|
graph,
|
|
100
101
|
board,
|
|
101
102
|
deploys: [...myDeploys, ...sides.flatMap((x) => (x.deploy > 0 ? [{ player: x.player, territoryId: x.deployTo, armies: x.deploy }] : []))],
|
|
103
|
+
...(input.bombs?.length ? { bombs: input.bombs.map((target) => ({ player: me, target })) } : {}),
|
|
104
|
+
...(input.abandons?.length ? { abandons: input.abandons.map((w) => ({ ...w, player: me })) } : {}),
|
|
105
|
+
...(input.blockades?.length ? { blockades: input.blockades.map((w) => ({ ...w, player: me })) } : {}),
|
|
106
|
+
...(myAirlifts.length ? { airlifts: myAirlifts } : {}),
|
|
102
107
|
orders: [{ player: me, orders: myOrders }, ...sides.map((x) => ({ player: x.player, orders: x.orders }))],
|
|
103
108
|
moveOrder,
|
|
104
109
|
...(input.settings ? { settings: input.settings } : {}),
|
|
@@ -106,7 +111,9 @@ export function stressPlan(input) {
|
|
|
106
111
|
...(input.orderPriority ? { orderPriority: [me] } : {}),
|
|
107
112
|
});
|
|
108
113
|
const baseline = simulate([], [me]);
|
|
109
|
-
|
|
114
|
+
// A territory I wall off (an Emergency Blockade or a Blockade) is given up on purpose: never a loss to a reply.
|
|
115
|
+
const walled = new Set([...(input.abandons ?? []), ...(input.blockades ?? [])].map((w) => w.target));
|
|
116
|
+
const mineAtStart = new Set([...start].filter(([id, t]) => t.owner === me && !walled.has(id)).map(([id]) => id));
|
|
110
117
|
const mineAfter = (r) => new Set([...r.territories].filter(([, t]) => t.owner === me).map(([id]) => id));
|
|
111
118
|
const baseMine = mineAfter(baseline);
|
|
112
119
|
const planned = [...baseMine].filter((id) => !mineAtStart.has(id)).sort(byNum);
|
|
@@ -145,6 +152,35 @@ export function stressPlan(input) {
|
|
|
145
152
|
if (c && c.owner === me && d.armies > 0)
|
|
146
153
|
c.armies += d.armies;
|
|
147
154
|
}
|
|
155
|
+
// My Bombs (phase 30) halve their targets after every deploy, before the Airlifts and moves.
|
|
156
|
+
for (const t of input.bombs ?? []) {
|
|
157
|
+
const c = afterMyDeploys.get(t);
|
|
158
|
+
if (c && c.owner !== 'unknown' && c.owner !== me)
|
|
159
|
+
c.armies = Math.floor(c.armies / 2);
|
|
160
|
+
}
|
|
161
|
+
// My Emergency Blockades (phase 37) wall their territories before the moves.
|
|
162
|
+
for (const w of input.abandons ?? []) {
|
|
163
|
+
const c = afterMyDeploys.get(w.target);
|
|
164
|
+
if (c && c.owner !== 'unknown') {
|
|
165
|
+
c.owner = 'neutral';
|
|
166
|
+
c.armies = roundHalfDown(c.armies * w.multiplier);
|
|
167
|
+
delete c.commander;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// My Airlifts land before any move, so the dodges and chains are searched on the board after them too.
|
|
171
|
+
for (const a of myAirlifts) {
|
|
172
|
+
const src = afterMyDeploys.get(a.from);
|
|
173
|
+
const dst = afterMyDeploys.get(a.to);
|
|
174
|
+
if (!src || !dst || a.from === a.to || src.owner !== me || !friendly(dst.owner))
|
|
175
|
+
continue;
|
|
176
|
+
const sent = Math.max(0, Math.min(Math.floor(a.armies), src.armies));
|
|
177
|
+
src.armies -= sent;
|
|
178
|
+
dst.armies += sent;
|
|
179
|
+
if (a.commander && src.commander === me && dst.owner === me) {
|
|
180
|
+
delete src.commander;
|
|
181
|
+
dst.commander = me;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
148
184
|
const allOf = (s, deploy) => (start.get(s)?.armies ?? 0) + deploy;
|
|
149
185
|
const stacksOf = (id) => [...start]
|
|
150
186
|
.filter(([, t]) => t.owner === id)
|
|
@@ -527,6 +563,10 @@ export function stressPlan(input) {
|
|
|
527
563
|
me,
|
|
528
564
|
opponents: input.opponents,
|
|
529
565
|
deploys: input.deploys,
|
|
566
|
+
...(input.airlifts?.length ? { airlifts: input.airlifts } : {}),
|
|
567
|
+
...(input.bombs?.length ? { bombs: input.bombs } : {}),
|
|
568
|
+
...(input.abandons?.length ? { abandons: input.abandons } : {}),
|
|
569
|
+
...(input.blockades?.length ? { blockades: input.blockades } : {}),
|
|
530
570
|
moves: input.moves,
|
|
531
571
|
...(input.settings ? { settings: input.settings } : {}),
|
|
532
572
|
...(teams ? { teams } : {}),
|
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
// The rules are the wiki's (docs/STRATEGY.md "Turn resolution" links each page):
|
|
5
5
|
// - Deployments come before every attack and transfer, and deployed armies may move that turn.
|
|
6
|
+
// - Bombs (card phase 30, after every deploy, before the Airlifts and the moves): the target keeps half its
|
|
7
|
+
// armies, rounded down — the client bundle's GameOrderPlayCardBombResult: round(armies / 2) with a half rounded
|
|
8
|
+
// down — its special units untouched; a Bomb on the bomber's own territory, or one whose armies are hidden,
|
|
9
|
+
// does nothing.
|
|
10
|
+
// - An Emergency Blockade (card phase 37, after the Bombs, before the Airlifts and moves) and a Blockade (phase 60,
|
|
11
|
+
// after every move) turn their territory neutral with its armies × the card's multiplier, rounded with a half
|
|
12
|
+
// down (the bundle's GameOrderPlayCardAbandonResult / …BlockadeResult); special units on it are lost. A Blockade
|
|
13
|
+
// acts only while its player still holds the territory (one taken during the turn stays taken); the Emergency
|
|
14
|
+
// Blockade does not check (the validator already refused a territory not mine).
|
|
15
|
+
// - Airlifts (card phase 43) run after every deploy and before every attack and transfer: the armies
|
|
16
|
+
// leave their source and land on the destination (the player's own, or a teammate's), where they
|
|
17
|
+
// cannot move again that turn (the wiki's Airlift Card). A commander goes along only to its owner's
|
|
18
|
+
// own territory and has then used its move. An Airlift sends what stands on its source when it runs.
|
|
6
19
|
// - Attack and transfer orders run interleaved in a zigzag over the turn's move order
|
|
7
20
|
// (1 2 … n, n … 2 1, 1 2 … n), each player's next order in each slot. An order that moves
|
|
8
21
|
// no armies takes no slot. An Order Priority card makes its player the first mover for the
|
|
@@ -41,6 +54,11 @@ const ASSUME_LOSSES = 'Losses on a territory that was attacked fell first on the
|
|
|
41
54
|
const ASSUME_SOURCE_LOST = 'An order from a territory that was captured first did nothing (the wiki does not say).';
|
|
42
55
|
const ASSUME_WIPE = 'With the guard off, an attack that wiped out both sides failed and left one defender (the wiki states this rule under the guard setting).';
|
|
43
56
|
const ASSUME_PERCENT = 'A percentage order took its share of the armies its territory could still move, the guard left out (the client rounds the share; what it counts is not stated).';
|
|
57
|
+
/** `x` rounded to the nearest whole number, a half rounded down (the client's `O.Bg(x, false, true)`). */
|
|
58
|
+
export function roundHalfDown(x) {
|
|
59
|
+
const whole = Math.floor(x);
|
|
60
|
+
return x - whole > 0.5 ? whole + 1 : whole;
|
|
61
|
+
}
|
|
44
62
|
/** `pct`% of `n`, rounded to nearest with a half rounded down, as the client works out a percentage order. */
|
|
45
63
|
export function percentOf(pct, n) {
|
|
46
64
|
const x = (pct / 100) * n;
|
|
@@ -93,6 +111,44 @@ export function simulateTurn(input) {
|
|
|
93
111
|
if (c && c.owner === d.player && d.armies > 0)
|
|
94
112
|
c.armies += d.armies;
|
|
95
113
|
}
|
|
114
|
+
// Phase 30: the Bombs. The target keeps round-half-down(armies / 2), i.e. half rounded down.
|
|
115
|
+
for (const b of input.bombs ?? []) {
|
|
116
|
+
const c = cells.get(b.target);
|
|
117
|
+
if (!c || c.owner === 'unknown' || c.owner === b.player)
|
|
118
|
+
continue;
|
|
119
|
+
c.armies = Math.floor(c.armies / 2);
|
|
120
|
+
c.moved = Math.min(c.moved, c.armies);
|
|
121
|
+
}
|
|
122
|
+
/** A wall: the territory neutral at its armies × the multiplier (a half rounded down), its special units lost. */
|
|
123
|
+
const wall = (c, m) => {
|
|
124
|
+
c.owner = 'neutral';
|
|
125
|
+
c.armies = roundHalfDown(c.armies * m);
|
|
126
|
+
c.moved = 0;
|
|
127
|
+
delete c.commander;
|
|
128
|
+
delete c.commanderMoved;
|
|
129
|
+
};
|
|
130
|
+
// Phase 37: the Emergency Blockades.
|
|
131
|
+
for (const w of input.abandons ?? []) {
|
|
132
|
+
const c = cells.get(w.target);
|
|
133
|
+
if (c && c.owner !== 'unknown')
|
|
134
|
+
wall(c, w.multiplier);
|
|
135
|
+
}
|
|
136
|
+
// Phase 43: the Airlifts, after every deploy. What lands cannot move again this turn.
|
|
137
|
+
for (const a of input.airlifts ?? []) {
|
|
138
|
+
const src = cells.get(a.from);
|
|
139
|
+
const dst = cells.get(a.to);
|
|
140
|
+
if (!src || !dst || a.from === a.to || src.owner !== a.player || !friendly(dst.owner, a.player))
|
|
141
|
+
continue;
|
|
142
|
+
const sent = Math.max(0, Math.min(Math.floor(a.armies), src.armies));
|
|
143
|
+
src.armies -= sent;
|
|
144
|
+
dst.armies += sent;
|
|
145
|
+
dst.moved += sent;
|
|
146
|
+
if (a.commander && src.commander === a.player && dst.owner === a.player) {
|
|
147
|
+
delete src.commander;
|
|
148
|
+
dst.commander = a.player;
|
|
149
|
+
dst.commanderMoved = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
96
152
|
/** A player whose commander died: everything it holds turns neutral, and its orders stop. */
|
|
97
153
|
const eliminate = (player) => {
|
|
98
154
|
if (eliminated.includes(player))
|
|
@@ -251,6 +307,12 @@ export function simulateTurn(input) {
|
|
|
251
307
|
takeSlot(p);
|
|
252
308
|
}
|
|
253
309
|
}
|
|
310
|
+
// Phase 60: the Blockades, after every move, only while their player still holds the territory.
|
|
311
|
+
for (const w of input.blockades ?? []) {
|
|
312
|
+
const c = cells.get(w.target);
|
|
313
|
+
if (c && c.owner === w.player)
|
|
314
|
+
wall(c, w.multiplier);
|
|
315
|
+
}
|
|
254
316
|
const territories = new Map();
|
|
255
317
|
for (const [id, c] of cells) {
|
|
256
318
|
territories.set(id, { owner: c.owner, armies: c.armies, ...(c.commander !== undefined ? { commander: c.commander } : {}) });
|