@chrischall/warapp-mcp 0.8.0 → 0.9.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.
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "metadata": {
9
9
  "description": "MCP server for war.app (Warzone) — your games, players, settings, map bonuses and chokepoints, board analysis and route planning through war.app's per-player GameFeed API, plus the live board, territory picks, cards, turn planning and submission, turn notifications and game chat through your signed-in war.app tab (joining, leaving or surrendering a game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
10
- "version": "0.8.0"
10
+ "version": "0.9.0"
11
11
  },
12
12
  "plugins": [
13
13
  {
@@ -15,7 +15,7 @@
15
15
  "displayName": "war.app (Warzone)",
16
16
  "source": "./",
17
17
  "description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
18
- "version": "0.8.0",
18
+ "version": "0.9.0",
19
19
  "author": {
20
20
  "name": "Chris Hall"
21
21
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "warapp-mcp",
3
3
  "displayName": "war.app (Warzone)",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
6
6
  "author": {
7
7
  "name": "Chris Hall",
package/README.md CHANGED
@@ -63,7 +63,7 @@ GameFeed has no list of your games, no player profiles, no live board during the
63
63
  no picks and no way to post chat. Those come from war.app's own web client (its protocol and
64
64
  its profile pages), which is authenticated by your browser's war.app session rather than by
65
65
  the API token. So the live-game tools — `warapp_my_games`, `warapp_scout_player`,
66
- `warapp_get_live_board`, `warapp_get_my_picks`, `warapp_plan_picks`, `warapp_submit_picks`, `warapp_plan_turn`, `warapp_check_plan`,
66
+ `warapp_get_live_board`, `warapp_get_my_picks`, `warapp_get_my_orders`, `warapp_plan_picks`, `warapp_submit_picks`, `warapp_plan_turn`, `warapp_check_plan`,
67
67
  `warapp_track_opponents`, `warapp_locate_opponents`, `warapp_profile_opponents`, `warapp_get_team`, `warapp_team_brief`, `warapp_submit_turn`, `warapp_uncommit_turn`, `warapp_leave_game`, `warapp_send_chat`, `warapp_wait_for_turn`, and `warapp_analyze_board`
68
68
  when GameFeed sends no board — relay each request through your signed-in war.app tab with the [fetchproxy](https://github.com/chrischall/fetchproxy) bridge.
69
69
  They need:
@@ -150,6 +150,7 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
150
150
  | `warapp_plan_route` | Shortest path between two territories, given by name or id. |
151
151
  | `warapp_get_live_board` | The live board through your war.app tab: every territory with its owner (player, `neutral`, or `pickable` during picks), armies and fog, and in a Commanders game whose `commander` stands there. Works in the pick phase and mid-game. `view`: compact / full (every special unit — commanders, bosses — with its owner). Narrow it with `owner` (`me`, `neutral`, `pickable` or a player), `territories`, and `limit`/`offset` paging. Fog levels use war.app's own names: `You` (yours), `Visible`, `OwnerOnly` (owner shown, armies hidden: `armies` is null) and `Fogged` (owner and armies hidden). |
152
152
  | `warapp_get_my_picks` | Your submitted territory picks in priority order, and how many the game allows. |
153
+ | `warapp_get_my_orders` | Your orders for the current turn read back from war.app (what the web client shows in "Modify orders"), read-only: `committed`, `orders` in exactly the shape `warapp_submit_turn` takes (card GUIDs and targets, players by GameFeed id, move options, Order Delay `before`) and `shown` (one line per order, with names). Resubmit them after `warapp_uncommit_turn` to change a committed turn without losing hand-made orders. `null` is unknown, never "none"; `unread` lists orders it could not read back. Committed orders verified live 2026-11-22; entered-but-uncommitted ones unverified. |
153
154
  | `warapp_plan_turn` | A plan for your turn from the live board (defaults to the signed-in account): income, your cards and whether you must play one, deploys and moves by name and id, expected captures, bonuses and next income, the `frontier` budget (borders left, those facing an enemy, what they need to hold next turn, next income), warnings and reasoning, and an `orders` array (card plays included); `chat.unread` counts the chat messages not yet marked seen (counts only, from GameFeed, so every count is under `unknown`; its `note` says so); `surrenderPending` lists other players' surrenders still pending (from the game details, unverified live; `null` when unreadable), and when one waits on your acceptance the first warning says so. `goal`: balanced (default: best income per army across holds, bonuses and breaking enemy bonuses, with at least 30% on expansion) / expand / complete-bonus / defend / siege (one opponent, `siege_target` by GameFeed id, default the strongest one bordering you: its bonus breaks are funded cheapest per income lost first, its other territories are left alone and the spare deploys build one strike stack facing it until the assault trigger fires — its income at 0.6× its baseline — the most the tracker saw it deploy over its window, or its income when the siege began — yours at 1.8× its, or a stack of yours able to take a member of its held bonus against its whole deploy — then the stack strikes; `siege` reports `target`, `opponentIncome`, `baseline`, `ratio`, `fallenTo`, `breaks`, `brokenThisTurn`, `ready`, `trigger` and `memory` — the siege's first turn, its turns, the target's income trend and the bonuses broken and broken again, kept per game while the siege runs, a gap of more than 3 turns starting a new one) — omit it and the game profile (`profile`: the One Army Must Stand Guard case and what it means for interior defence, format, phase, standing) picks it: siege when it fits — in contact and not ahead, against one opponent (in an FFA the leader, earning 1.5× any other opponent beside you) with a bonus break in view costing at most twice its value and at most your income; the plan's reported `goal` is then `siege` (with no `goal` passed it may read `siege` where it read `balanced` or `defend` before: an additive value, so a caller should accept it) and `siege.auto` is set, a line saying why the profile chose the siege (the break that made it fit); `siege.auto` is absent when you passed `goal: 'siege'` yourself; once the assault trigger fires the profile hands back to its own goal (a rationale line says so, and there is no `siege` block) — else defend when behind on income outside a 1v1, else balanced tuned to the format (1v1 in contact: holds and breaks before expansion that completes nothing; behind on income in a 1v1: strike — break their bonuses, inferred ones too, sized to land; behind on armies: no trade below even; in a 1v1, spare deploys build one strike stack facing the opponent; FFA: no second front; ahead in a 1v1: more fog pressure); an explicit goal overrides it; `focus` bonuses; `reserve`; `enemy_deploy` (armies an enemy is assumed to deploy; default per opponent from its visible bonuses, or what it was observed to deploy when that is larger — its tracked income, carried across turns, once `warapp_track_opponents` has 2+ turns of it; growth beside the fog beyond twice what it was expected to deploy reads as a move out of the fog, not a deploy; in an even-start 1v1 or free-for-all an opponent bordering the fog is assumed to earn at least your income, a player out of a free-for-all having its share of the hidden board split among the rest; while its income was read from under half its frontier, an opponent is sized at the midpoint between its lower bound — its tracked figure, raised to its trend's next step when its tracked income rose two turns running — and its upper bound — that fog prior, else the most it could earn — moving toward what the evidence gives as more of its frontier is read; a rising track read from more of its frontier raises it to that lower bound); the `outlook` adds `leaning: behind` when it read even for 3 turns while a bonus of yours fell on each; `known_income` (per-player incomes you know, by GameFeed id — what a player said in chat, say: each replaces that opponent's estimate, a Reinforcement card the clock adds kept on top, said in its warning; `enemy_deploy` wins over it; the commander block keeps the submit's sizing); `min_win_chance` (0.5–1; default 1 = certain captures with no luck, 0.95 with luck on; below 1, each capture is sized for that exact win chance, and the captures a bonus still needs reach it together); `first_mover` (`me` or `opponent`, when you know who moves first this turn — Cycle move orders swap the first mover every turn; when you move first, Order Priority is not advised; the same argument as `warapp_check_plan`'s). Every attack carries `winChance` (its exact probability of capturing at the game's kill rates, luck and rounding); idle armies top an attack up to its next efficient size when the extra kill can matter. Reports the borders it gives up (`conceded`: not worth or not affordable to hold, never deployed to unless every territory you hold is conceded; it may still attack out with the armies already on it; an idle interior stack beside one that would make it hold transfers in, and it is then held), `cardAdvice` (`order-priority` when you hold one and it protects your first order: a commander strike while your commander is threatened, or a move out of a conceded border carrying enough armies to be worth a card — any size when the card must go anyway; never when `first_mover` is `me`; otherwise `order-delay` when you hold Order Delay and the schedule puts an attack last — the orders then carry the card with `before`, placed above the first non-urgent order, see `cards.advice.orderDelay`; an Order Delay that must leave the hand is played there rather than discarded), `cards.advice` for the cards `warapp_submit_turn` plays but the plan never does — `diplomacy` (the opponent tying down most of your border armies, only with two or more in contact, never a truce partner the truce already covers unless the card adds protection), `sanctions` (the leader, passing over a truce partner or a player a Diplomacy card keeps at peace with you, with the reason), `airlift` (a border of yours or a teammate's that falls without it), `gift` (the members that complete a teammate's bonus), `spy` / `reconnaissance` / `surveillance` (only where the fog hides what the plan needs: an opponent out of view, a hidden territory on your border, a fogged member of a bonus you are completing; never with fog off) — each with an `order` to pass as is, never added to the orders (in a team game only cards read under you are played, discarded or advised; unverified live) and `trendSource` (where last turn's board came from — `history`, `cache` or null — for growing enemy stacks). Obeys the game's kill rates, Local Deployment and No-Split (`view: "full"` echoes the settings it assumed: `idleTransfers`, the planner's own switch for moving idle armies, beside the game's own `allowTransferOnly` and `allowAttackOnly`, `null` when GameFeed does not state them). Read-only; refuses outside a turn phase. In a Commanders game a commander counts as 7 armies, your commander's territory is never conceded (it gets the deploys it needs to hold against the worst case — the opponent's whole deploy, at least your own income, plus every enemy stack within two moves — or every army when that is not enough), and an adjacent enemy commander is attacked first, sized for its owner's full deploy. Within three moves of an enemy or the fog, with a safer territory of yours reachable, your commander walks one step a turn toward safety: a move in `orders` with `commander: true` (encoding not yet verified live), said in the first warning; the territory it leaves is held only for its own worth, plus what survives the attacks that may land before the walk (every enemy stack beside it, even when you move first: `warapp_submit_turn` checks both move orders; when that does not fit, each player's strongest attack, with the walk as your first order), no other order leaves it before the walk but a strike that ends a player, and Order Priority is advised for the walk only when even that falls short or the fog borders it; under No-Split a commander kill the walk displaces is named in a warning. Every turn of such a game `commander` reports your commander (#274): its territory, the armies there after the plan, `movesToEnemy` (to the nearest enemy or fog), `killedBy` (the smallest deploy, made by each opponent at once, at which a reply kills it: `player`, and `partner` when it is two opponents striking together; null when none reaches it this turn), and `safe` / `needs` at the larger of the estimate and your income; when it is not safe the first warning says so and whether `warapp_submit_turn` would refuse those orders (it does not without Commanders in the settings, nor when only an `enemy_deploy` what-if makes the commander unsafe). When the server kept your pick list, `award` says what the award of picks showed: the territories of your list that are another player's start for certain (in a two-player game planned as the opponent's while still fogged), whether you were awarded first or second and who moves first this turn under a `Cycle` move order, and with commanders the opponent's first award when the award pins it. `relations` reports each truce recorded with `warapp_record_agreement` as the plan treated it (honoured in a free-for-all; in a team or two-player game only its covered territories stay off-limits): while active or in notice no covered territory of the partner is attacked, a covered border facing only the partner is held against its stacks without a deploy (never your commander's, a border worth more than a quarter of your income, or any while trust is `watch`), and a border cap is kept: no move of yours fills that border past it, and the excess moves one step back (a warning when your own deploy for a hold is what exceeds it — deploy less, or give notice and ask before exceeding it — or when the cap leaves a border that also faces another opponent, or your commander's, short of its hold); `advice` says `give-notice` when the endgame or the partner outgrowing you made the trust `watch`; a truce the board shows broken is planned as an ordinary opponent, with the evidence (record it as `broken-by-them` before submitting: `warapp_submit_turn` reads only the ledger); each honoured truce reports `lossIfBroken` (what you would lose this turn if the partner landed its whole deploy beside your costliest covered territory, from any territory of its there, and attacked, carried out against the plan's orders: territories, armies, bonuses and income; logged per turn in the ledger beside the armies it freed); `tacit` lists quiet borders with no agreement (a report, never a truce). A Diplomacy card in effect between you and a player, read from the live board, is honoured in any format (that player is no threat and no target this turn), and Sanctions on you cut the plan's income (Sanctions on an opponent cut its estimate when that is read off the board, `sanctionsOnOthers`), when the decoder is sure of them (the card in play, its expiry within the game's duration); `cardsInEffect` lists them, marked `verified: false` (the active-card decoder is not yet checked live). Otherwise a warning says what was read and why it was not relied on. In a team game a bonus with a teammate's territory in it is never planned toward (a bonus pays one holder), and `team.sharedBonuses` lists each bonus you and a teammate both hold members of and who is `nearer` to holding it (advisory; team vision unverified). With your teammate's entered orders on the live board (unverified live): of two otherwise equal captures the one on the opponent they attack goes first (a "Team focus" rationale line); `team.support` lists a teammate's border that falls given their orders where your idle armies beside it would make it hold (each idle army offered to one border only, the border needing fewest first: the most borders held, not the most worth); `team.jointCaptures` a target neither of you takes alone but both together, resolved on the turn simulator in both orders (under a cyclic move order, `mustGoFirst`); and `cards.team` says who plays each card of the team hand — a card your teammate has entered is left to them and kept out of your plays. Support and joint captures are advice only (a move onto a teammate's territory is unverified live): never in `orders`. When one opponent touches two or more of your borders and no fixed split of the deploys there holds them all, `guess` offers a randomized split weighted by what each border is worth (each border's chance of being held, the best fixed split's worst case, the mix's expected loss, one draw seeded by the game, the turn and a local secret, so re-planning gives the same draw and the public code cannot reproduce it) and `guessOrders`, the plan's `orders` with that draw in place of its deploys on those borders — optional, a model of one opponent with one deploy, never taking armies off the territory your commander stands on or walks to, and dropped when its draw would be refused by the submit's commander check; the plan's `orders` are unchanged (`view: "full"` says why there is none). `reads` (opponent profiles, reported only — the plan never uses them): each opponent in contact with a habit at confidence 0.5 or a label, its `labels`, those habits with `n` and `basis`, and `gamesMet` (full adds the counter-play lines); absent with `WARAPP_PLAYER_PROFILE=off` or while a game's teams cannot be read. `headroom` (#275), weakest first: each border of yours with the smallest single deploy by a neighbouring opponent that takes it after the plan's orders, whether that is below your income, and what falls with it (bonuses, the territories behind it and their bonus income, and `breach`: the hollow territories within two moves behind it that only it shields, with their bonus income). The whole turn is carried out for it, so it may differ from the leftover spread's "~D" line (#268, reckoned on the deploys before any move); a player out of the game whose seat no AI plays gets no row. With the guard off the plan counts half of a border's breach income in its value. When one observation broke an opponent's estimate by 1.5× or more (a stack out of the fog, a capture, or an attack of yours it held), the first warning says so for 3 turns and the borders of your held bonuses facing it are sized for the larger of what it implied and your income (no `guess` is drawn against it then). Nothing is read once an opponent may hold an Airlift card or while the game's teams cannot be read (each `headroom` row then says `mayBeTeammate`); under Multi-Attack only a stack out of the fog is read. After turns 4 and 8 on a map you have finished games on, `pace` puts your income beside the median winner's there (reported only). `chat.messages` lists the newest unread messages other players sent (text delimited) with their `intent` and `advice` (compact: the stance and one reason; `messagesOmitted` counts the rest), from the plan's own standing: reported only, the orders never read chat. `chat.chatBlocks` lists the unread messages that would block the submit under `WARAPP_CHAT_BLOCKS_TURN` (report only). |
154
155
  | `warapp_check_plan` | A stress test of a list of orders before you submit it (`warapp_plan_turn`'s `orders`, or your own edit): the orders are carried out on the live board by the game's turn rules (deploys, then attacks and transfers in the zigzag move order, each an attack or a transfer by who holds its target when it runs) against the replies each opponent could make with one deploy — all of it on one stack and an attack on a territory you hold or are about to take, all of it on a territory you attack, or every stack attacking at once — with you moving first and with the opponent moving first unless `first_mover` says which. Returns `safe` (`null` when no reply could be tried), a one-line `summary`, the `worst` reply and the `otherReplies` that cost something (territories lost, captures that fail or are taken straight back, bonuses and income, your commander), everything `atRisk` to some single reply, `commander` (with your commander on the board: its territory, the armies there and `needs`, the armies that survive every reply tried — by `warapp_submit_turn`'s own check, each reply at the larger of the estimate and your income, `enemy_deploy` only raising it, both move orders, your Airlifts counted; when a reply kills it the `summary` starts with it), what the orders do unanswered, `blindBorders` (your territories next to the fog, where nothing could be tested) and `exposedNextTurn` (territories no stack touches today that one could take next turn by first taking the territory in between, each with the armies it would need to hold). Exact with no luck and straight rounding; otherwise `exact` is false. `known_income` (as `warapp_plan_turn`'s) tries a per-player income you know in place of that opponent's estimate (`enemyDeploy` source `known_income`; `enemy_deploy` wins over it; `commander` keeps the submit's sizing). Not tried: hidden stacks, a deploy above the estimate (`enemy_deploy` tests one), split deploys, opponents acting together, under Multi-Attack any chain but the one most damaging per stack, cards other than your own Order Priority (a Bomb or Emergency Blockade in the orders is warned of as not simulated). `award` (when the server kept your pick list) is the same reading `warapp_plan_turn` gives; its `firstMover` can be passed as `first_mover`. In a free-for-all with a recorded truce in force its partner is still tried (`safe` is safe against a break), a reply that attacks a territory the truce covers is marked `breaksTruce`, and `safeIfTruceHolds` is the verdict over the rest (`null` when every reply is a break); a Diplomacy card in effect that the decoder is sure of counts as such a truce in any format (`enforced`, `verified: false`). In a team game it warns, as `warapp_submit_turn` does, of a card play or discard your teammate has already entered. `headroom` (as `warapp_plan_turn`'s) gives each border the smallest single deploy that takes it after these orders; an opponent whose estimate an observation broke is tried at the larger of what it implied and your income (`enemyDeploy` source `untrusted`, said in the first warning). `belowPlan` (#275) compares the orders with the default plan made now on the same board, as `warapp_plan_turn` makes it with no options (or with its border guess when the deploys are the guess's: `belowPlanAgainst`): each border they leave below what that plan leaves standing there, with `planLeaves`, `left` and `short`, the largest shortfall first. `planLeaves` includes the plan's surplus, so a border named may still hold (see `headroom`). Read-only. |
155
156
  | `warapp_track_opponents` | Each opponent over your own board history (the boards `warapp_plan_turn` and this tool read, the last 10 turns, or the game history when war.app sends it), by name: its observed deploy each turn (territories visible both turns only — a stack that came out of the fog is not income), an income estimate (each observed deploy is a lower bound under fog, so the largest of its last three observed turns, or its visible army growth plus losses per turn (stacks out of the fog left out) when that is more; capped at what it could earn, at least its base plus the bonuses it visibly holds; `method` and `observedRange` say which term set it and how spread the observations were), `unexplainedArmies` (income earned since first seen minus its visible army change, its visible losses and its likely combat deaths: armies in the fog, spent there, or a misread) and `inferredBonuses` (the combinations of bonuses it could hold that best explain the gap, only those within 4 hops of its territories that it could have paid for, nearest first — candidates, never one asserted; none listed when more than 8 fit), with confidence notes. Every opponent still playing is listed, even with no territory in view (`visible` territories in view, `turnsUnseen` — a floor, `turnsUnseenAtLeast`, when your boards do not reach back to when it was last seen); one with nothing in view gets `earnedAtLeast` — its starting armies plus the base income for every turn so far, a lower bound on armies received (not held: its expansion cost some) — and a warning, also in `warapp_plan_turn`, when that beats your largest stack or your total visible armies. Once an opponent has 2+ observed turns, `warapp_plan_turn` uses this income in place of the single-turn observed figure. `view`: compact / full. Read-only on war.app (it caches the board it read); refuses outside a turn phase. `full` adds `pastGames`: the lessons of your finished games — how they were lost, when your income went flat, and this tracker's estimate ÷ the true income by format and coverage band (reported only). |
@@ -158,7 +159,7 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
158
159
  | `warapp_plan_picks` | A pick list for a manual-distribution game in the picking stage, from the map, the settings and the live board's pickable territories: priority order by name and id, a compact primary group (the territory limit) and a disjoint fallback group (as long as war.app's client allows), each pick's score and reasons (bonus, value, turns to complete, first-turn bonus, entry points, contested), the award (the sets the award order can grant, and the worst), the primary's `coverage` (the reasonable bonuses its picks can stand next to within 2 moves) and, in a 1v1 when it covers more, a coverage-first `alternative` list with its own `submitPicks` (compact is the default; the alternative suits a small board), warnings for assumed settings, and `submitPicks` — the ids in order, ready for `warapp_submit_picks`. In a team game only the players off your team are threats, `team` names your teammates, and the list is judged by both award orders that fit (`award.orders`; a team game's is unverified); `warapp_submit_picks` warns when a team game's list is shorter than starts × all players. When a teammate's pick list can be read (their entered orders, else `GetTerritoryPicks`; unverified live), each teammate carries `picks` and `team.coordination` reports the overlap with your list, the bonuses their top picks into (a bonus pays one holder, so your picks there are not credited) and a `mirrored` alternative — the same top picks in both lists, laid on the positions a reversing award gives one player, with the bonuses a repeating order would split and its own `submitPicks` — beside the split list in `submitPicks`, which leaves their top picks to them and is shortened only when disjoint from their list and theirs is full length; every `submitPicks` fits war.app's client limit. With no list read the plan is unchanged. The heuristics are in [docs/STRATEGY.md](docs/STRATEGY.md). `view`: compact / full. Read-only; refuses outside the picking stage. With finished games on the map, `mapRecord` reports them beside the list (reported only): your results by start bonus, where winners started, and the median income after turns 4 and 8. |
159
160
  | `warapp_submit_picks` | **Writes.** Replace your territory picks (priority order, pickable territories only; a list longer than war.app's client allows — players × territories per player — or shorter than each player's share is warned about in the preview). Confirm-gated; reads the picks back and reports `verified` only on an exact match. |
160
161
  | `warapp_submit_turn` | **Writes.** Commit your turn's orders (e.g. `warapp_plan_turn`'s `orders`) as the signed-in account: card plays (Reinforcement, Order Priority, Order Delay, Blockade, Airlift, Diplomacy — the Blockade and Airlift plays verified live 2026-11-16, Diplomacy 2026-11-18; Reconnaissance accepted live 2026-11-20 (the reveal itself not yet seen); and, encoded as the client does but not yet verified live, Spy, Surveillance, Gift, Sanctions, Bomb and Emergency Blockade with their targets — refused where war.app would refuse them, e.g. a commander gifted or airlifted to a teammate, a Spy or Sanctions on your own side, a Spy on the neutral (player `0`) unless the game's Spy card allows it, Diplomacy between teammates or naming a player who is out, a Bomb on your own side or not next to you, an Emergency Blockade on a territory not yours or on your commander; in a team game the preview warns when the orders play or discard a card your teammate has already entered (a card named by type is one nobody entered when there is one; their orders are read from the live board, unverified); an Airlift may send `armies: 0` with `commander` to move the commander alone, and a Gift to an opponent is named as one in the preview), discards, deploys and moves. Confirm-gated; validated on the live board (cards in your hand, your territories, adjacent moves, armies available, deploys = income + played Reinforcement armies; bonus armies inside their bonus under Local Deployment; one attack/transfer per territory under No-Split, with a warning when one sends less than the whole stack; enough card plays or discards when you hold more cards than the limit); confirmed from game state (`resolved` / `committed` / `unknown`). An order that attacks (or a Bomb that hits) a territory an active or in-notice truce covers (`warapp_record_agreement`) is refused unless `break_agreement: true`: the preview then names the agreement, and once the orders are committed the ledger records it broken by you (and the partner's player record says so). In a Commanders game, orders that leave your commander takeable by one opponent's single deploy, or two striking together when you lead a free-for-all (each reply sized at the larger of its estimate and your income, on the live board; your Airlifts are counted, after the deploys and before the moves, the commander with one that takes it), are refused with the armies that would hold (under Local Deployment the hint says a deploy there must come from a pool that reaches it), and so is a Blockade or Gift of a territory your commander stands on before or after the orders (not simulated), unless `accept_commander_risk: true` (ask first: losing the commander loses the game); the preview then warns first and the result records `commanderRiskAccepted`. The preview also warns when the orders break a promise a chat message declared (`warapp_send_chat`'s `commitments`): an attack you said you would not make, or an attack you said you would make and left out. It warns too (never refuses) when the orders leave a border of a bonus you hold falling to a single deploy below your own income (#275 headroom), and when they leave any border below what the default plan made now (as `warapp_plan_turn` makes it with no options, or its border guess when the deploys are the guess's) leaves standing there, naming each with the difference (#275). Other players see the results. Optional `override_reason` (at most 500 characters) and `override_by` (`hand` or `agent`, default `agent`) say why and by whom the orders differ from `warapp_plan_turn`'s for the turn: they change nothing sent, and are kept (names scrubbed) in the [decision log](#decision-log) beside the plan only when the orders do differ. Unread chat that may change the turn is listed in the preview's `chatWarnings`; with `WARAPP_CHAT_BLOCKS_TURN=on` it is refused instead, unless `chat_reviewed: true` (see [Chat advice](#chat-advice)). |
161
- | `warapp_uncommit_turn` | **Writes.** Withdraw your committed orders for the current turn (war.app's UnCommit, the game's "Modify orders") so you can submit corrected ones with `warapp_submit_turn`. Confirm-gated; refuses outside a turn phase and when your orders are not committed; reads the outcome from GameFeed (`uncommitted` / `unconfirmed`, or `unknown` when war.app did not answer — never resent). The game waits on you again, so recommit before the boot timer. A truce recorded broken by you on that turn (`break_agreement`) stays recorded: `agreementsStillBroken` names it. |
162
+ | `warapp_uncommit_turn` | **Writes.** Withdraw your committed orders for the current turn (war.app's UnCommit, the game's "Modify orders") so you can submit corrected ones with `warapp_submit_turn`. Confirm-gated; refuses outside a turn phase and when your orders are not committed; reads the outcome from GameFeed (`uncommitted` / `unconfirmed`, or `unknown` when war.app did not answer — never resent). The game waits on you again, so recommit before the boot timer. A truce recorded broken by you on that turn (`break_agreement`) stays recorded: `agreementsStillBroken` names it. The orders withdrawn are read back first and carried in the preview and result (`withdrawnOrders`, `warapp_submit_turn`'s shape; `null` when unreadable). |
162
163
  | `warapp_chat_inbox` | The chat you have not marked seen, across all your games in one call (your lobbies and games being picked or played, from your games list, and a finished game when war.app flags its chat unread, or when those flags do not read (`finishedUnflagged` counts these) — or exactly the games in `game_ids`; `gamesFrom` says which, and from the list `listed`/`complete` whether it was whole): per game with something new, `unread` per channel and only the new messages (the newest `limit`, delimited, as `warapp_get_chat` shows them); games with nothing new in `quiet`, a game whose read failed in `failed` (never an error for the call). At most `max_games` (default and max 10) games per call, read one at a time: pass `next` back as `cursor` for the rest. Reading marks nothing; `mark_seen: true` marks every channel of each game read as seen, on this machine only (war.app still shows them unread until `warapp_mark_chat_read` marks them read there). Read-only. Each new message from another player carries `intent` and `advice`, as `warapp_get_chat` gives them. |
163
164
  | `warapp_get_notifications` | Your war.app in-app notifications (the game's notifications screen), 30 per page and by id only: each with `id`, `kind` (`game-ended` when the title is war.app's `Game "…" has ended.` line, else `other`), `gameId` (the game its link names, or null), `time` and `unread`; never the title or body, which carry other players' names. `total`, `next` (pass back as `start`) and `unread_only`. A game-ended notification runs the end-of-game pass on that game once, as `warapp_get_game` does (`endOfGame`: `processed`, each with `profileFold`, and `pending`; at most two games a call, one history read each, none for a game already processed), and folds the opponent profile kept for it (`profilesFolded`: one game read, only when such a profile is still kept unfolded). Read from war.app's client code, unverified live. Read-only. |
164
165
  | `warapp_dismiss_notification` | **Writes.** Mark one or several notifications read by the ids `warapp_get_notifications` lists (war.app's AcknowledgeInAppNotifications; nothing is deleted — `warapp_delete_notification` deletes — and nothing reaches another player). Confirm-gated; the preview names ids and game ids only; refuses ids not listed or already read; the outcome is read back by listing again (`dismissed` only when every id reads read or is seen gone from the list; `unconfirmed` while one reads unread or was not seen in the pages read back; `unknown` when war.app did not answer — never resent). Verified live 2026-11-16. |
@@ -274,6 +274,11 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
274
274
  const need = b ? Math.max(0, holdArmies(b.threat) - unitsAt(x)) : 0;
275
275
  return Math.max(need - (stayAt(x) - avail.get(x)), keepOf(x, t));
276
276
  };
277
+ /**
278
+ * #416: under #319's bind (plan/spread-bind.ts), `x` beside the nearest bonus's missing members may not attack
279
+ * `t` unless `t` is a member of that bonus.
280
+ */
281
+ const barred = (x, t) => ps.bind !== undefined && ps.bind.from.has(x) && !ps.bind.members.has(t);
277
282
  /** Enemy commanders' territories attacked as a commander strike (rule 1s): exempt from R3. */
278
283
  const strikes = new Set();
279
284
  /** #272: captures out of a conceded border into a bonus (plan/conceded-out.ts), which R3 does not refuse. */
@@ -411,6 +416,9 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
411
416
  : movableFor(x, t);
412
417
  if (force && orderOf(force.from))
413
418
  return false;
419
+ // #416: under #319's bind, never from beside the nearest bonus's missing members (plan/spread-bind.ts).
420
+ if (force && barred(force.from, t))
421
+ return false;
414
422
  /** No-Split: why `x` must hold instead (it would send at least the capture's cost). */
415
423
  const held = (x) => mustHold(x, t, Math.max(avail.get(x), tg.cost));
416
424
  if (force) {
@@ -423,7 +431,7 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
423
431
  }
424
432
  const open = (x) => (!locked.has(x) || (!force && holdSource(x, t))) && (!conceded.has(x) || x === fromConceded || concededSource(x, t, tg.cost));
425
433
  // No-Split (#124): a covered exit (#179) issues no order — it would send its whole stack.
426
- const usable = (x) => open(x) && !held(x) && !(noSplit && coverOf(x) > 0);
434
+ const usable = (x) => open(x) && !held(x) && !(noSplit && coverOf(x) > 0) && !barred(x, t);
427
435
  const sources = force
428
436
  ? [force.from]
429
437
  : tg.sources.filter((x) => usable(x) && !orderOf(x)).sort((a, b) => avail.get(b) - avail.get(a) || a - b);
@@ -566,6 +574,7 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
566
574
  .filter((x) => !locked.has(x) &&
567
575
  !conceded.has(x) &&
568
576
  !myCommanders.has(x) &&
577
+ !barred(x, t) &&
569
578
  avail.get(x) > 0 &&
570
579
  !orderOf(x) &&
571
580
  !(noSplit && coverOf(x) > 0) &&
@@ -26,18 +26,44 @@ export function openingArmies(g, board, when = {}) {
26
26
  * #164: the deployments read as card plays that count as cards — each on or after the turn the clock
27
27
  * says one is due and before `turn` — and the turn the next card is due: a card's capturing turns after
28
28
  * the last one counted (pieces carry over while a card is held), never before the turn after the play.
29
+ * #427: a play in `seen` (read in that turn's orders) always counts and restarts the clock: the next
30
+ * card is due its capturing turns after it.
29
31
  */
30
- function cardsCounted(played, r, turn) {
32
+ function cardsCounted(played, r, turn, seen = new Set()) {
31
33
  let due = r.firstTurn;
34
+ // The turn the clock runs from, and the cards counted since it.
35
+ let anchor = r.firstTurn;
36
+ let since = 0;
37
+ const step = r.turnsPerCard === null ? null : Math.max(1, r.turnsPerCard);
32
38
  const counted = [];
33
39
  for (const t of [...new Set(played)].sort(byNum)) {
34
- if (t < due || t >= turn)
40
+ if (t >= turn)
41
+ continue;
42
+ const certain = seen.has(t);
43
+ if (!certain && t < due)
35
44
  continue;
36
45
  counted.push(t);
37
- due = r.turnsPerCard === null ? Infinity : Math.max(t + 1, r.firstTurn + counted.length * Math.max(1, r.turnsPerCard));
46
+ if (certain) {
47
+ anchor = t;
48
+ since = 1;
49
+ }
50
+ else
51
+ since++;
52
+ due = step === null ? Infinity : Math.max(t + 1, anchor + since * step);
38
53
  }
39
54
  return { counted, due };
40
55
  }
56
+ /**
57
+ * #427: the turns `playerId`'s Reinforcement card is read as played: the turns `inferred` from its
58
+ * deploys, less those whose orders were read (`plays.read`: there a play shows), plus the plays seen.
59
+ */
60
+ function playsOf(inferred, playerId, plays) {
61
+ if (!plays)
62
+ return { turns: [...inferred], seen: new Set() };
63
+ const read = new Set(plays.read);
64
+ const seen = new Set(plays.plays.filter((x) => x.player === playerId).map((x) => x.turn));
65
+ return { turns: [...inferred.filter((t) => !read.has(t)), ...seen], seen };
66
+ }
41
67
  /**
42
68
  * #368: an opponent's tracked figure as of each of its last three consecutive observed turns — the most
43
69
  * it was seen to earn (`earned`) over that turn and the two before it, the tracker's max-observed window —
@@ -194,7 +220,8 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
194
220
  let cardInTrack = null;
195
221
  if (usable && tracked !== null && when.reinforcement && when.reinforcement.armies > 0 && when.turn !== null && when.turn !== undefined) {
196
222
  const r = when.reinforcement;
197
- const plays = new Set(cardsCounted(usable.turns.filter((x) => above(x.low, x.visibleIncome)).map((x) => x.from), r, when.turn).counted);
223
+ const read = playsOf(usable.turns.filter((x) => above(x.low, x.visibleIncome)).map((x) => x.from), playerId, when.plays);
224
+ const plays = new Set(cardsCounted(read.turns, r, when.turn, read.seen).counted);
198
225
  const top = usable.turns.filter((x) => x.observed >= tracked);
199
226
  if (top.length && top.every((x) => plays.has(x.from))) {
200
227
  const without = Math.max(usable.visibleIncome, ...usable.turns.map((x) => (plays.has(x.from) ? Math.min(x.cap, Math.max(0, x.raw - r.armies)) : x.observed)));
@@ -384,10 +411,13 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
384
411
  }
385
412
  let card = null;
386
413
  let cardPlayed = null;
414
+ let cardSeen = false;
387
415
  if (when.reinforcement && when.turn !== null && when.turn !== undefined) {
388
416
  const r = when.reinforcement;
389
- const { counted, due } = cardsCounted(played, r, when.turn);
417
+ const read = playsOf(played, playerId, when.plays);
418
+ const { counted, due } = cardsCounted(read.turns, r, when.turn, read.seen);
390
419
  cardPlayed = counted.at(-1) ?? null;
420
+ cardSeen = cardPlayed !== null && read.seen.has(cardPlayed);
391
421
  if (when.turn >= due && r.armies > 0)
392
422
  card = { armies: r.armies, due };
393
423
  }
@@ -419,6 +449,7 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
419
449
  exact,
420
450
  card,
421
451
  cardPlayed,
452
+ ...(cardSeen ? { cardSeen: true } : {}),
422
453
  ...(cardInTrack ? { cardInTrack } : {}),
423
454
  ...(priorFull !== null && priorFigure < priorFull ? { stated: { full: priorFull, scaled: priorFigure, lower: seen, midpoint: statedMid } } : {}),
424
455
  };
@@ -96,6 +96,7 @@ export function planEnemyEstimates(input) {
96
96
  turn,
97
97
  fog: ctx.fog,
98
98
  reinforcement: ctx.reinforcement,
99
+ ...(ctx.reinforcementPlays ? { plays: ctx.reinforcementPlays } : {}),
99
100
  ...(previousBoard && input.previousOrders ? { previousOrders: input.previousOrders } : {}),
100
101
  });
101
102
  const priced = applyKnown(applyArmyPrice(applySanctions(estimates, input.sanctions ?? []), input.settings?.armyCostMultiplier ?? 0), input.known ?? []);
@@ -0,0 +1,49 @@
1
+ // #416 part 4 (owner 2026-11-22): while #319 fires, pass-3 plain expansion and advances into other bonuses may
2
+ // not spend deploys, or armies on a territory beside the nearest bonus's missing members, until that bonus's
3
+ // reachable steps are funded. Holds keep their places.
4
+ //
5
+ // - The nearest bonus is the one #319's warning names (rule 4f's order: `Targets.spreadNearest`).
6
+ // - Its reachable steps are its missing members a capture can reach this turn: capture targets beside a
7
+ // territory of mine (rule 4f's first layer). "Funded" means captured by this plan; once every one is, the
8
+ // bind lifts and the rest flows as before. A step refused for another reason (rule 4d, R3, income) keeps
9
+ // the bind for the turn: the leftover saves toward it instead.
10
+ // - A stack beside the missing members of the nearest bonus and of another is the nearest bonus's.
11
+ // - Bound: advances into another bonus (pass 2, the `balanced` greedy's advance slots, #439's two-move
12
+ // stage), pass 3 and rule 5b's leftover expansion (pass 3's order, paid by the leftover); the bonus's own
13
+ // members never are. Not bound: completions of any bonus, focused bonuses, holds, breaks, counters, the
14
+ // 1v1 race, strikes, rule 4e's fallback, the card-piece capture and the army cap's spend.
15
+ // - What is bound may still attack from my other territories with the armies standing there.
16
+ import { neighborsOf } from '../graph.js';
17
+ export function spreadBind(pc, ps, tgt) {
18
+ const p = tgt.spreadNearest;
19
+ if (!p)
20
+ return undefined;
21
+ const { g, mine, mineSet, reserve, label, bonusName, bonusTs } = pc;
22
+ const steps = p.remaining.filter((t) => tgt.targets.has(t) && neighborsOf(g, t).some((x) => mineSet.has(x))).sort((a, b) => a - b);
23
+ if (!steps.length)
24
+ return undefined;
25
+ const missing = new Set(p.remaining);
26
+ const members = new Set(bonusTs.get(p.bonusId) ?? p.remaining);
27
+ const beside = new Set(mine.filter((x) => neighborsOf(g, x).some((t) => missing.has(t))));
28
+ const open = () => steps.some((t) => !ps.captured.has(t));
29
+ const line = `#319 binds the deploys (#416): until ${bonusName(p.bonusId)}'s reachable step${steps.length === 1 ? '' : 's'} ` +
30
+ `(${steps.map(label).join(', ')}) ${steps.length === 1 ? 'is' : 'are'} taken, plain expansion and advances into other bonuses ` +
31
+ `spend no deploys and no armies on ${[...beside].sort((a, b) => a - b).map(label).join(', ')}.`;
32
+ const bound = (exempt, f) => {
33
+ if (exempt || ps.bind || !open())
34
+ return f();
35
+ if (!ps.rationale.includes(line))
36
+ ps.rationale.push(line);
37
+ const withheld = Math.max(0, ps.budget - reserve);
38
+ ps.budget -= withheld;
39
+ ps.bind = { from: beside, members };
40
+ try {
41
+ return f();
42
+ }
43
+ finally {
44
+ ps.budget += withheld;
45
+ ps.bind = undefined;
46
+ }
47
+ };
48
+ return { bonusId: p.bonusId, open, bound };
49
+ }
@@ -952,9 +952,12 @@ export function closestBonus(pc, ps, input, prev, hd) {
952
952
  }
953
953
  // #319: in the opening (turns 2–6), many territories on an income near base means the captures are
954
954
  // spread over bonuses and none completed (six lost games held 11–20 territories on 8 or less after
955
- // turn 4). A warning only, naming rule 4f's nearest bonus with its armies and turns: no order changes.
955
+ // turn 4). The warning names rule 4f's nearest bonus with its armies and turns; #416 (owner 2026-11-22) binds
956
+ // the deploys to it (plan/spread-bind.ts).
956
957
  const turnNow = pc.game.turn ?? null;
957
958
  const base = Math.max(0, Math.floor(input.settings?.baseIncome ?? DEFAULT_BASE_INCOME));
959
+ /** #416 part 4: the nearest bonus #319 names, whose reachable steps the deploys are bound to (plan/spread-bind.ts). */
960
+ let spreadNearest;
958
961
  if (turnNow !== null &&
959
962
  turnNow >= 2 &&
960
963
  turnNow <= SPREAD_LAST_TURN &&
@@ -962,6 +965,7 @@ export function closestBonus(pc, ps, input, prev, hd) {
962
965
  mine.length >= SPREAD_TERRITORIES &&
963
966
  income <= base + SPREAD_INCOME_SLACK) {
964
967
  const nearest = committing ? byCloseness.find((p) => !p.focus) ?? byCloseness[0] : undefined;
968
+ spreadNearest = nearest;
965
969
  ps.warnings.push(`${mine.length} territories, ${noBonusText}: the captures are spread (income ${income}, base ${base}). ` +
966
970
  (nearest
967
971
  ? `Nearest bonus to complete: ${bonusName(nearest.bonusId)}, ${nearest.cost} armies to finish${fogNote(nearest)}${standingNote(nearest)}, ` +
@@ -980,5 +984,5 @@ export function closestBonus(pc, ps, input, prev, hd) {
980
984
  ? `${label(t)} can be retaken after it breaks ${bonusName(bonusId)}: ${survivors} survivors need ${take} to take, against ~${counter} next turn.`
981
985
  : undefined;
982
986
  };
983
- return { holdsBonus, neutralsInReach, committing, advancedLast, fromMine, depthOf, turnsOf, scoreRank, byCloseness, turnsText, retakeChecks, retakeWarning };
987
+ return { holdsBonus, neutralsInReach, committing, advancedLast, fromMine, depthOf, turnsOf, scoreRank, byCloseness, turnsText, spreadNearest, retakeChecks, retakeWarning };
984
988
  }
@@ -1000,13 +1000,19 @@ export function borderThreats(pc, ps, input, src, forces) {
1000
1000
  const c = e.cardInTrack;
1001
1001
  warnings.push(`Player ${p}'s tracked income of ${c.was} counts the Reinforcement card it played on turn ${c.turns.join(', ')}: ${c.income} without it (#427), so the card is counted once, on the clock, not carried as income.`);
1002
1002
  }
1003
- // #164: a Reinforcement card the clock says it may hold, on top of its income.
1003
+ // #164: a Reinforcement card the clock says it may hold, on top of its income. #427: with card plays
1004
+ // not fogged, a play is seen in the orders, and the next card is due its capturing turns after it.
1005
+ const cardPlaysRead = input.game?.reinforcementPlays !== undefined;
1006
+ const perCard = input.game?.reinforcement?.turnsPerCard;
1007
+ const cardDue = (t) => (perCard === null || perCard === undefined ? 'never (no further card comes)' : `turn ${t + Math.max(1, perCard)}`);
1004
1008
  if (e.card)
1005
- warnings.push(`Player ${p} may hold a Reinforcement card from turn ${e.card.due} (the card clock${e.cardPlayed !== null ? `; it last played one on turn ${e.cardPlayed}` : ''}): +${e.card.armies} added to its deploy, ~${e.estimate} in all, until a deployment above its income is seen; one card at most is counted, though more may be in hand after a long time due.`);
1009
+ warnings.push(`Player ${p} may hold a Reinforcement card from turn ${e.card.due} (the card clock${e.cardPlayed !== null ? `; it last played one on turn ${e.cardPlayed}${e.cardSeen ? ', seen in the orders' : ''}` : ''}): +${e.card.armies} added to its deploy, ~${e.estimate} in all, until ${cardPlaysRead ? 'a play is seen in the orders' : 'a deployment above its income is seen'}; one card at most is counted, though more may be in hand after a long time due.`);
1006
1010
  else if (e.cardPlayed !== null)
1007
- warnings.push(e.source === 'exact'
1008
- ? `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment above its exact income), so none is added until the next can be due; armies the board misread, or that moved into view out of a territory whose armies the fog hid, can look the same, so it may still hold one and the estimate errs low.`
1009
- : `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment of a card's armies over its visible income), so none is added until the next can be due; income the fog hides can look the same, so it may still hold one and the estimate errs low.`);
1011
+ warnings.push(e.cardSeen
1012
+ ? `Player ${p} played a Reinforcement card on turn ${e.cardPlayed} (seen in that turn's orders: card plays are not fogged in this game), so none is added until the next can be due: ${cardDue(e.cardPlayed)}.`
1013
+ : e.source === 'exact'
1014
+ ? `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment above its exact income), so none is added until the next can be due; armies the board misread, or that moved into view out of a territory whose armies the fog hid, can look the same, so it may still hold one and the estimate errs low.`
1015
+ : `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment of a card's armies over its visible income), so none is added until the next can be due; income the fog hides can look the same, so it may still hold one and the estimate errs low.`);
1010
1016
  // #164: the income behind the estimate; a card the clock adds is named on top of it.
1011
1017
  const income = e.estimate - (e.card?.armies ?? 0);
1012
1018
  // G2 (D3): Sanctions on it the decoder is sure of — applied to a figure read off the board only.
@@ -17,6 +17,7 @@
17
17
  // 4h. the army cap prices idle armies (#253) .................. plan/cap-spend.ts
18
18
  // 5. the leftover deploy, 3b's short borders (#121) ........... plan/leftover.ts
19
19
  // 5b. a neutral the leftover pays for (#218) ................. plan/after-leftover.ts
20
+ // #319's bind (#416): other expansion waits for the nearest bonus .. plan/spread-bind.ts
20
21
  // 6. transfers, #125 staging ................................. plan/transfers.ts
21
22
  // #277: a held bonus funded from a second sure sizing ......... plan/second-sizing.ts
22
23
  // 7. move order, rule 1s's Order Priority ..................... plan/move-order.ts
@@ -1227,6 +1228,16 @@
1227
1228
  // at least TWO_MOVE_MIN_VALUE two moves away through a visible neutral is a two-turn completion
1228
1229
  // (cost: that neutral plus the territory); the neutral in between is a `stage` candidate under
1229
1230
  // `balanced` (net over both costs, ranked as an advance), else taken before the advances.
1231
+ // #319 binds (#416, owner 2026-11-22; plan/spread-bind.ts): while #319's opening warning fires, pass-3
1232
+ // plain expansion and advances into other bonuses may not spend deploys, or armies on a territory beside the
1233
+ // nearest bonus's missing members, until that bonus's reachable steps are funded. Holds keep their places.
1234
+ // The nearest bonus is the one the warning names; its reachable steps are its missing members that are
1235
+ // capture targets beside a territory of mine; funded = captured by this plan, after which the rest flows
1236
+ // as before (a step refused for another reason keeps the bind for the turn: the leftover saves toward it).
1237
+ // A stack beside two bonuses' missing members is the nearest bonus's. Bound: other bonuses' advances (pass
1238
+ // 2, the `balanced` advance slots, #439's stage), pass 3 and rule 5b; never the bonus's own members, a
1239
+ // focused bonus, completions, holds, breaks, counters, the 1v1 race, strikes, rule 4e, 4g or 4h. What is
1240
+ // bound may still attack with the armies on my other territories. A "#319 binds the deploys" line says so.
1230
1241
  // 3b. One surplus per territory (#121). A border that holds at the start of the turn (its armies
1231
1242
  // beat its visible threat, rule 1) and is not conceded keeps what holds it, as my commander's
1232
1243
  // territory does (rule 1k): a capture from it spends only its armies above that, plus deploys
@@ -1672,6 +1683,7 @@ import { threatsPhase } from './plan/threats.js';
1672
1683
  import { applyShortGates } from './plan/horizon.js';
1673
1684
  import { targetsPhase } from './plan/targets.js';
1674
1685
  import { capturesPhase } from './plan/captures.js';
1686
+ import { spreadBind } from './plan/spread-bind.js';
1675
1687
  import { completedMembers } from './plan/completed.js';
1676
1688
  import { chooseStrikeStack, leadStrikes, spendStrikeStack, strikesPhase } from './plan/strike.js';
1677
1689
  import { contestedBonuses } from './plan/stockpile.js';
@@ -2038,6 +2050,10 @@ function planPass(input, pass) {
2038
2050
  const { strikes, worstCase, defendersAt, tryCapture, snapshot, complete, tryExpand, advance } = caps;
2039
2051
  /** #439: single-territory bonuses two moves away, each with its neutral in between. */
2040
2052
  const stages = twoMoveStages(pc, tgt);
2053
+ /** #416 part 4: while #319 fires, other advances and pass 3 wait for the nearest bonus's steps (plan/spread-bind.ts). */
2054
+ const bind = spreadBind(pc, ps, tgt);
2055
+ const bound = (exempt, f) => (bind ? bind.bound(exempt, f) : f());
2056
+ const otherBonus = (p) => p.focus || p.bonusId === bind?.bonusId;
2041
2057
  // ---- 1e. finish off an opponent, 1s. strike an enemy commander, #165 guard-off breaks (plan/strike.ts) ----
2042
2058
  const { struck } = strikesPhase(pc, ps, book, threats, hd, tgt, caps);
2043
2059
  // ---- #276: guard off — free retakes and raids one step deeper (plan/guard-off.ts) ----
@@ -2177,12 +2193,12 @@ function planPass(input, pass) {
2177
2193
  worthOf.set(p.bonusId, p.net === p.value ? `+${p.value}` : `+${p.value}, net +${p.net}`);
2178
2194
  if (p.completable)
2179
2195
  candidates.push({ kind: 'complete', score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => complete(p)) });
2180
- candidates.push({ kind: 'advance', score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => advance(p)) });
2196
+ candidates.push({ kind: 'advance', score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => bound(otherBonus(p), () => advance(p))) });
2181
2197
  }
2182
2198
  // #439: a single-territory bonus two moves away is a two-turn completion: its neutral in between
2183
2199
  // competes as an advance does, on the income per army of both captures.
2184
2200
  for (const st of stages)
2185
- candidates.push({ kind: 'stage', score: st.net / st.cost, cost: st.cost, id: st.bonusId, value: st.net, focus: false, borders: 0, target: st.via, run: spend(() => stageTwoMove(pc, ps, st, gainWith, tryExpand)) });
2201
+ candidates.push({ kind: 'stage', score: st.net / st.cost, cost: st.cost, id: st.bonusId, value: st.net, focus: false, borders: 0, target: st.via, run: spend(() => bound(st.bonusId === bind?.bonusId, () => stageTwoMove(pc, ps, st, gainWith, tryExpand))) });
2186
2202
  // #417, the 1v1 race: while a static seat's land is still untaken, its cheap captures rank ahead of
2187
2203
  // rule 0p.1's "expansion last" (`ahead` below); held-bonus gates and my commander's hold go first.
2188
2204
  const races = oneVsOne ? raceTargets(pc, targets, captured) : [];
@@ -2807,11 +2823,11 @@ function planPass(input, pass) {
2807
2823
  // #439: the neutral in between toward a single-territory bonus two moves away, before any advance.
2808
2824
  if (goal !== 'complete-bonus')
2809
2825
  for (const st of stages) {
2810
- stageTwoMove(pc, ps, st, gainWith, tryExpand);
2826
+ bound(st.bonusId === bind?.bonusId, () => stageTwoMove(pc, ps, st, gainWith, tryExpand));
2811
2827
  garrisonCompleted();
2812
2828
  }
2813
2829
  for (const p of byCloseness) {
2814
- advance(p);
2830
+ bound(otherBonus(p), () => advance(p));
2815
2831
  garrisonCompleted();
2816
2832
  }
2817
2833
  // #285: as under `balanced`.
@@ -2846,41 +2862,44 @@ function planPass(input, pass) {
2846
2862
  const plainScore = plainOrderCosts(pc, tgt, eligible.map((t) => t.id));
2847
2863
  const rest = eligible.sort((a, b) => plainScore.get(a.id) - plainScore.get(b.id) || a.cost - b.cost || a.id - b.id);
2848
2864
  // Rule 4c: plain expansion never lowers income (a capture completing a negative bonus).
2849
- for (const t of rest) {
2850
- const gain = gainWith([t.id]);
2851
- if (gain < 0 && !inFocus(t.id))
2852
- continue;
2853
- if (tgt.emptyEnemies.has(t.id)) {
2854
- // #281: never one lowering income, focused or not; sized for its owner's deploy (#120).
2855
- if (gain >= 0)
2856
- tryEmptyEnemy(pc, ps, book, tgt, caps, t.id);
2857
- continue;
2858
- }
2859
- // #125: its own economy test. A member of an economic bonus is judged by that bonus; any
2860
- // other capture pays for the armies it loses with the income it adds within PAYBACK_TURNS,
2861
- // and one that adds none may lose at most PLAIN_EXPANSION_LOSS.
2862
- {
2863
- const refused = plainEconomy(pc, tgt, t.id, gain);
2864
- if (refused) {
2865
- const { lost, worth } = refused;
2866
- const reach = Math.max(...neighborsOf(g, t.id).filter((x) => avail.has(x)).map((x) => (avail.get(x) ?? 0) + roomAt(x)));
2867
- if (reach >= t.cost)
2868
- rationale.push(worth > 0
2869
- ? `Do not expand into ${label(t.id)}: it adds +${worth} a turn and loses ~${lost} armies, more than ${pc.capturePaybackTurns} turns of it pay back.`
2870
- : `Do not expand into ${label(t.id)}: it adds no income and loses ~${lost} armies (more than ${PLAIN_EXPANSION_LOSS}), in no bonus worth completing.`);
2871
- continue;
2865
+ // #416: the nearest bonus's own members are its steps; everything else waits under #319's bind.
2866
+ const nearestTs = bind ? new Set(bonusTs.get(bind.bonusId)) : undefined;
2867
+ for (const t of rest)
2868
+ bound(nearestTs?.has(t.id) ?? true, () => {
2869
+ const gain = gainWith([t.id]);
2870
+ if (gain < 0 && !inFocus(t.id))
2871
+ return;
2872
+ if (tgt.emptyEnemies.has(t.id)) {
2873
+ // #281: never one lowering income, focused or not; sized for its owner's deploy (#120).
2874
+ if (gain >= 0)
2875
+ tryEmptyEnemy(pc, ps, book, tgt, caps, t.id);
2876
+ return;
2872
2877
  }
2873
- }
2874
- // #281 × #282: a denial is never sourced from the territory my commander walks from (its transit hold).
2875
- // #426: a no-loss capture in a bonus too costly to finish says why it is taken all the same.
2876
- const reason = onlyNoLoss(pc, tgt, t.id)
2877
- ? `expands territory: a no-loss capture (its defenders kill none of the attackers; what lands stays mine), so the cost of finishing its bonus does not stop it (#426)`
2878
- : 'expands territory';
2879
- if (tgt.denials.has(t.id))
2880
- withoutTransit(pc, tgt, t.id, () => tryExpand(t.id, reason));
2881
- else
2882
- tryExpand(t.id, reason);
2883
- }
2878
+ // #125: its own economy test. A member of an economic bonus is judged by that bonus; any
2879
+ // other capture pays for the armies it loses with the income it adds within PAYBACK_TURNS,
2880
+ // and one that adds none may lose at most PLAIN_EXPANSION_LOSS.
2881
+ {
2882
+ const refused = plainEconomy(pc, tgt, t.id, gain);
2883
+ if (refused) {
2884
+ const { lost, worth } = refused;
2885
+ const reach = Math.max(...neighborsOf(g, t.id).filter((x) => avail.has(x)).map((x) => (avail.get(x) ?? 0) + roomAt(x)));
2886
+ if (reach >= t.cost)
2887
+ rationale.push(worth > 0
2888
+ ? `Do not expand into ${label(t.id)}: it adds +${worth} a turn and loses ~${lost} armies, more than ${pc.capturePaybackTurns} turns of it pay back.`
2889
+ : `Do not expand into ${label(t.id)}: it adds no income and loses ~${lost} armies (more than ${PLAIN_EXPANSION_LOSS}), in no bonus worth completing.`);
2890
+ return;
2891
+ }
2892
+ }
2893
+ // #281 × #282: a denial is never sourced from the territory my commander walks from (its transit hold).
2894
+ // #426: a no-loss capture in a bonus too costly to finish says why it is taken all the same.
2895
+ const reason = onlyNoLoss(pc, tgt, t.id)
2896
+ ? `expands territory: a no-loss capture (its defenders kill none of the attackers; what lands stays mine), so the cost of finishing its bonus does not stop it (#426)`
2897
+ : 'expands territory';
2898
+ if (tgt.denials.has(t.id))
2899
+ withoutTransit(pc, tgt, t.id, () => tryExpand(t.id, reason));
2900
+ else
2901
+ tryExpand(t.id, reason);
2902
+ });
2884
2903
  dropEmptyEnemyTargets(ps, tgt, empties);
2885
2904
  }
2886
2905
  // ---- 4e. never stand still (#104, #107), the contact fallback (plan/stand-still.ts) ----
@@ -3062,7 +3081,8 @@ function planPass(input, pass) {
3062
3081
  // ---- 5b. a neutral the leftover pays for (#218) (plan/after-leftover.ts) ----
3063
3082
  // The strike stack concentrates for its strike, and a step's source saves toward it: neither spends.
3064
3083
  const keepWhole = new Set([...(strikeStack ? [strikeStack.id] : []), ...(staging ? [staging.from] : [])]);
3065
- const takenAfter = afterLeftoverCaptures(pc, ps, book, threats, hd, tgt, caps, beforeLeftover, keepWhole, poolDeployed);
3084
+ // #416: rule 5b is plain expansion too: under #319's bind it leaves the stacks beside the nearest bonus alone.
3085
+ const takenAfter = bound(false, () => afterLeftoverCaptures(pc, ps, book, threats, hd, tgt, caps, beforeLeftover, keepWhole, poolDeployed));
3066
3086
  // #288: the rest of the leftover offered to another capture rides the expansion stack's attacks
3067
3087
  // after all when rule 5b took nothing from where it was offered.
3068
3088
  if (offered && !moves.some((m) => m.kind === 'attack' && m.from === offered.at && takenAfter.includes(m.to)))