@chrischall/warapp-mcp 0.4.0 → 0.6.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 +41 -5
- package/dist/analysis/card-support.js +2 -1
- package/dist/analysis/card-threats.js +59 -12
- package/dist/analysis/game-lessons.js +3 -4
- 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 +75 -7
- package/dist/analysis/opponents.js +2 -2
- package/dist/analysis/outlook.js +39 -0
- package/dist/analysis/picks.js +91 -12
- package/dist/analysis/plan/bonus-attempts.js +105 -0
- package/dist/analysis/plan/capture-instead.js +116 -0
- package/dist/analysis/plan/captures.js +45 -4
- package/dist/analysis/plan/conceded-out.js +13 -2
- package/dist/analysis/plan/estimates.js +135 -26
- package/dist/analysis/plan/holds.js +31 -3
- package/dist/analysis/plan/jabs.js +113 -0
- package/dist/analysis/plan/leftover.js +249 -4
- package/dist/analysis/plan/orders.js +76 -4
- package/dist/analysis/plan/relations.js +21 -1
- package/dist/analysis/plan/report.js +69 -3
- package/dist/analysis/plan/second-sizing.js +133 -0
- package/dist/analysis/plan/shared.js +82 -20
- package/dist/analysis/plan/siege.js +303 -0
- package/dist/analysis/plan/stand-still.js +7 -3
- package/dist/analysis/plan/state.js +8 -0
- package/dist/analysis/plan/strike.js +10 -5
- package/dist/analysis/plan/targets.js +91 -60
- package/dist/analysis/plan/threats.js +41 -6
- package/dist/analysis/plan/transfers.js +46 -6
- package/dist/analysis/planner.js +234 -16
- package/dist/analysis/profile.js +13 -2
- package/dist/analysis/stress.js +8 -2
- package/dist/bonus-attempt-store.js +55 -0
- package/dist/bundle.js +48009 -39350
- package/dist/cards.js +7 -5
- package/dist/chat.js +46 -4
- package/dist/commerce.js +111 -0
- package/dist/index.js +9 -1
- package/dist/live.js +43 -0
- package/dist/move-order.js +64 -3
- package/dist/my-games.js +1 -1
- package/dist/normalize.js +17 -0
- package/dist/profile-store.js +12 -2
- package/dist/protocol/bundle.js +28 -10
- package/dist/protocol/codec.js +1 -1
- package/dist/protocol/dialect.js +371 -0
- package/dist/protocol/interp.js +143 -66
- package/dist/protocol/methods.js +95 -34
- package/dist/protocol/rpc.js +35 -3
- package/dist/push/socketio.js +2 -2
- package/dist/relations-store.js +38 -4
- package/dist/siege-store.js +49 -0
- package/dist/state-bundle.js +525 -0
- package/dist/state-cli.js +69 -0
- package/dist/surrender-pending.js +4 -4
- package/dist/team-cards.js +25 -0
- package/dist/tools/award.js +15 -1
- package/dist/tools/card-advice.js +16 -5
- package/dist/tools/card-plays.js +2 -2
- package/dist/tools/card-support-advice.js +2 -1
- package/dist/tools/chat-inbox.js +36 -3
- package/dist/tools/chat-read-mark.js +3 -1
- package/dist/tools/chat.js +65 -6
- package/dist/tools/check-plan.js +54 -10
- package/dist/tools/commerce-deploy.js +33 -0
- package/dist/tools/common.js +31 -0
- package/dist/tools/end-of-game.js +5 -3
- package/dist/tools/index.js +7 -0
- package/dist/tools/my-games.js +10 -3
- package/dist/tools/notifications.js +2 -2
- package/dist/tools/picks.js +12 -0
- package/dist/tools/profile-opponents.js +2 -0
- package/dist/tools/push.js +2 -1
- package/dist/tools/relations.js +137 -0
- package/dist/tools/state.js +227 -0
- package/dist/tools/stress-opponents.js +5 -2
- package/dist/tools/surrender-pending.js +11 -6
- 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 +332 -60
- package/dist/version.js +1 -1
- package/manifest.json +10 -2
- package/mint.yaml +14 -4
- package/package.json +4 -4
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +31 -9
package/dist/tools/turn.js
CHANGED
|
@@ -4,20 +4,23 @@
|
|
|
4
4
|
import { CONFIRM_INJECTION_RULE, McpToolError, toolAnnotations } from '@chrischall/mcp-utils';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { CARD_BLOCKADE, CARD_ORDER_DELAY, CARD_ORDER_PRIORITY, holdsOrderPriority, playsOrderPriority, advisedOrderPriority, CARD_REINFORCEMENT, cardRules, cardTypeByName, cardTypeName, chooseCardPlays, normalizeGuid, cardsToShed, handReadable, isMyCard, readHand, reinforcementArmies, } from '../cards.js';
|
|
7
|
-
import { chargeDeploys, DEFAULT_OFFENSIVE_KILL_RATE, deployPools, expectedKills, specialUnitStrength, winChance, incomeDetail, armyCapPoolsUncertainty, deployCheckUncertainties, overrideUncertainties, neighborsOf, planTurn, planEnemyEstimates, repulsedAttacks, borderGuess, guessSeed, AHEAD_PRESSURE_FACTOR, PRESSURE_FACTOR, symmetricStart, unevenStart, trackGame, trackOpponents, } from '../analysis/index.js';
|
|
7
|
+
import { chargeDeploys, DEFAULT_OFFENSIVE_KILL_RATE, deployPools, expectedKills, specialUnitStrength, winChance, incomeDetail, armyCapPoolsUncertainty, deployCheckUncertainties, overrideUncertainties, neighborsOf, PAYBACK_TURNS, planTurn, planEnemyEstimates, repulsedAttacks, borderGuess, guessSeed, AHEAD_PRESSURE_FACTOR, PRESSURE_FACTOR, symmetricStart, unevenStart, trackGame, trackOpponents, } from '../analysis/index.js';
|
|
8
8
|
import { parseGameId } from '../client.js';
|
|
9
9
|
import { COMMANDER_STRENGTH, luckFraction, straightKills } from '../analysis/combat.js';
|
|
10
10
|
import { guardOffExposure } from '../analysis/guard-off.js';
|
|
11
|
-
import { holdsBelowPlan } from '../analysis/hold-diff.js';
|
|
11
|
+
import { BELOW_PLAN_MIN_SHORT, holdsBelowPlan } from '../analysis/hold-diff.js';
|
|
12
12
|
import { guardCase } from '../analysis/profile.js';
|
|
13
13
|
import { boardStateFromLive, inGameId, playersByInGameId } from '../live.js';
|
|
14
|
+
import { armiesForGold, cityAdvice, cityPurchaseCost, commerceDeploy, commerceRules, goldForArmies } from '../commerce.js';
|
|
15
|
+
import { commerceDeployOf, submitCommerceCheck } from './commerce-deploy.js';
|
|
14
16
|
import { checkMoveOptions, MOVE_MODES } from './order-options.js';
|
|
15
17
|
import { AttackTransferMode, Method, TARGETED_CARD_PLAYS, UNVERIFIED_CARD_PLAYS, writeSendOrdersParams, } from '../protocol/methods.js';
|
|
16
18
|
import { SERVER_ERROR_MESSAGES } from '../protocol/rpc.js';
|
|
19
|
+
import { inferFirstMover } from '../move-order.js';
|
|
17
20
|
import { assumedWarning, awardView, firstMoverFor, loadAward, openingThreat } from './award.js';
|
|
18
21
|
import { boardCardsInEffect, CARDS_IN_EFFECT_UNVERIFIED, sanctionMyIncome } from './card-effects.js';
|
|
19
22
|
import { adviseCards, cardGame, cardPieceOption, handOwners, opponentCanHold, opponentReinforcement, TEAM_HAND } from './card-advice.js';
|
|
20
|
-
import { currentTurn, turnsCompleted, gameIdArg, graphOf, namer, readAnnotations, respond, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedDescription, untrustedText, viewArg, } from './common.js';
|
|
23
|
+
import { currentTurn, turnsCompleted, gameIdArg, knownIncomeArg, avoidPlayersArg, avoidTerritoriesArg, graphOf, namer, readAnnotations, respond, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedDescription, untrustedText, viewArg, } from './common.js';
|
|
21
24
|
import { lookupMeta, mintMeta } from './hints.js';
|
|
22
25
|
import { chatSummary } from './chat.js';
|
|
23
26
|
import { readPendingSurrenders, surrenderOwedLine } from './surrender-pending.js';
|
|
@@ -46,16 +49,21 @@ import { commitmentWarnings } from '../analysis/commitments.js';
|
|
|
46
49
|
import { planRelationsFrom, truceBreaksIn } from '../analysis/relations.js';
|
|
47
50
|
import { recordBrokenByMe } from './relations.js';
|
|
48
51
|
import { withTeammateOrders } from '../team-orders.js';
|
|
49
|
-
import { claimedCardUses, claimedCardWarning, teamCardClaims, teamCardRoles, teamHandLeft, unclaimedFirst } from '../team-cards.js';
|
|
52
|
+
import { claimedCardUses, claimedCardWarning, teamCardClaims, teamCardLimit, teamCardRoles, teamHandLeft, unclaimedFirst, } from '../team-cards.js';
|
|
50
53
|
import { isTeamGame, teammatesOf } from '../teams.js';
|
|
51
54
|
import { readLedger, recordTruceUsage } from '../relations-store.js';
|
|
55
|
+
import { resolveIntel } from '../analysis/intel.js';
|
|
56
|
+
import { readSiegeMemory, writeSiegeMemory } from '../siege-store.js';
|
|
57
|
+
import { readBonusAttempts, writeBonusAttempts } from '../bonus-attempt-store.js';
|
|
58
|
+
import { rememberBonusAttempts } from '../analysis/plan/bonus-attempts.js';
|
|
59
|
+
import { rememberSiegeTurn } from '../analysis/plan/siege.js';
|
|
52
60
|
import { resolveTeams, resolveTeamsFor } from './team-source.js';
|
|
53
61
|
import { stressOpponents } from './stress-opponents.js';
|
|
54
62
|
import { myCommanderTerritory } from '../analysis/commander-safety.js';
|
|
55
63
|
import { commanderCheckOn, guessKeepsCommander } from './commander-check.js';
|
|
56
64
|
import { HEADROOM_COMPACT, headroomView, headroomWarnings, keepTripwires, readTripwires, safeHeadroom, teamsOf, tripwireWarnings, untrustedDeploy } from './survival.js';
|
|
57
65
|
const VIEWS = ['compact', 'full'];
|
|
58
|
-
const GOALS = ['balanced', 'expand', 'complete-bonus', 'defend'];
|
|
66
|
+
const GOALS = ['balanced', 'expand', 'complete-bonus', 'defend', 'siege'];
|
|
59
67
|
/** The only GameFeed state in which turns are played. */
|
|
60
68
|
const TURN_PHASE_STATE = 'Playing';
|
|
61
69
|
const MAX_ORDERS = 500;
|
|
@@ -83,9 +91,11 @@ const TEAM_JOINT_NOTE = "A target neither your teammate's entered attack nor you
|
|
|
83
91
|
/** PLAN-TEAMS C3.7: what `cards.team` means. */
|
|
84
92
|
const TEAM_CARDS_NOTE = "Who plays each card of the team hand this turn: a teammate for a card they have already entered a play or discard " +
|
|
85
93
|
"of (so the team never uses one card twice; the plan chooses from the rest), you for a card your orders play or " +
|
|
86
|
-
'discard, nobody for a card held. Read from their entered orders on the live board (unverified, V5)
|
|
87
|
-
"
|
|
94
|
+
'discard, nobody for a card held. Read from their entered orders on the live board (unverified, V5). The hand is the ' +
|
|
95
|
+
"team's: every teammate's cards, each kept under that teammate's id (V8, verified).";
|
|
88
96
|
const territoryRef = z.union([z.string(), z.number()]);
|
|
97
|
+
/** #332: the most cities one purchase order may name (a sanity bound, not a game rule). */
|
|
98
|
+
const MAX_CITIES_PER_ORDER = 50;
|
|
89
99
|
const playerRef = z.union([z.string().min(1).max(100), z.number()]);
|
|
90
100
|
const armiesArg = z.coerce.number().int().min(1);
|
|
91
101
|
/** One order of a turn: territories by id or name. */
|
|
@@ -203,6 +213,10 @@ export function plannerSettings(s) {
|
|
|
203
213
|
out.noSplit = true;
|
|
204
214
|
if (s.armyCap !== undefined && s.armyCap !== null && s.armyCap > 0)
|
|
205
215
|
out.armyCap = s.armyCap;
|
|
216
|
+
// #332: a commerce game's rising army price (0, one gold per army, changes nothing and is left out).
|
|
217
|
+
const m = commerceRules(s)?.armyCostMultiplier ?? 0;
|
|
218
|
+
if (m > 0)
|
|
219
|
+
out.armyCostMultiplier = m;
|
|
206
220
|
if (s.wastelands && s.wastelands.count > 0)
|
|
207
221
|
out.wastelands = { ...s.wastelands };
|
|
208
222
|
// #271 review: the first turn an opponent may play a Bomb (a bomb reads as a failed attack on my hold).
|
|
@@ -258,6 +272,8 @@ function shownOrder(o) {
|
|
|
258
272
|
}
|
|
259
273
|
if (o.players)
|
|
260
274
|
out.players = o.players.map(shownPlace);
|
|
275
|
+
if (o.cities)
|
|
276
|
+
out.cities = o.cities.map((c) => ({ ...c, territory: shownPlace(c.territory) }));
|
|
261
277
|
return out;
|
|
262
278
|
}
|
|
263
279
|
/**
|
|
@@ -334,17 +350,101 @@ export function modsWarning(s) {
|
|
|
334
350
|
];
|
|
335
351
|
}
|
|
336
352
|
/**
|
|
337
|
-
* #167:
|
|
338
|
-
*
|
|
339
|
-
*
|
|
353
|
+
* #167, #332: what the plan still does not model in a commerce game, said only when it applies. The plan deploys what
|
|
354
|
+
* my gold buys at the game's army price (`commerceDeployOf`), so with the `Commerce` settings read (their shape VERIFIED
|
|
355
|
+
* live 2026-11-17; a plain game sends `{}`) it names: gold that could not be read from the board (the deploy then rests
|
|
356
|
+
* on the income model, which leaves out saved gold), an army price that rises within a turn (the plan's own values and
|
|
357
|
+
* payback are priced at one gold per army), and cities (the plan's orders buy none; `commerce.cityAdvice` and
|
|
358
|
+
* `warapp_submit_turn`'s `cities` do). A commerce game whose settings did not read gets the old unmodelled warning;
|
|
359
|
+
* every other game, nothing.
|
|
340
360
|
*/
|
|
341
|
-
export function commerceWarning(s) {
|
|
361
|
+
export function commerceWarning(s, deploy) {
|
|
342
362
|
if (!s?.commerce)
|
|
343
363
|
return [];
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
364
|
+
const rules = commerceRules(s);
|
|
365
|
+
if (!rules) {
|
|
366
|
+
return [
|
|
367
|
+
'This looks like a commerce game, but its Commerce settings did not read: the plan models income as armies ' +
|
|
368
|
+
'only — it does not model gold, the army price or cities. Check what gold buys before following it.',
|
|
369
|
+
];
|
|
370
|
+
}
|
|
371
|
+
const out = [];
|
|
372
|
+
if (deploy?.source === 'model')
|
|
373
|
+
out.push(`Commerce: your gold could not be read from the board, so the deploy is what this turn's modelled income ` +
|
|
374
|
+
`(${deploy.gold} gold) buys; gold saved from earlier turns is not counted.`);
|
|
375
|
+
if (rules.armyCostMultiplier > 0)
|
|
376
|
+
out.push(`Commerce: armies cost more the more you buy in a turn (army cost multiplier ${rules.armyCostMultiplier}), but ` +
|
|
377
|
+
'the plan values income, bonuses and payback at one army per gold.');
|
|
378
|
+
if (rules.cityBaseCost !== null)
|
|
379
|
+
out.push('Commerce: this game allows cities; the plan does not buy any (a city pays more gold on later turns) — ' +
|
|
380
|
+
'`commerce.cityAdvice` says where one would pay, and warapp_submit_turn takes `cities`.');
|
|
381
|
+
return out;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* #332, advice only: where a city would pay this turn (`cityAdvice`, src/commerce.ts) — my cheapest territory with no
|
|
385
|
+
* neighbour I do not hold, repaid within PAYBACK_TURNS or not — as `{ cityAdvice }`, else `{}`.
|
|
386
|
+
*/
|
|
387
|
+
function cityAdviceOf(settings, graph, board, me, gold) {
|
|
388
|
+
const rules = commerceRules(settings);
|
|
389
|
+
if (!rules)
|
|
390
|
+
return {};
|
|
391
|
+
const mine = new Set(board.territories.filter((t) => t.owner.kind === 'player' && t.owner.playerId === me).map((t) => t.territoryId));
|
|
392
|
+
const sites = board.territories
|
|
393
|
+
.filter((t) => mine.has(t.territoryId))
|
|
394
|
+
.map((t) => ({
|
|
395
|
+
territoryId: t.territoryId,
|
|
396
|
+
interior: neighborsOf(graph, t.territoryId).every((n) => mine.has(n)),
|
|
397
|
+
cities: t.cities ?? 0,
|
|
398
|
+
}));
|
|
399
|
+
const advice = cityAdvice(rules, sites, gold, PAYBACK_TURNS);
|
|
400
|
+
return advice ? { cityAdvice: advice } : {};
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* #332: a turn's city purchase, checked as the client checks it — a commerce game that allows cities (602), my own
|
|
404
|
+
* territories (600), whole positive counts (601), merged per territory, priced by the game's formula
|
|
405
|
+
* (`cityPurchaseCost`) and paid for from my gold (597). `undefined` when none is asked for.
|
|
406
|
+
*/
|
|
407
|
+
export function cityPurchaseOf(game, asked, map, board, myInGameId, gold) {
|
|
408
|
+
if (!asked.length)
|
|
409
|
+
return undefined;
|
|
410
|
+
const rules = commerceRules(game.settings);
|
|
411
|
+
if (!rules || rules.cityBaseCost === null || !gold) {
|
|
412
|
+
throw new McpToolError(`${SERVER_ERROR_MESSAGES[602]} Nothing was sent.`, {
|
|
413
|
+
hint: rules ? 'Drop `cities`.' : 'Cities exist only in commerce games that allow them; drop `cities`.',
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
const merged = new Map();
|
|
417
|
+
for (const a of asked) {
|
|
418
|
+
const t = resolveTerritory(map, a.territory);
|
|
419
|
+
const held = board.find((x) => x.territoryId === t.id);
|
|
420
|
+
if (!held || held.owner !== myInGameId) {
|
|
421
|
+
throw new McpToolError(`${untrustedText(t.name)} (${t.id}) is not yours on the live board. ${SERVER_ERROR_MESSAGES[600]}`, {
|
|
422
|
+
hint: 'Build cities only on territories you hold at the start of the turn.',
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
const m = merged.get(t.id);
|
|
426
|
+
if (m)
|
|
427
|
+
m.count += a.count;
|
|
428
|
+
else
|
|
429
|
+
merged.set(t.id, { territory: { id: t.id, name: t.name }, count: a.count });
|
|
430
|
+
}
|
|
431
|
+
const cities = [...merged.values()];
|
|
432
|
+
const existing = new Map(board.flatMap((x) => (x.cities ? [[x.territoryId, x.cities]] : [])));
|
|
433
|
+
const mine = board.reduce((n, x) => n + (x.owner === myInGameId ? (x.cities ?? 0) : 0), 0);
|
|
434
|
+
const cost = cityPurchaseCost(rules, cities.map((c) => ({ territoryId: c.territory.id, count: c.count })), existing, mine);
|
|
435
|
+
const count = cities.reduce((n, c) => n + c.count, 0);
|
|
436
|
+
// Only gold read from the board is enforced (#353 review): the model's leaves out gold saved on earlier turns.
|
|
437
|
+
if (cost > gold.gold && gold.source === 'standing') {
|
|
438
|
+
throw new McpToolError(`${count} cit${count === 1 ? 'y' : 'ies'} cost ${cost} gold, but you have ${gold.gold}. ${SERVER_ERROR_MESSAGES[597]}`, { hint: 'Buy fewer cities; nothing was sent.' });
|
|
439
|
+
}
|
|
440
|
+
const left = gold.gold - cost;
|
|
441
|
+
const note = `Commerce: ${count} cit${count === 1 ? 'y' : 'ies'} for ${cost} gold (each pays ${rules.cityIncome} gold a turn), ` +
|
|
442
|
+
(gold.source === 'standing'
|
|
443
|
+
? `leaving ${left} gold for the deploys. `
|
|
444
|
+
: `against the income model's ${gold.gold} gold (your gold could not be read from the board, and saved gold is not in ` +
|
|
445
|
+
`it${left < 0 ? ', so war.app may refuse the purchase: error 597' : ''}). `) +
|
|
446
|
+
"The purchase order's encoding is read from the client and UNVERIFIED live: check the cities on the board once the turn resolves.";
|
|
447
|
+
return { cities, cost, note };
|
|
348
448
|
}
|
|
349
449
|
/**
|
|
350
450
|
* #165: One Army Must Stand Guard off. My territories the orders leave at 0 beside an enemy or the
|
|
@@ -472,7 +572,21 @@ export function validateTurn(args) {
|
|
|
472
572
|
}
|
|
473
573
|
}
|
|
474
574
|
const deployed = deploys.reduce((s, d) => s + d.armies, 0);
|
|
475
|
-
if (deployed !== income
|
|
575
|
+
if (args.commerce && deployed !== income) {
|
|
576
|
+
const { gold, armyCostMultiplier: m } = args.commerce;
|
|
577
|
+
const cards = income - armiesForGold(gold, m);
|
|
578
|
+
if (deployed < income) {
|
|
579
|
+
const saved = gold - goldForArmies(Math.max(0, deployed - cards), m);
|
|
580
|
+
warnings.push(`These orders deploy ${deployed} of the ${income} armies your ${gold} gold buys` +
|
|
581
|
+
`${cards > 0 ? ` (with ${cards} card armies)` : ''}: ${saved} gold is saved for a later turn.`);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
const cost = goldForArmies(Math.max(0, deployed - cards), m);
|
|
585
|
+
throw new McpToolError(`These orders deploy ${deployed} armies, which cost ${cost} gold, but you have ${gold} gold (buying ${income} armies` +
|
|
586
|
+
`${cards > 0 ? `, ${cards} of them from cards` : ''}).`, { hint: `Deploy at most ${income} armies — war.app refuses a deploy you cannot pay for (error 597 InsufficientGold).` });
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
else if (deployed !== income && args.incomeUncertain?.length) {
|
|
476
590
|
warnings.push(`These orders deploy ${deployed} armies, but the modelled income is ${income} this turn. The model may be off ` +
|
|
477
591
|
`(${args.incomeUncertain.join(' ')}), so they are not refused here: check the "armies per turn" the game ` +
|
|
478
592
|
'shows — war.app refuses any other total (error 11).');
|
|
@@ -729,7 +843,7 @@ const PLAYABLE = {
|
|
|
729
843
|
[CARD_ORDER_PRIORITY]: 'OrderPriority',
|
|
730
844
|
[CARD_ORDER_DELAY]: 'OrderDelay',
|
|
731
845
|
[CARD_BLOCKADE]: 'Blockade',
|
|
732
|
-
// PLAN-TEAMS part D: encoded from the bundle's writers, UNVERIFIED live (V9).
|
|
846
|
+
// PLAN-TEAMS part D: encoded from the bundle's writers, UNVERIFIED live (V9) save Airlift (#296) and Diplomacy (#369).
|
|
733
847
|
2: 'Spy',
|
|
734
848
|
6: 'Airlift',
|
|
735
849
|
7: 'Gift',
|
|
@@ -838,24 +952,28 @@ function resolveCardPlays(map, hand, rules, inputs) {
|
|
|
838
952
|
return out;
|
|
839
953
|
}
|
|
840
954
|
/**
|
|
841
|
-
* The team's
|
|
842
|
-
*
|
|
955
|
+
* The team's hand is over the limit but the limit does not bind these orders (V8, #310): a teammate has yet to
|
|
956
|
+
* commit (war.app refuses only the last of the team to commit), or a committed teammate's orders were unread.
|
|
843
957
|
*/
|
|
844
|
-
function teamHandOver(
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
'
|
|
958
|
+
function teamHandOver(team, rules, given) {
|
|
959
|
+
const held = team.left.length;
|
|
960
|
+
const shed = team.shed;
|
|
961
|
+
return (`The team's hand (your cards and your teammates', less what committed teammates play or discard) holds ${held} cards; ` +
|
|
962
|
+
`the limit is ${rules.maxCardsHold}, so ${shed} card${shed === 1 ? '' : 's'} must leave it this turn; these orders use ${given}. ` +
|
|
963
|
+
(team.lastToCommit
|
|
964
|
+
? "A committed teammate's orders could not be read, so this is not refused: war.app refuses the last of the team to commit (error 51) while the team is over the limit."
|
|
965
|
+
: 'A teammate has yet to commit, so war.app takes these orders: it refuses only the last of the team to commit (error 51) while the team is still over the limit. Agree in team chat who plays or discards.'));
|
|
849
966
|
}
|
|
850
|
-
/** Cards these orders use that were read only under a teammate's id (V8, #
|
|
967
|
+
/** Cards these orders use that were read only under a teammate's id (V8, #310): a warning, never a refusal. */
|
|
851
968
|
export function teammateCardWarning(cards) {
|
|
852
969
|
return (`${cards.map((c) => `${c.name} ${c.id}`).join(', ')} ${cards.length === 1 ? 'was' : 'were'} read under a teammate, not under you. ` +
|
|
853
|
-
"A team shares one hand
|
|
854
|
-
'
|
|
970
|
+
"A team shares one hand: war.app's order check (the client bundle's) takes any card of the team's hand, but no play of a " +
|
|
971
|
+
"teammate's card has been sent live yet, and a card a committed teammate already uses is swapped for another of its type " +
|
|
972
|
+
'or refused (error 50, CardInstanceUnavailable). Agree in team chat first.');
|
|
855
973
|
}
|
|
856
974
|
/** The required-play refusal (war.app's error 51, `MustUseCard`), raised before anything is sent. */
|
|
857
|
-
function mustPlayCard(hand, rules, shed, given) {
|
|
858
|
-
return new McpToolError(`${SERVER_ERROR_MESSAGES[51]} (You hold ${hand.length}; the limit is ${rules.maxCardsHold}, so ${shed} card${shed === 1 ? '' : 's'} must be played or discarded; these orders use ${given}.)`, {
|
|
975
|
+
function mustPlayCard(hand, rules, shed, given, team = false) {
|
|
976
|
+
return new McpToolError(`${SERVER_ERROR_MESSAGES[51]} (${team ? 'Your team holds' : 'You hold'} ${hand.length}${team ? ", every teammate has committed and you are the last to" : ''}; the limit is ${rules.maxCardsHold}, so ${shed} card${shed === 1 ? '' : 's'} must be played or discarded; these orders use ${given}.)`, {
|
|
859
977
|
hint: `Add card plays or discards, e.g. { "kind": "discard", "card": "${hand[0]?.name ?? 'Order Delay'}" } (warapp_plan_turn suggests which). ${handHint(hand, true)}`,
|
|
860
978
|
});
|
|
861
979
|
}
|
|
@@ -1104,7 +1222,22 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1104
1222
|
const board = award?.board ?? seen;
|
|
1105
1223
|
const opening = openingThreat(award, game, graph, seen, turn);
|
|
1106
1224
|
// #127: who moves first — first_mover, else a turn kept for this game alternated, else the award.
|
|
1107
|
-
|
|
1225
|
+
// #299: my own first order last turn can prove the opponent moved first then.
|
|
1226
|
+
const lastTurn = turn !== null ? history.boards.find((b) => b.turn === turn - 1) : undefined;
|
|
1227
|
+
const rival = game.players.length === 2 ? game.players.find((p) => p.id !== me.id) : undefined;
|
|
1228
|
+
const inferred = turn !== null && lastTurn?.orders && rival
|
|
1229
|
+
? inferFirstMover({
|
|
1230
|
+
turn: turn - 1,
|
|
1231
|
+
before: lastTurn.board,
|
|
1232
|
+
after: seen,
|
|
1233
|
+
orders: lastTurn.orders,
|
|
1234
|
+
me: me.id,
|
|
1235
|
+
opponent: rival.id,
|
|
1236
|
+
rates: plannerSettings(game.settings),
|
|
1237
|
+
orderPriorityPossible: opponentCanHold(game.settings, 'Order Priority', turn - 1),
|
|
1238
|
+
})
|
|
1239
|
+
: null;
|
|
1240
|
+
const mover = await firstMoverFor(ctx.dataDir, game, me, turn, first_mover, award, { write, ...(inferred ? { inferred } : {}) });
|
|
1108
1241
|
const settings = plannerSettings(game.settings);
|
|
1109
1242
|
const rules = cardRules(game.settings);
|
|
1110
1243
|
// A team shares one hand (#163): mine and my teammates' cards.
|
|
@@ -1113,9 +1246,9 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1113
1246
|
const handUnknown = rules.inPlay.length > 0 && !handReadable(info, owners);
|
|
1114
1247
|
const inGame = cardGame(game, me);
|
|
1115
1248
|
// PLAN-TEAMS C3.7: a card my teammate has entered a play or discard of is theirs this turn, so my plan
|
|
1116
|
-
// chooses from the rest (their orders: V5; the team hand's keying: V8
|
|
1249
|
+
// chooses from the rest (their orders: V5, unverified live; the team hand's keying: V8, verified #310).
|
|
1117
1250
|
const { left: myHand, claimed: teamClaimed } = teamHandLeft(hand, inGame.team ? teamCardClaims(seen.teammateOrders, new Set(teammatesOf(game.players, me).map((p) => p.id))) : []);
|
|
1118
|
-
// V8: of what is left, a card read under a teammate's id is
|
|
1251
|
+
// V8: of what is left, a card read under a teammate's id is left to them (#310): chooseCardPlays
|
|
1119
1252
|
// and the card advice play, discard and advise only my own, so no card is both claimed and advised to me.
|
|
1120
1253
|
const cards = chooseCardPlays(myHand, rules, inGame);
|
|
1121
1254
|
const myCards = myHand.filter((c) => isMyCard(c, inGame.me));
|
|
@@ -1128,7 +1261,10 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1128
1261
|
// a Diplomacy card with a player makes it no foe this turn (T9).
|
|
1129
1262
|
const effect = boardCardsInEffect(game, me, turn, info);
|
|
1130
1263
|
const sanction = sanctionMyIncome(boardIncome, effect, { localDeployments: settings.localDeployments === true });
|
|
1131
|
-
|
|
1264
|
+
// #332: in a commerce game the income is gold and the deploy is what it buys at the game's army price. The
|
|
1265
|
+
// standing's gold already holds what was saved and any Sanctions (war.app pays it); the model is the fallback.
|
|
1266
|
+
const commerce = commerceDeployOf(game, me, info, sanction.income);
|
|
1267
|
+
const income = (commerce ? commerce.armies : sanction.income) + cards.extraArmies;
|
|
1132
1268
|
const trend = history.previous;
|
|
1133
1269
|
const previousOrders = turn !== null ? history.boards.find((b) => b.turn === turn - 1)?.orders : undefined;
|
|
1134
1270
|
// The opponents over my board history: one observed over 2+ turns gets its tracked income;
|
|
@@ -1139,6 +1275,9 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1139
1275
|
// #240: territories my cached orders show failed attacks on, their owner reinforcing them each
|
|
1140
1276
|
// time, on two or more of the last three turns: a further attack is sized for its owner's deploy.
|
|
1141
1277
|
const repulsed = turn !== null ? repulsedAttacks(graph, [...history.boards, { turn, board: seen }], me.id, settings) : [];
|
|
1278
|
+
// #298: the contested bonuses my plans attempted to complete in this game (read only here; only
|
|
1279
|
+
// warapp_plan_turn writes it): after two failed attempts the planner pushes all-in once or drops the bonus.
|
|
1280
|
+
const bonusAttempts = turn !== null && ctx.dataDir ? await readBonusAttempts(ctx.dataDir, game.id, me.id) : undefined;
|
|
1142
1281
|
// #178: won, lost, even or stuck, from my boards over the last turns (a basis, not a verdict).
|
|
1143
1282
|
// #201: the planner reads it too — a decided game shortens its payback horizon.
|
|
1144
1283
|
const cardArmies = cardArmyCeiling(game.settings);
|
|
@@ -1224,12 +1363,21 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1224
1363
|
staticSeats: staticSeats(game.players, game.endRules, me.id),
|
|
1225
1364
|
});
|
|
1226
1365
|
const untrusted = trip.tripwires.map((w) => ({ player: w.player, deploy: untrustedDeploy(w, boardIncome) }));
|
|
1366
|
+
// #303: my board income on each earlier board (as this turn's: after the army cap, cards aside), for the
|
|
1367
|
+
// plan's income trend. Not in a commerce game, where the income is gold and the deploy what it buys.
|
|
1368
|
+
const incomeHistory = commerceRules(game.settings)
|
|
1369
|
+
? []
|
|
1370
|
+
: history.boards.map((b) => ({ turn: b.turn, income: incomeDetail(graph, b.board, me.id, game.settings).income }));
|
|
1227
1371
|
const input = {
|
|
1228
1372
|
graph,
|
|
1229
1373
|
board,
|
|
1230
1374
|
me: me.id,
|
|
1231
1375
|
income,
|
|
1376
|
+
...(incomeHistory.length && turn !== null ? { incomeHistory } : {}),
|
|
1232
1377
|
...(untrusted.length ? { untrusted } : {}),
|
|
1378
|
+
// #368: incomes the caller knows. Not in the estimates above, which the tripwire keeps: those stay the
|
|
1379
|
+
// board's own (a figure supplied is no observation).
|
|
1380
|
+
...(a.args?.knownIncome?.length ? { knownIncome: a.args.knownIncome } : {}),
|
|
1233
1381
|
cardArmies: cards.extraArmies,
|
|
1234
1382
|
...(incomeCap ? { incomeCap } : {}),
|
|
1235
1383
|
...(truces?.relations.length ? { relations: truces.relations } : {}),
|
|
@@ -1238,9 +1386,11 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1238
1386
|
// #226: my orders on that turn, when this server sent them: a failed attack's kills count back.
|
|
1239
1387
|
...(trend && previousOrders ? { previousOrders } : {}),
|
|
1240
1388
|
...(repulsed.length ? { repulsed } : {}),
|
|
1389
|
+
...(bonusAttempts ? { bonusAttempts } : {}),
|
|
1241
1390
|
...(turn !== null ? { turn } : {}),
|
|
1242
1391
|
game: gameContext,
|
|
1243
1392
|
...(tracks ? { tracks } : {}),
|
|
1393
|
+
...(a.args?.siegeMemory ? { siegeMemory: a.args.siegeMemory } : {}),
|
|
1244
1394
|
// G2 (D3): Sanctions on another player the decoder is sure of cut its estimate read off the board.
|
|
1245
1395
|
...(effect.sanctionsOnOthers.length ? { sanctions: effect.sanctionsOnOthers } : {}),
|
|
1246
1396
|
options: {
|
|
@@ -1257,6 +1407,9 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1257
1407
|
...(reserve !== undefined ? { reserve } : {}),
|
|
1258
1408
|
...(enemy_deploy !== undefined ? { enemyDeploy: enemy_deploy } : {}),
|
|
1259
1409
|
...(min_win_chance !== undefined ? { minWinChance: min_win_chance } : {}),
|
|
1410
|
+
...(a.args?.avoid ? { avoid: a.args.avoid } : {}),
|
|
1411
|
+
...(a.args?.siegeTarget !== undefined ? { siegeTarget: a.args.siegeTarget } : {}),
|
|
1412
|
+
...(a.args?.jabs !== undefined ? { jabs: a.args.jabs } : {}),
|
|
1260
1413
|
// #127/#179: who moves first (firstMoverFor: first_mover, else the remembered turn, else the award).
|
|
1261
1414
|
...(mover.firstMover !== undefined ? { movesFirst: mover.firstMover === 'me' } : {}),
|
|
1262
1415
|
// #215 review: from the award (unverified), the schedule and card advice use it, holds do not.
|
|
@@ -1271,7 +1424,7 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1271
1424
|
return {
|
|
1272
1425
|
graph, seen, award, board, opening, mover, settings, rules, owners, hand, myHand, myCards, teamClaimed, handUnknown, inGame, cards,
|
|
1273
1426
|
boardIncome, income, trend, previousOrders, tracks, outlookInput, outlook, picking, opponents, gameContext, truces, input,
|
|
1274
|
-
effect, sanction, incomeCap, capUnknown: incomeOnBoard.capUnknown === true, estimates, trip, teams,
|
|
1427
|
+
effect, sanction, incomeCap, capUnknown: incomeOnBoard.capUnknown === true, estimates, trip, teams, commerce,
|
|
1275
1428
|
};
|
|
1276
1429
|
}
|
|
1277
1430
|
/**
|
|
@@ -1368,7 +1521,8 @@ function planBorderGuess(setup, plan, me, seed, enemyDeploy) {
|
|
|
1368
1521
|
export const BELOW_PLAN_BASIS = 'the plan warapp_plan_turn makes now on this board with no goal, focus, reserve, enemy_deploy or first_mover ' +
|
|
1369
1522
|
'(the award of picks read as it reads it, nothing written), or its border guess when the ' +
|
|
1370
1523
|
'deploys given are the guess\'s; a plan made with options may differ, and a figure is what that plan leaves ' +
|
|
1371
|
-
'standing there, surplus included, not the least that holds the border'
|
|
1524
|
+
'standing there, surplus included, not the least that holds the border; a border short by less than ' +
|
|
1525
|
+
`${BELOW_PLAN_MIN_SHORT} is left out (#306: that is the plan's surplus)`;
|
|
1372
1526
|
/** The same deploys, merged per territory (order and splitting ignored). */
|
|
1373
1527
|
function sameDeploys(a, b) {
|
|
1374
1528
|
const total = (ds) => {
|
|
@@ -1415,6 +1569,8 @@ export async function bordersBelowPlan(ctx, a) {
|
|
|
1415
1569
|
},
|
|
1416
1570
|
conceded: plan.conceded,
|
|
1417
1571
|
given,
|
|
1572
|
+
// #306: a border only 1 or 2 short is the plan's surplus, not a real difference.
|
|
1573
|
+
minShort: BELOW_PLAN_MIN_SHORT,
|
|
1418
1574
|
});
|
|
1419
1575
|
const turn = a.turn;
|
|
1420
1576
|
const held = new Set(a.history.boards.map((b) => b.turn));
|
|
@@ -1474,20 +1630,23 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1474
1630
|
"game's settings: your income, deploys and attacks/transfers by territory name and id (each attack with " +
|
|
1475
1631
|
'`winChance`, its exact capture probability), the expected captures, completed bonuses and next income ' +
|
|
1476
1632
|
'(with `nextIncomeIfConcededFall` and `bonusesAtRisk` when the plan concedes borders of a bonus you hold), ' +
|
|
1477
|
-
'the borders given up (`conceded`), the `frontier` budget, your cards (plays and discards when you must), ' +
|
|
1633
|
+
'the borders given up (`conceded`), the `frontier` budget, `incomeTrend` (my income over the last five turns, its slope per turn and whether it is flat; #303), in a 1v1 the `gates` (every border facing the opponent against its one floating deploy: what they need, what stands on them, the shortfall), your cards (plays and discards when you must), ' +
|
|
1478
1634
|
'warnings and the reasoning. Its `orders` array is exactly what warapp_submit_turn takes — review it with ' +
|
|
1479
1635
|
'the user first. Every plan reads the game profile (`profile`: format 1v1/ffa/teams, phase, standing ' +
|
|
1480
1636
|
'ahead/even/behind/unknown on income) and returns the `outlook` (winning/losing/even/stalemate from ' +
|
|
1481
|
-
'armies + 3 × income held over 3 turns of boards, with its `basis` and `evidence`: the two incomes compared and how much of each opponent\'s frontier was read, `thin` when under half, so even is not safe; thresholds unmeasured, so advice, not a verdict; ' +
|
|
1637
|
+
'armies + 3 × income held over 3 turns of boards, with its `basis` and `evidence`: the two incomes compared and how much of each opponent\'s frontier was read, `thin` when under half, so even is not safe; `leaning: behind` when even for 3 turns while a bonus of yours fell on each; thresholds unmeasured, so advice, not a verdict; ' +
|
|
1482
1638
|
'an opponent is bounded above by all it can have received (its start, or an even share of the map; each turn\'s most it could earn; ' +
|
|
1483
1639
|
'a fixed Reinforcement card by the card clock) — a scenario\'s starts, a Gift card or a progressive Reinforcement card leave it unbounded, and then `winning` is never read; ' +
|
|
1484
1640
|
'once winning or losing, payback tests count the turns the game has left instead of 10). With no `goal` the profile picks and tunes it (`goalSource` ' +
|
|
1485
|
-
'"profile"):
|
|
1641
|
+
'"profile"): siege when it fits (in contact, not ahead, one target — in an FFA the leader, earning 1.5× any other ' +
|
|
1642
|
+
'opponent beside me — with a sure break costing at most 2 turns of its bonus and at most my income; handed back ' +
|
|
1643
|
+
'once its assault trigger fires), else defend when behind outside a 1v1, else balanced — in an FFA with two or more opponents, no ' +
|
|
1486
1644
|
'second front; in a 1v1, one strike stack facing the opponent; ahead in a 1v1, fog pressure ' +
|
|
1487
1645
|
`up to ${AHEAD_PRESSURE_FACTOR}× a typical neutral capture. Goals: "balanced" (default) — income per army ` +
|
|
1488
1646
|
'across holds, bonuses and breaking enemy bonuses, at least 30% on expansion; "expand" — neutrals only; ' +
|
|
1489
1647
|
'"complete-bonus" — also attacks players to finish bonuses; "defend" — threatened borders worth holding ' +
|
|
1490
|
-
'first
|
|
1648
|
+
'first; "siege" — one opponent (`siege_target`): its cheapest bonus breaks first and one strike stack facing it, ' +
|
|
1649
|
+
'the main assault held until it is weakened (`siege` reports the trigger). An opponent next to the fog may be pressured: each of its visible territories attacked, sized for ' +
|
|
1491
1650
|
`its full deploy plus a margin, at most ${PRESSURE_FACTOR}× a typical neutral capture each — one visible ` +
|
|
1492
1651
|
'territory too costly blocks the pressure on all of them. Threats assume each enemy deploys `enemy_deploy` (default per opponent: ' +
|
|
1493
1652
|
'base income plus its visible bonuses, or its observed deploy when larger — its tracked income, carried across turns, once ' +
|
|
@@ -1500,7 +1659,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1500
1659
|
'withdrawal worth a card, a commander strike) or it is the card that must go (over the hold limit the cards worth ' +
|
|
1501
1660
|
'least in this game leave first; the timing cards are kept longest); never Blockade, Order Delay, Bomb or Emergency ' +
|
|
1502
1661
|
'Blockade — `cards.advice` says where those pay (Order Delay above the calm orders, a Bomb target or hold it, an ' +
|
|
1503
|
-
"Emergency Blockade wall; Diplomacy on the opponent pressing you hardest when two or more do, Sanctions on the leader, an Airlift onto a " +
|
|
1662
|
+
"Emergency Blockade wall on a conceded border that shields a bonus or your commander behind it, or kills more than it gives up, never where the stack can go around; Diplomacy on the opponent pressing you hardest when two or more do, Sanctions on the leader, an Airlift onto a " +
|
|
1504
1663
|
"border of yours or a teammate's that falls without it, a Gift that completes a teammate's bonus, Spy, Reconnaissance or Surveillance " +
|
|
1505
1664
|
'where the fog hides what the plan needs (never with fog off) — each with an `order` to pass to ' +
|
|
1506
1665
|
"warapp_submit_turn, never added to the orders), and the warnings flag an opponent's Bomb or Emergency Blockade and the cards in effect. Moves are listed in the " +
|
|
@@ -1567,9 +1726,12 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1567
1726
|
goal: z
|
|
1568
1727
|
.enum(GOALS)
|
|
1569
1728
|
.optional()
|
|
1570
|
-
.describe('Omit to let the game profile pick (defend when behind on income outside a 1v1, else balanced, tuned to the format). ' +
|
|
1729
|
+
.describe('Omit to let the game profile pick (siege when it fits, else defend when behind on income outside a 1v1, else balanced, tuned to the format). ' +
|
|
1571
1730
|
'balanced (default): best income per army across holds, bonuses and breaking enemy bonuses; expand: take ' +
|
|
1572
|
-
'neutrals only; complete-bonus: also attack players to finish bonuses; defend: hold threatened borders first
|
|
1731
|
+
'neutrals only; complete-bonus: also attack players to finish bonuses; defend: hold threatened borders first; ' +
|
|
1732
|
+
"siege: against one opponent (siege_target), fund its cheapest bonus breaks first and build one strike stack " +
|
|
1733
|
+
"facing it, holding the main assault until its income falls to 0.6× its baseline (tracked, or when the siege began), mine reaches 1.8× " +
|
|
1734
|
+
"its, or a stack of mine can take a member of its held bonus against its whole deploy (reported as `siege`). " +
|
|
1573
1735
|
'A goal given here overrides the profile.'),
|
|
1574
1736
|
focus: z
|
|
1575
1737
|
.array(z.union([z.string(), z.number()]))
|
|
@@ -1604,6 +1766,22 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1604
1766
|
'exact win chance (game kill rates, luck, rounding) reaches it — cheaper, but it can fail — and the ' +
|
|
1605
1767
|
'captures a bonus still needs reach it together. Attacks sized for a worst case (finishing a player off, ' +
|
|
1606
1768
|
'fog pressure, commander strikes) stay certain.'),
|
|
1769
|
+
siege_target: z.coerce
|
|
1770
|
+
.number()
|
|
1771
|
+
.int()
|
|
1772
|
+
.optional()
|
|
1773
|
+
.describe("With goal siege: the player to besiege (GameFeed player id). Default: the strongest opponent bordering my territories."),
|
|
1774
|
+
jabs: z
|
|
1775
|
+
.boolean()
|
|
1776
|
+
.optional()
|
|
1777
|
+
.describe('Single-army jabs (#361): only at 0% luck under straight rounding, where one attacking army kills ' +
|
|
1778
|
+
'round(1 × the offensive kill rate) = 1 defender and dies, a one-for-one trade. When on, armies still idle ' +
|
|
1779
|
+
'beyond a border\'s hold jab enemy stacks of 2 or more (one army each, at most one per stack) of an opponent ' +
|
|
1780
|
+
'I out-earn or out-army, or the siege target\'s bonus members; reported as `jabs`, attrition, never captures. ' +
|
|
1781
|
+
'Default: on under goal siege, off otherwise.'),
|
|
1782
|
+
known_income: knownIncomeArg,
|
|
1783
|
+
avoid_territories: avoidTerritoriesArg,
|
|
1784
|
+
avoid_players: avoidPlayersArg,
|
|
1607
1785
|
first_mover: z
|
|
1608
1786
|
.enum(['me', 'opponent'])
|
|
1609
1787
|
.optional()
|
|
@@ -1617,7 +1795,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1617
1795
|
view: viewArg(VIEWS, 'compact (default) gives the plan and orders (the profile as format, phase and standing); "full" adds each ' +
|
|
1618
1796
|
'move\'s reason, the whole profile and the settings the plan assumed.'),
|
|
1619
1797
|
}),
|
|
1620
|
-
}, async ({ game_id, player, goal, focus, reserve, enemy_deploy, min_win_chance, first_mover, view }) => {
|
|
1798
|
+
}, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, avoid_territories, avoid_players, min_win_chance, first_mover, view }) => {
|
|
1621
1799
|
// The chat comes in the same GameFeed read: the fallback for the unread counts (part A1).
|
|
1622
1800
|
const feed = await ctx.client.getGame(game_id, { settings: true, chat: true });
|
|
1623
1801
|
requireTurnPhase(feed);
|
|
@@ -1642,15 +1820,34 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1642
1820
|
// #317: a surrender waiting on my acceptance (the game details; null when unreadable). Never throws.
|
|
1643
1821
|
readPendingSurrenders(ctx, game, me),
|
|
1644
1822
|
]);
|
|
1823
|
+
// #386: the avoid targets and stated incomes warapp_record_intel kept, applied unless an argument of
|
|
1824
|
+
// that kind is given (an explicit one replaces the stored list); a stale stored income is left out.
|
|
1825
|
+
const intel = resolveIntel(ctx.dataDir ? (await readLedger(ctx.dataDir, game.id, me.id))?.intel : undefined, turn, {
|
|
1826
|
+
...(known_income !== undefined ? { knownIncome: known_income } : {}),
|
|
1827
|
+
...(avoid_territories !== undefined ? { avoidTerritories: avoid_territories } : {}),
|
|
1828
|
+
...(avoid_players !== undefined ? { avoidPlayers: avoid_players } : {}),
|
|
1829
|
+
});
|
|
1830
|
+
const knownIncome = intel.knownIncome;
|
|
1831
|
+
const avoidTerritories = intel.avoidTerritories;
|
|
1832
|
+
const avoidPlayers = intel.avoidPlayers;
|
|
1833
|
+
// #382: the siege's memory, kept per game while a siege runs.
|
|
1834
|
+
const siegeMemory = (goal === undefined || goal === 'siege') && ctx.dataDir && turn !== null ? await readSiegeMemory(ctx.dataDir, game.id, me.id) : undefined;
|
|
1645
1835
|
const setup = await livePlanSetup(ctx, {
|
|
1646
1836
|
game, map, me, turn, territories, info, history, teamsKnown,
|
|
1647
1837
|
args: {
|
|
1648
1838
|
...(goal !== undefined ? { goal } : {}),
|
|
1839
|
+
...(goal === 'siege' && siege_target !== undefined ? { siegeTarget: siege_target } : {}),
|
|
1840
|
+
...(jabs !== undefined ? { jabs } : {}),
|
|
1841
|
+
...(siegeMemory ? { siegeMemory } : {}),
|
|
1649
1842
|
focusBonusIds,
|
|
1650
1843
|
...(reserve !== undefined ? { reserve } : {}),
|
|
1651
1844
|
...(enemy_deploy !== undefined ? { enemyDeploy: enemy_deploy } : {}),
|
|
1652
1845
|
...(min_win_chance !== undefined ? { minWinChance: min_win_chance } : {}),
|
|
1653
1846
|
...(first_mover !== undefined ? { firstMover: first_mover } : {}),
|
|
1847
|
+
...(knownIncome?.length ? { knownIncome } : {}),
|
|
1848
|
+
...(avoidTerritories?.length || avoidPlayers?.length
|
|
1849
|
+
? { avoid: { territories: (avoidTerritories ?? []).map((t) => resolveTerritory(map, t).id), players: avoidPlayers ?? [] } }
|
|
1850
|
+
: {}),
|
|
1654
1851
|
},
|
|
1655
1852
|
});
|
|
1656
1853
|
const { graph, seen, award, board, mover, rules, hand, myHand, myCards, teamClaimed, handUnknown, inGame, cards, income, trend, tracks } = setup;
|
|
@@ -1705,6 +1902,16 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1705
1902
|
await writeGameRecord(ctx.dataDir, game);
|
|
1706
1903
|
if (ctx.dataDir && turn !== null)
|
|
1707
1904
|
await recordOutlook(ctx.dataDir, game.id, me.id, outlook);
|
|
1905
|
+
// #382: this siege turn joins the memory (not on an enemy_deploy what-if; planning the turn again replaces it).
|
|
1906
|
+
if (ctx.dataDir && turn !== null && plan.siege && enemy_deploy === undefined)
|
|
1907
|
+
await writeSiegeMemory(ctx.dataDir, game.id, me.id, rememberSiegeTurn(siegeMemory, turn, plan.siege));
|
|
1908
|
+
// #298: this turn's attempts on contested bonuses and its drops join the memory (never on a what-if
|
|
1909
|
+
// plan; planning the turn again replaces them).
|
|
1910
|
+
if (ctx.dataDir && turn !== null && !whatIf) {
|
|
1911
|
+
const attempts = rememberBonusAttempts(setup.input.bonusAttempts, turn, graph, setup.input.board, me.id, plan.expected.bonusesCompleted, plan.bonusPush);
|
|
1912
|
+
if (attempts.bonuses.length || setup.input.bonusAttempts)
|
|
1913
|
+
await writeBonusAttempts(ctx.dataDir, game.id, me.id, attempts);
|
|
1914
|
+
}
|
|
1708
1915
|
// B2: what each honoured truce freed this turn and what a break would have cost (T6), for "has it
|
|
1709
1916
|
// been useful in play?" (not a what-if plan).
|
|
1710
1917
|
const used = (plan.relations ?? []).filter((r) => r.honoured && r.agreement !== undefined);
|
|
@@ -1745,6 +1952,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1745
1952
|
...tripwireWarnings(setup.trip.tripwires, (w) => setup.input.untrusted?.find((u) => u.player === w.player)?.deploy ?? untrustedDeploy(w, setup.boardIncome), (p) => setup.trip.estimatesNow.get(p),
|
|
1746
1953
|
// Under enemy_deploy the planner ignores the mark (#275 review): say what the what-if used.
|
|
1747
1954
|
enemy_deploy),
|
|
1955
|
+
...intel.warnings,
|
|
1748
1956
|
...(me.hasCommittedOrders
|
|
1749
1957
|
? [
|
|
1750
1958
|
'You have already committed orders this turn; warapp_submit_turn will refuse until you withdraw them ' +
|
|
@@ -1772,7 +1980,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1772
1980
|
...plan.warnings,
|
|
1773
1981
|
...promised,
|
|
1774
1982
|
...modsWarning(game.settings),
|
|
1775
|
-
...commerceWarning(game.settings),
|
|
1983
|
+
...commerceWarning(game.settings, setup.commerce),
|
|
1776
1984
|
...guardOffWarnings(graph, map, board, me.id, friendsOf(game.players, me), game.settings, plan.deploys, plan.moves),
|
|
1777
1985
|
];
|
|
1778
1986
|
// The plan advises Order Priority (a withdrawal, a commander strike): play the one I
|
|
@@ -1900,6 +2108,9 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1900
2108
|
...(advised ? { orderPriority: true } : {}),
|
|
1901
2109
|
});
|
|
1902
2110
|
const guessOrders = guess ? guessOrdersOf(orders, guess) : undefined;
|
|
2111
|
+
// #385: siege_target only means something under goal siege; say so rather than drop it silently.
|
|
2112
|
+
if (siege_target !== undefined && goal !== 'siege')
|
|
2113
|
+
warnings.push(`siege_target is ignored: it applies only with goal "siege" (this plan's goal is ${goal ?? 'chosen by the game profile'}).`);
|
|
1903
2114
|
// #317: a surrender waiting on my acceptance is the first thing said, before the commander's line.
|
|
1904
2115
|
const owedLine = surrenderOwedLine(surrenders);
|
|
1905
2116
|
if (owedLine)
|
|
@@ -1921,8 +2132,16 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1921
2132
|
...(chat ? { chat } : {}),
|
|
1922
2133
|
// #317: the surrenders pending (the game details; null: unreadable, never "none").
|
|
1923
2134
|
surrenderPending: surrenders,
|
|
2135
|
+
// #386: the intel warapp_record_intel kept and what this plan did with it (absent when none is kept).
|
|
2136
|
+
...(intel.report ? { intel: intel.report } : {}),
|
|
1924
2137
|
goal: plan.goal,
|
|
1925
2138
|
goalSource: goal !== undefined ? 'explicit' : 'profile',
|
|
2139
|
+
// #382: the siege's state (goal siege only).
|
|
2140
|
+
...(plan.siege ? { siege: plan.siege } : {}),
|
|
2141
|
+
// #361: the single-army jabs among the orders (attrition, never captures); absent with none.
|
|
2142
|
+
...(plan.jabs ? { jabs: plan.jabs } : {}),
|
|
2143
|
+
// #298: the contested bonuses pushed all-in or dropped after repeated failed attempts; absent with none.
|
|
2144
|
+
...(plan.bonusPush ? { bonusPush: plan.bonusPush } : {}),
|
|
1926
2145
|
// #276: the guard case first, on or off, with what it means for interior defence.
|
|
1927
2146
|
profile: rung === 'full'
|
|
1928
2147
|
? { guard: guardCase(game.settings), ...plan.profile }
|
|
@@ -1943,7 +2162,13 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1943
2162
|
// #304: the compact view keeps what the state rests on beside it (`evidence`).
|
|
1944
2163
|
outlook: rung === 'full'
|
|
1945
2164
|
? outlook
|
|
1946
|
-
: {
|
|
2165
|
+
: {
|
|
2166
|
+
state: outlook.state,
|
|
2167
|
+
basis: outlook.basis,
|
|
2168
|
+
...(outlook.evidence ? { evidence: outlook.evidence } : {}),
|
|
2169
|
+
// #368: even while bonuses kept falling.
|
|
2170
|
+
...(outlook.leaning ? { leaning: outlook.leaning } : {}),
|
|
2171
|
+
},
|
|
1947
2172
|
// Part D: the opponent reads (reported only, never planned on); absent when none is at the bar.
|
|
1948
2173
|
...(reads?.length
|
|
1949
2174
|
? {
|
|
@@ -1963,6 +2188,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1963
2188
|
...(pace ? { pace } : {}),
|
|
1964
2189
|
// #253: the army cap's arithmetic (min(income, round(cap × income) − my armies on the board)), when the game has one.
|
|
1965
2190
|
...(setup.incomeCap ? { incomeCapped: setup.incomeCap } : {}),
|
|
2191
|
+
// #332: a commerce game's gold and what it buys (the deploy total is `armies`, card armies on top).
|
|
2192
|
+
...(setup.commerce ? { commerce: { ...setup.commerce, ...cityAdviceOf(game.settings, setup.graph, setup.seen, me.id, setup.commerce.gold) } } : {}),
|
|
1966
2193
|
enemyDeploy: plan.enemyDeploy,
|
|
1967
2194
|
// #127: who moves first this turn and how it is known; null when unknown.
|
|
1968
2195
|
firstMover: mover.view,
|
|
@@ -2009,8 +2236,24 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2009
2236
|
plan.frontier.income < (plan.expected.nextIncomeIfConcededFall ?? plan.expected.nextIncome)
|
|
2010
2237
|
? `; the plan counts on ${plan.frontier.income}`
|
|
2011
2238
|
: ''}`,
|
|
2239
|
+
// #297: in a 1v1, the gates against the opponent's one floating deploy (compact: one line).
|
|
2240
|
+
...(plan.gates
|
|
2241
|
+
? {
|
|
2242
|
+
gates: rung === 'full'
|
|
2243
|
+
? { ...plan.gates, gates: plan.gates.gates.map((x) => ({ ...x, territory: name(x.id) })) }
|
|
2244
|
+
: `${plan.gates.gates.length} gates facing player ${plan.gates.player}${plan.gates.gates.some((x) => x.conceded) ? ` (${plan.gates.gates.filter((x) => x.conceded).length} conceded)` : ''}: they need ${plan.gates.need} against its one floating deploy, ${plan.gates.onGates} stand on them (${plan.gates.deficit} short across them), next income ${plan.gates.income}${plan.gates.short > 0 ? `: ${plan.gates.short} short` : ': it covers them'}`,
|
|
2245
|
+
}
|
|
2246
|
+
: {}),
|
|
2247
|
+
// #303: my income over the last turns and its slope (compact: one line).
|
|
2248
|
+
...(plan.incomeTrend
|
|
2249
|
+
? {
|
|
2250
|
+
incomeTrend: rung === 'full'
|
|
2251
|
+
? plan.incomeTrend
|
|
2252
|
+
: `${plan.incomeTrend.turns.map((t) => t.income).join(' → ')} over turns ${plan.incomeTrend.turns[0].turn}–${plan.incomeTrend.turns[plan.incomeTrend.turns.length - 1].turn}: ${plan.incomeTrend.slope >= 0 ? '+' : ''}${plan.incomeTrend.slope}/turn${plan.incomeTrend.flat ? ', flat' : ''}`,
|
|
2253
|
+
}
|
|
2254
|
+
: {}),
|
|
2012
2255
|
// #275 (a): each border's headroom, the weakest first (compact: the first few).
|
|
2013
|
-
headroom: headroomView(headroom, map, myIncome, rung === 'full', !teamsKnown),
|
|
2256
|
+
headroom: headroomView(headroom, map, myIncome, rung === 'full', !teamsKnown, (p) => estimates.find((e) => e.playerId === p)?.estimate),
|
|
2014
2257
|
...(rung !== 'full' && headroom.length > HEADROOM_COMPACT ? { headroomMore: headroom.length - HEADROOM_COMPACT } : {}),
|
|
2015
2258
|
// #72: the offensive options considered, full view only.
|
|
2016
2259
|
...(rung === 'full' ? { offence: plan.offence.map((o) => ({ ...o, target: name(o.target) })) } : {}),
|
|
@@ -2259,6 +2502,17 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2259
2502
|
.describe('Only in a Commanders game, when the orders leave your commander takeable by a single-deploy reply (the refusal ' +
|
|
2260
2503
|
'says so and names the armies that would hold): true submits them anyway, and the result records the risk ' +
|
|
2261
2504
|
'taken (`commanderRiskAccepted`). Losing the commander loses the game: ask the owner first.'),
|
|
2505
|
+
cities: z
|
|
2506
|
+
.array(z.object({
|
|
2507
|
+
territory: territoryRef.describe('Your territory to build on: id or name.'),
|
|
2508
|
+
count: z.coerce.number().int().min(1).max(MAX_CITIES_PER_ORDER).describe('Cities to build there.'),
|
|
2509
|
+
}))
|
|
2510
|
+
.max(MAX_CITIES_PER_ORDER)
|
|
2511
|
+
.optional()
|
|
2512
|
+
.describe('Commerce games that allow cities only (#332): cities to buy this turn with your gold, on your own territories — ' +
|
|
2513
|
+
"e.g. `commerce.cityAdvice` from warapp_plan_turn. Their cost (the game's formula) comes out of the same gold as " +
|
|
2514
|
+
'the deploys, so deploy that much less. One purchase per turn. The purchase encoding is read from the client, ' +
|
|
2515
|
+
'UNVERIFIED live: the preview says so.'),
|
|
2262
2516
|
});
|
|
2263
2517
|
defineGatedWrite(server, {
|
|
2264
2518
|
title: 'Submit my turn in a war.app game',
|
|
@@ -2273,7 +2527,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2273
2527
|
'(`target`), Surveillance (`bonus`), Airlift (`from` yours, `to` yours or a teammate\'s, `armies`, optional ' +
|
|
2274
2528
|
'`commander`), Gift (`target` yours, `player`), Diplomacy (`players`: two), Sanctions (`player`), Bomb (`target` ' +
|
|
2275
2529
|
"next to yours, not yours or a teammate's) and Emergency Blockade (`target` yours, never your commander's), encoded " +
|
|
2276
|
-
'as the client does (the Airlift verified live; the others not yet), each refused where war.app would refuse it (a commander is never ' +
|
|
2530
|
+
'as the client does (the Airlift and Diplomacy verified live; the others not yet), each refused where war.app would refuse it (a commander is never ' +
|
|
2277
2531
|
'gifted or airlifted to a teammate, no Spy or Sanctions on yourself or a teammate, no Diplomacy between ' +
|
|
2278
2532
|
'teammates); discards any card (`{ kind: "discard", card }`); refuses ' +
|
|
2279
2533
|
'when your hand is over the hold limit and the orders do not play or discard enough cards; in a team game warns ' +
|
|
@@ -2315,7 +2569,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2315
2569
|
openWorld: true,
|
|
2316
2570
|
}),
|
|
2317
2571
|
inputSchema: submitSchema,
|
|
2318
|
-
async plan({ game_id, player, orders, income: givenIncome, break_agreement, accept_commander_risk }) {
|
|
2572
|
+
async plan({ game_id, player, orders, income: givenIncome, break_agreement, accept_commander_risk, cities }) {
|
|
2319
2573
|
const feed = await ctx.client.getGame(parseGameId(game_id), { settings: true });
|
|
2320
2574
|
requireTurnPhase(feed);
|
|
2321
2575
|
// The bridge always acts as the signed-in account: an explicit `player` naming anyone
|
|
@@ -2371,9 +2625,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2371
2625
|
const board = withTeammateOrders(boardStateFromLive(territories, me, game.players), info, me, game.players);
|
|
2372
2626
|
const playerId = inGameId(me);
|
|
2373
2627
|
const rules = cardRules(game.settings);
|
|
2374
|
-
// A team shares one hand (#163):
|
|
2375
|
-
//
|
|
2376
|
-
// as before, and the team's gathered count is a warning until a live team board verifies it.
|
|
2628
|
+
// A team shares one hand (#163, V8 #310): the standing keeps each player's cards under that player's
|
|
2629
|
+
// id, and the team's hand is all of them, counted against the one limit (teamCardLimit).
|
|
2377
2630
|
const owners = handOwners(game, me);
|
|
2378
2631
|
const myHand = readHand(info, playerId);
|
|
2379
2632
|
const hand = owners.length > 1 ? readHand(info, owners) : myHand;
|
|
@@ -2393,12 +2646,14 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2393
2646
|
const placedAt = (p) => (p.before !== undefined && p.before <= moves.length ? p.before : undefined);
|
|
2394
2647
|
const discards = resolveDiscards(pickFrom, plays, discardInputs);
|
|
2395
2648
|
// Every play and discard takes its card out of the hand; war.app refuses (error 51) while more
|
|
2396
|
-
// than MaxCardsHold remain (verified, #20).
|
|
2649
|
+
// than MaxCardsHold remain (verified, #20). In a team game the hand is the team's, less what my
|
|
2650
|
+
// committed teammates' orders use, and war.app refuses only the last of the team to commit (V8, #310).
|
|
2397
2651
|
const used = plays.length + discards.length;
|
|
2398
|
-
const
|
|
2652
|
+
const team = owners.length > 1 ? teamCardLimit(hand, rules, teammatesOf(game.players, me), board.teammateOrders) : undefined;
|
|
2653
|
+
const shed = team ? (team.binding ? team.shed : 0) : cardsToShed(myHand, rules);
|
|
2399
2654
|
if (used < shed)
|
|
2400
|
-
throw mustPlayCard(myHand, rules, shed, used);
|
|
2401
|
-
const teamShed =
|
|
2655
|
+
throw mustPlayCard(team ? team.left : myHand, rules, shed, used, team !== undefined);
|
|
2656
|
+
const teamShed = team && !team.binding ? team.shed : 0;
|
|
2402
2657
|
for (const p of plays) {
|
|
2403
2658
|
const t = p.target && territories.find((x) => x.territoryId === p.target.id);
|
|
2404
2659
|
if (p.target && (!t || t.fogged || t.owner !== playerId)) {
|
|
@@ -2456,7 +2711,16 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2456
2711
|
const options = checkMoveOptions({ moves, board: territories, myInGameId: playerId, settings: game.settings, teammates, deployedOn });
|
|
2457
2712
|
// #253: the army cap's cut included (min(income, round(cap × income) − my armies on the board)).
|
|
2458
2713
|
const incomeOnBoard = incomeDetail(graphOf(map), board, me.id, game.settings);
|
|
2459
|
-
|
|
2714
|
+
// #332: in a commerce game the deploy is what my gold buys, as warapp_plan_turn has it.
|
|
2715
|
+
const commerceGold = commerceDeployOf(game, me, info, incomeOnBoard.income);
|
|
2716
|
+
// #332: cities bought this turn come out of the same gold, before the deploys (purchases run in phase 0).
|
|
2717
|
+
const purchase = cityPurchaseOf(game, cities ?? [], map, territories, playerId, commerceGold);
|
|
2718
|
+
// What is left for the deploys keeps the gold's source: only gold read from the board is enforced (#353 review).
|
|
2719
|
+
const commerce = commerceGold && purchase
|
|
2720
|
+
? commerceDeploy(commerceRules(game.settings), commerceGold.source === 'standing' ? commerceGold.gold - purchase.cost : undefined, commerceGold.gold - purchase.cost)
|
|
2721
|
+
: commerceGold;
|
|
2722
|
+
const commerceCheck = submitCommerceCheck(commerce);
|
|
2723
|
+
const modelled = commerce ? commerce.armies : incomeOnBoard.income;
|
|
2460
2724
|
const cardArmies = plays.reduce((sum, p) => sum + p.armies, 0);
|
|
2461
2725
|
// #130: war.app's own number, given after an error 11, replaces the model for the check.
|
|
2462
2726
|
const income = (givenIncome ?? modelled) + cardArmies;
|
|
@@ -2502,6 +2766,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2502
2766
|
guard: game.settings?.oneArmyStandsGuard ?? true,
|
|
2503
2767
|
deploys,
|
|
2504
2768
|
moves,
|
|
2769
|
+
...(commerceCheck.commerce && givenIncome === undefined ? { commerce: commerceCheck.commerce } : {}),
|
|
2505
2770
|
airlifts: plays.flatMap((p) => p.kind === 'Airlift' && p.targets?.from && p.targets.to && p.targets.armies !== undefined
|
|
2506
2771
|
? [{ from: p.targets.from.id, to: p.targets.to.id, armies: p.targets.armies }]
|
|
2507
2772
|
: []),
|
|
@@ -2516,7 +2781,10 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2516
2781
|
}),
|
|
2517
2782
|
incomeUncertain: givenIncome !== undefined
|
|
2518
2783
|
? []
|
|
2519
|
-
:
|
|
2784
|
+
: [
|
|
2785
|
+
...deployCheckUncertainties(game.settings, incomeOnBoard.cap ? { armyCap: incomeOnBoard.cap } : {}),
|
|
2786
|
+
...commerceCheck.uncertain,
|
|
2787
|
+
],
|
|
2520
2788
|
poolsUncertain: [
|
|
2521
2789
|
...overrideUncertainties(game.settings),
|
|
2522
2790
|
...(overridden ? [`The ${overridden}, so the bonus pools may differ too.`] : []),
|
|
@@ -2559,9 +2827,9 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2559
2827
|
const unverifiedPlays = [...new Set(plays.filter((p) => UNVERIFIED_CARD_PLAYS.has(p.kind)).map((p) => p.card.name))];
|
|
2560
2828
|
if (unverifiedPlays.length)
|
|
2561
2829
|
warnings.push(unverifiedCardWarning(unverifiedPlays));
|
|
2562
|
-
if (used < teamShed)
|
|
2563
|
-
warnings.push(teamHandOver(
|
|
2564
|
-
// V8:
|
|
2830
|
+
if (team && used < teamShed)
|
|
2831
|
+
warnings.push(teamHandOver(team, rules, used));
|
|
2832
|
+
// V8 (#310): war.app's order check takes a teammate's card, but none has been played live: a warning.
|
|
2565
2833
|
const theirs = [...plays.map((p) => p.card), ...discards].filter((c) => !isMyCard(c, playerId));
|
|
2566
2834
|
if (theirs.length)
|
|
2567
2835
|
warnings.push(teammateCardWarning(theirs));
|
|
@@ -2673,6 +2941,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2673
2941
|
}));
|
|
2674
2942
|
if (belowPlan)
|
|
2675
2943
|
warnings.push(belowPlan);
|
|
2944
|
+
if (purchase)
|
|
2945
|
+
warnings.push(purchase.note);
|
|
2676
2946
|
// The owner, 2026-11-17: while an older build stands in for a client this server cannot read, say so first.
|
|
2677
2947
|
const standInNote = standInLine(standInOf(ctx));
|
|
2678
2948
|
if (standInNote)
|
|
@@ -2687,6 +2957,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2687
2957
|
merged.set(d.territory.id, { ...d });
|
|
2688
2958
|
}
|
|
2689
2959
|
const send = [
|
|
2960
|
+
...(purchase ? [{ kind: 'purchase', cities: purchase.cities.map((c) => ({ territoryId: c.territory.id, count: c.count })) }] : []),
|
|
2690
2961
|
...discards.map((c) => ({ kind: 'discard', cardId: c.id })),
|
|
2691
2962
|
...plays.map((p) => ({
|
|
2692
2963
|
kind: 'card',
|
|
@@ -2712,6 +2983,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2712
2983
|
}),
|
|
2713
2984
|
];
|
|
2714
2985
|
const named = [
|
|
2986
|
+
...(purchase ? [{ kind: 'purchase', cities: purchase.cities }] : []),
|
|
2715
2987
|
...discards.map((c) => ({ kind: 'discard', card: cardView(c) })),
|
|
2716
2988
|
...plays.map((p) => ({
|
|
2717
2989
|
kind: 'card',
|