@chrischall/warapp-mcp 0.6.0 → 0.8.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 +100 -7
- package/dist/analysis/accept-surrender.js +20 -2
- package/dist/analysis/calibrate.js +1 -0
- package/dist/analysis/card-support.js +187 -20
- package/dist/analysis/card-threats.js +68 -3
- package/dist/analysis/chat-advice.js +182 -0
- package/dist/analysis/chat-blocks.js +106 -0
- package/dist/analysis/chat-intent.js +559 -0
- package/dist/analysis/chat-read.js +159 -0
- package/dist/analysis/coalition.js +55 -0
- package/dist/analysis/decision-replay.js +279 -0
- package/dist/analysis/decision-truth.js +146 -0
- package/dist/analysis/finished-game.js +62 -3
- package/dist/analysis/game-lessons.js +12 -6
- package/dist/analysis/local-deploy.js +14 -0
- package/dist/analysis/opponent-profile.js +46 -3
- package/dist/analysis/opponents.js +246 -19
- package/dist/analysis/outlook.js +323 -17
- package/dist/analysis/picks.js +270 -37
- package/dist/analysis/plan/after-leftover.js +28 -3
- package/dist/analysis/plan/captures.js +80 -16
- package/dist/analysis/plan/completed.js +8 -1
- package/dist/analysis/plan/conceded-out.js +16 -11
- package/dist/analysis/plan/deploy-estimates.js +513 -0
- package/dist/analysis/plan/doomed-out.js +135 -0
- package/dist/analysis/plan/estimates.js +73 -7
- package/dist/analysis/plan/free-capture.js +34 -0
- package/dist/analysis/plan/guard-off.js +2 -1
- package/dist/analysis/plan/holds.js +85 -313
- package/dist/analysis/plan/horizon.js +42 -0
- package/dist/analysis/plan/leftover.js +188 -10
- package/dist/analysis/plan/observe.js +896 -0
- package/dist/analysis/plan/orders.js +35 -1
- package/dist/analysis/plan/relations.js +115 -2
- package/dist/analysis/plan/report.js +10 -4
- package/dist/analysis/plan/shared.js +7 -1189
- package/dist/analysis/plan/stand-still.js +7 -5
- package/dist/analysis/plan/state.js +12 -0
- package/dist/analysis/plan/stockpile.js +104 -0
- package/dist/analysis/plan/strike-stack.js +467 -0
- package/dist/analysis/plan/strike.js +8 -441
- package/dist/analysis/plan/targets.js +374 -72
- package/dist/analysis/plan/threats.js +120 -9
- package/dist/analysis/plan/transfers.js +35 -1
- package/dist/analysis/plan/two-move.js +70 -0
- package/dist/analysis/plan/vacated.js +124 -2
- package/dist/analysis/plan/withdraw.js +316 -0
- package/dist/analysis/planner.js +356 -53
- package/dist/analysis/player.js +4 -0
- package/dist/analysis/relations.js +8 -2
- package/dist/analysis/since-last.js +18 -5
- package/dist/analysis/stress.js +1 -1
- package/dist/board.js +36 -2
- package/dist/build-id.js +106 -0
- package/dist/bundle.js +15863 -10242
- package/dist/chat-automation.js +22 -0
- package/dist/client.js +14 -0
- package/dist/decision-log.js +1093 -0
- package/dist/finished-store.js +5 -1
- package/dist/lessons-store.js +322 -21
- package/dist/my-games.js +2 -0
- package/dist/open-games.js +122 -18
- package/dist/outlook-log.js +42 -1
- package/dist/protocol/methods.js +4 -2
- package/dist/review-export.js +198 -0
- package/dist/state-bundle.js +62 -3
- package/dist/state-cli.js +5 -3
- package/dist/strategy/notes.js +56 -0
- package/dist/tools/accept-surrender.js +23 -9
- package/dist/tools/award.js +5 -1
- package/dist/tools/card-advice.js +102 -33
- package/dist/tools/card-support-advice.js +53 -8
- package/dist/tools/chat-advice.js +330 -0
- package/dist/tools/chat-inbox.js +15 -4
- package/dist/tools/chat.js +41 -11
- package/dist/tools/check-plan.js +16 -3
- package/dist/tools/commander-check.js +2 -1
- package/dist/tools/decision-capture.js +461 -0
- package/dist/tools/end-of-game.js +146 -18
- package/dist/tools/game-kind.js +92 -0
- package/dist/tools/how-lost.js +7 -2
- package/dist/tools/index.js +3 -0
- package/dist/tools/join-game.js +51 -9
- package/dist/tools/live-context.js +6 -0
- package/dist/tools/live.js +43 -6
- package/dist/tools/map-curves.js +73 -0
- package/dist/tools/notifications.js +4 -3
- package/dist/tools/open-games.js +2 -2
- package/dist/tools/opponents.js +2 -0
- package/dist/tools/past-games.js +74 -8
- package/dist/tools/picks.js +169 -57
- package/dist/tools/profile-hook.js +62 -3
- package/dist/tools/profile-opponents.js +2 -0
- package/dist/tools/push.js +2 -2
- package/dist/tools/relations.js +2 -0
- package/dist/tools/scout.js +16 -2
- package/dist/tools/state.js +6 -1
- package/dist/tools/strategy.js +3 -3
- package/dist/tools/stress-opponents.js +2 -0
- package/dist/tools/surrender-pending.js +10 -1
- package/dist/tools/surrender.js +18 -3
- package/dist/tools/turn.js +353 -19
- package/dist/tools/where.js +3 -1
- package/dist/version.js +1 -1
- package/manifest.json +23 -2
- package/mint.yaml +23 -0
- package/package.json +1 -1
- package/server.json +20 -2
- package/skills/warapp-mcp/SKILL.md +42 -8
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
import { bonusTerritories } from '../bonuses.js';
|
|
6
6
|
import { armiesToTake, straightKills } from '../combat.js';
|
|
7
7
|
import { neighborsOf } from '../graph.js';
|
|
8
|
+
import { poolShortfall } from '../local-deploy.js';
|
|
9
|
+
import { noLossNeutral } from './after-leftover.js';
|
|
10
|
+
import { visibleState } from './observe.js';
|
|
8
11
|
import { captureCost } from './shared.js';
|
|
9
12
|
import { byNum } from './util.js';
|
|
10
13
|
import { denialLine, emptyEnemyLine } from './vacated.js';
|
|
@@ -17,7 +20,7 @@ export function capturesPhase(pc, ps, pass, book, threats, hd, tgt) {
|
|
|
17
20
|
}
|
|
18
21
|
/** R3: a completion must leave a frontier I can hold; No-Split (#124): a stack that must hold. */
|
|
19
22
|
export function captureRules(pc, ps, book, threats, hd) {
|
|
20
|
-
const { g, s, foe, goal, guarded, reserve, deployOf, territories: state, label, bonusName, mine, mineSet, armiesOf, unitsAt, defenceAt, bonusTs, completedBy, guard, toTake, noSplit, myCommanders, } = pc;
|
|
23
|
+
const { g, s, foe, goal, guarded, reserve, deployOf, territories: state, label, bonusName, mine, mineSet, armiesOf, unitsAt, defenceAt, bonusTs, completedBy, guard, toTake, noSplit, myCommanders, rates, } = pc;
|
|
21
24
|
const { warnings, rationale, deployed, avail, captured, survivorsAt, incoming } = ps;
|
|
22
25
|
const { guardAt, valueOf } = book;
|
|
23
26
|
const { holdArmies, nextTurnAt, exposure, borderAt } = threats;
|
|
@@ -39,8 +42,9 @@ export function captureRules(pc, ps, book, threats, hd) {
|
|
|
39
42
|
* The total need is checked, not each member alone: holding the bonus needs every
|
|
40
43
|
* exposed member held. The leftover is as of this check; a later capture this turn
|
|
41
44
|
* may still spend it (defence funds held borders first, so this is rarely material).
|
|
45
|
+
* `lost`: the attackers the capture of `t` loses (#422), for the payback exemption below.
|
|
42
46
|
*/
|
|
43
|
-
const defensible = (t, survivors) => {
|
|
47
|
+
const defensible = (t, survivors, lost) => {
|
|
44
48
|
const after = new Set([...mine, ...captured]);
|
|
45
49
|
const completes = g.map.bonuses
|
|
46
50
|
.filter((b) => {
|
|
@@ -84,6 +88,8 @@ export function captureRules(pc, ps, book, threats, hd) {
|
|
|
84
88
|
.flatMap(exposedOf))
|
|
85
89
|
earlier.set(e.id, Math.max(earlier.get(e.id) ?? 0, e.added));
|
|
86
90
|
let ok = true;
|
|
91
|
+
/** #422: the completions let through on payback, kept only when the capture is (no other bonus refuses it). */
|
|
92
|
+
const payback = [];
|
|
87
93
|
for (const b of completes) {
|
|
88
94
|
const exposed = exposedOf(b.id);
|
|
89
95
|
const total = exposed.reduce((sum, e) => sum + e.added, 0);
|
|
@@ -93,10 +99,28 @@ export function captureRules(pc, ps, book, threats, hd) {
|
|
|
93
99
|
// A completion that adds no exposure (total 0) is never refused: refusing it saves nothing,
|
|
94
100
|
// whatever the earlier completions need (it only adds income).
|
|
95
101
|
if (total === 0 || total + before <= nextIncome + Math.min(spare, held)) {
|
|
102
|
+
// #422: judged holdable now (a later try, with more income), so no longer a payback completion.
|
|
103
|
+
ps.paybackBonuses.delete(b.id);
|
|
96
104
|
if (anyway.length && guarded)
|
|
97
105
|
rationale.push(`Complete bonus ${bonusName(b.id)} though ${anyway.map((e) => label(e.id)).join(', ')} may fall next turn: ${anyway.length === 1 ? 'it is' : 'they are'} exposed whether or not it is completed, so refusing would save nothing.`);
|
|
98
106
|
continue;
|
|
99
107
|
}
|
|
108
|
+
// #422: the payback exemption. A bonus held at the end of this turn pays its value in next turn's
|
|
109
|
+
// income even if it falls straight after, so a completion whose losses — the attackers its captures
|
|
110
|
+
// lose this turn plus the armies left on the members that would fall — are at most that value
|
|
111
|
+
// repays itself in one turn: refusing it only gives the income up.
|
|
112
|
+
if (guarded) {
|
|
113
|
+
const falls = exposed.filter((e) => e.added > 0);
|
|
114
|
+
const left = falls.reduce((n, e) => n + stays(e.id), 0);
|
|
115
|
+
const killed = bonusTerritories(g, b.id)
|
|
116
|
+
.filter((m) => captured.has(m) && !mineSet.has(m))
|
|
117
|
+
.reduce((n, m) => n + (m === t && lost !== undefined ? lost : straightKills(defenceAt(m), rates.defensiveKillRate)), 0);
|
|
118
|
+
if (killed + left <= b.value) {
|
|
119
|
+
const line = `Complete bonus ${bonusName(b.id)} though its frontier cannot be held next turn (it needs ${total} more armies${before ? `, on top of the ${before} this turn's other completions need` : ''}, next income ${nextIncome}): it can lose at most ${killed + left} armies (${killed} killed taking it, ${left} left on ${falls.map((e) => label(e.id)).join(', ')}), no more than the +${b.value} it pays next turn (#422).`;
|
|
120
|
+
payback.push({ line, bonusId: b.id, falls: falls.map((e) => e.id) });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
100
124
|
const worst = [...exposed].sort((a, b) => b.added - a.added || b.need - a.need || a.id - b.id)[0];
|
|
101
125
|
const head = `completing ${bonusName(b.id)} leaves ${label(worst.id)} indefensible (player ${worst.player} can take it for ${worst.take}; next income ${nextIncome})`;
|
|
102
126
|
if (guarded) {
|
|
@@ -114,6 +138,14 @@ export function captureRules(pc, ps, book, threats, hd) {
|
|
|
114
138
|
warnings.push(w);
|
|
115
139
|
}
|
|
116
140
|
}
|
|
141
|
+
if (ok)
|
|
142
|
+
for (const x of payback) {
|
|
143
|
+
if (!rationale.includes(x.line))
|
|
144
|
+
rationale.push(x.line);
|
|
145
|
+
for (const f of x.falls)
|
|
146
|
+
ps.paybackFalls.set(f, x.line);
|
|
147
|
+
ps.paybackBonuses.set(x.bonusId, x.line);
|
|
148
|
+
}
|
|
117
149
|
return ok;
|
|
118
150
|
};
|
|
119
151
|
// ---- No-Split: the whole stack moves (#124) ----
|
|
@@ -476,7 +508,7 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
476
508
|
captured.add(t);
|
|
477
509
|
const survivors = sent - straightKills(defendersSeen(t), rates.defensiveKillRate);
|
|
478
510
|
// A commander strike is never refused by R3: killing the commander eliminates a player.
|
|
479
|
-
if (!strikes.has(t) && !r3Exempt.has(t) && !defensible(t, survivors)) {
|
|
511
|
+
if (!strikes.has(t) && !r3Exempt.has(t) && !defensible(t, survivors, sent - survivors)) {
|
|
480
512
|
// Undo: under a guarded goal a bonus that falls next turn is not completed.
|
|
481
513
|
avail.set(src, avail.get(src) + sent - need);
|
|
482
514
|
const left = (deployed.get(src) ?? 0) - need;
|
|
@@ -516,8 +548,9 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
516
548
|
}
|
|
517
549
|
return true;
|
|
518
550
|
};
|
|
519
|
-
|
|
520
|
-
|
|
551
|
+
// #421: the strike share is said on its own line (planner.ts), not as the caller's reserve.
|
|
552
|
+
if (reserve - pc.strikeShare)
|
|
553
|
+
rationale.push(`Hold a reserve of ${reserve - pc.strikeShare} out of captures.`);
|
|
521
554
|
// ---- 3a. combined (multi-source) captures (R4) ----
|
|
522
555
|
/**
|
|
523
556
|
* The cheapest combined capture of `t` (fewest sources) under exact 0%-luck,
|
|
@@ -630,7 +663,9 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
630
663
|
}
|
|
631
664
|
avail.set(plan.finisher, avail.get(plan.finisher) - plan.armies);
|
|
632
665
|
captured.add(t);
|
|
633
|
-
|
|
666
|
+
// #422: what the combined capture loses — every softener's dead and the finisher's.
|
|
667
|
+
const lost = plan.softeners.reduce((n, x) => n + x.armies - x.survivors, 0) + plan.armies - plan.survivors;
|
|
668
|
+
if (!defensible(t, plan.survivors, lost)) {
|
|
634
669
|
for (const [k, v] of before.avail)
|
|
635
670
|
avail.set(k, v);
|
|
636
671
|
incoming.clear();
|
|
@@ -850,11 +885,11 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
850
885
|
}
|
|
851
886
|
/** Pass 1 (complete a bonus, all or nothing) and pass 2 (advance one a capture at a time, rule 4c(c), 4d). */
|
|
852
887
|
export function bonusPasses(pc, ps, book, hd, tgt, prev) {
|
|
853
|
-
const { g, s, guarded, paybackTurns, territories: state, label, bonusName, mineSet, incomeGain, incomeAfter, defenceAt, bonusTs, completedBy, inFocus, } = pc;
|
|
888
|
+
const { g, s, guarded, capturePaybackTurns: paybackTurns, territories: state, label, bonusName, mineSet, incomeGain, incomeAfter, defenceAt, bonusTs, completedBy, inFocus, } = pc;
|
|
854
889
|
const { warnings, rationale, deployed, avail, captured, combined, moves, survivorsAt, captureOrder, staged, incoming, } = ps;
|
|
855
890
|
const { heldNow, gainWith } = book;
|
|
856
|
-
const { heldBorders, keptIncome, stayAt } = hd;
|
|
857
|
-
const { targets, leadSteps, leadTry, leadNote, bonusTarget, frontierDelta, targetScoreCost, frontierOf, startHold, toFinish, byCloseness, committing, denials, emptyEnemies, } = tgt;
|
|
891
|
+
const { heldBorders, keptIncome, keptHeld, stayAt } = hd;
|
|
892
|
+
const { targets, leadSteps, leadTry, leadNote, bonusTarget, frontierDelta, targetScoreCost, frontierOf, frontierNeeds, startHold, toFinish, byCloseness, committing, denials, emptyEnemies, } = tgt;
|
|
858
893
|
const { worstCase, tryCapture, siblings, fundedOnConceded, bareOn } = prev;
|
|
859
894
|
// ---- pass 1: complete a bonus this turn (all or nothing) ----
|
|
860
895
|
/** Snapshot the captures, deploys and notes so far; the result undoes everything since. */
|
|
@@ -1047,11 +1082,18 @@ export function bonusPasses(pc, ps, book, hd, tgt, prev) {
|
|
|
1047
1082
|
return null;
|
|
1048
1083
|
const f = frontierOf(held, stays);
|
|
1049
1084
|
const next = keptIncome(held);
|
|
1050
|
-
|
|
1085
|
+
// #433: under Local Deployment a bonus's armies deploy only on its own territories, so the gates get only the
|
|
1086
|
+
// free income and the pools of the bonuses they are in: the whole income read "not short" when that was short.
|
|
1087
|
+
const pooled = s.localDeployments ? poolShortfall(g, keptHeld(held), next, frontierNeeds(held, stays)) : null;
|
|
1088
|
+
const short = pooled ? pooled.short : Math.max(0, f.holdCost - next);
|
|
1089
|
+
if (short <= 0 || f.holdCost <= frontierOf(without, stays).holdCost)
|
|
1051
1090
|
return null;
|
|
1091
|
+
const byPools = pooled !== null && f.holdCost <= next;
|
|
1052
1092
|
if (!stopped.some((x) => x.t === t))
|
|
1053
|
-
stopped.push({ t, holdCost: f.holdCost, income: next });
|
|
1054
|
-
return
|
|
1093
|
+
stopped.push({ t, holdCost: f.holdCost, income: next, ...(byPools ? { deployable: pooled.deployable } : {}) });
|
|
1094
|
+
return byPools
|
|
1095
|
+
? `${stoppedLine(t)} and in this 1v1 it opens another gate${gateFoe(t)}: the gates would then need ${f.holdCost} next turn against its one floating deploy; under Local Deployment only ${pooled.deployable} of the next income of ${next} can be deployed on them (the free income and the pools of the bonuses they are in): ${short} short (#297, #433).`
|
|
1096
|
+
: `${stoppedLine(t)} and in this 1v1 it opens another gate${gateFoe(t)}: the gates would then need ${f.holdCost} next turn against its one floating deploy, more than the next income of ${next} (#297).`;
|
|
1055
1097
|
};
|
|
1056
1098
|
/** #297: " facing player P" for the opponent beside `t` (in a 1v1, the one opponent), else nothing. */
|
|
1057
1099
|
const gateFoe = (t) => {
|
|
@@ -1060,6 +1102,17 @@ export function bonusPasses(pc, ps, book, hd, tgt, prev) {
|
|
|
1060
1102
|
.find((x) => x?.kind === 'player' && pc.foe(x.playerId));
|
|
1061
1103
|
return o?.kind === 'player' ? ` facing player ${o.playerId}` : '';
|
|
1062
1104
|
};
|
|
1105
|
+
/**
|
|
1106
|
+
* #426: whether only the fog faces `t` once taken: no neighbour not mine is a player's territory shown with
|
|
1107
|
+
* its armies (a stack in view). A player's territory whose armies the fog hides, or one not shown at all,
|
|
1108
|
+
* is the fog.
|
|
1109
|
+
*/
|
|
1110
|
+
const fogOnlyFaces = (t) => neighborsOf(g, t).every((n) => {
|
|
1111
|
+
if (mineSet.has(n))
|
|
1112
|
+
return true;
|
|
1113
|
+
const st = state.get(n);
|
|
1114
|
+
return !(st?.owner.kind === 'player' && pc.foe(st.owner.playerId) && visibleState(st));
|
|
1115
|
+
});
|
|
1063
1116
|
/**
|
|
1064
1117
|
* Rule 4d's frontier budget, judged with `t` just captured: under a guarded goal, a capture
|
|
1065
1118
|
* that adds a border facing an enemy without completing a bonus (and not focused) is stopped
|
|
@@ -1079,11 +1132,12 @@ export function bonusPasses(pc, ps, book, hd, tgt, prev) {
|
|
|
1079
1132
|
const f = frontierOf(held, stays);
|
|
1080
1133
|
const next = keptIncome(held);
|
|
1081
1134
|
const start = startHold();
|
|
1082
|
-
if (f.holdCost <= next)
|
|
1083
|
-
return null;
|
|
1084
1135
|
// #297: in a 1v1 the start-of-turn hold is no excuse — a capture that opens another gate the next income
|
|
1085
1136
|
// cannot hold is stopped even when this turn's other orders bring the total back under where it started.
|
|
1137
|
+
// #433: nor, under Local Deployment, is a next income the gates' pools and free income cannot carry there.
|
|
1086
1138
|
const gate = pc.profile.format === '1v1' ? gateStop(t) : null;
|
|
1139
|
+
if (f.holdCost <= next && !gate)
|
|
1140
|
+
return null;
|
|
1087
1141
|
if (f.holdCost <= start && !gate)
|
|
1088
1142
|
return null;
|
|
1089
1143
|
// #281: land a static seat left, which a live stack beside it takes free next turn: the border
|
|
@@ -1101,8 +1155,18 @@ export function bonusPasses(pc, ps, book, hd, tgt, prev) {
|
|
|
1101
1155
|
denied.set(t, emptyEnemyLine(pc, t, e));
|
|
1102
1156
|
return null;
|
|
1103
1157
|
}
|
|
1158
|
+
// #426: a no-loss neutral whose new border faces only the fog (no player's territory beside it shown with
|
|
1159
|
+
// its armies): its hold cost prices a stack nobody has seen, and the capture risks only the armies that
|
|
1160
|
+
// land. Not in a 1v1, where #297's gate budget prices the one opponent's floating deploy wherever it is.
|
|
1161
|
+
// The owner's cap (2026-11-22): only while the hold the capture adds is at most the next income (1×);
|
|
1162
|
+
// over it, rule 4d decides as before (a golden synthetic board let one through at 85 against an income of 9).
|
|
1163
|
+
const adds = f.holdCost - frontierOf(without, stays).holdCost;
|
|
1164
|
+
if (!gate && adds <= next && noLossNeutral(pc, tgt, t) && fogOnlyFaces(t)) {
|
|
1165
|
+
denied.set(t, `Take ${label(t)} though holding the frontier next turn would then need ${f.holdCost} (the next income is ${next}): its defenders kill none of the attackers, only the fog faces its new border and the ${adds} it adds are within that income, so all it risks is the armies that land there (#426).`);
|
|
1166
|
+
return null;
|
|
1167
|
+
}
|
|
1104
1168
|
// Only the 1v1 gate budget stops it (rule 4d's start-of-turn escape would have let it through): its own line.
|
|
1105
|
-
if (gate && f.holdCost <= start)
|
|
1169
|
+
if (gate && (f.holdCost <= start || f.holdCost <= next))
|
|
1106
1170
|
return gate;
|
|
1107
1171
|
const why = `${stoppedLine(t)} and the frontier would then need ${f.holdCost} next turn to hold (${f.enemyBorders} enemy-facing borders), more than the next income of ${next} and more than the ${start} it needed at the start of the turn.${gate ? ` In this 1v1 that is another gate${gateFoe(t)} (#297).` : ''}`;
|
|
1108
1172
|
if (!stopped.some((x) => x.t === t))
|
|
@@ -1193,7 +1257,7 @@ export function bonusPasses(pc, ps, book, hd, tgt, prev) {
|
|
|
1193
1257
|
if (stepping === null)
|
|
1194
1258
|
continue;
|
|
1195
1259
|
const worth = p.net === p.value ? `+${p.value}` : `+${p.value}, net +${p.net}`;
|
|
1196
|
-
const reason = (stepping?.reason ?? `advances bonus ${bonusName(p.bonusId)} (${worth}, ${toFinish(p.cost, p
|
|
1260
|
+
const reason = (stepping?.reason ?? `advances bonus ${bonusName(p.bonusId)} (${worth}, ${toFinish(p.cost, p)})`) + leadNote(t);
|
|
1197
1261
|
// Only a lead step (#203) can be funded on a conceded source.
|
|
1198
1262
|
const before = whole || !lead ? undefined : snapshot();
|
|
1199
1263
|
const tried = before && new Map(leadTry);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// #265: a member of a bonus this turn's captures complete that faces an enemy and is short of its
|
|
2
|
+
// hold once the captures land. Rule 1c (#18) and the #122 garrison keep and garrison such members;
|
|
3
|
+
// what neither could fund is the leftover's first call (rule 5, plan/leftover.ts), and a combined
|
|
4
|
+
// capture (#17) it is a source of is rebalanced at the same kills to leave armies on it
|
|
5
|
+
// (plan/captures.ts, `rebalanceCombined`).
|
|
6
|
+
import { paybackLive } from './state.js';
|
|
1
7
|
/**
|
|
2
8
|
* `weakMember(id)`: my open `id` in a positive bonus this turn's captures complete (one I did not
|
|
3
9
|
* hold at the start), next to a visible enemy once the captures land, whose `stays` armies (with
|
|
@@ -8,7 +14,8 @@ export function completedMembers(pc, ps, threats, open, stays) {
|
|
|
8
14
|
const { g, mine, mineSet, completedBy, bonusTs, unitsAt, toTake } = pc;
|
|
9
15
|
const before = new Set(completedBy(mineSet));
|
|
10
16
|
const now = completedBy(new Set([...mine, ...ps.captured]))
|
|
11
|
-
|
|
17
|
+
// #422: a payback completion is expected to fall next turn: its members are no weak members to fund.
|
|
18
|
+
.filter((b) => !before.has(b) && !paybackLive(ps, ps.paybackBonuses, b) && (g.bonusById.get(b)?.value ?? 0) > 0)
|
|
12
19
|
.sort((a, b) => g.bonusById.get(b).value - g.bonusById.get(a).value || a - b);
|
|
13
20
|
const weakMember = (id) => {
|
|
14
21
|
if (!now.length || !mineSet.has(id) || !open(id))
|
|
@@ -20,6 +20,21 @@ import { teamFocusLine } from './team.js';
|
|
|
20
20
|
import { byNum } from './util.js';
|
|
21
21
|
/** #272: a target holding at most this many armies is "empty or near-empty". */
|
|
22
22
|
export const CONCEDED_OUT_MAX = 2;
|
|
23
|
+
/**
|
|
24
|
+
* #286: rule 1c keeps my `x` — a positive bonus containing it is completed by this turn's captures —
|
|
25
|
+
* so its armies would not withdraw: they are its garrison, not a free step. Live, a +2 member
|
|
26
|
+
* attacked out with 3 into an uneconomic bonus, was kept, and ended 1 army short of its hold.
|
|
27
|
+
*/
|
|
28
|
+
export function keptByCompletion(pc, ps, x) {
|
|
29
|
+
const { g, mineSet } = pc;
|
|
30
|
+
const holding = (y) => mineSet.has(y) || ps.captured.has(y);
|
|
31
|
+
return g.map.bonuses.some((b) => {
|
|
32
|
+
if (b.value <= 0)
|
|
33
|
+
return false;
|
|
34
|
+
const ts = bonusTerritories(g, b.id);
|
|
35
|
+
return ts.includes(x) && ts.every(holding) && !ts.every((y) => mineSet.has(y));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
23
38
|
export function attackOutOfConceded(pc, ps, book, hd, tgt, caps) {
|
|
24
39
|
const { g, goal, foe, territories: state, label, bonusName, mineSet, unitsAt, uncounted, defenceAt, costAt, myCommanders, noSplit } = pc;
|
|
25
40
|
const { avail, captured, spared, rationale } = ps;
|
|
@@ -46,17 +61,7 @@ export function attackOutOfConceded(pc, ps, book, hd, tgt, caps) {
|
|
|
46
61
|
}
|
|
47
62
|
return { completes, advances };
|
|
48
63
|
};
|
|
49
|
-
|
|
50
|
-
* #286: rule 1c keeps `x` — a positive bonus containing it is completed by this turn's captures —
|
|
51
|
-
* so its armies would not withdraw: they are its garrison, not a free step. Live, a +2 member
|
|
52
|
-
* attacked out with 3 into an uneconomic bonus, was kept, and ended 1 army short of its hold.
|
|
53
|
-
*/
|
|
54
|
-
const keptBy1c = (x) => g.map.bonuses.some((b) => {
|
|
55
|
-
if (b.value <= 0)
|
|
56
|
-
return false;
|
|
57
|
-
const ts = bonusTerritories(g, b.id);
|
|
58
|
-
return ts.includes(x) && ts.every(holding) && !ts.every((y) => mineSet.has(y));
|
|
59
|
-
});
|
|
64
|
+
const keptBy1c = (x) => keptByCompletion(pc, ps, x);
|
|
60
65
|
const tried = new Set();
|
|
61
66
|
for (;;) {
|
|
62
67
|
const cands = [];
|