@chrischall/warapp-mcp 0.7.0 → 0.9.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 +5 -4
- 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 +86 -14
- package/dist/analysis/plan/completed.js +8 -1
- package/dist/analysis/plan/conceded-out.js +16 -11
- package/dist/analysis/plan/deploy-estimates.js +544 -0
- package/dist/analysis/plan/doomed-out.js +135 -0
- package/dist/analysis/plan/estimates.js +4 -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/spread-bind.js +49 -0
- 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 +219 -28
- package/dist/analysis/plan/threats.js +23 -9
- 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 +106 -43
- 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 +4578 -3405
- package/dist/cards.js +37 -0
- package/dist/my-games.js +2 -0
- package/dist/my-orders.js +134 -0
- package/dist/open-games.js +94 -10
- package/dist/team-cards.js +2 -2
- package/dist/team-orders.js +51 -23
- package/dist/tools/card-advice.js +57 -13
- 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/index.js +3 -0
- package/dist/tools/join-game.js +44 -8
- package/dist/tools/live.js +43 -5
- package/dist/tools/my-orders.js +110 -0
- package/dist/tools/open-games.js +2 -2
- package/dist/tools/picks.js +128 -51
- package/dist/tools/team-brief.js +1 -1
- package/dist/tools/team.js +25 -9
- package/dist/tools/turn.js +61 -6
- package/dist/tools/uncommit.js +27 -5
- package/dist/trend.js +36 -1
- package/dist/version.js +1 -1
- package/manifest.json +5 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +9 -2
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// larger of its estimate and my income (and enemy_deploy, a what-if floor; an untrusted opponent's at
|
|
5
5
|
// least at the figure its #275 tripwire gave it, as the stress test sizes it), both move orders, the
|
|
6
6
|
// free-for-all lead (#180), Order Priority and my Airlifts. No I/O: the callers load the boards.
|
|
7
|
+
import { gameBaseIncome } from '../analysis/player.js';
|
|
7
8
|
import { commanderSafety } from '../analysis/commander-safety.js';
|
|
8
9
|
/**
|
|
9
10
|
* Card plays that turn my territory over, which the commander check does not simulate (an Airlift it
|
|
@@ -34,7 +35,7 @@ export function commanderCheckOn(a) {
|
|
|
34
35
|
settings: a.settings,
|
|
35
36
|
...(so.teams.size ? { teams: so.teams } : {}),
|
|
36
37
|
orderPriority: a.orderPriority,
|
|
37
|
-
...(a.settings.localDeployments ? { localDeployments: true } : {}),
|
|
38
|
+
...(a.settings.localDeployments ? { localDeployments: true, baseIncome: gameBaseIncome(a.settings) } : {}),
|
|
38
39
|
...(a.settings.localDeployments && (a.settings.bonusArmyPer ?? 0) > 0 ? { perTerritoryIncome: true } : {}),
|
|
39
40
|
leader: so.leader,
|
|
40
41
|
killedBy: a.killedBy ?? false,
|
|
@@ -315,9 +315,9 @@ export function settingsKey(game) {
|
|
|
315
315
|
* seats, pace and boot time; GameFeed's Local Deployment, Commanders, kill rates, luck, fog and cards when it
|
|
316
316
|
* read the lobby) and the joining policy's checks by code. Name-free. Pure but for the clock.
|
|
317
317
|
*/
|
|
318
|
-
export function joinContextLog(listed, feed, screen, now = Date.now()) {
|
|
318
|
+
export function joinContextLog(listed, feed, screen, now = Date.now(), account) {
|
|
319
319
|
const s = feed?.settings;
|
|
320
|
-
const policy = policyChecks(listed, screen);
|
|
320
|
+
const policy = policyChecks(listed, screen, account);
|
|
321
321
|
const seats = listed.maxPlayers ?? listed.seats;
|
|
322
322
|
return {
|
|
323
323
|
at: new Date(now).toISOString(),
|
|
@@ -379,6 +379,8 @@ const PICK_WARNING_CODES = [
|
|
|
379
379
|
[/^In a 1v1 the best /, 'spread-relaxed'],
|
|
380
380
|
[/^Only \d+ pickable territor/, 'short-pickable'],
|
|
381
381
|
[/^The fallback group scores more than the primary/, 'fallback-outscores'],
|
|
382
|
+
// #429: a primary pick replaced by one that pays when a pick above it goes to the opponent.
|
|
383
|
+
[/^Primary pick \d+ is /, 'primary-answered'],
|
|
382
384
|
[/^Territory limit missing/, 'assumed-territory-limit'],
|
|
383
385
|
[/^Full distribution \(DistributionMode 0/, 'full-distribution'],
|
|
384
386
|
[/^Could not tell which seat is yours/, 'team-seat-unknown'],
|
package/dist/tools/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import { registerAcceptSurrenderTool } from './accept-surrender.js';
|
|
|
32
32
|
import { registerTeamTool } from './team.js';
|
|
33
33
|
import { registerTeamBriefTool } from './team-brief.js';
|
|
34
34
|
import { registerTurnTools } from './turn.js';
|
|
35
|
+
import { registerMyOrdersTool } from './my-orders.js';
|
|
35
36
|
import { registerUncommitTool } from './uncommit.js';
|
|
36
37
|
import { registerLeaveGameTool } from './leave-game.js';
|
|
37
38
|
import { registerWhereTool } from './where.js';
|
|
@@ -119,6 +120,8 @@ export function registerAllTools(server, deps = {}) {
|
|
|
119
120
|
// Opponent profiling, read-only: habits counted from the boards seen (on unless WARAPP_PLAYER_PROFILE=off).
|
|
120
121
|
registerProfileOpponentsTool(server, live, deps.env ? { env: deps.env } : {});
|
|
121
122
|
registerUncommitTool(server, live);
|
|
123
|
+
// Read-only: my own orders this turn read back from the live board, in warapp_submit_turn's shape.
|
|
124
|
+
registerMyOrdersTool(server, live);
|
|
122
125
|
registerChatTools(server, live, deps.env ? { env: deps.env } : {});
|
|
123
126
|
registerChatInboxTool(server, live);
|
|
124
127
|
// Local and hosted: war.app's own chat read mark, confirm-gated (#311).
|
package/dist/tools/join-game.js
CHANGED
|
@@ -17,6 +17,10 @@ import { captureJoin, joinContextLog } from './decision-capture.js';
|
|
|
17
17
|
import { mintMeta } from './hints.js';
|
|
18
18
|
import { requireApprovedAccount, writeAccount } from './live-context.js';
|
|
19
19
|
import { fetchMyGames } from './my-games.js';
|
|
20
|
+
import { attendedGames } from '../my-games.js';
|
|
21
|
+
import { mapRecordSummary } from '../lessons-store.js';
|
|
22
|
+
import { mapRecordFor } from './past-games.js';
|
|
23
|
+
import { mapOf } from './map.js';
|
|
20
24
|
import { markLotteries, openGamesPage } from './open-games.js';
|
|
21
25
|
import { holdsSeat, playerStateName } from '../player-states.js';
|
|
22
26
|
import { NO_TEAM } from '../teams.js';
|
|
@@ -136,11 +140,19 @@ function joinColor(requested, html, bundle, lobby, gameId) {
|
|
|
136
140
|
*/
|
|
137
141
|
async function lobbyScreen(ctx, gameId) {
|
|
138
142
|
try {
|
|
139
|
-
|
|
143
|
+
// #423: the map too, for the negative-bonus check (the join reads one lobby; the map store keeps it).
|
|
144
|
+
const game = await ctx.client.getGame(gameId, { settings: true, map: true });
|
|
140
145
|
const { screen, gaps } = feedScreen(game.settings ?? { cards: [], raw: {} });
|
|
146
|
+
let negativeBonus;
|
|
147
|
+
try {
|
|
148
|
+
negativeBonus = mapOf(game).bonuses.some((b) => b.value < 0);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
negativeBonus = undefined;
|
|
152
|
+
}
|
|
141
153
|
return screen
|
|
142
|
-
? { screen, gaps, game }
|
|
143
|
-
: { screen: null, gaps, game, note: "GameFeed's settings name no neutral size, so the neutral-cost screen was skipped." };
|
|
154
|
+
? { screen, gaps, game, ...(negativeBonus !== undefined ? { negativeBonus } : {}) }
|
|
155
|
+
: { screen: null, gaps, game, ...(negativeBonus !== undefined ? { negativeBonus } : {}), note: "GameFeed's settings name no neutral size, so the neutral-cost screen was skipped." };
|
|
144
156
|
}
|
|
145
157
|
catch (e) {
|
|
146
158
|
return {
|
|
@@ -184,7 +196,7 @@ export function registerJoinGameTool(server, ctx) {
|
|
|
184
196
|
'pass); the preview shows which, plus a screen from the lobby\'s GameFeed settings (does the cheapest ' +
|
|
185
197
|
'neutral cost at most one turn of base income; Light Fog) and `policy`: whether the lobby keeps the ' +
|
|
186
198
|
'joining policy (no Commerce, mods or custom scenarios; that cheap neutral; at most four seats; a boot time ' +
|
|
187
|
-
'of at least 12 hours; no lottery — `lottery`, read from the data as warapp_list_open_games does)
|
|
199
|
+
'of at least 12 hours; no lottery — `lottery`, read from the data as warapp_list_open_games does) (also no Local Deployment, Commanders, No-Split, army cap, Multi-Attack or non-default kill rates) — a lobby that breaks it is refused unless `override_policy: true` (#423). You become a player and are expected ' +
|
|
188
200
|
'to take turns — leaving later means declining or being booted.' +
|
|
189
201
|
`${noBrowserNote(ctx.hosted)} ${CONFIRM_INJECTION_RULE}`,
|
|
190
202
|
annotations: toolAnnotations({
|
|
@@ -205,6 +217,12 @@ export function registerJoinGameTool(server, ctx) {
|
|
|
205
217
|
.describe('In a team game: the team to join (a team number with an open seat; the preview lists the teams offered and ' +
|
|
206
218
|
'the seats on the chosen one). Implies allow_team. Refused outside a team game, with random teams, and for a ' +
|
|
207
219
|
'team that is full or not in the game.'),
|
|
220
|
+
override_policy: z
|
|
221
|
+
.boolean()
|
|
222
|
+
.optional()
|
|
223
|
+
.describe("Join a game that breaks the owner's joining policy (#423: Commerce, mods, custom scenarios, costly neutrals, " +
|
|
224
|
+
'more than four seats, a short boot time, lotteries, Local Deployment, Commanders, No-Split, an army cap, ' +
|
|
225
|
+
'Multi-Attack, non-default kill rates). Default false: such a join is refused, naming each break.'),
|
|
208
226
|
accept_entry_fee: z
|
|
209
227
|
.boolean()
|
|
210
228
|
.optional()
|
|
@@ -219,7 +237,7 @@ export function registerJoinGameTool(server, ctx) {
|
|
|
219
237
|
'higher ones need an unlock). Default: your preferred colour, else your secondary, else the first ' +
|
|
220
238
|
'standard colour no player in the game has.'),
|
|
221
239
|
}),
|
|
222
|
-
async plan({ game_id, allow_team, team: askedTeam, accept_entry_fee, color: requested }) {
|
|
240
|
+
async plan({ game_id, allow_team, team: askedTeam, accept_entry_fee, override_policy, color: requested }) {
|
|
223
241
|
const gameId = parseGameId(game_id);
|
|
224
242
|
// One fresh read gives the account the gate binds and its in-game id (sliced from the
|
|
225
243
|
// token TEXT, #130), so the already-joined check is for that same account. A join always
|
|
@@ -238,6 +256,20 @@ export function registerJoinGameTool(server, ctx) {
|
|
|
238
256
|
// #217: the lobby's screen, then whether it is a lottery (its map read only for that settings shape).
|
|
239
257
|
const screened = await lobbyScreen(ctx, gameId);
|
|
240
258
|
const [game] = (await markLotteries(ctx, [listed]));
|
|
259
|
+
// #423: the joining policy is a refusal, not advice: a break needs an explicit override.
|
|
260
|
+
let attended;
|
|
261
|
+
try {
|
|
262
|
+
attended = attendedGames((await fetchMyGames(ctx)).games, myId);
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
attended = undefined;
|
|
266
|
+
}
|
|
267
|
+
const account = { attendedGames: attended, negativeBonus: screened.negativeBonus };
|
|
268
|
+
const policy = joiningPolicy(game, screened.screen, account);
|
|
269
|
+
const record = await mapRecordFor(ctx.dataDir, undefined, game.mapId);
|
|
270
|
+
if (policy.passes === false && override_policy !== true) {
|
|
271
|
+
refuse(`Game ${gameId} breaks the joining policy, so it was not joined: ${policy.breaks.map(untrustedText).join('; ')}.`, 'Pass override_policy: true to join it anyway, or pick another game from warapp_list_open_games.');
|
|
272
|
+
}
|
|
241
273
|
return {
|
|
242
274
|
gate: {
|
|
243
275
|
action: 'warapp.join_game',
|
|
@@ -266,8 +298,12 @@ export function registerJoinGameTool(server, ctx) {
|
|
|
266
298
|
// #132: worth joining only when the cheapest neutral costs at most a turn of base income.
|
|
267
299
|
screen: screened.screen,
|
|
268
300
|
...(screened.note ? { screenNote: screened.note } : {}),
|
|
269
|
-
// #134: the owner's joining policy
|
|
270
|
-
policy
|
|
301
|
+
// #134/#423: the owner's joining policy; a break was refused above unless `override_policy` was given.
|
|
302
|
+
policy,
|
|
303
|
+
...(attended !== undefined ? { attendedGames: attended } : {}),
|
|
304
|
+
// #423: my finished games on this map, reported only (the join never reads it).
|
|
305
|
+
...(record && record !== 'unreadable' ? { mapRecord: (({ games, outcomes }) => ({ games, outcomes }))(mapRecordSummary(record)) } : {}),
|
|
306
|
+
...(policy.passes === false ? { policyOverridden: true } : {}),
|
|
271
307
|
color: { index: color, source },
|
|
272
308
|
// C4: in a team game, the team joined and who already sits on it.
|
|
273
309
|
...(game.teamGame ? { team: teamView(game, lobby, team) } : {}),
|
|
@@ -283,7 +319,7 @@ export function registerJoinGameTool(server, ctx) {
|
|
|
283
319
|
team,
|
|
284
320
|
color,
|
|
285
321
|
account: String(token),
|
|
286
|
-
join: joinContextLog(game, screened.game, screened.screen),
|
|
322
|
+
join: joinContextLog(game, screened.game, screened.screen, undefined, account),
|
|
287
323
|
},
|
|
288
324
|
};
|
|
289
325
|
},
|
package/dist/tools/live.js
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
import { CONFIRM_INJECTION_RULE, McpToolError, toolAnnotations } from '@chrischall/mcp-utils';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { clientPickLimits } from '../analysis/picks.js';
|
|
7
|
-
import { isTeamGame } from '../teams.js';
|
|
7
|
+
import { isTeamGame, teammatesOf } from '../teams.js';
|
|
8
|
+
import { teammateOrdersOf } from '../team-orders.js';
|
|
8
9
|
import { parseGameId } from '../client.js';
|
|
9
10
|
import { FOG_LEVEL_NAMES, inGameId, OWNER_NEUTRAL, OWNER_PICKABLE, playersByInGameId, } from '../live.js';
|
|
10
11
|
import { pickingNeutrals, writePickable, writePickList } from '../pick-list.js';
|
|
11
12
|
import { Method, writeSendTerritoryPicksParams } from '../protocol/methods.js';
|
|
12
13
|
import { currentTurn, gameIdArg, namer, readAnnotations, respond, shownAccount, turnsCompleted, UNTRUSTED_PREVIEW_NOTE, untrustedDescription, UNTRUSTED_LIST_MAX, untrustedList, untrustedText, viewArg, } from './common.js';
|
|
13
14
|
import { lookupMeta, mintMeta } from './hints.js';
|
|
14
|
-
import { loadLiveTerritories, loadPicks, requireApprovedAccount, writeAccount } from './live-context.js';
|
|
15
|
+
import { loadLiveGame, loadLiveTerritories, loadPicks, requireApprovedAccount, writeAccount } from './live-context.js';
|
|
16
|
+
import { notTeammateWarning, readTeammatePicks } from './team.js';
|
|
15
17
|
import { mapOf } from './map.js';
|
|
16
18
|
import { resolvePlayer, resolveTerritory } from './resolve.js';
|
|
17
19
|
import { defineGatedWrite, requireMySeat, sendAndVerify } from './write-kit.js';
|
|
@@ -253,6 +255,12 @@ export function registerLiveTools(server, ctx) {
|
|
|
253
255
|
.min(1)
|
|
254
256
|
.max(MAX_PICK_ARGS)
|
|
255
257
|
.describe('Your picks in priority order (first = most wanted): territory ids or names. Replaces any picks already submitted.'),
|
|
258
|
+
without_teammate_list: z
|
|
259
|
+
.boolean()
|
|
260
|
+
.optional()
|
|
261
|
+
.describe("Team games only (#435): submit even though a teammate's list could not be read (unknown, not empty). " +
|
|
262
|
+
'Default false: the submit is refused until it can be read, since a pick you both list goes to one of you. ' +
|
|
263
|
+
'Set it only when waiting is worse, e.g. the pick deadline is close.'),
|
|
256
264
|
});
|
|
257
265
|
defineGatedWrite(server, {
|
|
258
266
|
title: 'Submit territory picks in a war.app game',
|
|
@@ -262,7 +270,8 @@ export function registerLiveTools(server, ctx) {
|
|
|
262
270
|
description: 'Submit your territory picks for a war.app (Warzone) game in manual distribution, in priority order — ' +
|
|
263
271
|
'they replace any picks you submitted before. Every territory must be pickable on the live board; a list ' +
|
|
264
272
|
"longer than war.app's client allows (players × territories per player) or shorter than the territories " +
|
|
265
|
-
'each player is granted is warned about in the preview.
|
|
273
|
+
'each player is granted is warned about in the preview. In a team game it is refused while a teammate\'s pick ' +
|
|
274
|
+
'list cannot be read (unknown, not empty) unless `without_teammate_list: true` is passed (#435). After sending, the picks are read back and ' +
|
|
266
275
|
`reported verified only if they match exactly. ${BRIDGE_NOTE} ${CONFIRM_INJECTION_RULE}`,
|
|
267
276
|
annotations: toolAnnotations({
|
|
268
277
|
title: 'Submit war.app picks',
|
|
@@ -272,7 +281,7 @@ export function registerLiveTools(server, ctx) {
|
|
|
272
281
|
openWorld: true,
|
|
273
282
|
}),
|
|
274
283
|
inputSchema: submitSchema,
|
|
275
|
-
async plan({ game_id, player, territories }) {
|
|
284
|
+
async plan({ game_id, player, territories, without_teammate_list }) {
|
|
276
285
|
const feed = await ctx.client.getGame(parseGameId(game_id), { settings: true });
|
|
277
286
|
const map = mapOf(feed);
|
|
278
287
|
// A write through the bridge always acts as the signed-in account, whatever `player` says
|
|
@@ -288,7 +297,7 @@ export function registerLiveTools(server, ctx) {
|
|
|
288
297
|
}
|
|
289
298
|
seen.add(t.id);
|
|
290
299
|
}
|
|
291
|
-
const board = await
|
|
300
|
+
const { territories: board, info } = await loadLiveGame(ctx, game);
|
|
292
301
|
const owner = new Map(board.map((t) => [t.territoryId, t]));
|
|
293
302
|
const unpickable = picks.filter((t) => {
|
|
294
303
|
const s = owner.get(t.id);
|
|
@@ -326,6 +335,35 @@ export function registerLiveTools(server, ctx) {
|
|
|
326
335
|
"A shorter list is safe only when no teammate lists any of its picks (warapp_plan_picks shortens it only then).");
|
|
327
336
|
if (bounds && picks.length < bounds.min)
|
|
328
337
|
lengthWarnings.push(`war.app expects at least ${bounds.min} picks here (the territories each player is granted); got ${picks.length}, which it may reject.`);
|
|
338
|
+
// #435 (bug): a team game's picks went in while a teammate's list was unread (null), so an
|
|
339
|
+
// overlap could not be seen (45731288: my second pick went to my teammate). Each teammate still
|
|
340
|
+
// playing has its list read as warapp_plan_picks reads it (V5 teammate orders, else V6
|
|
341
|
+
// GetTerritoryPicks); an unread one refuses the submit unless the caller says to go without it.
|
|
342
|
+
// An empty list read is no refusal: the teammate has not picked yet, and picks around mine.
|
|
343
|
+
// V6 (verified live 2026-11-22): a refusal that never lifts (187: war.app calls the player an opponent;
|
|
344
|
+
// 188: automatic distribution) is no unread list — it would hold every submit for good — so it does not
|
|
345
|
+
// refuse; 187 is named in the preview, as the team read may be wrong.
|
|
346
|
+
const unread = [];
|
|
347
|
+
const notMates = [];
|
|
348
|
+
if (isTeamGame(game.players)) {
|
|
349
|
+
const entries = teammateOrdersOf(info, game.players);
|
|
350
|
+
for (const mate of teammatesOf(game.players, me).filter((p) => (p.state ?? 'Playing') === 'Playing')) {
|
|
351
|
+
const read = await readTeammatePicks(ctx, game.id, mate, entries?.find((e) => e.playerId === mate.id));
|
|
352
|
+
if (read === null)
|
|
353
|
+
unread.push(mate.id);
|
|
354
|
+
else if (read.refused === 'not-teammate')
|
|
355
|
+
notMates.push(mate.id);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (notMates.length)
|
|
359
|
+
lengthWarnings.push(notTeammateWarning(notMates));
|
|
360
|
+
if (unread.length && without_teammate_list !== true)
|
|
361
|
+
throw new McpToolError(`Your teammate's list (player ${unread.join(', ')}) could not be read, so an overlap with yours cannot be seen: a pick you both list goes to one of you.`, {
|
|
362
|
+
hint: "Nothing was sent. Wait until it can be read (warapp_get_team, warapp_plan_picks show it), agree a list in team chat, " +
|
|
363
|
+
'or pass without_teammate_list: true to submit anyway when the pick deadline is close.',
|
|
364
|
+
});
|
|
365
|
+
if (unread.length)
|
|
366
|
+
lengthWarnings.push(`Your teammate's list (player ${unread.join(', ')}) was not read: submitted without it (without_teammate_list), so an overlap cannot be seen.`);
|
|
329
367
|
const playerId = inGameId(me);
|
|
330
368
|
const territoryIds = picks.map((t) => t.id);
|
|
331
369
|
const named = picks.map((t) => ({ id: t.id, name: t.name }));
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// warapp_get_my_orders: my own orders this turn, read back from the live board — the orders the web client shows
|
|
2
|
+
// again in "Modify orders" — in the shape warapp_submit_turn takes, so a withdrawn turn (warapp_uncommit_turn) can
|
|
3
|
+
// be resubmitted exactly as it was, by hand-made orders too. Read-only. Where they live and what is verified:
|
|
4
|
+
// src/my-orders.ts (LatestGameInfo's first field, VERIFIED live 2026-11-22 for committed turns).
|
|
5
|
+
import { McpToolError } from '@chrischall/mcp-utils';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { parseGameId } from '../client.js';
|
|
8
|
+
import { myOrdersOf } from '../my-orders.js';
|
|
9
|
+
import { bonusNamer, gameIdArg, namer, readAnnotations, respond, untrustedDescription, untrustedText } from './common.js';
|
|
10
|
+
import { lookupMeta } from './hints.js';
|
|
11
|
+
import { readLatestBoard } from './live-context.js';
|
|
12
|
+
import { BRIDGE_NOTE } from './live.js';
|
|
13
|
+
import { mapOf } from './map.js';
|
|
14
|
+
import { currentTurn, requireTurnPhase } from './turn.js';
|
|
15
|
+
import { accountUnknown } from './write-kit.js';
|
|
16
|
+
/** My orders this turn from the live board; never throws (a failed read is `failure`, the orders unknown). */
|
|
17
|
+
export async function readMyOrders(ctx, game) {
|
|
18
|
+
try {
|
|
19
|
+
const { info } = await readLatestBoard(ctx, game.id);
|
|
20
|
+
return { read: myOrdersOf(info, game.players) };
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
return { read: null, failure: e instanceof Error ? e.message : String(e) };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** One line per order, for a person: territories, bonuses and players named (names are untrusted). */
|
|
27
|
+
export function shownOrders(orders, game) {
|
|
28
|
+
const map = game.map ? mapOf(game) : undefined;
|
|
29
|
+
const t = (id) => (map ? `${untrustedText(namer(map)(id).name)} (${id})` : `territory ${id}`);
|
|
30
|
+
const b = (id) => (map ? `${untrustedText(bonusNamer(map)(id).name)} (${id})` : `bonus ${id}`);
|
|
31
|
+
const p = (id) => {
|
|
32
|
+
if (id === 0)
|
|
33
|
+
return 'neutral';
|
|
34
|
+
const seat = game.players.find((x) => x.id === id);
|
|
35
|
+
return seat ? `${untrustedText(seat.name)} (${id})` : `player ${id}`;
|
|
36
|
+
};
|
|
37
|
+
return orders.map((o) => {
|
|
38
|
+
if (o.kind === 'deploy')
|
|
39
|
+
return `Deploy ${o.armies} on ${t(o.territory)}`;
|
|
40
|
+
if (o.kind === 'discard')
|
|
41
|
+
return `Discard card ${o.card}`;
|
|
42
|
+
if (o.kind === 'move') {
|
|
43
|
+
const opts = [o.mode, o.percent ? 'percent' : undefined, o.commander ? 'with commander' : undefined, o.attack_teammates ? 'attack teammates' : undefined]
|
|
44
|
+
.filter((x) => x !== undefined);
|
|
45
|
+
return `Move ${o.armies}${o.percent ? '%' : ''} ${t(o.from)} → ${t(o.to)}${opts.length ? ` (${opts.join(', ')})` : ''}`;
|
|
46
|
+
}
|
|
47
|
+
const parts = [
|
|
48
|
+
o.target !== undefined ? `on ${t(o.target)}` : undefined,
|
|
49
|
+
o.player !== undefined ? `player ${p(o.player)}` : undefined,
|
|
50
|
+
o.players ? `between ${p(o.players[0])} and ${p(o.players[1])}` : undefined,
|
|
51
|
+
o.bonus !== undefined ? `on ${b(o.bonus)}` : undefined,
|
|
52
|
+
o.from !== undefined && o.to !== undefined ? `${o.armies ?? 0} ${t(o.from)} → ${t(o.to)}${o.commander ? ' with commander' : ''}` : undefined,
|
|
53
|
+
o.before !== undefined ? `above move ${o.before}` : undefined,
|
|
54
|
+
].filter((x) => x !== undefined);
|
|
55
|
+
return `Play ${o.cardType} card${parts.length ? ` ${parts.join(', ')}` : ''}`;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const COMMITTED_NOTE = "Read from the live board: war.app's own copy of your committed orders (what the web client shows in \"Modify " +
|
|
59
|
+
'orders"), verified live. Pass `orders` to warapp_submit_turn unchanged to resubmit them (after warapp_uncommit_turn), ' +
|
|
60
|
+
'or edit them first. `cardType` and `shown` are for display only.';
|
|
61
|
+
const ENTERED_NOTE = 'Your orders are not committed: these are the orders war.app holds as entered for you, which is UNVERIFIED live ' +
|
|
62
|
+
'(only committed orders have been checked). Pass `orders` to warapp_submit_turn to commit them.';
|
|
63
|
+
const UNKNOWN_NOTE = 'war.app sent no list of your orders for this turn, so they are unknown (null), never "none": nothing entered, ' +
|
|
64
|
+
'or not sent. Check the web client before submitting replacements.';
|
|
65
|
+
export function registerMyOrdersTool(server, ctx) {
|
|
66
|
+
server.registerTool('warapp_get_my_orders', {
|
|
67
|
+
title: 'Read back my orders for this war.app turn',
|
|
68
|
+
description: untrustedDescription('Your own orders for the current turn of a war.app (Warzone) game, read back from war.app — the orders the ' +
|
|
69
|
+
'web client shows again in "Modify orders": whether they are committed, and the deploys, moves (with ' +
|
|
70
|
+
'their options), card plays (card GUID and targets: territory, player, bonus, Airlift from/to/armies, ' +
|
|
71
|
+
'Order Delay `before`) and discards in exactly the shape warapp_submit_turn takes (ids; players by GameFeed ' +
|
|
72
|
+
'id), plus `shown`, one readable line per order with names. Use it before warapp_uncommit_turn, or after, to ' +
|
|
73
|
+
'resubmit a committed turn unchanged or with one order added — hand-made orders included. `orders` is null ' +
|
|
74
|
+
'when war.app sent none or the board could not be read: unknown, never "none". Committed orders are verified ' +
|
|
75
|
+
`live; entered but uncommitted ones are not. Refuses outside a turn phase. ${BRIDGE_NOTE} Read-only.`),
|
|
76
|
+
_meta: lookupMeta(['my orders', 'my committed orders', 'read back my orders', 'resubmit my turn', 'modify orders', 'what did i order']),
|
|
77
|
+
annotations: readAnnotations('Read back my war.app orders'),
|
|
78
|
+
inputSchema: z.object({ game_id: gameIdArg }),
|
|
79
|
+
}, async ({ game_id }) => {
|
|
80
|
+
const gameId = parseGameId(game_id);
|
|
81
|
+
const game = await ctx.client.getGame(gameId);
|
|
82
|
+
requireTurnPhase(game);
|
|
83
|
+
const token = await ctx.myInviteToken().catch(() => undefined);
|
|
84
|
+
if (token === undefined)
|
|
85
|
+
throw accountUnknown(ctx, 'your orders cannot be read');
|
|
86
|
+
const seat = game.players.find((p) => p.id === token);
|
|
87
|
+
if (!seat) {
|
|
88
|
+
throw new McpToolError(`The signed-in war.app account is not a player in game ${game.id}.`, {
|
|
89
|
+
hint: 'Check the game id with warapp_my_games.',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const { read, failure } = await readMyOrders(ctx, game);
|
|
93
|
+
const warnings = failure ? [`The live board could not be read (${failure}): your orders are unknown.`] : [];
|
|
94
|
+
return respond(undefined, ['compact'], () => ({
|
|
95
|
+
game: { id: game.id, name: game.name === undefined ? null : untrustedText(game.name), turn: currentTurn(game) },
|
|
96
|
+
committed: seat.hasCommittedOrders,
|
|
97
|
+
orders: read?.orders ?? null,
|
|
98
|
+
shown: read ? shownOrders(read.orders, game) : null,
|
|
99
|
+
...(read?.unread.length ? { unread: read.unread } : {}),
|
|
100
|
+
note: !read ? UNKNOWN_NOTE : seat.hasCommittedOrders ? COMMITTED_NOTE : ENTERED_NOTE,
|
|
101
|
+
...(read?.unread.length
|
|
102
|
+
? {
|
|
103
|
+
unreadNote: 'Orders war.app holds that this server could not read back: they are not in `orders`, so resubmitting ' +
|
|
104
|
+
'`orders` would drop them. Check the web client.',
|
|
105
|
+
}
|
|
106
|
+
: {}),
|
|
107
|
+
...(warnings.length ? { warnings } : {}),
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
}
|
package/dist/tools/open-games.js
CHANGED
|
@@ -93,8 +93,8 @@ export function registerOpenGamesTool(server, ctx) {
|
|
|
93
93
|
});
|
|
94
94
|
// #134: advisory — the neutral-cost part needs each lobby's GameFeed settings, so only the join preview has it.
|
|
95
95
|
const games = (await markLotteries(ctx, filtered)).map((g) => {
|
|
96
|
-
const { breaks } = joiningPolicy(g, null);
|
|
97
|
-
return breaks.length ? {
|
|
96
|
+
const { breaks, warnings } = joiningPolicy(g, null);
|
|
97
|
+
return { ...g, ...(breaks.length ? { policyBreaks: breaks } : {}), ...(warnings ? { policyWarnings: warnings } : {}) };
|
|
98
98
|
});
|
|
99
99
|
return respond(undefined, ['compact'], () => ({
|
|
100
100
|
games,
|