@chrischall/warapp-mcp 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "metadata": {
9
9
  "description": "MCP server for war.app (Warzone) — your games, players, settings, map bonuses and chokepoints, board analysis and route planning through war.app's per-player GameFeed API, plus the live board, territory picks, cards, turn planning and submission, turn notifications and game chat through your signed-in war.app tab (creating, joining, leaving or surrendering a game, accepting game invitations, closing out a finished game, accepting another player's surrender, a team surrender, a vote to end a game, booting a stalled player, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, nudging a player, joining or leaving a ladder, answering a clan invite, joining or leaving a clan, changing quickmatch settings, voting on quickmatch templates, joining or declining a tournament, showing a tournament among your favourites, mail (new threads, replies, adding players, deleting threads), forum posts (new threads, replies, votes, watching a thread), chat reactions, marking notifications and chat read, deleting notifications, importing local history and linking a session are confirm-gated).",
10
- "version": "0.25.0"
10
+ "version": "0.27.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.25.0",
18
+ "version": "0.27.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.25.0",
4
+ "version": "0.27.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",
@@ -117,7 +117,7 @@ export function cardsInEffect(input) {
117
117
  const pair = [px.id, py.id].sort((p, q) => p - q);
118
118
  const was = others.get(pair.join(','));
119
119
  if (!was || a.untilTurn > was.untilTurn)
120
- others.set(pair.join(','), { players: pair, untilTurn: a.untilTurn });
120
+ others.set(pair.join(','), { players: pair, untilTurn: a.untilTurn, fromTurn: a.untilTurn - durationOf(dipSettings) });
121
121
  continue;
122
122
  }
123
123
  if (myInGame === undefined)
@@ -0,0 +1,35 @@
1
+ import { neighborsOf } from './graph.js';
2
+ /** What a fog setting shows of a territory beside none of mine: its owner, or nothing. */
3
+ const OWNERS_EVERYWHERE = new Set(['LightFog', 'ModerateFog']);
4
+ /** Settings under which I see my own territories only (the wiki: no neighbour shown). */
5
+ const OWN_ONLY = new Set(['VeryFoggy', 'ExtremeFog']);
6
+ /**
7
+ * `board` (a whole board) as `me` sees it under `fog`: under `NoFog` as it is; otherwise my territories (and my
8
+ * teammates') and — except under Very Foggy / Extreme fog — every territory beside them shown whole; the rest show
9
+ * their owner only under Light / Moderate fog, else nothing.
10
+ */
11
+ export function fogView(graph, board, me, fog, allies = new Set()) {
12
+ const mode = fog ?? 'Foggy';
13
+ if (mode === 'NoFog')
14
+ return { ...board, territories: board.territories.map((t) => ({ ...t, fogLevel: 'Visible' })) };
15
+ const own = (t) => t.owner.kind === 'player' && (t.owner.playerId === me || allies.has(t.owner.playerId));
16
+ const mine = new Set(board.territories.filter(own).map((t) => t.territoryId));
17
+ const seen = new Set(mine);
18
+ if (!OWN_ONLY.has(mode))
19
+ for (const t of mine)
20
+ for (const n of neighborsOf(graph, t))
21
+ seen.add(n);
22
+ const ownersShown = OWNERS_EVERYWHERE.has(mode);
23
+ return {
24
+ ...board,
25
+ territories: board.territories.map((t) => {
26
+ if (mine.has(t.territoryId))
27
+ return { ...t, fogLevel: 'You' };
28
+ if (seen.has(t.territoryId))
29
+ return { ...t, fogLevel: 'Visible' };
30
+ if (ownersShown)
31
+ return { territoryId: t.territoryId, owner: t.owner, armies: null, fogLevel: 'OwnerOnly' };
32
+ return { territoryId: t.territoryId, owner: { kind: 'unknown' }, armies: null, fogLevel: 'Fogged' };
33
+ }),
34
+ };
35
+ }
@@ -0,0 +1,26 @@
1
+ import { boardIncome } from './player.js';
2
+ /**
3
+ * The low end, from the plan's figures (pure). Taken as a difference from `nextIncome` so an army cap's cut (#253),
4
+ * which `nextIncome` already carries, is not run again. `undefined` when it equals `nextIncome` (nothing falls, or the
5
+ * falls cost nothing).
6
+ */
7
+ export function nextIncomeLow(a) {
8
+ const after = new Set(a.captures);
9
+ for (const t of a.board.territories)
10
+ if (t.owner.kind === 'player' && t.owner.playerId === a.me)
11
+ after.add(t.territoryId);
12
+ const conceded = a.conceded.filter((t) => after.has(t));
13
+ const belowEstimate = [
14
+ ...new Set(a.headroom
15
+ .filter((r) => after.has(r.territory) && !conceded.includes(r.territory) && r.deploy !== null && r.deploy < (a.estimateOf(r.opponent) ?? -Infinity))
16
+ .map((r) => r.territory)),
17
+ ].sort((x, y) => x - y);
18
+ const falls = [...new Set([...conceded, ...belowEstimate])].sort((x, y) => x - y);
19
+ if (!falls.length)
20
+ return undefined;
21
+ const kept = new Set([...after].filter((t) => !falls.includes(t)));
22
+ const lost = boardIncome(a.graph, after, a.rules).total - boardIncome(a.graph, kept, a.rules).total;
23
+ if (lost <= 0)
24
+ return undefined;
25
+ return { low: Math.max(0, a.nextIncome - lost), falls, belowEstimate };
26
+ }
@@ -112,6 +112,22 @@ export function pactViews(a, me) {
112
112
  export function trucesWithMe(agreements, pacts, me) {
113
113
  return [...agreements, ...(pacts ?? []).flatMap((p) => pactViews(p, me))];
114
114
  }
115
+ const pairOf = (x, y) => (x < y ? [x, y] : [y, x]);
116
+ /** #686: whether parties `x` and `y` of `k` have broken with each other. */
117
+ export const pairBroken = (k, x, y) => {
118
+ const [a, b] = pairOf(x, y);
119
+ return (k.brokenPairs ?? []).some(([p, q]) => p === a && q === b);
120
+ };
121
+ /** #686: the watch's verdict on a pact's parties: its broken pairs, and `broken` once every pair is. */
122
+ function watched(parties, flags) {
123
+ const keys = new Map();
124
+ for (const f of flags)
125
+ if (f.kind === 'broken')
126
+ keys.set(pairOf(f.by, f.against).join(','), pairOf(f.by, f.against));
127
+ const brokenPairs = [...keys.values()].filter(([a, b]) => parties.includes(a) && parties.includes(b)).sort((x, y) => x[0] - y[0] || x[1] - y[1]);
128
+ const pairs = (parties.length * (parties.length - 1)) / 2;
129
+ return { flags: [...flags], ...(brokenPairs.length ? { brokenPairs } : {}), ...(pairs > 0 && brokenPairs.length >= pairs ? { broken: true } : {}) };
130
+ }
115
131
  /** #686: whether a Gift may be in play (`cards` from the settings; unknown: any card may be). */
116
132
  const giftPossible = (cards) => cards === undefined || cards.includes('Gift');
117
133
  /**
@@ -183,36 +199,58 @@ export function pactsWithoutMe(input) {
183
199
  source: a.source ?? 'ledger',
184
200
  agreement: a.id,
185
201
  ...(st.endsTurn !== undefined ? { endsTurn: st.endsTurn } : {}),
186
- ...(flags ? { flags, ...(flags.some((f) => f.kind === 'broken') ? { broken: true } : {}) } : {}),
202
+ ...(flags ? watched(st.remaining, flags) : {}),
187
203
  });
188
204
  }
189
205
  const pair = (x, y) => (x === y || x === me || y === me || !bound(players, x) || !bound(players, y) ? undefined : [x, y].sort(byNum));
206
+ // #686, owner decision of 2026-12-01: a pact the game enforces is watched too, as one agreed from `from` (a card: the
207
+ // first turn it binds; the mod's alliance, whose start is not read: the turn just resolved only) until `until`.
208
+ const watchGame = (parties, from, until) => {
209
+ if (!input.watch)
210
+ return {};
211
+ const a = {
212
+ id: 'game',
213
+ with: parties[1],
214
+ parties,
215
+ kind: 'truce',
216
+ status: 'agreed',
217
+ createdTurn: from,
218
+ agreedTurn: from,
219
+ ...(until !== undefined ? { endedTurn: until } : {}),
220
+ terms: { scope: 'all', noticeTurns: 0 },
221
+ history: [],
222
+ };
223
+ return watched(parties, pactBreachWatch(a, { ...input.watch, me, turn, players }));
224
+ };
190
225
  for (const d of input.diplomacy ?? []) {
191
226
  const p = pair(d.players[0], d.players[1]);
192
227
  if (p && d.untilTurn > turn)
193
- out.push({ parties: p, source: 'card', untilTurn: d.untilTurn });
228
+ out.push({ parties: p, source: 'card', untilTurn: d.untilTurn, ...watchGame(p, d.fromTurn ?? turn - 1, d.untilTurn) });
194
229
  }
195
230
  for (const m of input.mod ?? []) {
196
231
  const p = pair(m[0], m[1]);
197
232
  if (p)
198
- out.push({ parties: p, source: 'mod' });
233
+ out.push({ parties: p, source: 'mod', ...watchGame(p, turn - 1, undefined) });
199
234
  }
200
235
  const key = (k) => k.parties.join(',');
201
236
  return out.sort((x, y) => (key(x) < key(y) ? -1 : key(x) > key(y) ? 1 : x.source.localeCompare(y.source)));
202
237
  }
203
- /** #686: the pacts that still count: a broken one does not. */
238
+ /** #686: the pacts that still count: one every pair of which has broken does not (a pact with some pairs broken does). */
204
239
  export const pactsInForce = (pacts) => pacts.filter((k) => !k.broken);
205
- /** The players `player` is at peace with by `pacts` (every other party of a pact naming it, a broken one aside), ascending. */
240
+ /** The parties of `k` that `player` is still at peace with (its broken pairs aside), ascending. */
241
+ export const peersOf = (k, player) => k.parties.filter((p) => p !== player && !pairBroken(k, p, player)).sort(byNum);
242
+ /** The players `player` is at peace with by `pacts` (every other party of a pact naming it, a broken pair aside), ascending. */
206
243
  export function atPeaceWith(pacts, player) {
207
- return [...new Set(pactsInForce(pacts).filter((k) => k.parties.includes(player)).flatMap((k) => k.parties.filter((p) => p !== player)))].sort(byNum);
244
+ return [...new Set(pactsInForce(pacts).filter((k) => k.parties.includes(player)).flatMap((k) => peersOf(k, player)))].sort(byNum);
208
245
  }
209
- /** Pairs of players at peace with each other by `pacts` (a broken one aside), as `a,b` keys (a < b). */
246
+ /** Pairs of players at peace with each other by `pacts` (a broken pair aside), as `a,b` keys (a < b). */
210
247
  export function pactPairs(pacts) {
211
248
  const out = new Map();
212
249
  for (const k of pactsInForce(pacts))
213
250
  for (let i = 0; i < k.parties.length; i++)
214
251
  for (let j = i + 1; j < k.parties.length; j++)
215
- out.set(`${k.parties[i]},${k.parties[j]}`, [k.parties[i], k.parties[j]]);
252
+ if (!pairBroken(k, k.parties[i], k.parties[j]))
253
+ out.set(`${k.parties[i]},${k.parties[j]}`, [k.parties[i], k.parties[j]]);
216
254
  return [...out.values()].sort((x, y) => x[0] - y[0] || x[1] - y[1]);
217
255
  }
218
256
  /** A pact as a sentence names its source. */
@@ -255,8 +293,10 @@ export function pactJointThreats(graph, board, me, pacts) {
255
293
  if (!was || armies > was.armies)
256
294
  best.set(owner, { player: owner, from: n, armies });
257
295
  }
258
- if (best.size >= 2)
259
- out.push({ territory: t, pact, stacks: [...best.values()].sort((x, y) => x.player - y.player) });
296
+ // #686: only parties still at peace with another party beside it strike together.
297
+ const stacks = [...best.values()].filter((s) => [...best.keys()].some((q) => q !== s.player && !pairBroken(pact, s.player, q)));
298
+ if (stacks.length >= 2)
299
+ out.push({ territory: t, pact, stacks: stacks.sort((x, y) => x.player - y.player) });
260
300
  }
261
301
  }
262
302
  return out;
@@ -280,6 +320,8 @@ export function pactsBasis(all) {
280
320
  const pacts = pactsInForce(all);
281
321
  if (!pacts.length)
282
322
  return '';
283
- const list = pacts.map((k) => `players ${k.parties.join(' and ')} (${pactLabel(k)})`).join('; ');
323
+ const list = pacts
324
+ .map((k) => `players ${k.parties.join(' and ')} (${pactLabel(k)}${k.brokenPairs?.length ? `; ${k.brokenPairs.map(([a, b]) => `${a} and ${b}`).join(', ')} broke with each other` : ''})`)
325
+ .join('; ');
284
326
  return ` Known pacts between other players: ${list} — they may act together; each opponent's strength above is its own (report only, #680).`;
285
327
  }
@@ -0,0 +1,145 @@
1
+ // Turn order (#693): who moves before whom, this turn and the next few, from the turns this server saw. Pure.
2
+ //
3
+ // The rule, read from the client bundle's ServerGame (the server code ships in it): a game keeps one fixed
4
+ // `CyclicMoveOrder` (a list of player ids, random at the start, or by first-turn speed under NoLuckCycle); each turn
5
+ // the players still playing take it forward on an even turn count and REVERSED on an odd one (the client's help:
6
+ // "ABCD becomes DCBA"), then the turn's Order Priority / Order Delay plays re-sort it for that turn only. So whoever
7
+ // moved first moves last on the next turn, in a free-for-all as in a 1v1, and a seat that leaves drops out without
8
+ // changing the others' order. Under `Random` every turn is drawn afresh. Not yet seen live: a projection is the rule's.
9
+ //
10
+ // What is known of a past turn (an `OrderFact`):
11
+ // - `move-order`: the turn's own MoveOrder, when war.app sent it (src/turn-orders.ts; null on every live read so far);
12
+ // - `orders`: inferred from the order the turn's visible moves ran in. Moves run in rounds — one attack/transfer per
13
+ // player per round — and the client REVERSES the player order after every round (A B C, C B A, A B C, …: the
14
+ // turn's order on odd rounds, reversed on even ones; read from the client bundle, and every live turn read so far
15
+ // fits it, war.app's own MoveOrder included). A player's j-th visible move ran in round j or later (fog may hide
16
+ // earlier ones; an order that cannot run is skipped within its slot, so each round runs one per player). When it ran
17
+ // before my j-th move (all of mine are visible, and in round j when every move I sent ran), that player moved before
18
+ // me in round j: before me in the turn's order when j is odd, AFTER me when j is even. A player read both ways in one
19
+ // turn is dropped. The converse (a move after mine) is never sound under fog.
20
+ // A turn with a visible Order Priority or Order Delay play is not used (it re-sorts that turn); one not visible (card
21
+ // plays fogged) can still skew a fact, so facts that disagree are reported as a conflict, never resolved.
22
+ /** The cards that re-sort a turn's move order. */
23
+ const RESORTING_CARDS = new Set(['Order Priority', 'Order Delay']);
24
+ /**
25
+ * What one resolved turn says about the move order relative to me (`null`: nothing). `sentMoves`: how many moves I
26
+ * sent that turn, when known — fewer of mine in the list means one did not run, and my rounds are then unknown.
27
+ */
28
+ export function factOfTurn(seen, me, o = {}) {
29
+ if (seen.orders.some((x) => x.kind === 'card' && x.card !== undefined && RESORTING_CARDS.has(x.card)))
30
+ return null;
31
+ if (seen.moveOrder && seen.moveOrder.length >= 2 && seen.moveOrder.includes(me))
32
+ return { turn: seen.turn, source: 'move-order', full: [...seen.moveOrder] };
33
+ // A move that moved nothing (`actual` 0: no armies left on its source) shares its slot with the player's next order,
34
+ // which war.app runs in it and lists right after it (finished games' histories, 2026-12-01: 34 of 41; the other 7
35
+ // were the player's last order). Counted apart, the pair would shift the player's later rounds by one. One not
36
+ // followed by its player's move keeps its place: under fog the order that ran in that slot may be out of view.
37
+ const moves = seen.orders.map((x, i) => [x, i]).filter(([x]) => x.kind === 'move' && x.player !== null);
38
+ const at = new Map();
39
+ let listedMine = 0;
40
+ moves.forEach(([x, i], k) => {
41
+ if (x.player === me)
42
+ listedMine++;
43
+ if (x.actual === 0 && moves[k + 1]?.[0].player === x.player)
44
+ return;
45
+ const list = at.get(x.player) ?? [];
46
+ list.push(i);
47
+ at.set(x.player, list);
48
+ });
49
+ const mine = at.get(me) ?? [];
50
+ if (!mine.length || (o.sentMoves !== undefined && listedMine < o.sentMoves))
51
+ return null;
52
+ const before = [];
53
+ const after = [];
54
+ for (const [player, idx] of at) {
55
+ if (player === me)
56
+ continue;
57
+ // The rounds (1-based) where this player's move ran before mine: odd → before me, even → after me (snake).
58
+ const rounds = idx.map((pos, j) => (j < mine.length && pos < mine[j] ? j + 1 : 0)).filter((r) => r > 0);
59
+ const inOdd = rounds.some((r) => r % 2 === 1);
60
+ const inEven = rounds.some((r) => r % 2 === 0);
61
+ if (inOdd && !inEven)
62
+ before.push(player);
63
+ else if (inEven && !inOdd)
64
+ after.push(player);
65
+ }
66
+ if (!before.length && !after.length)
67
+ return null;
68
+ return { turn: seen.turn, source: 'orders', ...(before.length ? { before } : {}), ...(after.length ? { after } : {}) };
69
+ }
70
+ const flip = (r) => (r === 'before' ? 'after' : 'before');
71
+ const odd = (n) => Math.abs(n) % 2 === 1;
72
+ const at = (r, from, to) => (odd(to - from) ? flip(r) : r);
73
+ /** A fact's relations at its own turn: every player it places against me. */
74
+ function relationsOf(f, me) {
75
+ const out = new Map();
76
+ if (f.full) {
77
+ const mine = f.full.indexOf(me);
78
+ f.full.forEach((p, i) => p !== me && out.set(p, i < mine ? 'before' : 'after'));
79
+ }
80
+ for (const p of f.before ?? [])
81
+ out.set(p, 'before');
82
+ for (const p of f.after ?? [])
83
+ out.set(p, 'after');
84
+ return out;
85
+ }
86
+ function rowOf(turn, status, rel, playing, order) {
87
+ const pick = (r) => (order ? order.filter((p) => rel.get(p) === r) : playing.filter((p) => rel.get(p) === r));
88
+ return { turn, status, order, beforeMe: pick('before'), afterMe: pick('after'), unknown: playing.filter((p) => !rel.has(p)) };
89
+ }
90
+ export function readTurnOrder(a) {
91
+ const { turn, me, playing } = a;
92
+ const cyclic = a.moveOrder === 'Cycle' || a.moveOrder === 'NoLuckCycle';
93
+ const facts = [...a.facts].filter((f) => f.turn < turn).sort((x, y) => x.turn - y.turn);
94
+ const past = facts.slice(-(a.pastTurns ?? 5)).map((f) => {
95
+ const rel = relationsOf(f, me);
96
+ return { ...rowOf(f.turn, 'known', rel, f.full ? f.full.filter((p) => p !== me) : [...rel.keys()].filter((p) => p !== me), f.full ?? null), basis: f.source };
97
+ });
98
+ // Past rows list every seat the fact placed; the unknown are the players still playing it did not place.
99
+ for (const r of past)
100
+ r.unknown = playing.filter((p) => !r.beforeMe.includes(p) && !r.afterMe.includes(p));
101
+ const perOpponent = playing.map((player) => {
102
+ if (!cyclic)
103
+ return { player, thisTurn: null, basis: null };
104
+ let seen;
105
+ let conflict = false;
106
+ for (const f of facts) {
107
+ const r = relationsOf(f, me).get(player);
108
+ if (!r)
109
+ continue;
110
+ const now = at(r, f.turn, turn);
111
+ if (seen && seen.rel !== now)
112
+ conflict = true;
113
+ seen = { rel: now, basis: f.source, from: f.turn };
114
+ }
115
+ if (conflict)
116
+ return { player, thisTurn: null, basis: null, conflict: true };
117
+ return seen ? { player, thisTurn: seen.rel, basis: seen.basis, fromTurn: seen.from } : { player, thisTurn: null, basis: null };
118
+ });
119
+ const ahead = [];
120
+ const whole = cyclic ? [...facts].reverse().find((f) => f.full) : undefined;
121
+ for (let t = turn; t <= turn + (a.horizon ?? 5); t++) {
122
+ if (!cyclic) {
123
+ ahead.push(rowOf(t, 'unknown', new Map(), playing, null));
124
+ continue;
125
+ }
126
+ const rel = new Map();
127
+ for (const p of perOpponent)
128
+ if (p.thisTurn)
129
+ rel.set(p.player, at(p.thisTurn, turn, t));
130
+ let order = null;
131
+ if (whole && playing.every((p) => whole.full.includes(p) && rel.has(p))) {
132
+ const kept = whole.full.filter((p) => p === me || playing.includes(p));
133
+ order = odd(t - whole.turn) ? kept.reverse() : kept;
134
+ }
135
+ ahead.push(rowOf(t, rel.size ? 'projected' : 'unknown', rel, playing, order));
136
+ }
137
+ const now = perOpponent.map((p) => p.thisTurn);
138
+ const basisNow = perOpponent.some((p) => p.basis === 'orders') ? 'orders' : 'move-order';
139
+ const firstMover = playing.length && now.every((r) => r === 'after')
140
+ ? { who: 'me', turn, basis: basisNow }
141
+ : playing.length && now.every((r) => r === 'before')
142
+ ? { who: 'opponent', turn, basis: basisNow }
143
+ : null;
144
+ return { moveOrder: a.moveOrder ?? null, cyclic, turns: [...past, ...ahead], perOpponent, firstMover };
145
+ }