@chrischall/warapp-mcp 0.10.0 → 0.12.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 +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +10 -8
- package/dist/analysis/cards-in-effect.js +10 -1
- package/dist/analysis/chat-mentions.js +17 -0
- package/dist/analysis/commander-fog.js +126 -0
- package/dist/analysis/end-game-stats.js +149 -0
- package/dist/analysis/local-deploy.js +3 -2
- package/dist/analysis/outlook.js +133 -55
- package/dist/analysis/picks.js +125 -0
- package/dist/analysis/plan/commander.js +3 -2
- package/dist/analysis/plan/deploy-estimates.js +11 -7
- package/dist/analysis/plan/estimates.js +63 -9
- package/dist/analysis/plan/relations.js +29 -14
- package/dist/analysis/plan/shared.js +21 -0
- package/dist/analysis/plan/threats.js +74 -5
- package/dist/analysis/player-record.js +31 -1
- package/dist/analysis/player.js +23 -10
- package/dist/analysis/relations.js +83 -9
- package/dist/analysis/scale.js +71 -0
- package/dist/analysis/single-pick.js +356 -0
- package/dist/bundle.js +3099 -809
- package/dist/chat-links.js +141 -0
- package/dist/finished-store.js +30 -0
- package/dist/index.js +1 -1
- package/dist/known-mods.js +33 -0
- package/dist/map-stats.js +24 -2
- package/dist/mod-alliances.js +217 -0
- package/dist/mod-data.js +160 -0
- package/dist/my-games.js +53 -2
- package/dist/normalize.js +7 -0
- package/dist/outlook-log.js +13 -0
- package/dist/player-record-store.js +5 -3
- package/dist/protocol/methods.js +14 -2
- package/dist/relations-store.js +29 -1
- package/dist/tools/card-advice.js +29 -9
- package/dist/tools/card-effects.js +3 -1
- package/dist/tools/card-support-advice.js +1 -1
- package/dist/tools/chat-advice.js +1 -1
- package/dist/tools/chat-inbox.js +67 -10
- package/dist/tools/chat.js +46 -8
- package/dist/tools/check-plan.js +115 -11
- package/dist/tools/close-finished-game.js +110 -0
- package/dist/tools/commander-check.js +80 -1
- package/dist/tools/diplomacy.js +11 -2
- package/dist/tools/end-of-game.js +57 -3
- package/dist/tools/game.js +7 -3
- package/dist/tools/how-lost.js +68 -5
- package/dist/tools/index.js +21 -1
- package/dist/tools/map.js +50 -1
- package/dist/tools/mod-alliances.js +191 -0
- package/dist/tools/my-games.js +12 -1
- package/dist/tools/pace.js +44 -0
- package/dist/tools/picks.js +41 -1
- package/dist/tools/relations.js +120 -7
- package/dist/tools/session.js +20 -6
- package/dist/tools/stress-opponents.js +25 -2
- package/dist/tools/turn.js +338 -42
- package/dist/tools/write-kit.js +1 -0
- package/dist/version.js +1 -1
- package/manifest.json +10 -2
- package/mint.yaml +3 -4
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +73 -11
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"email": "chris.c.hall@gmail.com"
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
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.
|
|
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, closing out a finished 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.12.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.
|
|
18
|
+
"version": "0.12.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.
|
|
4
|
+
"version": "0.12.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
|
@@ -142,8 +142,9 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
|
|
|
142
142
|
| `warapp_accept_surrender` | **Writes.** Accept another player's pending surrender (where the game asks the others to accept one). Confirm-gated; refuses when no surrender is pending from that player, when your acceptance is not owed, finished games and games you are not playing. `player` names the surrendering player (optional with one pending). The preview says what accepting does: whose seat, whether its land turns neutral or goes to an AI, which players border that land (live board), whether others still owe their acceptance, whether it leaves only your side playing (a win), and in a free-for-all one advice line naming the neighbour that gains most. Reads the outcome back from GameFeed and the game details: `accepted`, `pending` (others still owe theirs), `unconfirmed` or `unknown` (never resent). The encoding is read from the war.app client, not yet verified live. |
|
|
143
143
|
| `warapp_begin_turn` | **Writes.** Press Begin in a game whose first turn is a speed race (move order "No-luck cycle"): war.app hides the board until Begin, and Begin starts your turn timer, so call it only when ready to plan and submit at once. Confirm-gated; refuses games past turn 1, games without the speed first turn and games whose board is already visible; reports `begun` once the board reads back. The encoding is read from the war.app client, not yet verified live. |
|
|
144
144
|
| `warapp_scout_player` | Scout a player (through your signed-in tab): level, games played, last seen, boots, ranked records per format, and your head-to-head record; `met` (when the opponent-profile record holds the player) gives the earlier finished games of yours they were in and the read from them — each habit with `value`, `n`, `confidence` and `basis`, and the labels. Never returns location or other personal details. |
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
145
|
+
| `warapp_close_finished_game` | **Writes.** Close out a finished game you played so the app's My Games stops listing it — what viewing its Victory / Defeat window does: war.app's GetEndGameWindowData, which marks your seat's end-of-game window seen (the app's My Games lists a finished game only while it is unseen). Confirm-gated; reaches no other player and changes nothing in the game; refuses a game not finished, one you did not play, and one already closed out. Reports `closed` once your games list shows it seen, else `unconfirmed`, or `unknown` when war.app did not answer (never resent). Verified live. |
|
|
146
|
+
| `warapp_get_game` | A game's state, turn, players (and who has committed orders), settings digest and map. A game you lost says how (`howLost`), once finished or while the others play on once your seat is out (#283): a surrender or boot (with the last turn played here and the last logged outlook: its state, your income and armies against the strongest opponent's in view, with its tracked income, frontier read and calibrated income range when logged, and the strongest on income when another opponent, #522), or from the boards cached while you played, the turn you were eliminated on and the cause — your commander's territory that fell (what it held, the attackers that needed, who bordered it; read at the destination, flagged uncertain, when your orders walked the commander that turn) or your last territories. Kept name-free in the outlook log. With `include_history` it says whether the game's history read (`historyRead`: boards, first and last turn, layout) or why not (`historyUnreadable`: the reason and the reply's top-level key names, never values). A finished game you played gets its end-of-game pass once (`endOfGame`, #312): its history read once from GameFeed (one more request) and kept name-free under `<data dir>/finished/` for later games — the outcome and its turn, your picks and the award, the final outlook line when this server planned the game (state, turn, ratio, estimated or thin; no id or words), every player's income and bonuses by turn, what stood on each target your attacks failed to take, and every player's end-of-game stats as the client's end-of-game screen shows them (`endOfGame.stats`, #523: armies produced, lost and killed, highest income, cards, the turn a seat left, and the All Graphs series — armies, territories, income, armies deployed and cumulative luck per turn) — then folded into the opponent profiles, the map's record and the lessons (`endOfGame.processed`); a failed read is recorded (`read-failed` / `history-unreadable` with its reason) and not retried, except by a call with `include_history`, which re-runs it from that read (and adds the stats to a record kept before them: `backfilled: 'stats'`, nothing else re-run); a read whose record could not be written is not repeated while the server runs (`attempted`). With `WARAPP_PLAYER_PROFILE=off` the pass makes no request at all. Not yet a trigger: war.app's game-ended in-app notification (#311). `view`: compact / full / raw. |
|
|
147
|
+
| `warapp_get_map` | The game map's bonuses ranked easiest first, plus chokepoints. Filter by `bonus` name to see one bonus's territories, borders and entry points. View `full` also lists each distribution mode with the territories a player may start on (read once from war.app's map details through the web-client channel (direct or bridge) and kept with the map; `null` when unknown). `income_map: true` lists only the bonuses that pay at the game's values (overrides applied), with members and size, and the base income. |
|
|
147
148
|
| `warapp_map_stats` | **Opt-in, local only.** What has worked on a map, from finished ladder games: the most-picked starting territories, the win rate by every bonus a player started in, the turn of each player's first bonus completion and the sample size (a sample under 5 games and a bonus rate under 10 players are flagged; games whose history could not be read are counted apart, not cached, and `collected.unreadableGames` lists up to 10 of them with why, by key name). Off unless `WARAPP_STATS=1`, always off when hosted. Each call reads the ladder's game-ID feed (`ladder_id`, default 0 = 1v1) and fetches up to `max_new_games` new games (default 10, max 50) at one request a second; finished games are cached forever under `<dataDir>/stats/<mapId>/`. `myGames` adds your own finished games on the map (from their histories, no request): your results by start bonus, where winners started, and the median income after turns 4 and 8. |
|
|
148
149
|
| `warapp_analyze_board` | Advice for one `player` from the current board: income, the bonuses closest to completion with armies needed, and visible threats. Needs a board; lobbies have none. The board parser is unverified, so the advice states its assumptions. |
|
|
149
150
|
| `warapp_strategy` | Strategy notes in our own words, each with its community-guide or wiki source and topic (format, settings, cards, reading the game, opening, timing, fighting, diplomacy, map). With `game_id`, the notes that fit the game (format, phase — from your seat on the live board when the signed-in account plays in it, else GameFeed, `profile.source` `live` or `gamefeed`, and `profile.liveError` the short reason when the live board was tried and did not read, with the frozen-tab hint on a bridge timeout — fog level, move order, distribution, kill rates, the cards in play, private messaging), its `cardClock` (per card, the first turn it can be played) and map notes: bonuses ranked by value per army to take at its settings with entry points, chokepoints, and income targets by turn while picks are open (from the territories the game lists as pickable; none listed, none given). With `map_id` alone (a map already loaded), the map notes; with neither, the topics and every note's id (`topic` gives one topic's notes, view `full` every note). Also served as the resources `warapp://strategy` and `warapp://strategy/map/{mapId}`. See [docs/STRATEGY.md](docs/STRATEGY.md). `view`: compact / full. Read-only. |
|
|
@@ -151,14 +152,14 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
|
|
|
151
152
|
| `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
153
|
| `warapp_get_my_picks` | Your submitted territory picks in priority order, and how many the game allows. |
|
|
153
154
|
| `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. |
|
|
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). |
|
|
155
|
+
| `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 save a completing `gift` (its play verified live 2026-11-23, #435: its card plays go into `orders` and the transfers out of or into the gifted members are dropped; never a territory with a special unit such as your commander, never one an attack leaves from) and a Reconnaissance (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). |
|
|
155
156
|
| `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. |
|
|
156
157
|
| `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). |
|
|
157
158
|
| `warapp_locate_opponents` | Where each opponent probably is and what it may be doing, by name. `seen` is the only fact: its territories in view, and those your earlier boards last showed as its own. Everything else is a simple model's guess with its `basis`, and every `likelihood` is that model's estimate, not a measured probability: `starts` (proven by the award of your picks, then the likely ones among the territories the live board showed as pickable — kept by `warapp_plan_picks` and the `warapp_submit_picks` preview — or, in a game dealt automatically from a map distribution mode, that mode's territories — read once from war.app's map details and kept with the map, with a `warnings` line when unknown — less those a board showed as a neutral or as yours), `presence` (hidden territories it may hold: last seen, start, the corridor between a likely start and a sighting, what it could have grown into from that start, bonuses that explain its tracked income), `bonuses` it probably holds, its tracked `income` and `hiddenArmies` (`warapp_track_opponents`' `unexplainedArmies`), `approaches` (the earliest turn it could attack each of your border territories, from a stack in view with the armies that could arrive, or `guessed`) and `doing`; then `prepare` (`hold`, `contested`, `scout`). The start prior is uniform, or — locally with `WARAPP_STATS=1`, never hosted — weighted by the starts in the finished games `warapp_map_stats` already cached for the map. No war.app request beyond the live board and the game feed, and the map details once per map for a mode's territories. `view`: compact / full (adds the assumptions). Read-only on war.app (it caches the board it read); refuses outside a turn phase. `warapp_plan_turn` does not use it yet. `startCandidates` says where the start candidates came from (and, for a distribution mode, its id and name). |
|
|
158
159
|
| `warapp_profile_opponents` | What each opponent tends to do, by name, counted from your boards and the orders this server sent: per opponent `seen.turnsObserved` (the only fact) and `habits` — `reinforce` (your attack on its territory met more armies than the board showed; measured only at 0% luck with straight rounding), `attack` (turns in contact it attacked you), `firstStrike`, `stacking` (share of its visible growth on one territory), `retaliate` and `retake` (within two turns) — each this game's counts pooled with the player's faded counts from your earlier finished games (`seen.gamesMet`) and shrunk toward a prior (all players in this format, then all players, once that pool has 10 opportunities; the AI pool for an AI seat; else a neutral default) — a `value`, its `n`, `confidence` and `basis` (`this-game`, `past-games`, `population` or `default`), then `labels` and `counter` lines at confidence 0.5 or more. Known teammates are never profiled; while a game's teams cannot be read, nothing is kept and every other player carries `mayBeTeammate: true`. The turns are kept per game (`<dataDir>/profiles/games/`, ids and counts only) by this tool, `warapp_plan_turn` (not a what-if plan), `warapp_track_opponents`, `warapp_locate_opponents` and `warapp_get_relations`, unless `WARAPP_PLAYER_PROFILE=off`. `profile` says whether the turns are `kept`, `not-kept` (no data dir, or the teams unknown) or `off`. `detail`: compact / full (adds the counts and each observed turn). `lastAttackTurn` beside the labels is the last turn it attacked you (null: none seen); `turtle` is never given within two turns of one. Given a finished game it folds it into the cross-game counts instead (`fold`: once, from the turns kept while it was played, else a backfill from the boards cached then — no other request, nothing while its teams are unknown — or "counts start with games played on this build"); `warapp_get_game` does the same on a finished game (`profileFold`). Read-only on war.app (it caches the board it read); refuses any other state outside a turn phase. `warapp_plan_turn` reports a compact read as `reads` (with `lastAttackTurn`) but does not use it. A habit whose past weighs most and was mostly read from finished games' histories reads `basis: history`. |
|
|
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. |
|
|
160
|
+
| `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. In a game that overrides bonus values with a territory limit of 1 on a huge map (1,000+ territories, 3+ players), `startRanking` ranks single starts instead — income at the game's values, turns to the first income above the base, wastelands, commander safety — 25 per `page`, with `submitPicks` the ranking cut at players × 1. |
|
|
160
161
|
| `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. |
|
|
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,
|
|
162
|
+
| `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, Gift 2026-11-23; 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, 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)). |
|
|
162
163
|
| `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). |
|
|
163
164
|
| `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. |
|
|
164
165
|
| `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. |
|
|
@@ -169,7 +170,8 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
|
|
|
169
170
|
| `warapp_get_team` | Your team in a team game, read-only: your team id and where it came from (`gamefeed`, or `my-games` when GameFeed sends no team — GameFeed's team field is unverified), each teammate (GameFeed id, name, `human` or `ai`, state, `committed`, `visibleIncome` on the live board, the `orders` they have entered this turn — deploys, moves, card plays — or while picking their `picks`), the other players by team, the team's shared `hand` (`{ inPlay: false }` in a game without cards) and unread team chat (a count, no text; from the web chat only). `null` means unknown, never "none". Teammate orders and picks come from the client's own structures (picks fall back to `GetTerritoryPicks` with the teammate's id) and are unverified live. Refuses outside a team game. |
|
|
170
171
|
| `warapp_team_brief` | The facts for a team-chat message in a team game, read-only and never sent: while picking, your pick list and each teammate's, the `overlap` (both positions) and `sharedBonuses` you both pick into; on turn 1, the picks your kept list `lost` and to whom (`teammate` or `opponent`); each turn, each opponent's estimated income and its `basis`, the plan's `deploys` and `attacks` (warapp_plan_turn's plan), your `asks` (keep a joint attack, cover a border you concede), your `offers` (a teammate's border your idle armies would hold), the `cards` you play and those left to a teammate, and the `conflicts` with the orders your teammates entered (a target you both attack, a bonus your plan completes or captures into, an order onto your territory; `null` when none were read: unknown). Word it and send it with `warapp_send_chat` (`channel: "team"`). Teammate orders and picks are unverified live; a move onto a teammate's territory is never in `orders`. Refuses outside a team game. |
|
|
171
172
|
| `warapp_send_chat` | **Writes.** Post a chat message to the whole game, to your team (`channel: "team"`, refused outside a team game or when your team is unknown; unverified live), or privately to one player (`to`; refused when the game turns private messaging off). Confirm-gated; the preview names the channel. The game is read from GameFeed first, so it needs the GameFeed credentials as well as the bridge (an unknown game, or a private message to yourself, is refused); a message reaches other players and cannot be unsent. `outcome`: `confirmed` when war.app's reply shows it as your newest message there, `accepted` when the reply cannot be read, `unconfirmed` otherwise. Whatever a message promises is declared in `commitments` (the text is never read): `no-attack` (a player, optionally some territories or bonuses, for 1–10 turns), `will-attack` (a player or a territory, this turn only), `notice` (on an agreed truce, optionally the turn the message says it ends, which must be the one the agreed notice gives; with 0 turns of notice the truce ends with the message), `propose` / `accept` (a truce on structured terms; an accept compares only the terms it restates, and a truce whose last turn is past is refused; a proposal, acceptance or notice goes to the partner — privately or to the whole game — and is refused privately to anyone else or on the team channel). Each is checked against this turn's plan (made in the call, or the orders this server already submitted) and the agreement ledger, and one they do not carry refuses the send. Once the message is confirmed or accepted they are recorded in the ledger as yours (a proposal, an acceptance or a notice also creates or moves the agreement), and `warapp_submit_turn` (and `warapp_plan_turn`, for its plan) warns when later orders break one — an attack into the fog under a promise over all of a player's territories is warned on as unchecked. `automated: true` marks a reply the owner did not ask for: refused before anything is sent unless `WARAPP_CHAT_AUTOMATION=on`, and then still confirm-gated (the result records `automated`). |
|
|
172
|
-
| `warapp_get_relations` | The truces you recorded for a game (`warapp_record_agreement`), each with its state this turn (proposed, active, in notice and the turn it ends, or over and why), and for a live one watch `flags` from your own board history — `broken` (the partner took or attacked a covered territory), `cap-exceeded`, `massing` (its visible armies near the covered border grew two turns running, or an event the fog leaves open), `outgrowing`, `kept` — and `trust` (`clear`, or `watch` on any flag but kept, their notice, or the endgame). Also `tacit`: neighbours with no agreement whose shared border stayed quiet three turns or more (reported, never relied on), and per partner the cross-game `record` of how it kept earlier agreements (tallies, kept rate, notices honoured, breaks in the endgame or while leading, retaliation, turns to a break; `view: "full"` adds the name-free entries). Chat never moves a flag; only the board does. Caches the board it read. |
|
|
173
|
+
| `warapp_get_relations` | The truces you recorded for a game (`warapp_record_agreement`), each with its state this turn (proposed, active, in notice and the turn it ends, or over and why), and for a live one watch `flags` from your own board history — `broken` (the partner took or attacked a covered territory), `cap-exceeded`, `massing` (its visible armies near the covered border grew two turns running, or an event the fog leaves open), `outgrowing`, `kept` — and `trust` (`clear`, or `watch` on any flag but kept, their notice, or the endgame). Also `tacit`: neighbours with no agreement whose shared border stayed quiet three turns or more (reported, never relied on), and per partner the cross-game `record` of how it kept earlier agreements (tallies, kept rate, notices honoured, breaks in the endgame or while leading, retaliation, turns to a break; `view: "full"` adds the name-free entries). Chat never moves a flag; only the board does. In a game running the Diplomacy 2 mod (mod 191) each agreement carries `source: "ledger"` and `modAlliances` lists the mod's alliances (`source: "mod"`) with any `mismatches` against the ledger and `notices` (an ally's break, once applied). Caches the board it read. |
|
|
174
|
+
| `warapp_get_mod_alliances` | The Diplomacy 2 mod's (mod 191) alliances in a game that runs it, read from the game details (UNVERIFIED live): each pair `allied`, `breaking` (your own break order entered: it still holds this turn, either side can attack from `endsTurn`) or `pending` (a proposal to you), who proposed it and the mod's `id` (its order; the mod keeps no turn), your `allies` and the mod's `alerts`. Proposals you sent and an ally's break before it applies are not visible. Proposing, accepting and breaking are manual only (the mod's menu in the web client). Read-only. |
|
|
173
175
|
| `warapp_record_agreement` | **Writes (locally).** Record a truce you made, proposed or received in a free-for-all, or a change to it (agreed, notice, ended, broken by them or by you), with structured terms: what it covers (all, territories or bonuses), turns of notice (0–3), an optional border cap, an end (a turn, or a player out). Refused for yourself, an AI, a player out, a teammate, in a 1v1 and once two players remain. Refused too when no third player or team stands outside you, your team and the partner's, and for an `until_turn` already past. Writes only the server's ledger (`<dataDir>/relations/`, name-free) and, unless `WARAPP_PLAYER_RECORD=off` (on locally and hosted: owner decision D5), the cross-game player record: per partner, keyed by a salted hash with no id, game, name or message, one entry per agreement (format, turns, terms shape, outcome, a break's turn, flag and context, retaliation, proposing again) and tallies; nothing goes to war.app, so it is not confirm-gated. |
|
|
174
176
|
| `warapp_record_intel` | **Writes (locally).** Keep what diplomacy told you for a game in its agreement ledger (#386): `avoid_territories` (with an optional `promised_to`), `avoid_players` (each with a reason code: promised, asked-by-them, joint-enemy, kingmaker, other) and `known_income` (a player's stated income and the turn it was stated, `stated_turn`, default this turn); `forget` removes entries. `warapp_plan_turn` and `warapp_check_plan` then apply them by default and report `intel` (what was applied, the kinds an explicit argument overrode, and stale incomes); an explicit `avoid_territories`, `avoid_players` or `known_income` replaces the stored list of its kind for that call, and a stored income more than 3 turns old is not applied (the estimate stands, with a warning). Ids, turns and reason codes only; nothing goes to war.app, so it is not confirm-gated. |
|
|
175
177
|
| `warapp_backfill_history` | **Writes (locally).** Give the end-of-game pass to up to `limit` (default 10, max 25) of your finished games not yet processed, newest first, among your newest `window` (default 250, max 500) finished games: each history read once from GameFeed, never again, and kept name-free for the profiles, map records and lessons (what `warapp_my_games` does two games per call). Reports `processed`, `processedCount`, `remaining` and `outsideWindow`; safe to call again until `remaining` is 0. Writes only this server's state, never war.app, so it is not confirm-gated. |
|
|
@@ -182,7 +184,7 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
|
|
|
182
184
|
| `warapp_sign_in` | **Hosted only, for mcp-host's sign-in flow.** Signs in to war.app once with your email and password and returns the session cookie to the host, which keeps it as this connection's secret. The password is never stored; a refusal is never retried. Not offered on a local install. |
|
|
183
185
|
| `warapp_link_session` | **Writes (locally).** Capture your signed-in war.app session cookie once and store it on this machine for the direct transport. Confirm-gated; stores a full-account credential locally (file mode `0600`) and never shows or sends it anywhere but war.app. |
|
|
184
186
|
|
|
185
|
-
Everything except `warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_join_game`, `warapp_leave_game`, `warapp_surrender`, `warapp_accept_surrender`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_dismiss_notification`, `warapp_delete_notification`, `warapp_mark_chat_read`, `warapp_link_session`, `warapp_import_state` (hosted only: this server's own state), `warapp_backfill_history` (this server's state only, not confirm-gated), `warapp_sign_in` (hosted only: starts a war.app session for the host's sign-in flow, not confirm-gated), `warapp_record_agreement` and `warapp_record_intel` (this machine's agreement ledger only, not confirm-gated) only reads. Player, game, map
|
|
187
|
+
Everything except `warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_join_game`, `warapp_leave_game`, `warapp_close_finished_game`, `warapp_surrender`, `warapp_accept_surrender`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_dismiss_notification`, `warapp_delete_notification`, `warapp_mark_chat_read`, `warapp_link_session`, `warapp_import_state` (hosted only: this server's own state), `warapp_backfill_history` (this server's state only, not confirm-gated), `warapp_sign_in` (hosted only: starts a war.app session for the host's sign-in flow, not confirm-gated), `warapp_record_agreement` and `warapp_record_intel` (this machine's agreement ledger only, not confirm-gated) only reads. Player, game, map
|
|
186
188
|
and chat text comes back marked as untrusted third-party content.
|
|
187
189
|
|
|
188
190
|
## Moving local history to the hosted server
|
|
@@ -216,7 +218,7 @@ server keeps its own sign-in. Neither tool ever returns the salt or a file's con
|
|
|
216
218
|
|
|
217
219
|
## Confirming writes
|
|
218
220
|
|
|
219
|
-
`warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_leave_game`, `warapp_surrender`, `warapp_accept_surrender`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_dismiss_notification`, `warapp_delete_notification`, `warapp_mark_chat_read`, `warapp_join_game`, `warapp_import_state` and `warapp_link_session` are confirmation-gated:
|
|
221
|
+
`warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_leave_game`, `warapp_close_finished_game`, `warapp_surrender`, `warapp_accept_surrender`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_dismiss_notification`, `warapp_delete_notification`, `warapp_mark_chat_read`, `warapp_join_game`, `warapp_import_state` and `warapp_link_session` are confirmation-gated:
|
|
220
222
|
|
|
221
223
|
- **Clients that support MCP elicitation** show a confirmation prompt describing the change.
|
|
222
224
|
- **Other clients** make **no** change on the first call: it returns a preview and a
|
|
@@ -36,6 +36,10 @@ export function sanctionedIncome(income, percentages) {
|
|
|
36
36
|
}
|
|
37
37
|
return out;
|
|
38
38
|
}
|
|
39
|
+
/** The percentage several Sanctions cards come to together (they compound): 1 − Π(1 − p), to 4 places. */
|
|
40
|
+
export function sanctionPercentage(percentages) {
|
|
41
|
+
return Math.round((1 - percentages.reduce((f, p) => f * (1 - p), 1)) * 10000) / 10000;
|
|
42
|
+
}
|
|
39
43
|
function cardSettings(settings, card) {
|
|
40
44
|
if (!settings?.cards.includes(card))
|
|
41
45
|
return undefined;
|
|
@@ -117,7 +121,12 @@ export function cardsInEffect(input) {
|
|
|
117
121
|
unsure.push(`Sanctions on you were read from the board, but the plan's income does not apply them: ${doubt}.`);
|
|
118
122
|
continue;
|
|
119
123
|
}
|
|
120
|
-
const s = {
|
|
124
|
+
const s = {
|
|
125
|
+
player: target.id,
|
|
126
|
+
percentage: pct,
|
|
127
|
+
untilTurn: a.untilTurn,
|
|
128
|
+
fromTurn: a.untilTurn - durationOf(sanSettings),
|
|
129
|
+
};
|
|
121
130
|
(onMe ? sanctionsOnMe : sanctionsOnOthers).push(s);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Whether a chat message mentions me (warapp_chat_inbox `only: "mentionsMe"`, its public summary): my name, or a
|
|
2
|
+
// territory I hold — by name (a whole word, any case) or by its chat link token `<a t=<id>>` (src/chat-links.ts).
|
|
3
|
+
// Pure; other players' text is only matched, never echoed from here.
|
|
4
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
5
|
+
/** A whole-word, case-insensitive matcher for `word` (letters and digits around it end no word). */
|
|
6
|
+
const wordRe = (word) => new RegExp(`(?<![\\p{L}\\p{N}_])${escapeRe(word)}(?![\\p{L}\\p{N}_])`, 'iu');
|
|
7
|
+
const usable = (s) => s.trim().length >= 2;
|
|
8
|
+
/** The mentions of me in `text`: my name, and the ids of my territories named or linked; undefined when none. */
|
|
9
|
+
export function mentionsOf(text, me) {
|
|
10
|
+
const name = me.names.some((n) => usable(n) && wordRe(n.trim()).test(text));
|
|
11
|
+
const linked = new Set([...text.matchAll(/<a t=(\d{1,10})>/g)].map((m) => Number(m[1])));
|
|
12
|
+
const territories = me.territories
|
|
13
|
+
.filter((t) => linked.has(t.id) || (usable(t.name) && wordRe(t.name.trim()).test(text)))
|
|
14
|
+
.map((t) => t.id)
|
|
15
|
+
.sort((a, b) => a - b);
|
|
16
|
+
return name || territories.length ? { name, territories } : undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Part 5 of the mega-game spec: my commander against opponents the fog hides. Pure and deterministic.
|
|
2
|
+
//
|
|
3
|
+
// In a big free-for-all under fog the players beside my commander are mostly unknown, and two of them
|
|
4
|
+
// striking it in the same turn is likely. Every fogged territory within two moves of the commander's
|
|
5
|
+
// territory may hide one: beside it, it strikes this turn; one step beyond a territory not mine whose
|
|
6
|
+
// armies show, it takes that territory this turn and strikes next turn (my next deploy and its next
|
|
7
|
+
// deploy cancel out, so it is sized as one turn's: what taking the territory in between costs it comes
|
|
8
|
+
// off). Each is assumed a player as strong as the caller says — `stack` armies (one figure, or per fogged
|
|
9
|
+
// territory: the planner gives a start's armies only to a likely holder, #529) plus a whole `deploy` —
|
|
10
|
+
// and the `count` strongest strike in turn: every one but the last softens (its luck-free kills come off),
|
|
11
|
+
// and the last must not take what is left.
|
|
12
|
+
import { COMMANDER_STRENGTH, guaranteedKills, straightKills } from './combat.js';
|
|
13
|
+
import { neighborsOf } from './graph.js';
|
|
14
|
+
/** How many fogged neighbours strike my commander together by default in a big free-for-all. */
|
|
15
|
+
export const DEFAULT_FOGGED_ATTACKERS = 2;
|
|
16
|
+
/** Players (me included) from which a game without teams is a big free-for-all for {@link defaultFoggedAttackers}. */
|
|
17
|
+
export const FOG_FFA_MIN_PLAYERS = 8;
|
|
18
|
+
/** The sentinel player of a border sized for the fog's attackers (no player id is negative). */
|
|
19
|
+
export const FOG_PLAYER = -1;
|
|
20
|
+
/**
|
|
21
|
+
* Every fogged territory that may strike my `t` (see the header), the strongest first (then by id); each
|
|
22
|
+
* once, at its strongest. `gone` territories (taken this turn) neither hide one nor are passed through.
|
|
23
|
+
*/
|
|
24
|
+
export function foggedAttacks(g, view, t, strength, gone = () => false) {
|
|
25
|
+
const { stack } = strength;
|
|
26
|
+
/** What a player hidden on fogged `m` strikes with: its stack (`stack`, or the caller's per-territory reading) and a deploy. */
|
|
27
|
+
const fullAt = (m) => Math.max(0, typeof stack === 'number' ? stack : stack(m)) + Math.max(0, strength.deploy);
|
|
28
|
+
const best = new Map();
|
|
29
|
+
const offer = (a) => {
|
|
30
|
+
const was = best.get(a.territory);
|
|
31
|
+
if (a.armies > 0 && (!was || a.armies > was.armies))
|
|
32
|
+
best.set(a.territory, a);
|
|
33
|
+
};
|
|
34
|
+
for (const n of neighborsOf(g, t)) {
|
|
35
|
+
if (gone(n) || view.mine(n))
|
|
36
|
+
continue;
|
|
37
|
+
if (view.fogged(n)) {
|
|
38
|
+
offer({ territory: n, armies: fullAt(n) });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const there = view.armies(n);
|
|
42
|
+
if (there === null)
|
|
43
|
+
continue;
|
|
44
|
+
// Taking `n` first: its defenders kill this many of the attackers (luck-free).
|
|
45
|
+
const cost = straightKills(there, strength.defensiveKillRate);
|
|
46
|
+
for (const m of neighborsOf(g, n)) {
|
|
47
|
+
if (m === t || gone(m) || view.mine(m) || !view.fogged(m))
|
|
48
|
+
continue;
|
|
49
|
+
offer({ territory: m, via: n, armies: fullAt(m) - cost });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return [...best.values()].sort((a, b) => b.armies - a.armies || a.territory - b.territory);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The `count` strongest of `attacks` striking in turn: the most defenders they take together
|
|
56
|
+
* (`takesAlone` of the last plus `killsOf` every softener), the last tried as each of them. 0 with none.
|
|
57
|
+
*/
|
|
58
|
+
export function foggedTakes(attacks, count, killsOf, takesAlone) {
|
|
59
|
+
const used = [...attacks].sort((a, b) => b - a).slice(0, Math.max(0, count));
|
|
60
|
+
let takes = 0;
|
|
61
|
+
for (const [i, last] of used.entries()) {
|
|
62
|
+
const soft = used.reduce((n, a, j) => (j === i ? n : n + killsOf(a)), 0);
|
|
63
|
+
takes = Math.max(takes, soft + takesAlone(last));
|
|
64
|
+
}
|
|
65
|
+
return takes;
|
|
66
|
+
}
|
|
67
|
+
/** The default number of fogged attackers: {@link DEFAULT_FOGGED_ATTACKERS} in a big free-for-all with commanders, else 0 (off). */
|
|
68
|
+
export function defaultFoggedAttackers(a) {
|
|
69
|
+
return a.commanders && a.fog && !a.teams && a.players >= FOG_FFA_MIN_PLAYERS ? DEFAULT_FOGGED_ATTACKERS : 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The armies a hidden player's stack is taken to hold: an opponent's start (the game's armies on each
|
|
73
|
+
* player's starting territory, when it sets them), else my largest stack — a player as strong as I am.
|
|
74
|
+
*/
|
|
75
|
+
export function foggedStack(startArmies, myLargest) {
|
|
76
|
+
return startArmies !== undefined && startArmies > 0 ? startArmies : Math.max(0, myLargest);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* My commander on `territory` with `armies` of mine there against the `count` strongest fogged attacks:
|
|
80
|
+
* each softener's luck-free kills come off, and the last must not kill every defender left (my commander
|
|
81
|
+
* fights as {@link COMMANDER_STRENGTH}). Undefined with no fogged territory in reach.
|
|
82
|
+
*/
|
|
83
|
+
export function foggedCommanderCheck(g, view, territory, armies, a) {
|
|
84
|
+
if (a.count <= 0)
|
|
85
|
+
return undefined;
|
|
86
|
+
const from = foggedAttacks(g, view, territory, a);
|
|
87
|
+
if (!from.length)
|
|
88
|
+
return undefined;
|
|
89
|
+
const used = from.slice(0, a.count);
|
|
90
|
+
const kills = (n) => guaranteedKills(n, a.offensiveKillRate, 0, 'StraightRound');
|
|
91
|
+
const survives = (d) => used.every((last, i) => {
|
|
92
|
+
const left = d + COMMANDER_STRENGTH - used.reduce((n, x, j) => (j === i ? n : n + kills(x.armies)), 0);
|
|
93
|
+
return left > 0 && kills(last.armies) < left;
|
|
94
|
+
});
|
|
95
|
+
let needs = Math.max(0, armies);
|
|
96
|
+
if (!survives(needs)) {
|
|
97
|
+
needs = 0;
|
|
98
|
+
while (!survives(needs))
|
|
99
|
+
needs++;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
while (needs > 0 && survives(needs - 1))
|
|
103
|
+
needs--;
|
|
104
|
+
}
|
|
105
|
+
return { territory, armies, attackers: used.length, from: used, safe: survives(armies), needs };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* #529 (owner decision): the armies a player hidden on fogged `t` may hold. A start's `stack` only on a likely
|
|
109
|
+
* holder — a possible start this turn (`starts`), a territory whose owner shows as another player, or one where a
|
|
110
|
+
* player's stack was last seen (`lastSeen`) — else the territory's usual estimate: the vacated size (#417), its last
|
|
111
|
+
* sighting (#428), the picking board's neutral (#201), else the game's neutral size (0 when unknown). One reading for
|
|
112
|
+
* the planner's hold and warapp_plan_turn's `commander.fogged`.
|
|
113
|
+
*/
|
|
114
|
+
export function likelyStackAt(a) {
|
|
115
|
+
return (t) => {
|
|
116
|
+
const seen = a.lastSeen?.get(t);
|
|
117
|
+
const shown = a.shownPlayer(t);
|
|
118
|
+
if ((shown !== undefined && shown !== a.me) || a.starts?.has(t) || (seen && seen.owner !== null && seen.owner !== a.me))
|
|
119
|
+
return a.stack;
|
|
120
|
+
if (a.vacated?.has(t))
|
|
121
|
+
return a.vacatedArmies;
|
|
122
|
+
if (seen)
|
|
123
|
+
return seen.armies;
|
|
124
|
+
return a.rememberedNeutrals?.get(t) ?? a.neutralArmies ?? 0;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { playersByInGameId } from '../live.js';
|
|
2
|
+
const isRec = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
3
|
+
const num = (v) => {
|
|
4
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : Number.NaN;
|
|
5
|
+
return Number.isFinite(n) ? n : 0;
|
|
6
|
+
};
|
|
7
|
+
const yes = (v) => v === true || (typeof v === 'string' && v.toLowerCase() === 'true');
|
|
8
|
+
const SAFE_STATE = /^[A-Za-z]{1,40}$/;
|
|
9
|
+
/**
|
|
10
|
+
* The stats from a GameFeed history (the gathered `standing<N>` / `turn<N>` object, or a `history` wrapper of
|
|
11
|
+
* it), `undefined` when no turn's orders read. `players`: the game's players (owners may be in-game ids).
|
|
12
|
+
*/
|
|
13
|
+
export function endGameStats(history, players) {
|
|
14
|
+
try {
|
|
15
|
+
const h = unwrap(history);
|
|
16
|
+
if (!h)
|
|
17
|
+
return undefined;
|
|
18
|
+
const byInGame = playersByInGameId(players);
|
|
19
|
+
const feedIds = new Set(players.map((p) => p.id));
|
|
20
|
+
const feedOf = (raw) => {
|
|
21
|
+
const n = num(raw);
|
|
22
|
+
if (!Number.isInteger(n) || n <= 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (feedIds.has(n))
|
|
25
|
+
return n;
|
|
26
|
+
return byInGame.get(n)?.id;
|
|
27
|
+
};
|
|
28
|
+
const out = new Map(players.map((p) => [p.id, { produced: 0, lost: 0, killed: 0, killedNeutral: 0, cardsPlayed: 0, cardsReceived: 0, deployed: [], luck: [0], offensiveLuck: [0], defensiveLuck: [0] }]));
|
|
29
|
+
const off = new Map();
|
|
30
|
+
const def = new Map();
|
|
31
|
+
const add = (m, p, v) => m.set(p, (m.get(p) ?? 0) + v);
|
|
32
|
+
let turnsRead = 0;
|
|
33
|
+
const turns = Object.keys(h)
|
|
34
|
+
.map((k) => /^turn_?(\d+)$/i.exec(k))
|
|
35
|
+
.filter((m) => m !== null)
|
|
36
|
+
.map((m) => ({ n: Number(m[1]), key: m[0] }))
|
|
37
|
+
.sort((a, b) => a.n - b.n);
|
|
38
|
+
for (const { n, key } of turns) {
|
|
39
|
+
const t = h[key];
|
|
40
|
+
const orders = isRec(t) ? t.orders : Array.isArray(t) ? t : undefined;
|
|
41
|
+
if (!Array.isArray(orders))
|
|
42
|
+
continue;
|
|
43
|
+
turnsRead++;
|
|
44
|
+
const owner = ownersOf(h[`standing${n}`] ?? h[`standing_${n}`], feedOf);
|
|
45
|
+
const deployed = new Map();
|
|
46
|
+
for (const o of orders) {
|
|
47
|
+
if (!isRec(o) || typeof o.type !== 'string')
|
|
48
|
+
continue;
|
|
49
|
+
const p = feedOf(o.playerID);
|
|
50
|
+
const s = p === undefined ? undefined : out.get(p);
|
|
51
|
+
if (o.type === 'GameOrderDeploy') {
|
|
52
|
+
if (s && p !== undefined) {
|
|
53
|
+
s.produced += num(o.armies);
|
|
54
|
+
add(deployed, p, num(o.armies));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (o.type === 'GameOrderAttackTransfer') {
|
|
58
|
+
const r = o.result;
|
|
59
|
+
if (!isRec(r) || !yes(r.isAttack))
|
|
60
|
+
continue;
|
|
61
|
+
const to = String(o.to);
|
|
62
|
+
const attackersDied = num(r.attackingArmiesKilled);
|
|
63
|
+
const defendersDied = num(r.defendingArmiesKilled);
|
|
64
|
+
const holder = owner.get(to);
|
|
65
|
+
// The client's luck (Statistics metrics 4–6): the attacker's offense less defense luck, the defender's the reverse.
|
|
66
|
+
const luck = num(r.offenseLuck) - num(r.defenseLuck);
|
|
67
|
+
if (s && p !== undefined) {
|
|
68
|
+
s.lost += attackersDied;
|
|
69
|
+
s.killed += defendersDied;
|
|
70
|
+
if (holder === 'neutral')
|
|
71
|
+
s.killedNeutral += defendersDied;
|
|
72
|
+
add(off, p, luck);
|
|
73
|
+
}
|
|
74
|
+
const d = typeof holder === 'number' ? out.get(holder) : undefined;
|
|
75
|
+
if (d && holder !== p) {
|
|
76
|
+
d.lost += defendersDied;
|
|
77
|
+
d.killed += attackersDied;
|
|
78
|
+
add(def, holder, -luck);
|
|
79
|
+
}
|
|
80
|
+
if (yes(r.isSuccessful) && p !== undefined)
|
|
81
|
+
owner.set(to, p);
|
|
82
|
+
}
|
|
83
|
+
else if (o.type.startsWith('GameOrderPlayCard')) {
|
|
84
|
+
if (s)
|
|
85
|
+
s.cardsPlayed++;
|
|
86
|
+
}
|
|
87
|
+
else if (o.type === 'GameOrderReceiveCard') {
|
|
88
|
+
if (s && Array.isArray(o.cardsMadeWhole))
|
|
89
|
+
s.cardsReceived += o.cardsMadeWhole.length;
|
|
90
|
+
}
|
|
91
|
+
else if (o.type === 'GameOrderStateTransition') {
|
|
92
|
+
const state = typeof o.newState === 'string' && SAFE_STATE.test(o.newState) ? o.newState : 'unknown';
|
|
93
|
+
if (s)
|
|
94
|
+
s.left = { turn: n + 1, state };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const r2 = (v) => Math.round(v * 100) / 100;
|
|
98
|
+
for (const [id, s] of out) {
|
|
99
|
+
// The client adds a turn's deploy point only while the seat is still in after it.
|
|
100
|
+
if (!s.left || n + 1 < s.left.turn)
|
|
101
|
+
s.deployed.push(deployed.get(id) ?? 0);
|
|
102
|
+
const o = off.get(id) ?? 0;
|
|
103
|
+
const d = def.get(id) ?? 0;
|
|
104
|
+
s.offensiveLuck.push(r2(o));
|
|
105
|
+
s.defensiveLuck.push(r2(d));
|
|
106
|
+
s.luck.push(r2(o + d));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return turnsRead ? { players: out, turnsRead } : undefined;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** The gathered history object (a `history` / `History` wrapper opened). */
|
|
116
|
+
function unwrap(history) {
|
|
117
|
+
if (!isRec(history))
|
|
118
|
+
return undefined;
|
|
119
|
+
for (const k of ['history', 'History'])
|
|
120
|
+
if (isRec(history[k]))
|
|
121
|
+
return history[k];
|
|
122
|
+
return history;
|
|
123
|
+
}
|
|
124
|
+
/** A raw standing's owners by territory id: a player's GameFeed id, `neutral`, or absent (unknown). */
|
|
125
|
+
function ownersOf(standing, feedOf) {
|
|
126
|
+
const out = new Map();
|
|
127
|
+
const rows = Array.isArray(standing) ? standing : isRec(standing) ? Object.values(standing) : [];
|
|
128
|
+
for (const t of rows) {
|
|
129
|
+
if (!isRec(t) || t.terrID === undefined)
|
|
130
|
+
continue;
|
|
131
|
+
const id = String(t.terrID);
|
|
132
|
+
if (typeof t.ownedBy === 'string' && t.ownedBy.toLowerCase() === 'neutral')
|
|
133
|
+
out.set(id, 'neutral');
|
|
134
|
+
else {
|
|
135
|
+
const p = feedOf(t.ownedBy);
|
|
136
|
+
if (p !== undefined)
|
|
137
|
+
out.set(id, p);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
/** The most income each player had on the history boards (`turns[].players.<id>.income`), by id. */
|
|
143
|
+
export function highestIncomes(turns) {
|
|
144
|
+
const out = new Map();
|
|
145
|
+
for (const t of turns)
|
|
146
|
+
for (const [id, pt] of t.players)
|
|
147
|
+
out.set(id, Math.max(out.get(id) ?? 0, pt.income));
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Local Deployment (GameFeed `LocalDeployments`): armies earned from a bonus may
|
|
2
2
|
// only be deployed on that bonus's territories; the rest of the income (base
|
|
3
|
-
// income
|
|
4
|
-
//
|
|
3
|
+
// income — MinimumArmyBonus, or floor(territories / BonusArmyPer) when larger — card
|
|
4
|
+
// armies, cities) may go anywhere; a 0-value bonus makes no pool. Read from the client
|
|
5
|
+
// bundle's income and deploy check (docs/WARAPP-API.md), not yet seen live.
|
|
5
6
|
// Pure and deterministic.
|
|
6
7
|
import { bonusTerritories } from './bonuses.js';
|
|
7
8
|
/**
|