@chrischall/warapp-mcp 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -2
- package/dist/analysis/card-support.js +12 -4
- package/dist/analysis/coalition.js +55 -0
- package/dist/analysis/local-deploy.js +14 -0
- package/dist/analysis/opponents.js +2 -1
- package/dist/analysis/picks.js +270 -37
- package/dist/analysis/plan/after-leftover.js +26 -4
- package/dist/analysis/plan/captures.js +76 -13
- package/dist/analysis/plan/completed.js +8 -1
- package/dist/analysis/plan/conceded-out.js +16 -11
- package/dist/analysis/plan/deploy-estimates.js +513 -0
- package/dist/analysis/plan/doomed-out.js +135 -0
- package/dist/analysis/plan/estimates.js +3 -1
- package/dist/analysis/plan/free-capture.js +34 -0
- package/dist/analysis/plan/holds.js +8 -309
- package/dist/analysis/plan/horizon.js +42 -0
- package/dist/analysis/plan/leftover.js +43 -5
- package/dist/analysis/plan/observe.js +896 -0
- package/dist/analysis/plan/orders.js +35 -1
- package/dist/analysis/plan/report.js +10 -4
- package/dist/analysis/plan/shared.js +4 -1376
- package/dist/analysis/plan/stand-still.js +5 -3
- package/dist/analysis/plan/state.js +12 -0
- package/dist/analysis/plan/strike-stack.js +467 -0
- package/dist/analysis/plan/strike.js +3 -463
- package/dist/analysis/plan/targets.js +213 -26
- package/dist/analysis/plan/threats.js +12 -4
- package/dist/analysis/plan/transfers.js +24 -1
- package/dist/analysis/plan/two-move.js +1 -1
- package/dist/analysis/plan/withdraw.js +316 -0
- package/dist/analysis/planner.js +54 -11
- package/dist/analysis/player.js +4 -0
- package/dist/analysis/relations.js +8 -2
- package/dist/analysis/stress.js +1 -1
- package/dist/bundle.js +8008 -7184
- package/dist/my-games.js +2 -0
- package/dist/open-games.js +94 -10
- package/dist/tools/card-advice.js +26 -11
- package/dist/tools/card-support-advice.js +17 -1
- package/dist/tools/check-plan.js +2 -1
- package/dist/tools/commander-check.js +2 -1
- package/dist/tools/decision-capture.js +4 -2
- package/dist/tools/join-game.js +44 -8
- package/dist/tools/live.js +33 -5
- package/dist/tools/open-games.js +2 -2
- package/dist/tools/picks.js +120 -47
- package/dist/tools/turn.js +43 -4
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "MCP server for war.app (Warzone) — your games, players, settings, map bonuses and chokepoints, board analysis and route planning through war.app's per-player GameFeed API, plus the live board, territory picks, cards, turn planning and submission, turn notifications and game chat through your signed-in war.app tab (joining, leaving or surrendering a game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.8.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "war.app (Warzone)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
18
|
-
"version": "0.
|
|
18
|
+
"version": "0.8.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "warapp-mcp",
|
|
3
3
|
"displayName": "war.app (Warzone)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.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
|
@@ -136,7 +136,7 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
|
|
|
136
136
|
| `warapp_healthcheck` | Check that war.app accepts your email and API token; report the active transport and whether a direct session is linked. |
|
|
137
137
|
| `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. |
|
|
138
138
|
| `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. |
|
|
139
|
-
| `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. |
|
|
139
|
+
| `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. |
|
|
140
140
|
| `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). |
|
|
141
141
|
| `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. |
|
|
142
142
|
| `warapp_accept_surrender` | **Writes.** Accept another player's pending surrender (where the game asks the others to accept one). Confirm-gated; refuses when no surrender is pending from that player, when your acceptance is not owed, finished games and games you are not playing. `player` names the surrendering player (optional with one pending). The preview says what accepting does: whose seat, whether its land turns neutral or goes to an AI, which players border that land (live board), whether others still owe their acceptance, whether it leaves only your side playing (a win), and in a free-for-all one advice line naming the neighbour that gains most. Reads the outcome back from GameFeed and the game details: `accepted`, `pending` (others still owe theirs), `unconfirmed` or `unknown` (never resent). The encoding is read from the war.app client, not yet verified live. |
|
|
@@ -157,7 +157,7 @@ Locally `WARAPP_AUTH_TOKEN` is ignored.
|
|
|
157
157
|
| `warapp_profile_opponents` | What each opponent tends to do, by name, counted from your boards and the orders this server sent: per opponent `seen.turnsObserved` (the only fact) and `habits` — `reinforce` (your attack on its territory met more armies than the board showed; measured only at 0% luck with straight rounding), `attack` (turns in contact it attacked you), `firstStrike`, `stacking` (share of its visible growth on one territory), `retaliate` and `retake` (within two turns) — each this game's counts pooled with the player's faded counts from your earlier finished games (`seen.gamesMet`) and shrunk toward a prior (all players in this format, then all players, once that pool has 10 opportunities; the AI pool for an AI seat; else a neutral default) — a `value`, its `n`, `confidence` and `basis` (`this-game`, `past-games`, `population` or `default`), then `labels` and `counter` lines at confidence 0.5 or more. Known teammates are never profiled; while a game's teams cannot be read, nothing is kept and every other player carries `mayBeTeammate: true`. The turns are kept per game (`<dataDir>/profiles/games/`, ids and counts only) by this tool, `warapp_plan_turn` (not a what-if plan), `warapp_track_opponents`, `warapp_locate_opponents` and `warapp_get_relations`, unless `WARAPP_PLAYER_PROFILE=off`. `profile` says whether the turns are `kept`, `not-kept` (no data dir, or the teams unknown) or `off`. `detail`: compact / full (adds the counts and each observed turn). `lastAttackTurn` beside the labels is the last turn it attacked you (null: none seen); `turtle` is never given within two turns of one. Given a finished game it folds it into the cross-game counts instead (`fold`: once, from the turns kept while it was played, else a backfill from the boards cached then — no other request, nothing while its teams are unknown — or "counts start with games played on this build"); `warapp_get_game` does the same on a finished game (`profileFold`). Read-only on war.app (it caches the board it read); refuses any other state outside a turn phase. `warapp_plan_turn` reports a compact read as `reads` (with `lastAttackTurn`) but does not use it. A habit whose past weighs most and was mostly read from finished games' histories reads `basis: history`. |
|
|
158
158
|
| `warapp_plan_picks` | A pick list for a manual-distribution game in the picking stage, from the map, the settings and the live board's pickable territories: priority order by name and id, a compact primary group (the territory limit) and a disjoint fallback group (as long as war.app's client allows), each pick's score and reasons (bonus, value, turns to complete, first-turn bonus, entry points, contested), the award (the sets the award order can grant, and the worst), the primary's `coverage` (the reasonable bonuses its picks can stand next to within 2 moves) and, in a 1v1 when it covers more, a coverage-first `alternative` list with its own `submitPicks` (compact is the default; the alternative suits a small board), warnings for assumed settings, and `submitPicks` — the ids in order, ready for `warapp_submit_picks`. In a team game only the players off your team are threats, `team` names your teammates, and the list is judged by both award orders that fit (`award.orders`; a team game's is unverified); `warapp_submit_picks` warns when a team game's list is shorter than starts × all players. When a teammate's pick list can be read (their entered orders, else `GetTerritoryPicks`; unverified live), each teammate carries `picks` and `team.coordination` reports the overlap with your list, the bonuses their top picks into (a bonus pays one holder, so your picks there are not credited) and a `mirrored` alternative — the same top picks in both lists, laid on the positions a reversing award gives one player, with the bonuses a repeating order would split and its own `submitPicks` — beside the split list in `submitPicks`, which leaves their top picks to them and is shortened only when disjoint from their list and theirs is full length; every `submitPicks` fits war.app's client limit. With no list read the plan is unchanged. The heuristics are in [docs/STRATEGY.md](docs/STRATEGY.md). `view`: compact / full. Read-only; refuses outside the picking stage. With finished games on the map, `mapRecord` reports them beside the list (reported only): your results by start bonus, where winners started, and the median income after turns 4 and 8. |
|
|
159
159
|
| `warapp_submit_picks` | **Writes.** Replace your territory picks (priority order, pickable territories only; a list longer than war.app's client allows — players × territories per player — or shorter than each player's share is warned about in the preview). Confirm-gated; reads the picks back and reports `verified` only on an exact match. |
|
|
160
|
-
| `warapp_submit_turn` | **Writes.** Commit your turn's orders (e.g. `warapp_plan_turn`'s `orders`) as the signed-in account: card plays (Reinforcement, Order Priority, Order Delay, Blockade, Airlift, Diplomacy — the Blockade and Airlift plays verified live 2026-11-16, Diplomacy 2026-11-18; and, encoded as the client does but not yet verified live, Spy,
|
|
160
|
+
| `warapp_submit_turn` | **Writes.** Commit your turn's orders (e.g. `warapp_plan_turn`'s `orders`) as the signed-in account: card plays (Reinforcement, Order Priority, Order Delay, Blockade, Airlift, Diplomacy — the Blockade and Airlift plays verified live 2026-11-16, Diplomacy 2026-11-18; Reconnaissance accepted live 2026-11-20 (the reveal itself not yet seen); and, encoded as the client does but not yet verified live, Spy, Surveillance, Gift, Sanctions, Bomb and Emergency Blockade with their targets — refused where war.app would refuse them, e.g. a commander gifted or airlifted to a teammate, a Spy or Sanctions on your own side, a Spy on the neutral (player `0`) unless the game's Spy card allows it, Diplomacy between teammates or naming a player who is out, a Bomb on your own side or not next to you, an Emergency Blockade on a territory not yours or on your commander; in a team game the preview warns when the orders play or discard a card your teammate has already entered (a card named by type is one nobody entered when there is one; their orders are read from the live board, unverified); an Airlift may send `armies: 0` with `commander` to move the commander alone, and a Gift to an opponent is named as one in the preview), discards, deploys and moves. Confirm-gated; validated on the live board (cards in your hand, your territories, adjacent moves, armies available, deploys = income + played Reinforcement armies; bonus armies inside their bonus under Local Deployment; one attack/transfer per territory under No-Split, with a warning when one sends less than the whole stack; enough card plays or discards when you hold more cards than the limit); confirmed from game state (`resolved` / `committed` / `unknown`). An order that attacks (or a Bomb that hits) a territory an active or in-notice truce covers (`warapp_record_agreement`) is refused unless `break_agreement: true`: the preview then names the agreement, and once the orders are committed the ledger records it broken by you (and the partner's player record says so). In a Commanders game, orders that leave your commander takeable by one opponent's single deploy, or two striking together when you lead a free-for-all (each reply sized at the larger of its estimate and your income, on the live board; your Airlifts are counted, after the deploys and before the moves, the commander with one that takes it), are refused with the armies that would hold (under Local Deployment the hint says a deploy there must come from a pool that reaches it), and so is a Blockade or Gift of a territory your commander stands on before or after the orders (not simulated), unless `accept_commander_risk: true` (ask first: losing the commander loses the game); the preview then warns first and the result records `commanderRiskAccepted`. The preview also warns when the orders break a promise a chat message declared (`warapp_send_chat`'s `commitments`): an attack you said you would not make, or an attack you said you would make and left out. It warns too (never refuses) when the orders leave a border of a bonus you hold falling to a single deploy below your own income (#275 headroom), and when they leave any border below what the default plan made now (as `warapp_plan_turn` makes it with no options, or its border guess when the deploys are the guess's) leaves standing there, naming each with the difference (#275). Other players see the results. Optional `override_reason` (at most 500 characters) and `override_by` (`hand` or `agent`, default `agent`) say why and by whom the orders differ from `warapp_plan_turn`'s for the turn: they change nothing sent, and are kept (names scrubbed) in the [decision log](#decision-log) beside the plan only when the orders do differ. Unread chat that may change the turn is listed in the preview's `chatWarnings`; with `WARAPP_CHAT_BLOCKS_TURN=on` it is refused instead, unless `chat_reviewed: true` (see [Chat advice](#chat-advice)). |
|
|
161
161
|
| `warapp_uncommit_turn` | **Writes.** Withdraw your committed orders for the current turn (war.app's UnCommit, the game's "Modify orders") so you can submit corrected ones with `warapp_submit_turn`. Confirm-gated; refuses outside a turn phase and when your orders are not committed; reads the outcome from GameFeed (`uncommitted` / `unconfirmed`, or `unknown` when war.app did not answer — never resent). The game waits on you again, so recommit before the boot timer. A truce recorded broken by you on that turn (`break_agreement`) stays recorded: `agreementsStillBroken` names it. |
|
|
162
162
|
| `warapp_chat_inbox` | The chat you have not marked seen, across all your games in one call (your lobbies and games being picked or played, from your games list, and a finished game when war.app flags its chat unread, or when those flags do not read (`finishedUnflagged` counts these) — or exactly the games in `game_ids`; `gamesFrom` says which, and from the list `listed`/`complete` whether it was whole): per game with something new, `unread` per channel and only the new messages (the newest `limit`, delimited, as `warapp_get_chat` shows them); games with nothing new in `quiet`, a game whose read failed in `failed` (never an error for the call). At most `max_games` (default and max 10) games per call, read one at a time: pass `next` back as `cursor` for the rest. Reading marks nothing; `mark_seen: true` marks every channel of each game read as seen, on this machine only (war.app still shows them unread until `warapp_mark_chat_read` marks them read there). Read-only. Each new message from another player carries `intent` and `advice`, as `warapp_get_chat` gives them. |
|
|
163
163
|
| `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. |
|
|
@@ -317,14 +317,16 @@ function redeployAirlift(cb, r, spare) {
|
|
|
317
317
|
/**
|
|
318
318
|
* A Gift as team support: my members of a bonus a teammate is nearer to holding, when giving them
|
|
319
319
|
* completes it (every other member is the teammate's) and I hold enough Gift cards — never a territory
|
|
320
|
-
* with a special unit on it (war.app refuses it) or one the plan
|
|
321
|
-
*
|
|
320
|
+
* with a special unit on it (war.app refuses it) or one the plan attacks from (the gift would cancel
|
|
321
|
+
* the attack). #435: judged before the idle transfers, as if they were not there — a transfer out of or
|
|
322
|
+
* into a gifted territory is listed in `drop` (45731288 turn 6: one idle army walking off the member
|
|
323
|
+
* hid a +4 completion). The most valuable bonus first, then ascending id. `undefined` when none.
|
|
322
324
|
*/
|
|
323
325
|
export function giftAdvice(cb, shared, gifts) {
|
|
324
326
|
if (gifts <= 0)
|
|
325
327
|
return undefined;
|
|
326
328
|
const r = reader(cb);
|
|
327
|
-
const ok = (t) => !(r.state.get(t)?.specialUnits ?? []).length &&
|
|
329
|
+
const ok = (t) => !(r.state.get(t)?.specialUnits ?? []).length && !cb.moves.some((m) => m.from === t && m.kind === 'attack');
|
|
328
330
|
const best = [...shared]
|
|
329
331
|
.filter((b) => b.nearer !== null && b.nearer !== cb.me && !b.others.length && b.teammates.length === 1 && b.mine.length <= gifts && b.mine.every(ok))
|
|
330
332
|
.sort((a, b) => b.value - a.value || a.bonusId - b.bonusId)[0];
|
|
@@ -332,14 +334,20 @@ export function giftAdvice(cb, shared, gifts) {
|
|
|
332
334
|
return undefined;
|
|
333
335
|
const mate = best.teammates[0].player;
|
|
334
336
|
const borders = best.mine.filter((t) => r.reachOf(t) !== undefined);
|
|
337
|
+
const gifted = new Set(best.mine);
|
|
338
|
+
const drop = cb.moves.filter((m) => m.kind === 'transfer' && (gifted.has(m.from) || gifted.has(m.to))).map((m) => ({ from: m.from, to: m.to }));
|
|
335
339
|
return {
|
|
336
340
|
player: mate,
|
|
337
341
|
bonus: best.bonusId,
|
|
338
342
|
value: best.value,
|
|
339
343
|
territories: [...best.mine],
|
|
344
|
+
drop,
|
|
340
345
|
why: `Gift ${best.mine.join(', ')} to your teammate ${mate}: it holds every other member of bonus ${best.bonusId}, so the gift completes it ` +
|
|
341
346
|
`(+${best.value} a turn for the team; a bonus pays only the player who holds all of it).` +
|
|
342
|
-
(borders.length ? ` ${borders.join(', ')} ${borders.length === 1 ? 'faces' : 'face'} an opponent: your teammate must hold ${borders.length === 1 ? 'it' : 'them'}.` : '')
|
|
347
|
+
(borders.length ? ` ${borders.join(', ')} ${borders.length === 1 ? 'faces' : 'face'} an opponent: your teammate must hold ${borders.length === 1 ? 'it' : 'them'}.` : '') +
|
|
348
|
+
(drop.length
|
|
349
|
+
? ` Drop the transfer${drop.length === 1 ? '' : 's'} ${drop.map((m) => `${m.from} → ${m.to}`).join(', ')}: the Gift lands before the moves run, so ${drop.length === 1 ? 'it' : 'they'} would not move your armies as planned.`
|
|
350
|
+
: ''),
|
|
343
351
|
};
|
|
344
352
|
}
|
|
345
353
|
/**
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Before surrendering a free-for-all, whether a coalition against the leader is viable and with whom (#445,
|
|
2
|
+
// owner 2026-11-20: "reach out to the weaker players and team up"). Pure, advice only: it never sends a
|
|
3
|
+
// message and never changes a plan. The grace window is the owner's to set (`COALITION_GRACE_TURNS`, the
|
|
4
|
+
// issue's suggested 2); the planner does not count it, the tool says it.
|
|
5
|
+
/** Turns the coalition attempt gets before the surrender advice returns (#445's suggestion; the owner may change it). */
|
|
6
|
+
export const COALITION_GRACE_TURNS = 2;
|
|
7
|
+
/** Owner decision of 2026-11-22: ask the best partner, and others only when "very close in strength": income at least this share of the best's. */
|
|
8
|
+
export const OUTREACH_CLOSE_RATIO = 0.9;
|
|
9
|
+
/**
|
|
10
|
+
* `rows`: every player in sight with its armies and income estimate (the profile's FFA ranking). `me`: my id.
|
|
11
|
+
* `bordersLeader`: the players with a territory beside the leader's. `excluded`: players ruled out (an agreement
|
|
12
|
+
* broken against me, at war with me, out of the game). Returns `null` outside a free-for-all of three or more
|
|
13
|
+
* (a 1v1 goes straight to the surrender advice) or when I lead.
|
|
14
|
+
*/
|
|
15
|
+
export function coalitionAdvice(input) {
|
|
16
|
+
const { rows, me, leader } = input;
|
|
17
|
+
if (rows.length < 3 || leader === me)
|
|
18
|
+
return null;
|
|
19
|
+
const lead = rows.find((r) => r.playerId === leader);
|
|
20
|
+
const mine = rows.find((r) => r.playerId === me);
|
|
21
|
+
if (!lead || !mine)
|
|
22
|
+
return null;
|
|
23
|
+
const partners = rows
|
|
24
|
+
.filter((r) => r.playerId !== me && r.playerId !== leader && !input.excluded?.has(r.playerId) && !input.breakers?.has(r.playerId))
|
|
25
|
+
.map((r) => ({ playerId: r.playerId, income: r.income, armies: r.armies, bordersLeader: input.bordersLeader.has(r.playerId) }))
|
|
26
|
+
.sort((a, b) => Number(b.bordersLeader) - Number(a.bordersLeader) || b.income - a.income || a.playerId - b.playerId);
|
|
27
|
+
const trailingIncome = mine.income + partners.reduce((n, p) => n + p.income, 0);
|
|
28
|
+
const viable = partners.length > 0 && trailingIncome >= lead.income;
|
|
29
|
+
const best = partners.find((p) => p.bordersLeader) ?? partners[0];
|
|
30
|
+
const leftOut = rows
|
|
31
|
+
.filter((r) => r.playerId !== me && r.playerId !== leader && input.breakers?.has(r.playerId) && !input.excluded?.has(r.playerId))
|
|
32
|
+
.map((r) => ({ playerId: r.playerId, reason: 'broke-a-truce' }));
|
|
33
|
+
const outreach = best
|
|
34
|
+
? [best.playerId, ...partners.filter((p) => p !== best && p.income >= OUTREACH_CLOSE_RATIO * best.income).map((p) => p.playerId)]
|
|
35
|
+
: [];
|
|
36
|
+
const advice = viable
|
|
37
|
+
? `Try a coalition first: the trailing players together earn ~${trailingIncome} against player ${leader}'s ~${lead.income}${best ? `; ${outreach.length > 1 ? `players ${outreach.join(', ')} are about equally strong, ask them together` : `player ${best.playerId} is the best partner${best.bordersLeader ? ' (it borders the leader)' : ''}`}` : ''}. Give it ${COALITION_GRACE_TURNS} turns; if nobody agrees, or the leader's lead keeps growing, the surrender advice stands (advice only; the server sends nothing).`
|
|
38
|
+
: `No coalition looks viable: the trailing players together earn ~${trailingIncome} against player ${leader}'s ~${lead.income}${partners.length ? '' : ' and there is no one left to ask'}, so the surrender advice stands.`;
|
|
39
|
+
return {
|
|
40
|
+
viable,
|
|
41
|
+
leader,
|
|
42
|
+
leaderIncome: lead.income,
|
|
43
|
+
trailingIncome,
|
|
44
|
+
partners,
|
|
45
|
+
graceTurns: COALITION_GRACE_TURNS,
|
|
46
|
+
outreach,
|
|
47
|
+
leftOut,
|
|
48
|
+
advice,
|
|
49
|
+
...(viable && best
|
|
50
|
+
? {
|
|
51
|
+
draft: `Player ${leader} is ahead of both of us and I would rather it not take either of us next. Would you be willing to hold off attacking each other and to press ${outreach.length === 1 && best.bordersLeader ? 'it on the border we share' : 'it where you can'}? I will tell you before I change that.`,
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -127,6 +127,20 @@ export function chargeDeploys(pools, deploys) {
|
|
|
127
127
|
anywhereUsed += n;
|
|
128
128
|
return { anywhereUsed, used };
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* #433: what `needs` (armies by territory, e.g. the gates' shortfalls next turn) lack under Local Deployment, for a
|
|
132
|
+
* player holding `held` with `income`: a bonus's pool deploys only on its own territories, so each need is paid
|
|
133
|
+
* from the pools of the bonuses it is in ({@link chargeDeploys}, as well as they can be split) and the rest from the
|
|
134
|
+
* free income. `deployable` is the part of the income that can land on any of them: the free armies plus every pool
|
|
135
|
+
* holding a need. Without a held bonus it is the plain shortfall, Σ needs − income (at least 0).
|
|
136
|
+
*/
|
|
137
|
+
export function poolShortfall(g, held, income, needs) {
|
|
138
|
+
const pools = deployPools(g, held, income);
|
|
139
|
+
const wanted = new Map([...needs].filter(([, n]) => n > 0));
|
|
140
|
+
const { anywhereUsed } = chargeDeploys(pools, wanted);
|
|
141
|
+
const deployable = pools.anywhere + pools.bonuses.reduce((n, p) => n + (p.territoryIds.some((t) => wanted.has(t)) ? p.value : 0), 0);
|
|
142
|
+
return { short: Math.max(0, anywhereUsed - pools.anywhere), deployable };
|
|
143
|
+
}
|
|
130
144
|
/**
|
|
131
145
|
* What an opponent may deploy anywhere under Local Deployment (#293): its free income — its base
|
|
132
146
|
* income (never below `floor`) plus the Reinforcement card armies its estimate counts. Bonus armies
|
|
@@ -4,7 +4,8 @@ import { neutralizeSeats, staticSeats } from './static-seats.js';
|
|
|
4
4
|
import { bonusTerritories } from './bonuses.js';
|
|
5
5
|
import { DEFAULT_DEFENSIVE_KILL_RATE, DEFAULT_OFFENSIVE_KILL_RATE, guaranteedKills, luckFraction, straightKills } from './combat.js';
|
|
6
6
|
import { bfsDistances, neighborsOf } from './graph.js';
|
|
7
|
-
import { bombPossibleOn,
|
|
7
|
+
import { bombPossibleOn, enemyDeployEstimates, localFreeOn, LOW_COVERAGE, TRACKED_MIN_TURNS } from './planner.js';
|
|
8
|
+
import { captureFloor, failedAttackKills, frontierCoverage, holdLosses, observeSigned, ownerShown, repelledFloor, coverageText, trackCoverage, visibleState } from './plan/observe.js';
|
|
8
9
|
import { boardIncome, DEFAULT_BASE_INCOME } from './player.js';
|
|
9
10
|
/** #164: a stack is large when its armies are at least this many turns of its visible income. */
|
|
10
11
|
const LOST_STACK_INCOMES = 2;
|