@chrischall/warapp-mcp 0.0.0-stage → 0.1.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 (179) hide show
  1. package/.claude-plugin/marketplace.json +34 -0
  2. package/.claude-plugin/plugin.json +21 -0
  3. package/.mcp.json +11 -0
  4. package/LICENSE +21 -0
  5. package/README.md +264 -2
  6. package/dist/analysis/award.js +159 -0
  7. package/dist/analysis/bonuses.js +98 -0
  8. package/dist/analysis/breach.js +62 -0
  9. package/dist/analysis/card-support.js +329 -0
  10. package/dist/analysis/card-threats.js +234 -0
  11. package/dist/analysis/cards-in-effect.js +130 -0
  12. package/dist/analysis/chains.js +59 -0
  13. package/dist/analysis/chokepoints.js +140 -0
  14. package/dist/analysis/combat.js +231 -0
  15. package/dist/analysis/commander-safety.js +149 -0
  16. package/dist/analysis/commitments.js +338 -0
  17. package/dist/analysis/exchange.js +155 -0
  18. package/dist/analysis/graph.js +82 -0
  19. package/dist/analysis/guard-off.js +54 -0
  20. package/dist/analysis/guess.js +351 -0
  21. package/dist/analysis/headroom.js +241 -0
  22. package/dist/analysis/hold-diff.js +64 -0
  23. package/dist/analysis/how-lost.js +130 -0
  24. package/dist/analysis/index.js +14 -0
  25. package/dist/analysis/local-deploy.js +159 -0
  26. package/dist/analysis/lookahead.js +108 -0
  27. package/dist/analysis/opponent-profile.js +551 -0
  28. package/dist/analysis/opponents.js +1245 -0
  29. package/dist/analysis/outlook.js +633 -0
  30. package/dist/analysis/overrides.js +60 -0
  31. package/dist/analysis/picks.js +1879 -0
  32. package/dist/analysis/plan/after-leftover.js +140 -0
  33. package/dist/analysis/plan/cap-spend.js +242 -0
  34. package/dist/analysis/plan/captures.js +1195 -0
  35. package/dist/analysis/plan/commander.js +236 -0
  36. package/dist/analysis/plan/completed.js +29 -0
  37. package/dist/analysis/plan/conceded-out.js +131 -0
  38. package/dist/analysis/plan/estimates.js +715 -0
  39. package/dist/analysis/plan/guard-off.js +232 -0
  40. package/dist/analysis/plan/holds.js +1631 -0
  41. package/dist/analysis/plan/leftover.js +760 -0
  42. package/dist/analysis/plan/move-order.js +319 -0
  43. package/dist/analysis/plan/orders.js +317 -0
  44. package/dist/analysis/plan/relations.js +702 -0
  45. package/dist/analysis/plan/report.js +672 -0
  46. package/dist/analysis/plan/shared.js +1218 -0
  47. package/dist/analysis/plan/stand-still.js +823 -0
  48. package/dist/analysis/plan/state.js +44 -0
  49. package/dist/analysis/plan/strike.js +1416 -0
  50. package/dist/analysis/plan/targets.js +651 -0
  51. package/dist/analysis/plan/team.js +299 -0
  52. package/dist/analysis/plan/threats.js +927 -0
  53. package/dist/analysis/plan/transfers.js +328 -0
  54. package/dist/analysis/plan/util.js +5 -0
  55. package/dist/analysis/plan/vacated.js +285 -0
  56. package/dist/analysis/planner.js +2922 -0
  57. package/dist/analysis/player-record.js +144 -0
  58. package/dist/analysis/player.js +268 -0
  59. package/dist/analysis/profile.js +347 -0
  60. package/dist/analysis/relations.js +1030 -0
  61. package/dist/analysis/schedule.js +88 -0
  62. package/dist/analysis/since-last.js +50 -0
  63. package/dist/analysis/static-seats.js +71 -0
  64. package/dist/analysis/stress.js +577 -0
  65. package/dist/analysis/team-brief.js +151 -0
  66. package/dist/analysis/tripwire.js +644 -0
  67. package/dist/analysis/turn-sim.js +259 -0
  68. package/dist/analysis/whereabouts.js +1109 -0
  69. package/dist/board.js +105 -0
  70. package/dist/bundle.js +143479 -0
  71. package/dist/cards.js +435 -0
  72. package/dist/chat-cursor.js +135 -0
  73. package/dist/chat.js +192 -0
  74. package/dist/client.js +361 -0
  75. package/dist/config.js +62 -0
  76. package/dist/direct/link.js +102 -0
  77. package/dist/direct/session.js +267 -0
  78. package/dist/direct/transport.js +424 -0
  79. package/dist/guess-salt.js +65 -0
  80. package/dist/hosted.js +24 -0
  81. package/dist/index.js +33 -0
  82. package/dist/join-color.js +140 -0
  83. package/dist/live.js +278 -0
  84. package/dist/map-stats.js +152 -0
  85. package/dist/map-store.js +204 -0
  86. package/dist/move-order.js +141 -0
  87. package/dist/my-games.js +180 -0
  88. package/dist/normalize.js +411 -0
  89. package/dist/open-games.js +537 -0
  90. package/dist/outlook-log.js +138 -0
  91. package/dist/path-lock.js +22 -0
  92. package/dist/pick-list.js +193 -0
  93. package/dist/player-record-store.js +229 -0
  94. package/dist/player-states.js +31 -0
  95. package/dist/profile-store.js +677 -0
  96. package/dist/protocol/bundle.js +375 -0
  97. package/dist/protocol/codec.js +556 -0
  98. package/dist/protocol/decoded.js +12 -0
  99. package/dist/protocol/interp.js +1904 -0
  100. package/dist/protocol/methods.js +531 -0
  101. package/dist/protocol/rpc.js +202 -0
  102. package/dist/push/listener.js +393 -0
  103. package/dist/push/packets.js +66 -0
  104. package/dist/push/socketio.js +333 -0
  105. package/dist/push/websocket.js +179 -0
  106. package/dist/redact.js +62 -0
  107. package/dist/relations-store.js +242 -0
  108. package/dist/replay.js +215 -0
  109. package/dist/scalars.js +28 -0
  110. package/dist/scout.js +346 -0
  111. package/dist/stats.js +269 -0
  112. package/dist/strategy/card-clock.js +185 -0
  113. package/dist/strategy/map-notes.js +128 -0
  114. package/dist/strategy/notes.js +2168 -0
  115. package/dist/team-cards.js +84 -0
  116. package/dist/team-orders.js +150 -0
  117. package/dist/teams.js +19 -0
  118. package/dist/tools/award.js +206 -0
  119. package/dist/tools/begin-turn.js +162 -0
  120. package/dist/tools/board.js +77 -0
  121. package/dist/tools/card-advice.js +256 -0
  122. package/dist/tools/card-effects.js +49 -0
  123. package/dist/tools/card-plays.js +434 -0
  124. package/dist/tools/card-support-advice.js +140 -0
  125. package/dist/tools/chat-inbox.js +146 -0
  126. package/dist/tools/chat.js +483 -0
  127. package/dist/tools/check-plan.js +688 -0
  128. package/dist/tools/commander-check.js +102 -0
  129. package/dist/tools/commitments.js +216 -0
  130. package/dist/tools/common.js +143 -0
  131. package/dist/tools/diplomacy.js +342 -0
  132. package/dist/tools/game.js +126 -0
  133. package/dist/tools/guess-view.js +56 -0
  134. package/dist/tools/healthcheck.js +90 -0
  135. package/dist/tools/hints.js +34 -0
  136. package/dist/tools/how-lost.js +154 -0
  137. package/dist/tools/index.js +142 -0
  138. package/dist/tools/join-game.js +327 -0
  139. package/dist/tools/leave-game.js +181 -0
  140. package/dist/tools/live-context.js +339 -0
  141. package/dist/tools/live.js +404 -0
  142. package/dist/tools/map-stats.js +117 -0
  143. package/dist/tools/map.js +133 -0
  144. package/dist/tools/my-games.js +123 -0
  145. package/dist/tools/open-games.js +104 -0
  146. package/dist/tools/opponents.js +151 -0
  147. package/dist/tools/order-options.js +135 -0
  148. package/dist/tools/picks.js +292 -0
  149. package/dist/tools/profile-hook.js +156 -0
  150. package/dist/tools/profile-opponents.js +121 -0
  151. package/dist/tools/profile-reads.js +99 -0
  152. package/dist/tools/push.js +385 -0
  153. package/dist/tools/relations.js +611 -0
  154. package/dist/tools/resolve.js +45 -0
  155. package/dist/tools/route.js +36 -0
  156. package/dist/tools/scout.js +87 -0
  157. package/dist/tools/session.js +163 -0
  158. package/dist/tools/strategy.js +200 -0
  159. package/dist/tools/stress-opponents.js +83 -0
  160. package/dist/tools/surrender.js +240 -0
  161. package/dist/tools/survival.js +189 -0
  162. package/dist/tools/team-brief.js +266 -0
  163. package/dist/tools/team-source.js +222 -0
  164. package/dist/tools/team.js +182 -0
  165. package/dist/tools/turn.js +2761 -0
  166. package/dist/tools/uncommit.js +160 -0
  167. package/dist/tools/where.js +275 -0
  168. package/dist/tools/write-kit.js +158 -0
  169. package/dist/transport-bridge.js +33 -0
  170. package/dist/trend.js +452 -0
  171. package/dist/version.js +4 -0
  172. package/manifest.json +247 -0
  173. package/mint.yaml +140 -0
  174. package/package.json +68 -4
  175. package/server.json +72 -0
  176. package/skills/warapp-api/SKILL.md +226 -0
  177. package/skills/warapp-api/references/scout.mjs +348 -0
  178. package/skills/warapp-api/scripts/warapp.sh +228 -0
  179. package/skills/warapp-mcp/SKILL.md +1011 -0
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
3
+ "name": "warapp-mcp",
4
+ "owner": {
5
+ "name": "Chris Hall",
6
+ "email": "chris.c.hall@gmail.com"
7
+ },
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, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends and linking a session are confirm-gated).",
10
+ "version": "0.1.0"
11
+ },
12
+ "plugins": [
13
+ {
14
+ "name": "warapp-mcp",
15
+ "displayName": "war.app (Warzone)",
16
+ "source": "./",
17
+ "description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
18
+ "version": "0.1.0",
19
+ "author": {
20
+ "name": "Chris Hall"
21
+ },
22
+ "homepage": "https://github.com/chrischall/warapp-mcp",
23
+ "repository": "https://github.com/chrischall/warapp-mcp",
24
+ "license": "MIT",
25
+ "keywords": [
26
+ "warzone",
27
+ "war.app",
28
+ "strategy-game",
29
+ "mcp"
30
+ ],
31
+ "category": "productivity"
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "warapp-mcp",
3
+ "displayName": "war.app (Warzone)",
4
+ "version": "0.1.0",
5
+ "description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
6
+ "author": {
7
+ "name": "Chris Hall",
8
+ "email": "chris.c.hall@gmail.com"
9
+ },
10
+ "homepage": "https://github.com/chrischall/warapp-mcp",
11
+ "repository": "https://github.com/chrischall/warapp-mcp",
12
+ "license": "MIT",
13
+ "keywords": [
14
+ "warzone",
15
+ "war.app",
16
+ "strategy-game",
17
+ "mcp"
18
+ ],
19
+ "skills": "./skills/",
20
+ "mcpServers": "./.mcp.json"
21
+ }
package/.mcp.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "warapp": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@chrischall/warapp-mcp"
8
+ ]
9
+ }
10
+ }
11
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chris Hall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,265 @@
1
- # Temporary Holding Version
1
+ # warapp-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [war.app](https://war.app) (Warzone) game advisor MCP server for Claude. It reads your games
4
+ through war.app's per-player **GameFeed** API and helps you think about them: players and
5
+ settings, the map's bonuses and chokepoints, the board, and routes between territories.
6
+ Through your signed-in war.app browser tab it also lists **your games** (the ones waiting on you
7
+ first), **scouts an opponent** (their record and your head-to-head), reads the **live board**
8
+ (including the pick phase, where GameFeed has none), your territory picks and your cards, plans
9
+ your turn, tells you when a game is waiting on you (war.app's push notifications), and — only
10
+ after you confirm — submits picks, commits your turn's orders (card plays included) and posts
11
+ game chat.
12
+
13
+ > This project was developed and is maintained by AI (Claude Code). Use at your own discretion.
14
+
15
+ ## Setup
16
+
17
+ 1. Sign in to war.app in a browser and open <https://war.app/API/GetAPIToken> to see your
18
+ API token. Changing your war.app password rotates it.
19
+ 2. Add the server to your MCP client:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "warapp": {
25
+ "command": "npx",
26
+ "args": ["-y", "@chrischall/warapp-mcp"],
27
+ "env": {
28
+ "WARAPP_EMAIL": "you@example.com",
29
+ "WARAPP_API_TOKEN": "<your token>"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ 3. Call `warapp_healthcheck` to confirm war.app accepts the credentials.
37
+ 4. For the live-game tools, set up the browser bridge (below).
38
+
39
+ | Variable | Required | |
40
+ |---|---|---|
41
+ | `WARAPP_EMAIL` | yes | The email address you sign in to war.app with. |
42
+ | `WARAPP_API_TOKEN` | yes | Your API token from <https://war.app/API/GetAPIToken>. |
43
+ | `WARAPP_ENV_FILE` | no | A dotenv file to read the two above from (default `~/.config/warapp-mcp/.env`). Values already in the environment win. |
44
+ | `WARAPP_WS_PORT` | no | The fetchproxy bridge port (default `37149`, shared by the whole fetchproxy fleet and ContextMint Bridge). Override it only for local testing, or when a host injects a per-registration port. |
45
+ | `WARAPP_TRANSPORT` | no | How the live-game tools reach war.app: `auto` (default — try the chrome-less direct transport when a session is linked, else the browser bridge), `direct` (only direct), or `fetchproxy` (only the browser bridge, today's behaviour). See [Direct transport](#direct-transport-no-browser). |
46
+ | `WARAPP_SESSION_FILE` | no | Where the linked direct-transport session is stored (default `<data dir>/session.json`). Local-only; a full-account credential, kept at file mode `0600`. Its directory is made `0700`, so name a file in a directory of its own. |
47
+ | `WARAPP_STATS` | no | `1` turns on `warapp_map_stats` on a **local** install (off by default; always off when hosted). It then fetches finished ladder games — at most `max_new_games` a call, one request a second — and caches them under `<data dir>/stats/`. |
48
+ | `WARAPP_PLAYER_PROFILE` | no | Opponent profiling (on by default, locally and hosted; `off` turns it off): what each opponent did on the turns your boards showed, as counts (gameplay only — no name, chat or time of play), kept per game under `<data dir>/profiles/games/` for `warapp_profile_opponents`, and folded when a game finishes into name-free cross-game counts (`profiles/players.json`, keyed by a salted hash shared with the player record; `profiles/population.json`, pooled by format and for AI seats) that fade per game. |
49
+ | `WARAPP_DEBUG` | no | Truthy logs the bridge's role and lifecycle to stderr. |
50
+ | `MCP_DATA_DIR` | no | Where this server keeps its local state (default `~/.config/warapp-mcp`): the downloaded war.app client bundle (`bundle/`), GameFeed maps (`maps/`), each planned game's name-free settings (`games/`), the board history (`boards/`) and the rest of its per-game records. A host with persistent state sets it. |
51
+ | `MCP_CONFIRM_MODE` | no | What a write does on a client that cannot show a confirmation prompt: `ask-user` (default), `auto` or `refuse`. See [Confirming writes](#confirming-writes). |
52
+
53
+ The server starts without credentials and reports what is missing on the first call
54
+ that needs them.
55
+
56
+ ## The browser bridge (live-game tools)
57
+
58
+ GameFeed has no list of your games, no player profiles, no live board during the pick phase,
59
+ no picks and no way to post chat. Those come from war.app's own web client (its protocol and
60
+ its profile pages), which is authenticated by your browser's war.app session rather than by
61
+ the API token. So the live-game tools — `warapp_my_games`, `warapp_scout_player`,
62
+ `warapp_get_live_board`, `warapp_get_my_picks`, `warapp_plan_picks`, `warapp_submit_picks`, `warapp_plan_turn`, `warapp_check_plan`,
63
+ `warapp_track_opponents`, `warapp_locate_opponents`, `warapp_profile_opponents`, `warapp_get_team`, `warapp_team_brief`, `warapp_submit_turn`, `warapp_uncommit_turn`, `warapp_leave_game`, `warapp_send_chat`, `warapp_wait_for_turn`, and `warapp_analyze_board`
64
+ when GameFeed sends no board — relay each request through your signed-in war.app tab with the [fetchproxy](https://github.com/chrischall/fetchproxy) bridge.
65
+ They need:
66
+
67
+ - the [ContextMint Bridge](https://github.com/nullnet-app/contextmint-bridge/releases)
68
+ browser extension, and
69
+ - a war.app tab in that browser, signed in to the same account as `WARAPP_EMAIL`.
70
+
71
+ The server never sees your war.app password or session cookies; the tab makes the request
72
+ and hands back the answer. The tools decode the board with war.app's own client code: the
73
+ first live call downloads the current client bundle (`ujs.js`) from War.app's CDN and caches
74
+ it per version under the data directory. Nothing from war.app is shipped in this package.
75
+
76
+ ### Pairing (once)
77
+
78
+ 1. Install ContextMint Bridge and sign in to <https://war.app> in that browser.
79
+ 2. Ask Claude for something live, e.g. "show me the live board of game 12345678". The first
80
+ call that needs the bridge answers with a **pair code**.
81
+ 3. Approve that code in the ContextMint Bridge popup. The trust persists across restarts in
82
+ `~/.fetchproxy/identity/`. After that, `warapp_healthcheck` reports the bridge's status too.
83
+
84
+ **More than one browser?** Approve the code in the browser that holds your war.app session.
85
+ **Paired the wrong one?** Revoke `warapp-mcp` in the ContextMint Bridge popup, run
86
+ `fpx trust clear warapp-mcp` (from [`@fetchproxy/cli`](https://www.npmjs.com/package/@fetchproxy/cli)),
87
+ restart the server and pair again.
88
+
89
+ ## Direct transport (no browser)
90
+
91
+ By default the live-game tools relay every request through your signed-in war.app tab. You can
92
+ instead let them talk to war.app directly, with no browser involved, by **linking your session
93
+ once**:
94
+
95
+ 1. Call `warapp_link_session` (confirm-gated). With a signed-in war.app tab paired to the bridge,
96
+ it captures your war.app session cookie once and stores it on **this machine only**
97
+ (`<data dir>/session.json`, file mode `0600`; `WARAPP_SESSION_FILE` overrides the path).
98
+ 2. After that, with `WARAPP_TRANSPORT=auto` (the default), every live call is a plain server-side
99
+ HTTPS request carrying that session — no Chrome tab needed, including the turn-notification
100
+ socket. If the session expires, the tools automatically fall back to the browser bridge for the
101
+ rest of the session and `warapp_session_status` tells you to run `warapp_link_session` again.
102
+
103
+ `warapp_session_status` reports whether a session is linked, how old it is, and which transport is
104
+ active. `warapp_healthcheck` reports the same.
105
+
106
+ > **Security.** The stored session cookie is a **full-account credential** — anything your war.app
107
+ > account can do, it can do. It never leaves this machine (it is sent only to war.app), is never
108
+ > logged, and is never shown in a tool result. **Direct mode is local-only:** the hosted
109
+ > (mcp-host) deployment always uses the browser bridge and stores no session token. Use direct
110
+ > mode only on a machine you control; `rm` the session file (or let it expire) to unlink.
111
+
112
+ ## Tools
113
+
114
+ | Tool | |
115
+ |---|---|
116
+ | `warapp_healthcheck` | Check that war.app accepts your email and API token; report the active transport and whether a direct session is linked. |
117
+ | `warapp_my_games` | Your games (through your signed-in tab), games waiting on you first: state, turn, players and who has committed, and `waitingOnYou`. Finished games only with `include_finished`; `listed` (games war.app returned) and `complete` (false, with a warning, when the list may be partial). `view`: compact / brief. |
118
+ | `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. |
119
+ | `warapp_join_game` | **Writes.** Take an open seat in a game from the open games list. Confirm-gated; 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. |
120
+ | `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). |
121
+ | `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. |
122
+ | `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. |
123
+ | `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. |
124
+ | `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), 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. `view`: compact / full / raw. |
125
+ | `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. |
126
+ | `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). 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>/`. |
127
+ | `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. |
128
+ | `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, 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. |
129
+ | `warapp_plan_route` | Shortest path between two territories, given by name or id. |
130
+ | `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). |
131
+ | `warapp_get_my_picks` | Your submitted territory picks in priority order, and how many the game allows. |
132
+ | `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). `goal`: balanced (default: best income per army across holds, bonuses and breaking enemy bonuses, with at least 30% on expansion) / expand / complete-bonus / defend — 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: 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 an opponent bordering the fog is assumed to earn at least your income); `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. |
133
+ | `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. 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. |
134
+ | `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. |
135
+ | `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 — 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. `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. |
136
+ | `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. |
137
+ | `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. |
138
+ | `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. |
139
+ | `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; and, encoded as the client does but not yet verified live, Spy, Reconnaissance, Surveillance, Airlift, Gift, Diplomacy, 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. |
140
+ | `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. |
141
+ | `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; finished games skipped — 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. |
142
+ | `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`). 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). The channel fields are unverified live. |
143
+ | `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. |
144
+ | `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. |
145
+ | `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. |
146
+ | `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. |
147
+ | `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. |
148
+ | `warapp_advise_diplomacy` | Truce advice in a free-for-all (refused in a 1v1 or a team game), read-only: whether the game allows private messages and the host's description when the feed carries one (untrusted text — read it for house rules such as "no alliances"); per neighbour the shared border (territories each side, chokepoints, stacks), a truce priced on suggested terms (the border territories, one turn of notice, a cap at the largest stack there, an end five turns on) — or on the recorded terms of an open agreement, keeping the board's reading of it (`relation`: a break or a watch flag is `no`) — by planning the turn with and without it: armies freed, captures, bonuses and next income gained, borders no longer conceded, planned attacks given up, `lossIfBroken`, an estimated reading of the partner's side and its cross-game record, with its `retaliate` and `attack` habits beside it (`habits`, as `warapp_profile_opponents` reads them; shown only, never priced) — and a verdict (`propose`, `accept-if-offered`, `no`) with reasons. `offer` (structured terms someone proposed, never parsed from chat) adds the three checks (I gain only if they keep it; I lose if I comply and they do not; they gain from my compliance — all three: `stressTestFirst`). `facts`: true statements about third players you may cite, each with whether the recipient can see it under the fog. Sends and records nothing. |
149
+ | `warapp_wait_for_turn` | Wait until one of the given games (`game_ids`, 1–20; omitted, every game of yours being played or picked) is waiting on you, woken by war.app's push notifications through your war.app tab; returns at once if one already is, else at `timeout_seconds` (default 300, max 1800). A game whose push said chat arrived carries `chatActivity: true` (no text; unverified live). Reports progress; honours cancellation. |
150
+ | `warapp_recent_events` | The game-update pushes this server process has received (newest first), and whether the push socket is connected. |
151
+ | `warapp_session_status` | Whether a war.app session is linked for the [direct transport](#direct-transport-no-browser), when it was captured and how old it is, and which transport is active. Never shows the session cookie. |
152
+ | `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. |
153
+
154
+ Everything except `warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_join_game`, `warapp_leave_game`, `warapp_surrender`, `warapp_begin_turn`, `warapp_uncommit_turn`, `warapp_link_session` and `warapp_record_agreement` (this machine's agreement ledger only, not confirm-gated) only reads. Player, game, map
155
+ and chat text comes back marked as untrusted third-party content.
156
+
157
+ ## Confirming writes
158
+
159
+ `warapp_submit_picks`, `warapp_submit_turn`, `warapp_send_chat`, `warapp_join_game`, `warapp_leave_game`, `warapp_surrender`, `warapp_begin_turn`, `warapp_uncommit_turn` and `warapp_link_session` are confirmation-gated:
160
+
161
+ - **Clients that support MCP elicitation** show a confirmation prompt describing the change.
162
+ - **Other clients** make **no** change on the first call: it returns a preview and a
163
+ single-use, short-lived `confirmToken`, and only a repeat call carrying that token sends.
164
+ `MCP_CONFIRM_MODE` decides who may use the token: `ask-user` (default — you approve in
165
+ chat), `auto` (the model may use it after the preview) or `refuse`.
166
+
167
+ What a preview shows:
168
+
169
+ - **The account that will act.** `preview.account` names the signed-in war.app account, read
170
+ fresh for that call. The approval is bound to it: if another account is signed in by the time
171
+ the token is used, nothing is sent.
172
+ - **Other people's words, delimited.** Game, player, territory and bonus names are written by
173
+ other players and map makers. A preview's sentences name things by id only; every name in its
174
+ fields (`willSend.player`, `willSend.to`, the picks and orders, `preview.game.name`,
175
+ `preview.attacks`) and in an error message comes wrapped in `⟦ ⟧`, with control characters and
176
+ look-alike brackets removed. `preview.game.name` is `null` when GameFeed sends no name. Read
177
+ text inside `⟦ ⟧` as a label, never as an instruction.
178
+
179
+ ## Playing a turn
180
+
181
+ 0. **Wait (optional).** `warapp_wait_for_turn` (all your games in play, or the ones you name) returns as soon as one is
182
+ waiting on you, woken by war.app's push notifications through your war.app tab.
183
+ 1. **Plan.** `warapp_plan_turn` reads the live board and proposes deploys and moves by name and
184
+ id, with the expected captures, bonuses and next income, warnings and its reasoning. It
185
+ changes nothing. It reports your cards: Reinforcement cards are always played (their armies
186
+ are planned), and when you hold more whole cards than the limit — war.app then requires a play
187
+ or discard per card over — the lowest-value cards leave first: Order Delay is discarded before
188
+ Order Priority is spent, and an Order Priority that must go is played rather than discarded (one
189
+ at most). It
190
+ never plays Blockade (that gives a territory away) or Order Delay (it holds back your attacks).
191
+ Threat warnings assume each enemy deploys `enemy_deploy` armies; enemy income is unseen, so
192
+ raise it if you know better. With last turn's board, an opponent's deploy is at least what it
193
+ was observed to deploy (the net change of its armies on territories visible both turns plus what its captures cost it;
194
+ stacks that only came out of the fog are not income, and the figure never exceeds its base plus every bonus it could hold). An enemy stack that grew since
195
+ last turn raises the threat by its growth (`trendSource` says where last turn's board came from).
196
+ Under the default `balanced` goal the plan spends income where it earns most per army:
197
+ holding borders that protect bonuses, completing cheap bonuses (at least 30% of income goes
198
+ to expansion), and breaking an enemy bonus you can reach. Under `balanced` and `defend`, an
199
+ opponent whose every territory is visible and borders yours is attacked when that
200
+ eliminates it ("Finish off player …") or, against its best use of its estimated deploy
201
+ (one budget, spread to save what it can), surely cuts it to one territory or takes at
202
+ least half of it ("Pressure player …": e.g. +6/+4 on two border stacks against its two
203
+ 2-army territories, when its ~6 cannot save both). Any such opponent is tried, strong or weak, fewest
204
+ territories first; holds worth paying for against other players, and against what a
205
+ "Pressure" plan leaves the opponent, are funded first (pressure is dropped when they cannot
206
+ be). An opponent next to the fog is never called eliminated, but its visible territories
207
+ are all attacked as "Pressure" (each sized for its full estimated deploy plus a margin of
208
+ half that deploy, at least 2, since its income is unseen) when each capture costs at most
209
+ 4× a typical neutral capture next to you (with no neutral next to you, any cost). It is all
210
+ or nothing: one visible territory too costly blocks the pressure on all of them. Otherwise
211
+ it is not attempted (a warning says so only when its visible territories could all fall),
212
+ and with fog anywhere else on the board the elimination is
213
+ hedged (it may hold unseen territories). A
214
+ border just taken last turn from a weak opponent (fewer territories, smaller deploy) is never
215
+ conceded. A border too costly to hold for
216
+ what it protects is `conceded`: nothing is deployed there (unless every territory you hold
217
+ is conceded) and no attack from it is funded, its armies withdraw to a border
218
+ that holds, and the largest such move is scheduled as your first order. `cardAdvice:
219
+ "order-priority"` says to play Order Priority (the `orders` already play it) so it runs before
220
+ the opponent's first — only when you hold one, you are not known to move first, and it carries
221
+ at least 5 armies (any number when the card must go anyway); otherwise a warning says why not.
222
+ A held bonus's border is not conceded on a near miss (short of a sure hold by at most 2 armies or 15%) or
223
+ while it still holds against the expected attack (enemy movable + its deploy estimate):
224
+ everything left goes there, with a warning that it may fall, and its armies stay.
225
+ 2. **Review.** Go through the plan and its warnings; edit the `orders` if you want something
226
+ different (territories by id or name, cards by id or type name).
227
+ 3. **Submit.** `warapp_submit_turn` with those `orders`. It always acts as the account signed in
228
+ to your war.app tab, and refuses another `player`. It validates the orders on the live board
229
+ (cards in your hand, your territories at the start of the turn, adjacent moves, armies
230
+ available with one left behind, deploys equal to your income plus played Reinforcement
231
+ armies — a preview warning instead when a setting such as an army cap makes the modelled
232
+ income uncertain), refuses with no card play when your hand is full, refuses outside a turn phase or
233
+ when you have already committed this turn (withdraw them with `warapp_uncommit_turn` first, or modify
234
+ orders in the game), and shows the
235
+ orders and the turn number before anything is sent.
236
+
237
+ war.app's reply to a commit does not say whether it worked, so the result is read back from the
238
+ game: `resolved` (the turn advanced), `committed` (your orders are in and the game waits on
239
+ others) or `unknown` (check the game with `warapp_get_game` before trying again — never resend
240
+ blindly). Once submitted, the orders play out and every player sees the results.
241
+
242
+ ## Skills
243
+
244
+ The package (and the Claude Code plugin) ships two skills under `skills/`:
245
+
246
+ - **warapp-mcp** — which tool answers which question, and how the tools behave in mcp-host context groups.
247
+ - **warapp-api** — the same GameFeed reads from a shell with curl and jq, no server needed. Source
248
+ `skills/warapp-api/scripts/warapp.sh` (bash or zsh) for `warapp_game`, `warapp_map` (cached per map)
249
+ and `warapp_feed`; it reads `WARAPP_EMAIL` / `WARAPP_API_TOKEN` from the environment or
250
+ `~/.config/warapp-mcp/.env` and never prints the token. It also scouts a player from a shell:
251
+ `fpx` ([`@fetchproxy/cli`](https://www.npmjs.com/package/@fetchproxy/cli), profile `warapp`)
252
+ fetches the Profile and CommonGames pages through your signed-in tab and
253
+ `references/scout.mjs` prints the same allowlisted JSON as `warapp_scout_player`.
254
+
255
+ ## Development
256
+
257
+ ```sh
258
+ npm install
259
+ npm run build # tsc --noEmit + esbuild bundle → dist/bundle.js
260
+ npm test # typecheck + vitest
261
+ ```
262
+
263
+ ## License
264
+
265
+ MIT
@@ -0,0 +1,159 @@
1
+ // What the award of picks reveals (#166). Pure and deterministic; no I/O.
2
+ //
3
+ // Picks are awarded round by round in move order, the order reversing each round, each player
4
+ // getting the highest-ranked territory of their own list that is still free (the community wiki's
5
+ // Manual distribution page; `pickOutcomes` in ./picks.ts enumerates what a list can yield). So once
6
+ // the territories I start on are known, my own list says things about the others:
7
+ // - a territory I listed and was not granted, while a lower-ranked one was, had been taken: it is
8
+ // another player's start. In a two-player game it is the opponent's.
9
+ // - in a two-player game the award order is A B B A A B …, and some granted sets can come about
10
+ // only as the first awarded, others only as the second (my k-th granted pick being list number
11
+ // 2k is exactly that case). Under a `Cycle` move order the award is turn 0 of the cycle, so the
12
+ // first awarded moves second on turn 1 (the wiki's Move order page and the client's help text)
13
+ // and the order alternates. Under `NoLuckCycle` play speed sets the first order instead.
14
+ // - a commander starts on its owner's first awarded territory (the wiki's Commanders page), so
15
+ // when every award that fits gives the opponent the same first territory of my list, its
16
+ // commander started there.
17
+ // With two players the reading is exact: every award that fits what I was granted is enumerated
18
+ // (the opponent's own list is unknown, so each of its awards may be any free territory of my list
19
+ // or one outside it), and only what holds in all of them is reported. With three or more players
20
+ // only the first point is read, and not whose start it is — except in a team game (C2), where a start
21
+ // the first board shows as a teammate's is the teammate's, never an opponent's.
22
+ import { impliedOpponentStarts } from './picks.js';
23
+ /** Search states {@link readAward} explores before it falls back to the rule that needs none. */
24
+ const MAX_AWARD_READ_STATES = 200_000;
25
+ const byNum = (a, b) => a - b;
26
+ /**
27
+ * Read the award from my pick list (in priority order) and the territories I hold on the first
28
+ * board after distribution. `null` when the list cannot explain that start (it is not the list
29
+ * the award used, or the board is not the first one), so nothing is inferred from it.
30
+ */
31
+ export function readAward(input) {
32
+ const list = [...new Set(input.list)];
33
+ const mine = new Set(input.mine);
34
+ const players = Number.isFinite(input.players) ? Math.floor(input.players) : 0;
35
+ const awards = mine.size;
36
+ if (players < 2 || !list.length || !awards)
37
+ return null;
38
+ const granted = list.filter((t) => mine.has(t));
39
+ const unlisted = [...mine].filter((t) => !list.includes(t)).sort(byNum);
40
+ const exact = players === 2 && list.length <= 30 ? readDuel(list, granted, awards) : undefined;
41
+ if (exact !== undefined)
42
+ return exact === null ? null : withTeammates({ granted, unlisted, ...exact }, input.teammateHeld);
43
+ // Three or more players (or a duel too large to enumerate): only what needs no award order.
44
+ // A list that ran out left me on territories I never listed: every listed one I lack was taken.
45
+ const theirs = unlisted.length ? list.filter((t) => !mine.has(t)) : impliedOpponentStarts(list, granted);
46
+ if (theirs.length > (players - 1) * awards)
47
+ return null;
48
+ return withTeammates({ granted, unlisted, opponentStarts: theirs, allStartsKnown: false, role: null, opponentFirstAward: null }, input.teammateHeld);
49
+ }
50
+ /** In a team game, the starts the board shows as a teammate's move from `opponentStarts` to `teammateStarts`. */
51
+ function withTeammates(r, teammateHeld) {
52
+ if (teammateHeld === undefined)
53
+ return r;
54
+ const mates = new Set(teammateHeld);
55
+ return {
56
+ ...r,
57
+ opponentStarts: r.opponentStarts.filter((t) => !mates.has(t)),
58
+ teammateStarts: r.opponentStarts.filter((t) => mates.has(t)),
59
+ };
60
+ }
61
+ /** The opponent's first award: not made yet, or a territory outside my list. */
62
+ const NOT_YET = -2;
63
+ const OUTSIDE = -1;
64
+ /**
65
+ * Every two-player award that fits: `null` when none does, `undefined` when the search would pass
66
+ * {@link MAX_AWARD_READ_STATES} states.
67
+ */
68
+ function readDuel(list, granted, awards) {
69
+ const n = list.length;
70
+ const bit = (i) => 1 << i;
71
+ let observed = 0;
72
+ list.forEach((t, i) => {
73
+ if (granted.includes(t))
74
+ observed |= bit(i);
75
+ });
76
+ const steps = 2 * awards;
77
+ const seen = new Set();
78
+ const fits = [];
79
+ let states = 0;
80
+ // pos: my place in the award order (0: awarded first). theirs / got: list positions the opponent / I hold.
81
+ const visit = (pos, step, theirs, got, first) => {
82
+ const key = `${pos}:${step}:${theirs}:${got}:${first}`;
83
+ if (seen.has(key))
84
+ return true;
85
+ seen.add(key);
86
+ if (++states > MAX_AWARD_READ_STATES)
87
+ return false;
88
+ if (step === steps) {
89
+ if (got === observed)
90
+ fits.push({ pos, theirs, first });
91
+ return true;
92
+ }
93
+ const round = Math.floor(step / 2);
94
+ const slot = step % 2;
95
+ const mover = round % 2 === 0 ? slot : 1 - slot;
96
+ if (mover === pos) {
97
+ let free = -1;
98
+ for (let i = 0; i < n; i++)
99
+ if (!((theirs | got) & bit(i))) {
100
+ free = i;
101
+ break;
102
+ }
103
+ // My list has run out: I am given a territory I never listed.
104
+ if (free < 0)
105
+ return visit(pos, step + 1, theirs, got, first);
106
+ // I would have been granted a pick I was not: this award does not fit.
107
+ if (!(observed & bit(free)))
108
+ return true;
109
+ return visit(pos, step + 1, theirs, got | bit(free), first);
110
+ }
111
+ // The opponent: a territory outside my list, or any free one on it that I was not granted.
112
+ if (!visit(pos, step + 1, theirs, got, first === NOT_YET ? OUTSIDE : first))
113
+ return false;
114
+ for (let i = 0; i < n; i++) {
115
+ if ((theirs | got | observed) & bit(i))
116
+ continue;
117
+ if (!visit(pos, step + 1, theirs | bit(i), got, first === NOT_YET ? i : first))
118
+ return false;
119
+ }
120
+ return true;
121
+ };
122
+ for (let pos = 0; pos < 2; pos++)
123
+ if (!visit(pos, 0, 0, 0, NOT_YET))
124
+ return undefined;
125
+ if (!fits.length)
126
+ return null;
127
+ let certain = ~0;
128
+ for (const f of fits)
129
+ certain &= f.theirs;
130
+ const opponentStarts = list.filter((_, i) => certain & bit(i));
131
+ const role = fits.every((f) => f.pos === fits[0].pos) ? (fits[0].pos === 0 ? 'first' : 'second') : null;
132
+ const first = fits.every((f) => f.first === fits[0].first) ? fits[0].first : NOT_YET;
133
+ return {
134
+ opponentStarts,
135
+ allStartsKnown: opponentStarts.length === awards,
136
+ role,
137
+ opponentFirstAward: first >= 0 ? list[first] : null,
138
+ };
139
+ }
140
+ /** A cyclic move order (GameFeed's `MoveOrder`): the order reverses every turn. Lives in plan/shared.ts (a leaf). */
141
+ export { isCyclicMoveOrder } from './plan/shared.js';
142
+ /**
143
+ * Who moves first on `turn` in a two-player game, from my place in the award: under a `Cycle`
144
+ * order the award is turn 0 of the cycle, so the first awarded moves second on turn 1, first on
145
+ * turn 2, and so on (the client's own help text: "if player A gets their first pick, player B
146
+ * will get first move on turn one"). `null` under a random (or unknown) order or without a role,
147
+ * and under `NoLuckCycle`, whose first order is set by how fast each player played turn one or
148
+ * the distribution (the same help text), not by the award (#127). An Order Priority or Order
149
+ * Delay card played that turn changes it.
150
+ */
151
+ export function firstMoverOnTurn(input) {
152
+ const { role, turn, moveOrder } = input;
153
+ if (role === null || turn === null || !Number.isInteger(turn) || turn < 1)
154
+ return null;
155
+ if (moveOrder !== 'Cycle')
156
+ return null;
157
+ const firstAwardedMovesFirst = turn % 2 === 0;
158
+ return (role === 'first') === firstAwardedMovesFirst ? 'me' : 'opponent';
159
+ }