@chrischall/warapp-mcp 0.5.0 → 0.7.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 +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +133 -8
- package/dist/analysis/accept-surrender.js +20 -2
- package/dist/analysis/calibrate.js +1 -0
- package/dist/analysis/card-support.js +177 -17
- package/dist/analysis/card-threats.js +126 -14
- package/dist/analysis/chat-advice.js +182 -0
- package/dist/analysis/chat-blocks.js +106 -0
- package/dist/analysis/chat-intent.js +559 -0
- package/dist/analysis/chat-read.js +159 -0
- package/dist/analysis/decision-replay.js +279 -0
- package/dist/analysis/decision-truth.js +146 -0
- package/dist/analysis/finished-game.js +62 -3
- package/dist/analysis/game-lessons.js +15 -10
- package/dist/analysis/hold-diff.js +3 -1
- package/dist/analysis/income-trend.js +38 -0
- package/dist/analysis/intel.js +75 -0
- package/dist/analysis/opens.js +64 -0
- package/dist/analysis/opponent-profile.js +121 -10
- package/dist/analysis/opponents.js +246 -20
- package/dist/analysis/outlook.js +360 -15
- package/dist/analysis/picks.js +91 -12
- package/dist/analysis/plan/after-leftover.js +4 -1
- package/dist/analysis/plan/bonus-attempts.js +105 -0
- package/dist/analysis/plan/capture-instead.js +116 -0
- package/dist/analysis/plan/captures.js +49 -7
- package/dist/analysis/plan/conceded-out.js +13 -2
- package/dist/analysis/plan/estimates.js +203 -30
- package/dist/analysis/plan/guard-off.js +2 -1
- package/dist/analysis/plan/holds.js +110 -9
- package/dist/analysis/plan/jabs.js +113 -0
- package/dist/analysis/plan/leftover.js +393 -8
- package/dist/analysis/plan/orders.js +76 -4
- package/dist/analysis/plan/relations.js +135 -2
- package/dist/analysis/plan/report.js +69 -3
- package/dist/analysis/plan/second-sizing.js +133 -0
- package/dist/analysis/plan/shared.js +279 -27
- package/dist/analysis/plan/siege.js +303 -0
- package/dist/analysis/plan/stand-still.js +9 -5
- package/dist/analysis/plan/state.js +8 -0
- package/dist/analysis/plan/stockpile.js +104 -0
- package/dist/analysis/plan/strike.js +39 -7
- package/dist/analysis/plan/targets.js +256 -110
- package/dist/analysis/plan/threats.js +148 -10
- package/dist/analysis/plan/transfers.js +57 -6
- package/dist/analysis/plan/two-move.js +70 -0
- package/dist/analysis/plan/vacated.js +124 -2
- package/dist/analysis/planner.js +527 -49
- package/dist/analysis/profile.js +13 -2
- package/dist/analysis/since-last.js +18 -5
- package/dist/analysis/stress.js +8 -2
- package/dist/board.js +36 -2
- package/dist/bonus-attempt-store.js +55 -0
- package/dist/build-id.js +106 -0
- package/dist/bundle.js +54138 -41059
- package/dist/cards.js +7 -5
- package/dist/chat-automation.js +22 -0
- package/dist/chat.js +35 -1
- package/dist/client.js +14 -0
- package/dist/commerce.js +111 -0
- package/dist/decision-log.js +1093 -0
- package/dist/finished-store.js +5 -1
- package/dist/index.js +9 -1
- package/dist/lessons-store.js +322 -21
- package/dist/live.js +43 -0
- package/dist/move-order.js +64 -3
- package/dist/normalize.js +17 -0
- package/dist/open-games.js +36 -16
- package/dist/outlook-log.js +42 -1
- package/dist/profile-store.js +12 -2
- package/dist/protocol/methods.js +62 -5
- package/dist/protocol/rpc.js +8 -0
- package/dist/relations-store.js +38 -4
- package/dist/review-export.js +198 -0
- package/dist/siege-store.js +49 -0
- package/dist/state-bundle.js +584 -0
- package/dist/state-cli.js +71 -0
- package/dist/strategy/notes.js +56 -0
- package/dist/team-cards.js +25 -0
- package/dist/tools/accept-surrender.js +23 -9
- package/dist/tools/award.js +20 -2
- package/dist/tools/card-advice.js +93 -28
- package/dist/tools/card-plays.js +2 -2
- package/dist/tools/card-support-advice.js +37 -7
- package/dist/tools/chat-advice.js +330 -0
- package/dist/tools/chat-inbox.js +19 -4
- package/dist/tools/chat.js +106 -17
- package/dist/tools/check-plan.js +68 -12
- package/dist/tools/commerce-deploy.js +33 -0
- package/dist/tools/common.js +31 -0
- package/dist/tools/decision-capture.js +459 -0
- package/dist/tools/end-of-game.js +151 -21
- package/dist/tools/game-kind.js +92 -0
- package/dist/tools/how-lost.js +7 -2
- package/dist/tools/index.js +10 -0
- package/dist/tools/join-game.js +10 -4
- package/dist/tools/live-context.js +6 -0
- package/dist/tools/live.js +10 -1
- package/dist/tools/map-curves.js +73 -0
- package/dist/tools/notifications.js +4 -3
- package/dist/tools/opponents.js +2 -0
- package/dist/tools/past-games.js +74 -8
- package/dist/tools/picks.js +61 -10
- package/dist/tools/profile-hook.js +62 -3
- package/dist/tools/profile-opponents.js +4 -0
- package/dist/tools/push.js +2 -2
- package/dist/tools/relations.js +139 -0
- package/dist/tools/scout.js +16 -2
- package/dist/tools/state.js +232 -0
- package/dist/tools/strategy.js +3 -3
- package/dist/tools/stress-opponents.js +7 -2
- package/dist/tools/surrender-pending.js +10 -1
- package/dist/tools/surrender.js +18 -3
- package/dist/tools/survival.js +11 -3
- package/dist/tools/team-brief.js +2 -2
- package/dist/tools/team.js +12 -3
- package/dist/tools/turn.js +643 -76
- package/dist/tools/where.js +3 -1
- package/dist/version.js +1 -1
- package/manifest.json +32 -3
- package/mint.yaml +37 -4
- package/package.json +4 -4
- package/server.json +20 -2
- package/skills/warapp-mcp/SKILL.md +73 -17
package/dist/tools/check-plan.js
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
// warapp_submit_turn takes) is carried out on the live board against the single replies each
|
|
3
3
|
// opponent could make with its estimated deploy, and the replies that cost something are
|
|
4
4
|
// reported, worst first (src/analysis/stress.ts, on the turn resolver src/analysis/turn-sim.ts).
|
|
5
|
-
// Read-only on war.app, and it writes nothing: not the board cache
|
|
5
|
+
// Read-only on war.app, and it writes nothing but its verdict to the decision log (#437): not the board cache.
|
|
6
6
|
import { McpToolError } from '@chrischall/mcp-utils';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { stressPlan } from '../analysis/stress.js';
|
|
9
9
|
import { neutralizeSeats, seatTerritories, staticSeats } from '../analysis/static-seats.js';
|
|
10
|
+
import { profileFormatOf } from '../analysis/opponent-profile.js';
|
|
10
11
|
import { handOwners } from './card-advice.js';
|
|
12
|
+
import { fogPaceFor, mapMatchOf } from './past-games.js';
|
|
11
13
|
import { sanctionMyIncome } from './card-effects.js';
|
|
12
14
|
import { cardTypeByName, cardTypeName, normalizeGuid, readHand } from '../cards.js';
|
|
13
15
|
import { claimedCardUses, claimedCardWarning, teamCardClaims, teamHandLeft, unclaimedFirst } from '../team-cards.js';
|
|
14
16
|
import { boardStateFromLive } from '../live.js';
|
|
15
17
|
import { withTeammateOrders } from '../team-orders.js';
|
|
16
18
|
import { assumedWarning, awardView, loadAward, openingThreat } from './award.js';
|
|
17
|
-
import {
|
|
19
|
+
import { readLedger } from '../relations-store.js';
|
|
20
|
+
import { resolveIntel } from '../analysis/intel.js';
|
|
21
|
+
import { avoidPlayersArg, avoidTerritoriesArg, gameIdArg, graphOf, knownIncomeArg, namer, readAnnotations, respond, untrustedDescription, untrustedText, viewArg } from './common.js';
|
|
18
22
|
import { lookupMeta } from './hints.js';
|
|
19
23
|
import { HEADROOM_COMPACT, headroomView, readTripwires, safeHeadroom, teamsOf, tripwireWarnings, untrustedDeploy } from './survival.js';
|
|
20
24
|
import { loadLiveGame, standInLine, standInOf } from './live-context.js';
|
|
@@ -25,6 +29,7 @@ import { BELOW_PLAN_BASIS, boardHistory, bordersBelowPlan, currentTurn, truceRel
|
|
|
25
29
|
import { resolveTeamsFor } from './team-source.js';
|
|
26
30
|
import { stressOpponents } from './stress-opponents.js';
|
|
27
31
|
import { COMMANDER_SIZING, commanderCheckOn } from './commander-check.js';
|
|
32
|
+
import { captureCheck, checkPlanLog } from './decision-capture.js';
|
|
28
33
|
const VIEWS = ['compact', 'full'];
|
|
29
34
|
const MAX_ENEMY_DEPLOY = 10_000;
|
|
30
35
|
/** Replies listed beside the worst one on the compact view; the full view lists the stress test's own maximum. */
|
|
@@ -125,6 +130,9 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
125
130
|
'income when larger; in a 1v1 that started even, an opponent bordering the fog at least your own income; while an ' +
|
|
126
131
|
'observation has made its estimate untrusted, the larger of what it implied and your own income). ' +
|
|
127
132
|
'Income in the fog is unseen, so raise it to test a stronger opponent.'),
|
|
133
|
+
known_income: knownIncomeArg,
|
|
134
|
+
avoid_territories: avoidTerritoriesArg,
|
|
135
|
+
avoid_players: avoidPlayersArg,
|
|
128
136
|
first_mover: z
|
|
129
137
|
.enum(['me', 'opponent'])
|
|
130
138
|
.optional()
|
|
@@ -133,7 +141,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
133
141
|
view: viewArg(VIEWS, `compact (default) gives the verdict, the worst reply and up to ${COMPACT_OTHERS} more; "full" adds every ` +
|
|
134
142
|
'reply listed, each order\'s result unanswered and the rules assumed.'),
|
|
135
143
|
}),
|
|
136
|
-
}, async ({ game_id, player, orders, enemy_deploy, first_mover, view }) => {
|
|
144
|
+
}, async ({ game_id, player, orders, enemy_deploy, known_income, avoid_territories, avoid_players, first_mover, view }) => {
|
|
137
145
|
const feed = await ctx.client.getGame(game_id, { settings: true });
|
|
138
146
|
requireTurnPhase(feed);
|
|
139
147
|
const map = mapOf(feed);
|
|
@@ -142,18 +150,26 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
142
150
|
// The teams: GameFeed's, else the game list's (asked once per game, kept).
|
|
143
151
|
const { game, me, source: teamSource, known: teamsKnown } = await resolveTeamsFor(ctx, feed, seat);
|
|
144
152
|
const turn = currentTurn(game);
|
|
153
|
+
// #386: the avoid targets and stated incomes warapp_record_intel kept, as warapp_plan_turn applies them.
|
|
154
|
+
const intel = resolveIntel(ctx.dataDir ? (await readLedger(ctx.dataDir, game.id, me.id))?.intel : undefined, turn, {
|
|
155
|
+
...(known_income !== undefined ? { knownIncome: known_income } : {}),
|
|
156
|
+
...(avoid_territories !== undefined ? { avoidTerritories: avoid_territories } : {}),
|
|
157
|
+
...(avoid_players !== undefined ? { avoidPlayers: avoid_players } : {}),
|
|
158
|
+
});
|
|
145
159
|
const [{ territories, info }, history] = await Promise.all([loadLiveGame(ctx, game), boardHistory(ctx, game, me, turn)]);
|
|
146
160
|
const graph = graphOf(map);
|
|
147
161
|
// As warapp_plan_turn does (#166): the opponent's starts the award of picks proves stand on
|
|
148
162
|
// the board the orders are tried on; the history and tracks stay what war.app showed.
|
|
149
163
|
const seen = withTeammateOrders(boardStateFromLive(territories, me, game.players), info, me, game.players);
|
|
150
|
-
const award = await loadAward(ctx.dataDir, game, me, seen, turn);
|
|
164
|
+
const award = await loadAward(ctx.dataDir, game, me, seen, turn, { decisionLog: ctx.decisionLog });
|
|
151
165
|
// #270: a player out of the game whose seat no AI plays deploys and attacks nothing: its
|
|
152
166
|
// territories are neutrals here (static armies), and it is tried as no opponent.
|
|
153
167
|
const seats = staticSeats(game.players, game.endRules, me.id);
|
|
154
168
|
const board = neutralizeSeats(award?.board ?? seen, seats);
|
|
155
169
|
const opening = openingThreat(award, game, graph, seen, turn);
|
|
156
170
|
const settings = plannerSettings(game.settings);
|
|
171
|
+
// #419: the past winners' pace, as warapp_plan_turn reads it (thin evidence's upper bound).
|
|
172
|
+
const mapPace = await fogPaceFor(ctx.dataDir, undefined, game.settings?.mapId ?? map.id, mapMatchOf(profileFormatOf(game.players), game.settings), turn === null ? null : turn - 1);
|
|
157
173
|
const deploys = [];
|
|
158
174
|
const moves = [];
|
|
159
175
|
/** Options the game would refuse (#165): the orders are still tried, and the warning says so. */
|
|
@@ -271,7 +287,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
271
287
|
hand,
|
|
272
288
|
info,
|
|
273
289
|
...(opening ? { opening } : {}),
|
|
290
|
+
...(mapPace ? { mapPace } : {}),
|
|
274
291
|
...(enemy_deploy !== undefined ? { enemyDeploy: enemy_deploy } : {}),
|
|
292
|
+
// #444: the stated incomes scale the other opponents' prior, as warapp_plan_turn has them.
|
|
293
|
+
...(intel.knownIncome?.length ? { known: intel.knownIncome } : {}),
|
|
275
294
|
});
|
|
276
295
|
const { tracks, income, effect, friend, teams, inView, leader, estimates } = so;
|
|
277
296
|
// #275 (b): an opponent whose estimate an observation broke is tried at the larger of what tripped it
|
|
@@ -294,7 +313,14 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
294
313
|
staticSeats: staticSeats(game.players, game.endRules, me.id),
|
|
295
314
|
});
|
|
296
315
|
const untrustedOf = new Map(trip.tripwires.map((w) => [w.player, untrustedDeploy(w, income)]));
|
|
316
|
+
// #368: an income the caller knows replaces the estimate (a Reinforcement card the clock adds on top),
|
|
317
|
+
// before an untrusted mark; enemy_deploy, a what-if for everyone, wins over both. The commander check
|
|
318
|
+
// below keeps the submit's sizing, so it never calls safe what warapp_submit_turn refuses.
|
|
319
|
+
const knownOf = new Map((enemy_deploy === undefined ? (intel.knownIncome ?? []) : []).map((k) => [k.player, k.income]));
|
|
297
320
|
const opponents = so.opponents.map((o) => {
|
|
321
|
+
const known = knownOf.get(o.id);
|
|
322
|
+
if (known !== undefined)
|
|
323
|
+
return { ...o, deploy: known + (o.card ?? 0) };
|
|
298
324
|
const untrusted = untrustedOf.get(o.id);
|
|
299
325
|
return enemy_deploy !== undefined || untrusted === undefined ? o : { ...o, deploy: Math.max(untrusted, o.deploy) };
|
|
300
326
|
});
|
|
@@ -313,7 +339,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
313
339
|
? r.enforcedUntil === undefined || turn === null || turn < r.enforcedUntil
|
|
314
340
|
: teams.size === 0 && (r.state === 'active' || r.state === 'notice') && (r.endsTurn === undefined || turn === null || turn < r.endsTurn)));
|
|
315
341
|
// D3: the deploy total is checked against my income under the Sanctions on me.
|
|
316
|
-
|
|
342
|
+
// #332: a commerce game's gold, read from the standing, already carries any Sanctions (war.app pays it).
|
|
343
|
+
const sanction = so.commerce?.source === 'standing'
|
|
344
|
+
? { income, warnings: [], applied: false }
|
|
345
|
+
: sanctionMyIncome(income, effect, { localDeployments: settings.localDeployments === true });
|
|
317
346
|
const report = stressPlan({
|
|
318
347
|
graph,
|
|
319
348
|
board,
|
|
@@ -351,6 +380,10 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
351
380
|
cardTargets,
|
|
352
381
|
});
|
|
353
382
|
const guard = checked?.safety;
|
|
383
|
+
// #437: the decision log keeps this check's verdict for the turn (the latest run wins). Writes only the
|
|
384
|
+
// log, never the board cache. A what-if (enemy_deploy or known_income given) is marked so.
|
|
385
|
+
if (turn !== null)
|
|
386
|
+
await captureCheck(ctx, game.id, me.id, turn, checkPlanLog(report, { whatIf: enemy_deploy !== undefined || known_income !== undefined }));
|
|
354
387
|
const name = namer(map);
|
|
355
388
|
const playerName = new Map(game.players.map((p) => [p.id, p.name]));
|
|
356
389
|
const who = (id) => ({ id, name: playerName.get(id) ?? String(id) });
|
|
@@ -481,6 +514,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
481
514
|
opponent: who(e.opponent),
|
|
482
515
|
bonusesLost: e.bonusesLost.map((b) => bonusOf(b.id)),
|
|
483
516
|
incomeLost: e.incomeLost,
|
|
517
|
+
...(e.breaksTruce ? { breaksTruce: true } : {}),
|
|
484
518
|
});
|
|
485
519
|
const orderView = (e) => ({
|
|
486
520
|
order: e.index + 1,
|
|
@@ -498,9 +532,15 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
498
532
|
? ` ${report.blindBorders.length} of your territories border the fog and were not tested.`
|
|
499
533
|
: '';
|
|
500
534
|
const inexact = report.exact ? '' : ' Battles are not exact in this game (luck or weighted rounding): each was resolved at its expectation.';
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
535
|
+
// #376: an exposure only a truce break reaches is counted apart, after the real ones.
|
|
536
|
+
const reachable = report.exposedNextTurn.filter((x) => !x.breaksTruce);
|
|
537
|
+
const ifBroken = report.exposedNextTurn.length - reachable.length;
|
|
538
|
+
const brokenLine = ifBroken ? ` ${ifBroken} more only if a truce breaks.` : '';
|
|
539
|
+
const ahead = reachable.length
|
|
540
|
+
? ` Next turn: ${reachable.length} ${plural(reachable.length, 'territory is', 'territories are')} within reach of a stack two steps away if you add nothing (see exposedNextTurn). First: ${exposure(reachable[0])}${brokenLine}`
|
|
541
|
+
: ifBroken
|
|
542
|
+
? ` Next turn: ${ifBroken} ${plural(ifBroken, 'territory is', 'territories are')} within reach of a stack two steps away only if a truce breaks (see exposedNextTurn).`
|
|
543
|
+
: '';
|
|
504
544
|
// #180: stacks you attack that can step out of the way first.
|
|
505
545
|
const escapes = report.dodges.filter((d) => d.took && d.escaped > 0);
|
|
506
546
|
const escapingStacks = new Set(escapes.map((d) => d.stack)).size;
|
|
@@ -539,9 +579,21 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
539
579
|
});
|
|
540
580
|
// #275 pattern 3: each border these orders leave below what the default plan leaves there (one plan per call).
|
|
541
581
|
const belowPlan = await bordersBelowPlan(ctx, { game, map, me, turn, territories, info, history, teamsKnown, given: { deploys, moves } });
|
|
582
|
+
// #375: an order into a territory to avoid, or one an avoided player holds.
|
|
583
|
+
const avoidT = new Set((intel.avoidTerritories ?? []).map((t) => resolveTerritory(map, t).id));
|
|
584
|
+
const avoidP = new Set(intel.avoidPlayers ?? []);
|
|
585
|
+
const ownerOf = (id) => {
|
|
586
|
+
const o = board.territories.find((t) => t.territoryId === id)?.owner;
|
|
587
|
+
return o?.kind === 'player' ? o.playerId : undefined;
|
|
588
|
+
};
|
|
589
|
+
const avoidedHits = [...new Set(moves.map((m) => m.to))].filter((to) => !mine.has(to) && (avoidT.has(to) || avoidP.has(ownerOf(to) ?? Number.NaN)));
|
|
542
590
|
const warnings = [
|
|
543
591
|
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
544
592
|
...[standInLine(standInOf(ctx))].filter((w) => w !== undefined),
|
|
593
|
+
...intel.warnings,
|
|
594
|
+
...(avoidedHits.length
|
|
595
|
+
? [`These orders attack ${avoidedHits.map((t) => name(t)).join(', ')}, which you asked to avoid (avoid_territories / avoid_players).`]
|
|
596
|
+
: []),
|
|
545
597
|
// #275 (b): an untrusted estimate is the first thing said (not under an explicit enemy_deploy).
|
|
546
598
|
...(enemy_deploy === undefined ? tripwireWarnings(trip.tripwires, (w) => untrustedOf.get(w.player) ?? untrustedDeploy(w, income), (p) => estimates.find((x) => x.playerId === p)?.estimate) : []),
|
|
547
599
|
...(award ? assumedWarning(award) : []),
|
|
@@ -563,7 +615,8 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
563
615
|
...effect.unsure,
|
|
564
616
|
...[claimedCardWarning(claimedCardUses(uses, claimed))].filter((w) => w !== undefined),
|
|
565
617
|
...unsimulatedCards,
|
|
566
|
-
|
|
618
|
+
// #332: in a commerce game a smaller deploy saves gold, so only a larger one is worth a line.
|
|
619
|
+
...(deployed !== sanction.income && !(so.commerce && deployed < sanction.income)
|
|
567
620
|
? [
|
|
568
621
|
`The orders deploy ${deployed} and your income is ${sanction.income}: the test used the orders as given (a Reinforcement card adds to the income; otherwise war.app refuses a wrong total).`,
|
|
569
622
|
]
|
|
@@ -596,16 +649,19 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
596
649
|
// #166: what the award of picks showed, the move order it implies included (absent with no pick list kept).
|
|
597
650
|
...(award ? { award: awardView(award, game, turn, name) } : {}),
|
|
598
651
|
orderPriority,
|
|
599
|
-
|
|
652
|
+
// #277: what I may deploy this turn, after any Sanctions on me (as warapp_plan_turn reports it).
|
|
653
|
+
income: sanction.income,
|
|
600
654
|
deployed,
|
|
601
655
|
warnings,
|
|
656
|
+
// #386: the intel warapp_record_intel kept and what this check did with it (absent when none is kept).
|
|
657
|
+
...(intel.report ? { intel: intel.report } : {}),
|
|
602
658
|
// Only an opponent with a stack in view can be given a reply; the others are named apart.
|
|
603
659
|
enemyDeploy: opponents
|
|
604
660
|
.filter((o) => inView.has(o.id))
|
|
605
661
|
.map((o) => ({
|
|
606
662
|
player: { id: o.id, name: playerName.get(o.id) ?? String(o.id) },
|
|
607
663
|
deploy: o.deploy,
|
|
608
|
-
source: enemy_deploy !== undefined ? 'enemy_deploy' : untrustedOf.has(o.id) ? 'untrusted' : 'estimate',
|
|
664
|
+
source: enemy_deploy !== undefined ? 'enemy_deploy' : knownOf.has(o.id) ? 'known_income' : untrustedOf.has(o.id) ? 'untrusted' : 'estimate',
|
|
609
665
|
})),
|
|
610
666
|
// #180: in a free-for-all, whether you lead (any two opponents are then tried together).
|
|
611
667
|
leader,
|
|
@@ -655,7 +711,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
655
711
|
jointFalls: report.jointFalls.slice(0, LIST_MAX).map(jointView),
|
|
656
712
|
...(report.jointFalls.length > LIST_MAX ? { jointFallsMore: report.jointFalls.length - LIST_MAX } : {}),
|
|
657
713
|
// #275 (a): each border's headroom, the weakest first (compact: the first few).
|
|
658
|
-
headroom: headroomView(headroom, map, income, rung === 'full', !teamsKnown),
|
|
714
|
+
headroom: headroomView(headroom, map, income, rung === 'full', !teamsKnown, (p) => estimates.find((e) => e.playerId === p)?.estimate),
|
|
659
715
|
...(rung !== 'full' && headroom.length > HEADROOM_COMPACT ? { headroomMore: headroom.length - HEADROOM_COMPACT } : {}),
|
|
660
716
|
// #275 pattern 3: absent when the default plan could not be made.
|
|
661
717
|
...(belowPlan
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// #332: a commerce game's deploy this turn, for every tool that checks or plans a deploy total (warapp_plan_turn,
|
|
2
|
+
// warapp_submit_turn, warapp_check_plan): one computation, so the three never disagree.
|
|
3
|
+
import { commerceDeploy, commerceRules } from '../commerce.js';
|
|
4
|
+
import { inGameOf, standingGold } from '../live.js';
|
|
5
|
+
/**
|
|
6
|
+
* The armies my gold buys at the game's army price: from the standing's gold (`standingGold`) when it reads — it
|
|
7
|
+
* already holds what was saved and any Sanctions, since war.app pays it — else from `modelGold` (the income model).
|
|
8
|
+
* `undefined` outside a commerce game, or when its settings were not read.
|
|
9
|
+
*/
|
|
10
|
+
export function commerceDeployOf(game, me, info, modelGold) {
|
|
11
|
+
const rules = commerceRules(game.settings);
|
|
12
|
+
if (!rules)
|
|
13
|
+
return undefined;
|
|
14
|
+
const id = inGameOf(me);
|
|
15
|
+
return commerceDeploy(rules, id === undefined ? undefined : standingGold(info, id), modelGold);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What `warapp_submit_turn` checks a commerce deploy against (#353 review). Gold read from the board is authoritative,
|
|
19
|
+
* so it is the deploy budget (`commerce`: deploying more than it buys is refused, error 597; less saves gold). Gold
|
|
20
|
+
* from the income model leaves out what was saved on earlier turns, so it is not enforced: it adds an `uncertain`
|
|
21
|
+
* reason instead, and a different total is a warning, as an uncertain income always was.
|
|
22
|
+
*/
|
|
23
|
+
export function submitCommerceCheck(c) {
|
|
24
|
+
if (!c)
|
|
25
|
+
return { uncertain: [] };
|
|
26
|
+
if (c.source === 'standing')
|
|
27
|
+
return { commerce: { gold: c.gold, armyCostMultiplier: c.armyCostMultiplier }, uncertain: [] };
|
|
28
|
+
return {
|
|
29
|
+
uncertain: [
|
|
30
|
+
`Your gold could not be read from the board, so the check uses the income model's ${c.gold}, which leaves out gold saved from earlier turns.`,
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
package/dist/tools/common.js
CHANGED
|
@@ -7,6 +7,37 @@ export const readAnnotations = (title) => toolAnnotations({ title, readOnly: tru
|
|
|
7
7
|
export const gameIdArg = z
|
|
8
8
|
.union([z.number(), z.string()])
|
|
9
9
|
.describe('The war.app game id — the number after GameID= in the game URL (war.app/MultiPlayer?GameID=<n>).');
|
|
10
|
+
/**
|
|
11
|
+
* #368: per-player incomes the caller knows (warapp_plan_turn's and warapp_check_plan's `known_income`):
|
|
12
|
+
* each replaces that opponent's estimate.
|
|
13
|
+
*/
|
|
14
|
+
export const knownIncomeArg = z
|
|
15
|
+
.array(z.object({
|
|
16
|
+
player: z.coerce.number().int().describe('The player\'s GameFeed id (as warapp_get_game lists it).'),
|
|
17
|
+
income: z.coerce.number().int().min(0).max(10_000).describe('The income it earns per turn, card armies aside.'),
|
|
18
|
+
}))
|
|
19
|
+
.max(50)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Per-player incomes you know (what a player said in diplomacy chat, say), by GameFeed id: each replaces that ' +
|
|
22
|
+
"opponent's estimate (a Reinforcement card the card clock adds stays on top), and the plan's warning says it was " +
|
|
23
|
+
'supplied. Taken as given, never checked against the board. Given, it replaces the incomes warapp_record_intel kept for this call. `enemy_deploy`, a what-if ' +
|
|
24
|
+
'for every opponent, wins over it; a player with none of its territories in view is named as unused.');
|
|
25
|
+
/** #375: territories never to attack (warapp_plan_turn's and warapp_check_plan's `avoid_territories`). */
|
|
26
|
+
export const avoidTerritoriesArg = z
|
|
27
|
+
.array(z.union([z.string(), z.number()]))
|
|
28
|
+
.max(200)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('Territories (ids or names) never to attack this turn, whoever holds them: a neutral promised to someone, say. ' +
|
|
31
|
+
'warapp_plan_turn plans around them; warapp_check_plan warns when the orders attack one. Given, it replaces the territories ' +
|
|
32
|
+
'warapp_record_intel kept, for this call (`[]`: none); omitted, those apply.');
|
|
33
|
+
/** #375: players never to attack (warapp_plan_turn's and warapp_check_plan's `avoid_players`). */
|
|
34
|
+
export const avoidPlayersArg = z
|
|
35
|
+
.array(z.coerce.number().int())
|
|
36
|
+
.max(50)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Players (GameFeed ids) never to attack this turn: peace promised outside a recorded truce. warapp_plan_turn ' +
|
|
39
|
+
'attacks none of their territories; warapp_check_plan warns when the orders do. Given, it replaces the players ' +
|
|
40
|
+
'warapp_record_intel kept, for this call (`[]`: none); omitted, those apply.');
|
|
10
41
|
/**
|
|
11
42
|
* Who writes the text these tools return: player and game names, chat, and
|
|
12
43
|
* map / territory / bonus names (maps are user-designed). None of it is the user.
|