@chrischall/warapp-mcp 0.22.0 → 0.23.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.
Files changed (73) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +49 -3
  4. package/dist/analysis/coalition.js +3 -2
  5. package/dist/analysis/guard-off.js +7 -0
  6. package/dist/analysis/headroom.js +1 -0
  7. package/dist/analysis/outlook.js +42 -2
  8. package/dist/analysis/plan/captures.js +2 -0
  9. package/dist/analysis/plan/holds.js +25 -8
  10. package/dist/analysis/plan/report.js +2 -2
  11. package/dist/analysis/plan/targets.js +15 -5
  12. package/dist/analysis/plan/threats.js +55 -2
  13. package/dist/analysis/planner.js +12 -1
  14. package/dist/bundle.js +10245 -3743
  15. package/dist/chat.js +93 -3
  16. package/dist/clans.js +308 -0
  17. package/dist/forums.js +70 -0
  18. package/dist/friends.js +83 -0
  19. package/dist/index.js +1 -1
  20. package/dist/invite-code.js +46 -0
  21. package/dist/join-color.js +23 -13
  22. package/dist/ladders.js +360 -0
  23. package/dist/lessons-store.js +2 -2
  24. package/dist/mail.js +295 -0
  25. package/dist/my-games.js +18 -1
  26. package/dist/notifications.js +22 -4
  27. package/dist/open-games.js +29 -2
  28. package/dist/outlook-log.js +1 -0
  29. package/dist/protocol/bundle.js +4 -4
  30. package/dist/protocol/codec.js +1 -1
  31. package/dist/protocol/methods.js +690 -8
  32. package/dist/protocol/rpc.js +28 -3
  33. package/dist/push/socketio.js +2 -2
  34. package/dist/quickmatch.js +264 -0
  35. package/dist/surrender-pending.js +62 -2
  36. package/dist/templates.js +451 -0
  37. package/dist/tools/bait.js +6 -2
  38. package/dist/tools/boot-player.js +165 -0
  39. package/dist/tools/chat.js +19 -0
  40. package/dist/tools/check-plan.js +5 -3
  41. package/dist/tools/clan-writes.js +208 -0
  42. package/dist/tools/clans.js +181 -0
  43. package/dist/tools/end-game-common.js +49 -0
  44. package/dist/tools/forums.js +535 -0
  45. package/dist/tools/friends.js +50 -0
  46. package/dist/tools/game.js +21 -3
  47. package/dist/tools/index.js +39 -0
  48. package/dist/tools/invites.js +347 -0
  49. package/dist/tools/join-game.js +4 -4
  50. package/dist/tools/ladders.js +418 -0
  51. package/dist/tools/leave-game.js +85 -27
  52. package/dist/tools/live-context.js +2 -2
  53. package/dist/tools/mail.js +600 -0
  54. package/dist/tools/my-games.js +50 -6
  55. package/dist/tools/notifications.js +12 -3
  56. package/dist/tools/nudge.js +178 -0
  57. package/dist/tools/past-games.js +23 -0
  58. package/dist/tools/quickmatch.js +481 -0
  59. package/dist/tools/react.js +177 -0
  60. package/dist/tools/session.js +6 -2
  61. package/dist/tools/team-surrender.js +206 -0
  62. package/dist/tools/templates.js +342 -0
  63. package/dist/tools/tournaments.js +495 -0
  64. package/dist/tools/turn.js +18 -8
  65. package/dist/tools/vote-to-end.js +142 -0
  66. package/dist/tools/write-kit.js +22 -1
  67. package/dist/tournaments.js +321 -0
  68. package/dist/version.js +1 -1
  69. package/manifest.json +190 -2
  70. package/mint.yaml +3 -4
  71. package/package.json +1 -1
  72. package/server.json +2 -2
  73. package/skills/warapp-mcp/SKILL.md +39 -6
@@ -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, 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.22.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 (creating, joining, leaving or surrendering a game, accepting game invitations, closing out a finished game, accepting another player's surrender, a team surrender, a vote to end a game, booting a stalled player, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, nudging a player, joining or leaving a ladder, answering a clan invite, joining or leaving a clan, changing quickmatch settings, voting on quickmatch templates, joining or declining a tournament, showing a tournament among your favourites, mail (new threads, replies, adding players, deleting threads), forum posts (new threads, replies, votes, watching a thread), chat reactions, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
10
+ "version": "0.23.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.22.0",
18
+ "version": "0.23.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.22.0",
4
+ "version": "0.23.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
@@ -137,10 +137,18 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
137
137
  | `warapp_healthcheck` | Check that war.app accepts your email and API token; report the active transport and whether a direct session is linked. |
138
138
  | `warapp_my_games` | Your games (through your signed-in tab), games waiting on you first: state, turn, players and who has committed, and `waitingOnYou`; `surrenderPending` per game (another player's surrender still pending, `owedByMe` true when it waits on your acceptance; read from the game details, unverified live; `null` when not read, never "none") and as a top-level count of games where one waits on you, which come first too (compact only). Finished games only with `include_finished`; `listed` (games war.app returned) and `complete` (false, with a warning, when the list may be partial). Each call also runs the end-of-game pass (as `warapp_get_game` does) on up to two of your finished games not yet processed, newest first, among your newest 250 finished games (`endOfGame`: `processed`, `pending`). `view`: compact / brief. |
139
139
  | `warapp_list_open_games` | Open games you could join, from war.app's Open Games page: pace, boot time, seats, team or not, entry fee, cards, rules (One Army Must Stand Guard on or off among them), `plannerGaps` (rules the planner does not model yet; a guard-off game is not one: the planner keeps a second line, raids and retakes with the guard off, a raid or retake sized for its owner's deploy there), `joined: true` on games you already hold a seat in, `lottery` (from the data, never the name: `true` for a map of at most four territories — its size read from GameFeed only for lobbies with base income 0 and overridden bonuses, at most five a call, or from a map already cached — `null` for that settings shape with the map size unread; `lotteryBasis` says which), and `policyBreaks`: the joining-policy rules a game breaks (Commerce, mods, custom scenarios, more than four seats, a boot time under 12 hours, a lottery (a likely one too); advisory). Filters: `pace`, `max_players`, `free_only`, `exclude_teams`, `limit`. A page GET, so it works without a browser once a session is linked. |
140
+ | `warapp_list_templates` | Game templates: your own saved ones, or those with the given `ids` — id, name, description, map, category, fog; `free_mod_game: true` adds your free-mod-game status (Available, Reserved or Used, and the coins per player otherwise). Read from war.app's client code, unverified live. |
141
+ | `warapp_get_template` | One template with its settings (kill rates, luck, fog, move order, distribution, base income, cards, the army cap, mods, overrides, boot times, ranked, real time) and `cannotCreate`: what stops `warapp_create_game` using it. Read from war.app's client code, unverified live. |
142
+ | `warapp_create_game` | **Writes.** Create a game from a template, its settings exactly the template's (only the `name` can change), inviting you, the `invite` players, `open_seats` and `ai_seats` — or, with `invite_link: true`, joined by an invite code war.app makes. Confirm-gated; the preview spells out the settings and names every seat by id; refuses custom scenarios, coin fees and single-player templates. Reports `created` with the new `gameId` once GameFeed shows you seated, else `unconfirmed`, or `unknown` when war.app did not answer (never resent). Read from war.app's client code, unverified live. |
140
143
  | `warapp_join_game` | **Writes.** Take an open seat in a game from the open games list. Confirm-gated; refuses a lobby that breaks the joining policy (Commerce, mods, custom scenarios, costly neutrals, more than four seats, a short boot time, lotteries, Local Deployment, Commanders, No-Split, an army cap, Multi-Attack, non-default kill rates) unless `override_policy: true` (#423); refuses team games and coin entry fees unless allowed (`allow_team`, `accept_entry_fee`; `team` picks a team by number and implies `allow_team` — refused when that team is full or not offered, with random teams, and outside a team game; the preview's `team` lists the teams offered and the seats on the chosen one by in-game id, `human` or `ai`; the team is sent as the chosen open seat's team, read from the client bundle and unverified live), and custom-scenario and mod games and games you already joined always. Joins with your preferred colour, else your secondary, else a free standard colour (or `color`, a war.app colour index). The preview adds a `screen` from the lobby's GameFeed settings — does the cheapest neutral cost at most one turn of base income — and flags Light Fog and costly neutrals in `plannerGaps`, plus `lottery` and `policy`: whether the lobby keeps the joining policy (the rules above plus that neutral cost and no lottery; advisory, never a refusal). Reports `joined` only once GameFeed or your games list shows you in the game. |
141
- | `warapp_leave_game` | **Writes.** Leave a game that has not started — a lobby still `WaitingForPlayers` — giving up your seat (war.app's DeclineGame, the lobby's Decline button; verified live for a lobby joined through an open seat). Confirm-gated; refuses a game that has started (surrender it instead), a lobby you hold no seat in, and mod games. The preview warns that the seat is given up (you can only come back through a seat still open) and that war.app may remove your chat in the game. Reports `left` only once GameFeed (or your games list) no longer shows you seated — `unconfirmed` otherwise, `unknown` when war.app did not answer (never resent). |
144
+ | `warapp_accept_invite` | **Writes.** Accept an invitation to a game `warapp_my_games` lists with your seat `Invited` (war.app's AcceptGame; read from the client bundle, UNVERIFIED live). Confirm-gated; refuses a game not in your list, a seat no longer invited, mod games, and a coin entry fee unless `accept_entry_fee`. The preview shows the game as `warapp_list_open_games` does and `policy`, the joining policy `warapp_join_game` applies: each rule the game breaks is reported, never refused, since an invitation is your choice. Accepts with your preferred colour, else your secondary, else a free one (or `color`; none when the host locked yours in). Reports `accepted` only once GameFeed or your games list shows you seated. Decline an invitation with `warapp_leave_game`. |
145
+ | `warapp_get_game_by_invite_code` | The game an invite code names (war.app's GetGameByInviteCode; UNVERIFIED live): `found: false` for an unknown code, `gameId: null` while the code's game is not made yet, else the game id, url, the code's player cap and, when the open games list or your games list carries it, the game as `warapp_list_open_games` shows it (with `policyBreaks`). Joining through a code is not built. Read-only. |
146
+ | `warapp_leave_game` | **Writes.** Leave a game that has not started — a lobby still `WaitingForPlayers` — giving up your seat (war.app's DeclineGame, the lobby's Decline button; verified live for a lobby joined through an open seat). It also declines an invitation to such a game (your seat `Invited`; the same call, UNVERIFIED live for an invitation), reported `declined` once your games list no longer shows the invitation. Confirm-gated; refuses a game that has started (surrender it instead), a lobby you hold no seat or invitation in, and mod games. The preview warns that the seat is given up (you can only come back through a seat still open) and that war.app may remove your chat in the game. Reports `left` only once GameFeed (or your games list) no longer shows you seated — `unconfirmed` otherwise, `unknown` when war.app did not answer (never resent). |
142
147
  | `warapp_surrender` | **Writes.** Surrender a game you are playing — you lose it and cannot rejoin — or, with `undo: true`, take back a pending surrender. Confirm-gated; refuses finished games and games you are not in; reads the outcome from GameFeed: `surrendered`, `pending` (more than two players: the others must accept), `still_playing` (after `undo`: GameFeed shows no pending surrender, so a take-back cannot be confirmed) or `unchanged`. Lobbies are refused too. |
143
148
  | `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. |
149
+ | `warapp_team_surrender` | **Writes.** In a team game, propose that your whole team surrenders, accept (vote yes) or decline (vote no) a teammate's proposal, or withdraw your own. If every teammate still playing accepts, everyone on the team surrenders and none of you can rejoin. Confirm-gated; reads the vote from the game details and refuses what the client would not offer; the preview shows who proposed, who voted and who has not. UNVERIFIED live. |
150
+ | `warapp_vote_to_end` | **Writes.** Vote to end a game, or take the vote back (`withdraw: true`). Once every player still playing has voted, the game ends by vote with no winner. Confirm-gated; the preview lists who has voted and whether yours is the last vote. UNVERIFIED live. |
151
+ | `warapp_boot_player` | **Writes.** Boot a player who has run past the game's direct-boot time (DirectBoot): they are kicked out at once and their seat becomes an AI or neutral. Confirm-gated; refused until the boot time has passed, and for a player who has committed, an AI or yourself. `warapp_get_game` says when a player can be booted. UNVERIFIED live. |
144
152
  | `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. |
145
153
  | `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. |
146
154
  | `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. |
@@ -167,8 +175,46 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
167
175
  | `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. |
168
176
  | `warapp_dismiss_notification` | **Writes.** Mark one or several notifications read by the ids `warapp_get_notifications` lists (war.app's AcknowledgeInAppNotifications; nothing is deleted — `warapp_delete_notification` deletes — and nothing reaches another player). Confirm-gated; the preview names ids and game ids only; refuses ids not listed or already read; the outcome is read back by listing again (`dismissed` only when every id reads read or is seen gone from the list; `unconfirmed` while one reads unread or was not seen in the pages read back; `unknown` when war.app did not answer — never resent). Verified live 2026-11-16. |
169
177
  | `warapp_delete_notification` | **Writes.** Delete one or several notifications, read or unread, by the ids `warapp_get_notifications` lists (war.app's DeleteInAppNotification, the game's Delete button: one request per id, in order). A deleted notification is gone for good; nothing reaches another player. Confirm-gated; the preview names ids and game ids only and says it cannot be undone; refuses ids not listed; an id war.app no longer holds when sent (its error 699) counts as already gone (`alreadyGone`); a refusal, or a request that could not be sent after an earlier id was deleted, stops there (the rest are `notSent`, read back as `unconfirmed`). The outcome is read back by listing again (`deleted` only when every id is seen gone from the list; `unconfirmed` while one is still listed, was not seen in the pages read back, or war.app refused one; `unknown` when war.app did not answer — never resent). Verified live 2026-11-16. |
178
+ | `warapp_mail_inbox` | Your war.app private mail (#629): war.app's unread-mail flag (it rides on every reply), the mail threads your in-app notifications link to (unread ones listed), and — with a player — every thread you share with them (war.app's SearchPrivateDiscussions). Read-only. UNVERIFIED live. |
179
+ | `warapp_get_mail_thread` | One mail thread (war.app's GetDiscussion): subject, players, whether it is locked or allows adding players, and a page of posts (the newest by default). Subjects, texts and names come back as untrusted third-party content. Read-only. UNVERIFIED live. |
180
+ | `warapp_reply_mail` | **Writes.** Reply to a mail thread you are in (war.app's CreatePost). Confirm-gated; refuses a locked thread and one whose last post is over 30 days old; an automated reply is refused unless `WARAPP_CHAT_AUTOMATION` is on, as for chat. Read back from the thread. UNVERIFIED live. |
181
+ | `warapp_create_mail` | **Writes.** Send new mail (war.app's CreatePrivateDiscussion): a subject and a first message to one or more players, with 6.09's choice to let them add others. Confirm-gated, under the same automated-chat rule. UNVERIFIED live. |
182
+ | `warapp_add_mail_players` | **Writes.** Add players to a mail thread that allows it (war.app's AddPlayersToPrivateDiscussion, new in 6.09). Confirm-gated, under the same automated-chat rule. UNVERIFIED live. |
183
+ | `warapp_delete_mail` | **Writes.** Delete a mail thread from your mail (war.app's DeletePrivateDiscussion), either until someone replies or for good. Confirm-gated; reaches no other player. UNVERIFIED live. |
184
+ | `warapp_list_forums` | The war.app forums (war.app's GetForums, #640): each forum's id, name and what posting needs (a level or ladder play). Read-only. UNVERIFIED live. |
185
+ | `warapp_forum_threads` | A page of 50 forum threads: one forum, every forum, a search (`query`) or a group's forum (`group_id`) — war.app's GetForumThreads, SearchForum and GetGroupForumThreads. Threads the client hides for downvotes are counted, not listed. Subjects and names come back as untrusted third-party content. Read-only. UNVERIFIED live. |
186
+ | `warapp_get_forum_thread` | One forum thread (war.app's GetDiscussion): subject, forum, locked, whether you watch it, and a page of 20 posts with their vote counts and yours. Mail threads are refused. Texts come back as untrusted third-party content. Read-only. UNVERIFIED live. |
187
+ | `warapp_create_forum_thread` | **Writes.** Start a forum thread (war.app's CreateForumThread): a subject and a first post in a forum. Confirm-gated; an automated post is refused unless `WARAPP_CHAT_AUTOMATION` is on, as for chat. Read back from the new thread. UNVERIFIED live. |
188
+ | `warapp_reply_forum_thread` | **Writes.** Reply to a forum thread (war.app's CreatePost). Confirm-gated, under the same automated-chat rule; refuses a locked thread and one whose last post is over 30 days old (outside Feature Requests). Read back from the thread. UNVERIFIED live. |
189
+ | `warapp_vote_forum_post` | **Writes.** Vote a forum post up or down, or take the vote back (war.app's ForumVote). Confirm-gated; posts no text. Read back from the thread. UNVERIFIED live. |
190
+ | `warapp_watch_forum_thread` | **Writes.** Watch a forum thread, or stop (war.app's WatchForumThread). Confirm-gated; reaches no other player. Read back from the thread's watchers. UNVERIFIED live. |
170
191
  | `warapp_get_chat` | A game's chat, oldest first: read through your war.app tab (the web client's GameRefresh, which tells public, team and private messages apart) or else GameFeed (channels `unknown`); when the web read has fewer messages than GameFeed's chat (a finished game's surrender line), GameFeed's are used too (its extra messages under `unknown`), flagged by `filledFromGamefeed: true` with `feedFill` giving the counts; `source` still says which read answered (`web` or `gamefeed`). Each message has its sender, delimited text, time, turn, `channel` (and team or recipient), `mine` and `new`; the result has `unread` per channel. `channel` filters; `mark_seen: true` marks the channels read as seen, kept on this machine (counts and times, never text; from GameFeed only `unknown`), older messages `limit` left out included (`markedUnshown` counts the unread ones); war.app itself is marked by `warapp_mark_chat_read`. The channel fields are unverified live. Read-only. Every message another player sent carries `intent` (`intents` such as `income-check`, `truce-proposal`, `threat`, `surrender-ask`, and a `confidence`) and an unread one `advice` (see [Chat advice](#chat-advice)); the text stays beside them, as other players' words. |
171
192
  | `warapp_mark_chat_read` | **Writes.** Mark a game's chat read on war.app itself (war.app's RegisterChatView), every channel or one (`channel`), up to the newest message read now, so the game stops showing unread messages; it changes only your own unread state, reaches no other player and posts nothing. Confirm-gated; needs the chat read through your war.app tab or linked session (GameFeed gives no message ids); refuses a chat with nothing to mark (including one whose web read returned no messages while GameFeed holds some: no message id to mark) or one your games list already shows read; the preview names ids only; the outcome is read back from your games list's unread-chat flags (`read` / `unconfirmed`, or `unknown` when war.app did not answer — never resent). Verified live 2026-11-16. |
193
+ | `warapp_get_friends` | Your war.app friends list (war.app's GetFriends): each friend's player id and name (delimited), nothing else about them; and `blocked`, the ids of the players you have blocked, read from a war.app page's startup parameters (`null` with `blockedNote` when that page cannot be read as your signed-in account's). Read-only. Read from the client code, UNVERIFIED live. |
194
+ | `warapp_quickmatch_settings` | Your quickmatch settings (war.app's GetQuickmatchSettings): wins, templates and votes unlocked, `multiDay.games` (how many multi-day quickmatch games war.app may start for you on its own; 0 is off), the coin wager, speed and your ratings (never the per-country one), and your unlocked templates with each one's setting; `lengths: true` adds average game lengths. Read-only. Read from the client code, UNVERIFIED live. |
195
+ | `warapp_quickmatch_templates` | The quickmatch templates players vote on (war.app's GetQuickmatchTemplates): votes, rank and your votes, plus your votes unlocked and available; `template_id` lists who voted for it (ids and delimited names). Read-only. UNVERIFIED live. |
196
+ | `warapp_quickmatch_leaderboard` | A quickmatch leaderboard (war.app's GetQuickmatchLeaderboards), global, by format or per template, 50 a page: rank, player id, delimited name and rating. Read-only. UNVERIFIED live. |
197
+ | `warapp_set_quickmatch_settings` | **Writes.** Change which quickmatch templates you play and `multi_day_games`, how many multi-day games war.app may start for you on its own (0 turns it off). Confirm-gated; the preview says how many games could start and where to turn them off. Everything else is re-sent as war.app has it. UNVERIFIED live. |
198
+ | `warapp_vote_quickmatch_template` | **Writes.** Set your votes (0–3) on a quickmatch template (war.app's SetQuickmatchTemplateVotes). Confirm-gated; refuses a fixed-rank template and more votes than you have. UNVERIFIED live. |
199
+ | `warapp_nudge_player` | **Writes.** Nudge a player who is holding up a game (war.app's Nudge): war.app sends them one of its four preset reminders (`message`: `turn`, `hurry`, `polite` by default, `holding_up`), never text of ours. Confirm-gated; refuses a finished game or a lobby, yourself, an AI seat, a player no longer playing and one already committed; war.app's refusal of a player who has blocked you is said plainly (error 227). `automated: true` is refused unless `WARAPP_CHAT_AUTOMATION` is on. Nothing can be read back: `nudged` (`accepted`), or `unknown` when war.app did not answer (never resent). Read from the client code, UNVERIFIED live. |
200
+ | `warapp_get_ladders` | The four war.app ladders (1v1, 2v2, 3v3, seasonal: season id, team size, games-at-once range, the level war.app's help gives), your standing on each you have played (war.app's GetLadderStats: rank, rating, best rank and rating, league, games at once, `participating`) and the seasonal ladder's seasons (GetLadderSeasons: state, template, dates, games per season, winners). Ids and names only. Read-only. Read from the client code, UNVERIFIED live. |
201
+ | `warapp_get_ladder` | One ladder season by `ladder` (the seasonal ladder: its current season) or `season_id`: `overview` (GetLadderSeason: the season, player count, top players, those around you, `me`, recent games), `players` or `games` (GetLadderPlayers / GetLadderGames, 50 a page from `start`; games optionally one `player_id`'s). Ids, names and ladder figures only. Read-only. Read from the client code, UNVERIFIED live. |
202
+ | `warapp_get_ladder_player` | One player's ladder page (GetLadderPlayer; default you): rank, rating, league, TrueSkill, teammates, notable wins, the newest rating points, recent ladder games and the `record` over them. Read-only. Read from the client code, UNVERIFIED live. |
203
+ | `warapp_join_ladder` | **Writes.** Join a ladder (war.app's JoinLadder): war.app then creates ladder games for you that you cannot decline. `games_at_once` (1v1 3–5, 2v2 and 3v3 2–5; the seasonal ladder sends one game every 3 days up to its season's count). Confirm-gated; the preview says what it commits you to (games at once, the seasonal pace and count, the template id — its boot time applies); refuses a ladder you are on. Read back from the season page (`joined` / `unconfirmed`, `unknown` never resent). Read from the client code, UNVERIFIED live. |
204
+ | `warapp_leave_ladder` | **Writes.** Leave a ladder (war.app's LeaveLadder). Not a loss: the ladder games you are in keep going and still count toward your rating; war.app only stops new ones (leaving costs that week's rank reward). Confirm-gated; refuses a ladder you are not on. Read back from the season page (`left` / `unconfirmed`, `unknown` never resent). Read from the client code, UNVERIFIED live. |
205
+ | `warapp_list_clans` | war.app clans (war.app's GetClans), or with `open: true` only the clans open for anyone to join (GetOpenClans, with member counts): each clan's id, name (delimited), creator's id, creation time and whether it is open; `query` filters by name, `offset`/`limit` page. Read-only. Read from the client code, UNVERIFIED live. |
206
+ | `warapp_get_clan` | One clan's page (war.app's GetClan): its tagline, bio and link (the clan's words, delimited), its members — each player id, name, level, clan title and manager flag, nothing else about them — its clan-war final ranks, and `me` (whether you are a member, a manager or invited). Read-only. Read from the client code, UNVERIFIED live. |
207
+ | `warapp_get_clan_wars` | Clan-war seasons (war.app's GetClanWars: each war's id, whether it is running, the winner), or one war (`war_id`, or `current: true`; GetClanWar): whether it has ended and the standings (clan, points, the day's points, wins and participants, final rank). Read-only. Read from the client code, UNVERIFIED live. |
208
+ | `warapp_get_clan_war_games` | A clan war's games (war.app's GetClanWarGames), every clan's or one clan's, paged: the war.app game id (none for a free win), day, template, each clan's players and the winning clan. Read-only. Read from the client code, UNVERIFIED live. |
209
+ | `warapp_answer_clan_invite` | **Writes.** Accept or decline your invite to a clan (war.app's AcceptClanInvite / RejectClanInvite, by the clan's id). Confirm-gated; refuses when the clan's page shows no invite for you or you are already a member; accepting moves you out of your current clan; a revoked invite and a full clan are said plainly. Read back from the clan's page (`accepted` / `declined`, else `unconfirmed`; `unknown` when war.app did not answer, never resent). Read from the client code, UNVERIFIED live. |
210
+ | `warapp_join_open_clan` | **Writes.** Join a clan open to anyone (war.app's JoinOpenClan). Confirm-gated; refuses a closed clan (pointing to the invite when there is one) or one you are in; joining moves you out of your current clan; a full or closed clan and a creator who has blocked you are said plainly. Read back from the clan's page (`joined`, else `unconfirmed`; `unknown` never resent). Read from the client code, UNVERIFIED live. |
211
+ | `warapp_leave_clan` | **Writes.** Leave the clan you are in (war.app's RemoveFromClan with your own id, the clan page's Leave button). Confirm-gated and destructive; refuses a clan that does not list you; war.app's refusal of its only manager is said plainly. Read back from the clan's page (`left`, else `unconfirmed`; `unknown` never resent). Read from the client code, UNVERIFIED live. |
212
+ | `warapp_list_tournaments` | Your war.app tournaments (the active ones you have not declined, with your state in each), the open ones, and the past ones you may show on your profile (with your placing): id, name and creator (delimited), type, state, pace, direct and auto boot times, team size, joined and spaces left, rounds, start time, entry fee and the template's rules. `which` picks the lists; a failed list is reported in `failed`. Read-only. Read from the client code, UNVERIFIED live. |
213
+ | `warapp_get_tournament` | One tournament (war.app's GetTournamentDetails): format, state, your state, how many games joining commits to (our estimate from the format), the template's settings (template, host, pace, boot times, map, entry fee, cards, mods, rules), the players (account id, name, state only) and its games by war.app game id (the id `warapp_get_game` takes; `mine` marks yours). Read-only. Read from the client code, UNVERIFIED live. |
214
+ | `warapp_get_tournament_chat` | A tournament's chat (war.app's GetTournamentChat): the newest `limit` messages, sender ids named from the players, text delimited. Read-only; this server never sends tournament chat. Read from the client code, UNVERIFIED live. |
215
+ | `warapp_join_tournament` | **Writes.** Join a tournament (war.app's JoinTournament). Confirm-gated; the preview names it by id and says what it commits to: the number of games, the pace, the direct and auto boot times and when it starts. Refuses one that has started, one you joined, a team tournament, mods, an entry fee in coins, and unreadable settings. Read back: `joined` (`confirmed`), `unconfirmed`, or `unknown` (never resent). Read from the client code, UNVERIFIED live. |
216
+ | `warapp_decline_tournament` | **Writes.** Decline a tournament you are invited to, or leave one you joined before it starts (war.app's DeclineTournament). Confirm-gated, by id; read back: `declined` (`confirmed`), `not_applied` when it started meanwhile, `unconfirmed`, or `unknown`. Read from the client code, UNVERIFIED live. |
217
+ | `warapp_set_favorite_tournament` | **Writes.** Show or hide one of your past tournaments among your profile's favourites (war.app's SetFavoriteTournament); changes only your profile. Confirm-gated; read back from the favourites. Read from the client code, UNVERIFIED live. |
172
218
  | `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. |
173
219
  | `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. |
174
220
  | `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`). |
@@ -187,7 +233,7 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
187
233
  | `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. |
188
234
  | `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. |
189
235
 
190
- 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
236
+ Everything except `warapp_join_tournament`, `warapp_decline_tournament`, `warapp_set_favorite_tournament`, `warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_join_game`, `warapp_create_game`, `warapp_accept_invite`, `warapp_leave_game`, `warapp_close_finished_game`, `warapp_surrender`, `warapp_accept_surrender`, `warapp_team_surrender`, `warapp_vote_to_end`, `warapp_boot_player`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_dismiss_notification`, `warapp_delete_notification`, `warapp_reply_mail`, `warapp_create_mail`, `warapp_add_mail_players`, `warapp_delete_mail`, `warapp_create_forum_thread`, `warapp_reply_forum_thread`, `warapp_vote_forum_post`, `warapp_watch_forum_thread`, `warapp_mark_chat_read`, `warapp_nudge_player`, `warapp_join_ladder`, `warapp_leave_ladder`, `warapp_react_to_message`, `warapp_answer_clan_invite`, `warapp_join_open_clan`, `warapp_leave_clan`, `warapp_set_quickmatch_settings`, `warapp_vote_quickmatch_template`, `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
191
237
  and chat text comes back marked as untrusted third-party content.
192
238
 
193
239
  ## Moving local history to the hosted server
@@ -221,7 +267,7 @@ server keeps its own sign-in. Neither tool ever returns the salt or a file's con
221
267
 
222
268
  ## Confirming writes
223
269
 
224
- `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:
270
+ `warapp_join_ladder`, `warapp_leave_ladder`, `warapp_answer_clan_invite`, `warapp_join_open_clan`, `warapp_leave_clan`, `warapp_set_quickmatch_settings`, `warapp_vote_quickmatch_template`, `warapp_join_tournament`, `warapp_decline_tournament`, `warapp_set_favorite_tournament`, `warapp_reply_mail`, `warapp_create_mail`, `warapp_add_mail_players`, `warapp_delete_mail`, `warapp_create_forum_thread`, `warapp_reply_forum_thread`, `warapp_vote_forum_post`, `warapp_watch_forum_thread`, `warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_leave_game`, `warapp_close_finished_game`, `warapp_surrender`, `warapp_accept_surrender`, `warapp_team_surrender`, `warapp_vote_to_end`, `warapp_boot_player`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_dismiss_notification`, `warapp_delete_notification`, `warapp_mark_chat_read`, `warapp_nudge_player`, `warapp_react_to_message`, `warapp_join_game`, `warapp_accept_invite`, `warapp_create_game`, `warapp_import_state` and `warapp_link_session` are confirmation-gated:
225
271
 
226
272
  - **Clients that support MCP elicitation** show a confirmation prompt describing the change.
227
273
  - **Other clients** make **no** change on the first call: it returns a preview and a
@@ -68,7 +68,8 @@ export function leaderBonuses(graph, board, leader, candidates) {
68
68
  /**
69
69
  * The consecutive turns, ending at `latest`, the outlook log shows under the surrender line (the outlook's own
70
70
  * test, {@link underSurrenderLine}, against the side it judges: the strongest anywhere when logged, else the
71
- * outlook's). With each one's lead: the side's estimate minus my income. Pure.
71
+ * outlook's). A turn the outlook held back (#623, `surrenderHeld`) ends the streak, as it does the line's.
72
+ * With each one's lead: the side's estimate minus my income. Pure.
72
73
  */
73
74
  export function surrenderStreak(turns, latest) {
74
75
  const leads = new Map();
@@ -76,7 +77,7 @@ export function surrenderStreak(turns, latest) {
76
77
  for (let t = latest;; t--) {
77
78
  const x = turns[String(t)];
78
79
  const side = x?.surrender ?? x?.income;
79
- if (!x?.income || !side || !underSurrenderLine(x.income.mine, side))
80
+ if (!x?.income || !side || x.surrenderHeld || !underSurrenderLine(x.income.mine, side))
80
81
  break;
81
82
  leads.set(t, side.estimate - x.income.mine);
82
83
  n++;
@@ -23,6 +23,13 @@ export function guardOffExposure(args) {
23
23
  for (const d of args.deploys)
24
24
  if (left.has(d.territoryId))
25
25
  left.set(d.territoryId, left.get(d.territoryId) + d.armies);
26
+ for (const a of args.airlifts ?? []) {
27
+ if (!left.has(a.from) || !left.has(a.to))
28
+ continue;
29
+ const sent = Math.min(a.armies, left.get(a.from));
30
+ left.set(a.from, left.get(a.from) - sent);
31
+ left.set(a.to, left.get(a.to) + sent);
32
+ }
26
33
  for (const m of args.moves) {
27
34
  if (left.has(m.from))
28
35
  left.set(m.from, Math.max(0, left.get(m.from) - m.armies));
@@ -87,6 +87,7 @@ export function headroomTable(input) {
87
87
  ...(input.settings ? { settings: input.settings } : {}),
88
88
  ...(teams ? { teams } : {}),
89
89
  ...(input.orderPriority ? { orderPriority: [me] } : {}),
90
+ ...(input.airlifts?.length ? { airlifts: input.airlifts.map((a) => ({ player: me, ...a })) } : {}),
90
91
  });
91
92
  /**
92
93
  * The filler counts worth trying for an attack from `s` on `b`: the attack, as the opponent's order
@@ -104,7 +104,9 @@
104
104
  // crossed when my income stayed under INCOME_BEHIND_RATIO × the strongest's estimate for SURRENDER_TURNS
105
105
  // consecutive turns and no bonus in reach closes the gap (`bonusesInReach`: a positive bonus I do not hold
106
106
  // whose every missing member borders my land and whose visible defenders are fewer than my armies beside them
107
- // plus my income; it closes the gap when my income plus its value reaches the line).
107
+ // plus my income; it closes the gap when my income plus its value reaches the line). #623: a turn in the opening
108
+ // (`surrenderOpeningTurns`) or with my strength at least the judged side's likely strength (`lineStrength`) does not
109
+ // count (`surrenderHeld`).
108
110
  //
109
111
  // OUTLOOK_RATIO (2.4×) is borrowed from a published bot's "lost" rule and has never been measured
110
112
  // for war.app: the outlook is a basis for a decision, not a verdict. The planner acts on it in one
@@ -168,6 +170,22 @@ export const INCOME_BEHIND_RATIO = 2 / 3;
168
170
  export const INCOME_AHEAD_RATIO = 1.5;
169
171
  /** #436: consecutive turns under the line before the surrender line is crossed (owner). */
170
172
  export const SURRENDER_TURNS = 3;
173
+ /**
174
+ * #623: turns that never count toward the surrender line, at least. An opening is no evidence of a lost game:
175
+ * nobody has completed much, and the income estimates rest on a sliver of each frontier. Unmeasured.
176
+ */
177
+ export const SURRENDER_OPENING_TURNS = 3;
178
+ /** #623: one more opening turn per this many territories a seat starts with a share of (unmeasured). */
179
+ export const SURRENDER_TERRITORIES_PER_OPENING_TURN = 20;
180
+ /**
181
+ * #623: the opening the surrender line skips: {@link SURRENDER_OPENING_TURNS}, or longer on a map with many
182
+ * territories per seat (3,066 territories among 25 seats: 6).
183
+ */
184
+ export function surrenderOpeningTurns(territories, seats) {
185
+ if (seats <= 0)
186
+ return SURRENDER_OPENING_TURNS;
187
+ return Math.max(SURRENDER_OPENING_TURNS, Math.floor(territories / seats / SURRENDER_TERRITORIES_PER_OPENING_TURN));
188
+ }
171
189
  /** #436: the samples a coverage band needs before its estimate ÷ truth calibrates an estimate (unmeasured). */
172
190
  export const MIN_CALIBRATION_SAMPLES = 5;
173
191
  /** #436: one turn's incomes, mine against the strongest opponent side's. */
@@ -728,6 +746,16 @@ export function gameOutlook(input) {
728
746
  near: scope.near.includes(all.playerId),
729
747
  };
730
748
  }
749
+ // #623: the judged side's likely strength, beside mine.
750
+ const judged = surrenderSide ?? theirs;
751
+ const judgedRows = judged
752
+ ? (judged.players ?? [judged.playerId]).map((id) => rows.find((x) => x.playerId === id) ?? (scope.far.includes(id) ? rowOf(id) : undefined))
753
+ : [];
754
+ // In full view a side's strength is exact (its low is its high); under fog its likely high stands in.
755
+ const likelyOf = (x) => (x === undefined ? undefined : (x.likely ?? (x.high === x.low ? x.low : undefined)));
756
+ const lineStrength = judgedRows.length && judgedRows.every((x) => likelyOf(x) !== undefined)
757
+ ? { mine, theirs: round2(judgedRows.reduce((n, x) => n + likelyOf(x), 0)) }
758
+ : undefined;
731
759
  const income = theirs
732
760
  ? {
733
761
  mine: myNow,
@@ -843,6 +871,7 @@ export function gameOutlook(input) {
843
871
  ...(bonusesLost.length ? { bonusesLost } : {}),
844
872
  ...(income ? { income } : {}),
845
873
  ...(surrenderSide ? { surrenderSide } : {}),
874
+ ...(lineStrength ? { lineStrength } : {}),
846
875
  ...(bonusesInReach.length ? { bonusesInReach } : {}),
847
876
  };
848
877
  });
@@ -967,10 +996,21 @@ export function gameOutlook(input) {
967
996
  ? { mine: t.income.mine, theirs: t.surrenderSide, calibrated: t.surrenderSide.calibrated, anywhere: true }
968
997
  : { mine: t.income.mine, theirs: t.income.theirs, calibrated: t.income.calibrated, anywhere: false }
969
998
  : undefined;
970
- const below = (t) => {
999
+ // #623: opening turns, and turns on which my strength is at least the judged side's likely strength, never count.
1000
+ const openingTurns = surrenderOpeningTurns(input.graph.territoryById.size, players.length);
1001
+ const underLine = (t) => {
971
1002
  const x = lineSide(t);
972
1003
  return !!x && underSurrenderLine(x.mine, x.theirs);
973
1004
  };
1005
+ for (const t of turns) {
1006
+ if (!underLine(t))
1007
+ continue;
1008
+ if (t.turn <= openingTurns)
1009
+ t.surrenderHeld = 'opening';
1010
+ else if (t.lineStrength && t.lineStrength.mine >= t.lineStrength.theirs)
1011
+ t.surrenderHeld = 'strength';
1012
+ }
1013
+ const below = (t) => !t.surrenderHeld && underLine(t);
974
1014
  let turnsBelow = 0;
975
1015
  for (let i = turns.length - 1; i >= 0 && below(turns[i]) && (i === turns.length - 1 || turns[i + 1].turn === turns[i].turn + 1); i--)
976
1016
  turnsBelow++;
@@ -482,6 +482,8 @@ export function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
482
482
  spare: Math.max(0, spare(src)),
483
483
  reach: Math.max(0, spareAt(src)),
484
484
  ...(holdSource(src, t) && spare(src) < 0 ? { hold: -spare(src) } : {}),
485
+ ...(holdSource(src, t) && spare(src) >= 0 ? { afterTake: true } : {}),
486
+ need: tg.cost,
485
487
  };
486
488
  if (force)
487
489
  return false;
@@ -1179,14 +1179,21 @@ export function floorTier(pc, ps, book, threats, hb, prev) {
1179
1179
  * `'untrusted'` (#275 b): the same, before any capture, for each contested unit a border of which faces
1180
1180
  * an opponent whose estimate a tripwire broke (sized for its untrusted figure), whether or not it pays
1181
1181
  * back: while the estimate is untrusted the gate is held before expansion, never left to what it leaves.
1182
+ * `'floored'` (rule 0p.1, a 1v1 in contact, after the whole holds and before the first advance): the
1183
+ * floored units only, whole where what is left covers them, else the rest spread over their borders —
1184
+ * an advance that completes nothing this turn never takes the armies a floored home bonus could use.
1185
+ * The other contested units, and the warnings, wait for the call after the captures.
1182
1186
  */
1183
1187
  const settleContested = (mode = false) => {
1184
- const wholeOnly = mode !== false;
1188
+ const wholeOnly = mode === true || mode === 'untrusted';
1189
+ const flooredOnly = mode === 'floored';
1185
1190
  const facesUntrusted = (u) => u.members.some((m) => {
1186
1191
  const b = borders.get(m.id);
1187
1192
  return !heldBorders.has(m.id) && b !== undefined && pc.untrustedAt(b.player, m.id) > 0;
1188
1193
  });
1189
- const open = units.filter((u) => u.contested && !u.conceded && (mode === 'untrusted' ? facesUntrusted(u) : !wholeOnly || u.loss !== 'payback'));
1194
+ const open = units.filter((u) => u.contested &&
1195
+ !u.conceded &&
1196
+ (flooredOnly ? u.floored : mode === 'untrusted' ? facesUntrusted(u) : !wholeOnly || u.loss !== 'payback'));
1190
1197
  if (!open.length) {
1191
1198
  if (mode === 'untrusted')
1192
1199
  fillUntrustedGates([]);
@@ -1252,11 +1259,13 @@ export function floorTier(pc, ps, book, threats, hb, prev) {
1252
1259
  ? `more than ${CONCEDE_FACTOR} × its worth`
1253
1260
  : null;
1254
1261
  if (more <= ps.budget &&
1255
- fundUnit(u, undefined, `Hold bonus ${bonusName(u.bonusId)} (+${u.value}) whole: ${floored ? 'past its floor ' : ''}its ${unitBorders(u)} need${u.members.length === 1 ? 's' : ''} ${more}${floored ? ' more' : ''}${why ? ` (${why})` : ''}, ${mode === 'untrusted'
1256
- ? `before any capture: player ${[...new Set(u.members.flatMap((m) => { const b = borders.get(m.id); return b && pc.untrustedAt(b.player, m.id) > 0 ? [b.player] : []; }))].sort((a, b) => a - b).join(', ')}'s estimate is untrusted (#275), so the border is held ahead of expansion.`
1257
- : wholeOnly
1258
- ? 'before any expansion that completes no bonus (1v1 in contact: an advance ranks below every hold).'
1259
- : 'and nothing else this turn uses those armies.'}`)) {
1262
+ fundUnit(u, undefined, `Hold bonus ${bonusName(u.bonusId)} (+${u.value}) whole: ${floored ? 'past its floor ' : ''}its ${unitBorders(u)} need${u.members.length === 1 ? 's' : ''} ${more}${floored ? ' more' : ''}${why ? ` (${why})` : ''}, ${flooredOnly
1263
+ ? 'before any expansion that completes no bonus (1v1 in contact: a home bonus under attack comes before a far advance).'
1264
+ : mode === 'untrusted'
1265
+ ? `before any capture: player ${[...new Set(u.members.flatMap((m) => { const b = borders.get(m.id); return b && pc.untrustedAt(b.player, m.id) > 0 ? [b.player] : []; }))].sort((a, b) => a - b).join(', ')}'s estimate is untrusted (#275), so the border is held ahead of expansion.`
1266
+ : wholeOnly
1267
+ ? 'before any expansion that completes no bonus (1v1 in contact: an advance ranks below every hold).'
1268
+ : 'and nothing else this turn uses those armies.'}`)) {
1260
1269
  u.contested = false;
1261
1270
  continue;
1262
1271
  }
@@ -1277,7 +1286,7 @@ export function floorTier(pc, ps, book, threats, hb, prev) {
1277
1286
  if (wholeOnly)
1278
1287
  return;
1279
1288
  const short = units
1280
- .filter((u) => u.contested && !u.conceded)
1289
+ .filter((u) => u.contested && !u.conceded && (!flooredOnly || u.floored))
1281
1290
  .flatMap((u) => u.members.filter((m) => !heldBorders.has(m.id)).map((m) => ({ m, u })));
1282
1291
  const value = (m) => Math.max(...short.filter((x) => x.m === m).map((x) => x.u.value));
1283
1292
  const members = [...new Set(short.map((x) => x.m))];
@@ -1301,6 +1310,14 @@ export function floorTier(pc, ps, book, threats, hb, prev) {
1301
1310
  for (const m of members)
1302
1311
  if (m.holdCost <= 0)
1303
1312
  heldBorders.add(m.id);
1313
+ if (flooredOnly && given.size)
1314
+ rationale.push(`1v1 in contact: what is left goes to the borders of ${[...new Set(short.map((x) => x.u))].map((u) => `${bonusName(u.bonusId)} (+${u.value})`).join(', ')} before any advance that completes nothing this turn — a home bonus the opponent's one stack can break is worth more than a far step toward another.`);
1315
+ if (flooredOnly) {
1316
+ for (const u of open)
1317
+ if (u.members.every((m) => heldBorders.has(m.id)))
1318
+ u.contested = false;
1319
+ return;
1320
+ }
1304
1321
  const stillShort = [];
1305
1322
  for (const u of units) {
1306
1323
  if (!u.contested || u.conceded)
@@ -514,9 +514,9 @@ export function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSp
514
514
  : ''}`
515
515
  : tried.hold !== undefined
516
516
  ? `; when its bonus's step was tried, ${label(tried.from)} holds its border, and with the step gone its hold needed ${tried.hold} more than it had; this turn's deploy could add at most ${tried.reach} there${local ? ' (Local Deployment)' : ''}: ${Math.max(0, tried.reach - tried.hold)} left for the attack`
517
- : `; when its bonus's step was tried, ${label(tried.from)} could spare ${tried.spare} for it and ${tried.reach === 0
517
+ : `; when its bonus's step was tried, ${label(tried.from)} could spare ${tried.spare} for it${tried.afterTake ? ` (what it keeps above its own hold once ${label(n)} is taken)` : ''} and ${tried.reach === 0
518
518
  ? 'none of this turn\'s deploy could still reach it'
519
- : `this turn's deploy could add at most ${tried.reach} there${local ? ' (Local Deployment)' : ''}: ${tried.spare + tried.reach} in all`}`;
519
+ : `this turn's deploy could add at most ${tried.reach} there${local ? ' (Local Deployment)' : ''}: ${tried.spare + tried.reach} in all`}${tried.need !== undefined && tried.need > tried.spare + tried.reach ? `, short of the ${tried.need} the step needed` : ''}`;
520
520
  const best = neighborsOf(g, n)
521
521
  .filter((x) => mineSet.has(x))
522
522
  .map((x) => ({ x, spare: spareNow(x, n) }))
@@ -29,6 +29,12 @@ export function targetsPhase(pc, ps, input, threats, hd) {
29
29
  * times the bonus's value — tighter than PAYBACK_TURNS (10), which the first draft used.
30
30
  */
31
31
  export const RETAKE_VALUE_TURNS = 5;
32
+ /**
33
+ * #661: behind (the profile's standing), a retake is still made when it costs at most this many times the
34
+ * bonus's value — it repays within a turn. #430 left every retake out when behind (the turn goes to holds and
35
+ * strikes), so a member broken off my +4 and left on 1 army was not retaken while the deploy sat on a border.
36
+ */
37
+ export const RETAKE_BEHIND_VALUE_TURNS = 1;
32
38
  /** The enemy bonuses I could break and the counter-attacks (under `balanced`, #72). */
33
39
  export function breakTargets(pc, input) {
34
40
  const { g, me, foe, balanced, territories: state, mineSet, unitsAt, costAt } = pc;
@@ -126,13 +132,17 @@ export function captureTargets(pc, ps, input, threats, prev) {
126
132
  * planner-era games). Such a member is a bonus target, in every format, when the retake completes
127
133
  * the bonus this turn (every missing member in view, beside mine, no special unit, a foe's or a
128
134
  * neutral; none of #298's dropped members), its capture costs together are at most
129
- * RETAKE_VALUE_TURNS (5) × the value, and the profile does not read me behind (behind, the turn goes to
130
- * holds and strikes: the evidence's confound). It then competes as a completion in the bonus passes
135
+ * RETAKE_VALUE_TURNS (5) × the value — or, when the profile reads me behind (the turn goes to holds and
136
+ * strikes: the evidence's confound), at most RETAKE_BEHIND_VALUE_TURNS (1) × the value, a retake that
137
+ * repays within a turn (#661). It then competes as a completion in the bonus passes
131
138
  * and rule 4a's greedy step, so a hold that scores higher is still funded first, and R3 still
132
139
  * refuses a retake that cannot be held.
133
140
  */
134
141
  const retakeMembers = new Set();
135
- if (balanced && input.previousBoard && profile.standing !== 'behind') {
142
+ if (balanced && input.previousBoard) {
143
+ // #661: behind, only a retake that repays within a turn (RETAKE_BEHIND_VALUE_TURNS); else RETAKE_VALUE_TURNS.
144
+ const behind = profile.standing === 'behind';
145
+ const capTurns = behind ? RETAKE_BEHIND_VALUE_TURNS : RETAKE_VALUE_TURNS;
136
146
  const before = new Map(input.previousBoard.territories.map((t) => [t.territoryId, t]));
137
147
  for (const b of [...g.map.bonuses].sort((x, y) => x.id - y.id)) {
138
148
  const ts = bonusTs.get(b.id) ?? [];
@@ -160,14 +170,14 @@ export function captureTargets(pc, ps, input, threats, prev) {
160
170
  cost += c;
161
171
  return true;
162
172
  });
163
- if (!ok || cost > RETAKE_VALUE_TURNS * b.value)
173
+ if (!ok || cost > capTurns * b.value)
164
174
  continue;
165
175
  const theirs = missing.filter((t) => state.get(t).owner.kind === 'player');
166
176
  if (!theirs.length)
167
177
  continue;
168
178
  for (const t of theirs)
169
179
  retakeMembers.add(t);
170
- rationale.push(`Retake ${theirs.map(label).join(', ')}: ${theirs.length > 1 ? 'they complete' : 'it completes'} bonus ${b.name} (+${b.value}) again, which I held in full last turn, for ${cost} armies (at most ${RETAKE_VALUE_TURNS} × its value), so ${theirs.length > 1 ? 'they are' : 'it is'} a bonus target (#430).`);
180
+ rationale.push(`Retake ${theirs.map(label).join(', ')}: ${theirs.length > 1 ? 'they complete' : 'it completes'} bonus ${b.name} (+${b.value}) again, which I held in full last turn, for ${cost} armies (at most ${capTurns} × its value${behind ? ': behind, only a retake that repays within a turn, #661' : ''}), so ${theirs.length > 1 ? 'they are' : 'it is'} a bonus target (#430${behind ? ', #661' : ''}).`);
171
181
  }
172
182
  }
173
183
  /**
@@ -348,6 +348,15 @@ export function threatSources(pc, ps, input) {
348
348
  for (const q of input.quiet ?? [])
349
349
  if (topUpOf.has(q.player))
350
350
  quietOf.set(q.player, { contactTurns: q.contactTurns, attacks: q.attacks });
351
+ // A quiet border (owner request 2026-11-28): no build-up beside my land for QUIET_DEPLOY_TURNS turns running.
352
+ if (!custom)
353
+ for (const tr of input.tracks ?? []) {
354
+ if (!foe(tr.playerId) || quietOf.has(tr.playerId) || !topUpOf.has(tr.playerId))
355
+ continue;
356
+ const q = quietBorder(tr);
357
+ if (q)
358
+ quietOf.set(tr.playerId, q);
359
+ }
351
360
  return {
352
361
  growthOf,
353
362
  teamOf,
@@ -365,6 +374,39 @@ export function threatSources(pc, ps, input) {
365
374
  quietOf,
366
375
  };
367
376
  }
377
+ /** A quiet border's run (owner request 2026-11-28): the turns read in a row, and the most put beside my land in one. */
378
+ export const QUIET_DEPLOY_TURNS = 3;
379
+ /** The most one stack of its beside my land may grow in a turn of a quiet run: one army is no build-up. */
380
+ export const QUIET_DEPLOY_MAX = 1;
381
+ /**
382
+ * The share of its deploy a quiet border's most valuable border of mine still holds against (owner decision
383
+ * 2026-11-28, after the Italy case's next turn: the opponent put ~12 of a ~17 deploy beside that stack).
384
+ */
385
+ export const QUIET_DEPLOY_SHARE = 0.5;
386
+ /** What a quiet border's most valuable border holds against beyond the stacks there: {@link QUIET_DEPLOY_SHARE} of `deploy`. */
387
+ export const quietFloor = (deploy) => Math.ceil(Math.max(0, deploy) * QUIET_DEPLOY_SHARE);
388
+ /**
389
+ * A quiet border (owner request 2026-11-28, the Italy case: a 24-army stack sat a whole turn guarding a
390
+ * bonus against an opponent that had put 0 or 1 armies beside my land for three turns). The opponent's
391
+ * last {@link QUIET_DEPLOY_TURNS} observed turns, consecutive and ending at its newest board, each read a
392
+ * top-up beside my land (`ObservedTurn.topUp`: a stack of its beside mine in view with armies on both
393
+ * boards) of at most {@link QUIET_DEPLOY_MAX}. Then it is read like #420's quiet neighbour: every border
394
+ * of mine facing it is sized at its stacks there plus its largest top-up seen, not its whole deploy, and
395
+ * what stands above that is free for captures. `null` when the run is shorter, broken or louder.
396
+ */
397
+ export function quietBorder(tr) {
398
+ const run = tr.turns.slice(-QUIET_DEPLOY_TURNS);
399
+ if (run.length < QUIET_DEPLOY_TURNS || run[run.length - 1].to !== tr.lastTurn)
400
+ return null;
401
+ for (let i = 0; i < run.length; i++) {
402
+ const t = run[i];
403
+ if (t.to !== t.from + 1 || (i > 0 && run[i - 1].to !== t.from))
404
+ return null;
405
+ if (t.topUp === undefined || t.topUp > QUIET_DEPLOY_MAX)
406
+ return null;
407
+ }
408
+ return { deployTurns: run.length, most: Math.max(...run.map((t) => t.topUp)) };
409
+ }
368
410
  /** What each opponent can bring against one territory: its stacks, its deploy, its Multi-Attack chains (#199). */
369
411
  export function threatForces(pc, ps, src, valueOf) {
370
412
  const { g, board, s, foe, territories: state, mineSet, unitsAt, guard, rates, toTake, ffaLeader, untrustedAt } = pc;
@@ -568,7 +610,11 @@ export function threatForces(pc, ps, src, valueOf) {
568
610
  // #603: the deploy floats once — a border other than the most valuable one holds against the stacks beside
569
611
  // it alone (a quiet neighbour, #420's P1 amendment, keeps its largest top-up seen on every border).
570
612
  const legacy = pc.opts.experiments?.includes('legacy-topup') === true;
571
- m.set(player, quiet || legacy ? src.topUpOf.get(player) : 0);
613
+ const top = src.topUpOf.get(player);
614
+ // A quiet border (owner, 2026-11-28): its most valuable border still holds against a share of the deploy.
615
+ const q = src.quietOf.get(player);
616
+ const floor = q && 'deployTurns' in q && t === ranked[0].t ? quietFloor(pc.deployOf(player)) : 0;
617
+ m.set(player, quiet || legacy ? Math.max(top, floor) : 0);
572
618
  oneBorderMemo.capAt.set(t, m);
573
619
  }
574
620
  }
@@ -929,7 +975,14 @@ export function borderThreats(pc, ps, input, src, forces) {
929
975
  const sized = [...capAt].filter(([t, m]) => borders.has(t) && m.has(player)).map(([t]) => t).sort(byNum);
930
976
  if (!sized.length)
931
977
  continue;
932
- rationale.push(`Player ${player} ${q.attacks ? `has attacked me on ${q.attacks} of ${q.contactTurns} contact turns, and not since it was read quiet` : `has not attacked me in ${q.contactTurns} contact turns`} (#420, P1 amended: a quiet neighbour): ${sized.map(label).join(', ')} ${sized.length === 1 ? 'is' : 'are'} sized at its stack beside ${sized.length === 1 ? 'it' : 'them'} plus its largest top-up seen, +${src.topUpOf.get(player)}, not its ~${pc.deployOf(player)} deploy, until its first attack on me.`);
978
+ const these = `${sized.map(label).join(', ')} ${sized.length === 1 ? 'is' : 'are'} sized at its stack beside ${sized.length === 1 ? 'it' : 'them'} plus its largest top-up seen, +${src.topUpOf.get(player)}, not its ~${pc.deployOf(player)} deploy`;
979
+ const most = sized
980
+ .map((t) => ({ t, at: capAt.get(t).get(player) }))
981
+ .filter((x) => x.at > src.topUpOf.get(player))
982
+ .map((x) => `${label(x.t)}, its most valuable, against half of it, ${x.at}`);
983
+ rationale.push('deployTurns' in q
984
+ ? `Player ${player} has put at most ${q.most} ${q.most === 1 ? 'army' : 'armies'} beside my land in each of its last ${q.deployTurns} turns (a quiet border, owner request 2026-11-28): ${these}${most.length ? ` (${most.join('; ')})` : ''}, so what stands above that is free for captures, until it builds up beside me.`
985
+ : `Player ${player} ${q.attacks ? `has attacked me on ${q.attacks} of ${q.contactTurns} contact turns, and not since it was read quiet` : `has not attacked me in ${q.contactTurns} contact turns`} (#420, P1 amended: a quiet neighbour): ${these}, until its first attack on me.`);
933
986
  }
934
987
  for (const [player, top] of [...primary].sort((a, b) => a[0] - b[0])) {
935
988
  // The deploy its most valuable border is sized for (under Local Deployment, what reaches it).
@@ -844,7 +844,8 @@
844
844
  // #430 (owner decision of 2026-11-22): under `balanced`, the opponents' territories that retake
845
845
  // a bonus I held in full on `previousBoard` are bonus targets too, in every format, when the retake
846
846
  // completes it this turn (every missing member in view, beside mine), costs at most RETAKE_VALUE_TURNS
847
- // (5) × its value, and the profile does not read me behind; it ranks as any completion, so a stronger hold
847
+ // (5) × its value — behind (the profile's standing), at most RETAKE_BEHIND_VALUE_TURNS (1) × its value,
848
+ // a retake that repays within a turn (#661); it ranks as any completion, so a stronger hold
848
849
  // funds first (plan/targets.ts, `retakeMembers`).
849
850
  // 3. Capture cost (#126): the fewest armies whose exact `winChance` reaches the capture's
850
851
  // chance — certain (chance 1) means every roll and rounding takes it: `armiesToTake` at 0%
@@ -2844,6 +2845,8 @@ function planPass(input, pass) {
2844
2845
  };
2845
2846
  /** #215, rule 0p.1: the contested units were held whole (where they fit) before the first advance. */
2846
2847
  let contestedDue = false;
2848
+ /** Lost 1v1 (2026-11-27): the floored units took what was left before the first advance. */
2849
+ let flooredDue = false;
2847
2850
  /** #275 (b): the contested units facing an untrusted opponent were held whole (where they fit) before the first capture. */
2848
2851
  let untrustedDue = false;
2849
2852
  candidates.forEach((c, i) => {
@@ -2862,6 +2865,14 @@ function planPass(input, pass) {
2862
2865
  contestedDue = true;
2863
2866
  settleContested(true);
2864
2867
  }
2868
+ // Lost 1v1 (2026-11-27): a home bonus that cannot be held whole was floored and the rest went to a
2869
+ // bonus 21 armies from done; the opponent broke it with one stack. In a 1v1 in contact the floored
2870
+ // units' borders take what is left before any advance that completes nothing (a #417 race still
2871
+ // goes first: it ranks ahead of the holds by the owner's decision).
2872
+ if (oneVsOne && (c.kind === 'advance' || c.kind === 'stage') && !c.focus && !flooredDue) {
2873
+ flooredDue = true;
2874
+ settleContested('floored');
2875
+ }
2865
2876
  if (completesNothing(c) && !c.focus && !unitsDue) {
2866
2877
  unitsDue = true;
2867
2878
  // Those waiting for the expansion share outscore everything still to run.