@chrischall/warapp-mcp 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +7 -6
- package/dist/analysis/airlift-plan.js +288 -0
- package/dist/analysis/blockade-plan.js +178 -0
- package/dist/analysis/bomb-plan.js +72 -0
- package/dist/analysis/card-threats.js +10 -9
- package/dist/analysis/cards-in-effect.js +20 -0
- package/dist/analysis/combat.js +5 -0
- package/dist/analysis/coordination.js +47 -0
- package/dist/analysis/lookahead.js +4 -0
- package/dist/analysis/plan/relations.js +57 -8
- package/dist/analysis/player-record.js +1 -0
- package/dist/analysis/relations.js +40 -0
- package/dist/analysis/stress.js +42 -2
- package/dist/analysis/turn-sim.js +62 -0
- package/dist/bundle.js +23219 -21662
- package/dist/card-state.js +157 -0
- package/dist/local-time.js +142 -0
- package/dist/relations-store.js +30 -5
- package/dist/tools/airlift-readback.js +87 -0
- package/dist/tools/alternative-orders.js +21 -0
- package/dist/tools/begin-turn.js +19 -5
- package/dist/tools/card-advice.js +5 -4
- package/dist/tools/card-plays.js +32 -20
- package/dist/tools/card-state-view.js +26 -0
- package/dist/tools/card-support-advice.js +25 -8
- package/dist/tools/chat-inbox.js +1 -1
- package/dist/tools/chat.js +1 -1
- package/dist/tools/check-plan.js +90 -8
- package/dist/tools/game.js +11 -2
- package/dist/tools/index.js +7 -1
- package/dist/tools/notifications.js +1 -1
- package/dist/tools/player-card-readback.js +45 -0
- package/dist/tools/relations.js +146 -14
- package/dist/tools/sanctions-played.js +51 -0
- package/dist/tools/turn.js +479 -13
- package/dist/version.js +1 -1
- package/manifest.json +9 -2
- package/mint.yaml +7 -0
- package/package.json +1 -1
- package/server.json +8 -2
package/dist/tools/turn.js
CHANGED
|
@@ -22,7 +22,15 @@ import { KNOWN_MODS } from '../known-mods.js';
|
|
|
22
22
|
import { assumedWarning, awardView, firstMoverFor, loadAward, openingThreat } from './award.js';
|
|
23
23
|
import { boardCardsInEffect, CARDS_IN_EFFECT_UNVERIFIED, sanctionMyIncome } from './card-effects.js';
|
|
24
24
|
import { sanctionPercentage } from '../analysis/cards-in-effect.js';
|
|
25
|
-
import { readMyOrderList } from '../my-orders.js';
|
|
25
|
+
import { myOrdersOf as committedOrdersOf, readMyOrderList } from '../my-orders.js';
|
|
26
|
+
import { checkAirlifts, checkTargeted, mismatchMessage, recordedWithCommit, sentAirlifts, sentTargeted, targetedMismatchParts } from './airlift-readback.js';
|
|
27
|
+
import { checkPlayerCards, playerCardMismatchParts, READ_BACK_PLAYER_CARDS, sentPlayerCards } from './player-card-readback.js';
|
|
28
|
+
import { alternativeOrders, cardsLeftAfter, playsCardType } from './alternative-orders.js';
|
|
29
|
+
/** The territory-targeted card plays read back after a commit (owner request 2026-11-24, part B). */
|
|
30
|
+
const READ_BACK_TARGETED = new Set(['Bomb', 'Blockade', 'EmergencyBlockade']);
|
|
31
|
+
import { compareScores, planAirlift, STAGING_DISCOUNT } from '../analysis/airlift-plan.js';
|
|
32
|
+
import { planBomb } from '../analysis/bomb-plan.js';
|
|
33
|
+
import { planBlockade, planWall } from '../analysis/blockade-plan.js';
|
|
26
34
|
import { breaksInOrders } from '../mod-alliances.js';
|
|
27
35
|
import { allyAttackLine, attacksOnAllies, MOD_ALLIANCES_NOTE, modAllianceWarnings, readModAlliances } from './mod-alliances.js';
|
|
28
36
|
import { adviseCards, cardGame, cardPieceOption, giftInOrders, intelOrders, handOwners, lastTurnPlays, opponentCanHold, opponentReinforcement, reinforcementPlaysShown, seenReinforcementPlays, TEAM_HAND } from './card-advice.js';
|
|
@@ -33,7 +41,7 @@ import { blockedLog, CHAT_BLOCKS_NOTE, chatSeats, planChatView, planStanding, tu
|
|
|
33
41
|
import { chatBlockLine } from '../analysis/chat-blocks.js';
|
|
34
42
|
import { chatAutomationMode, chatBlocksTurnMode } from '../chat-automation.js';
|
|
35
43
|
import { readPendingSurrenders, surrenderOwedLine } from './surrender-pending.js';
|
|
36
|
-
import { failureText, loadLiveGame, requireApprovedAccount, standInLine, standInOf, writeAccount } from './live-context.js';
|
|
44
|
+
import { failureText, loadLiveGame, readLatestBoard, requireApprovedAccount, standInLine, standInOf, writeAccount } from './live-context.js';
|
|
37
45
|
import { BRIDGE_NOTE, playerArg, resolveMe } from './live.js';
|
|
38
46
|
import { guessOrdersOf, guessView } from './guess-view.js';
|
|
39
47
|
import { guessSalt, peekGuessSalt } from '../guess-salt.js';
|
|
@@ -63,12 +71,13 @@ import { readDecisionLog, scrubNames } from '../decision-log.js';
|
|
|
63
71
|
import { readPickRecord } from '../pick-list.js';
|
|
64
72
|
import { commitmentWarnings } from '../analysis/commitments.js';
|
|
65
73
|
import { MAX_EXCEPTION_NOTE, planRelationsFrom, truceBreaksIn } from '../analysis/relations.js';
|
|
66
|
-
import { exceptionNote, recordBrokenByMe, recordPartnerApproved } from './relations.js';
|
|
74
|
+
import { coordinationView, exceptionNote, recordBrokenByMe, recordPartnerApproved } from './relations.js';
|
|
67
75
|
import { readPlayerRecord } from '../player-record-store.js';
|
|
68
76
|
import { withTeammateOrders } from '../team-orders.js';
|
|
69
77
|
import { claimedCardUses, claimedCardWarning, teamCardClaims, teamCardLimit, teamCardRoles, teamHandLeft, unclaimedFirst, } from '../team-cards.js';
|
|
70
78
|
import { isTeamGame, teammatesOf } from '../teams.js';
|
|
71
79
|
import { readLedger, recordTruceUsage } from '../relations-store.js';
|
|
80
|
+
import { coordinationDue, coordinationLine } from '../analysis/coordination.js';
|
|
72
81
|
import { resolveIntel } from '../analysis/intel.js';
|
|
73
82
|
import { readSiegeMemory, writeSiegeMemory } from '../siege-store.js';
|
|
74
83
|
import { readBonusAttempts, writeBonusAttempts } from '../bonus-attempt-store.js';
|
|
@@ -169,7 +178,8 @@ const turnOrderArg = z.discriminatedUnion('kind', [
|
|
|
169
178
|
player: playerRef
|
|
170
179
|
.optional()
|
|
171
180
|
.describe("Spy: the opponent to see (0 or \"neutral\": the neutral, when the game's Spy card allows it). Sanctions: the player whose " +
|
|
172
|
-
|
|
181
|
+
"income it changes — an opponent when the game's percentage is positive, yourself (or a teammate) when it is negative " +
|
|
182
|
+
'(a boost). Gift: who receives `target`. Id or name.'),
|
|
173
183
|
players: z
|
|
174
184
|
.array(playerRef)
|
|
175
185
|
.length(2)
|
|
@@ -1647,6 +1657,309 @@ export async function livePlanSetup(ctx, a) {
|
|
|
1647
1657
|
seenPlays: playsShown ? lastPlays : undefined,
|
|
1648
1658
|
};
|
|
1649
1659
|
}
|
|
1660
|
+
/** The Airlift card's type id. */
|
|
1661
|
+
const CARD_AIRLIFT = 6;
|
|
1662
|
+
/**
|
|
1663
|
+
* Owner request 2026-11-24 (part 3): `airliftPlan`, the best plan that plays my Airlift cards, beside the plain plan
|
|
1664
|
+
* (`src/analysis/airlift-plan.ts`; the plain plan and its `orders` never change). Only when I hold an Airlift card:
|
|
1665
|
+
* `undefined` otherwise, so a hand without one adds no field. Its orders are the plain orders' card plays and
|
|
1666
|
+
* discards, the Airlift plays, then the Airlift plan's deploys and moves; the advised Order Delay is left out (its
|
|
1667
|
+
* place names a move of the plain plan) and, when it had to leave the hand, discarded instead. A plan the submit's
|
|
1668
|
+
* commander check would refuse while the plain plan passes it is not offered.
|
|
1669
|
+
*/
|
|
1670
|
+
async function airliftPlanView(a) {
|
|
1671
|
+
const used = new Set([...a.cards.plays, ...a.cards.discards].map((c) => c.id));
|
|
1672
|
+
const held = a.myCards.filter((c) => c.type === CARD_AIRLIFT);
|
|
1673
|
+
if (!held.length)
|
|
1674
|
+
return undefined;
|
|
1675
|
+
const free = held.filter((c) => !used.has(c.id));
|
|
1676
|
+
const playable = Math.max(0, free.length - a.keepCards);
|
|
1677
|
+
const none = (note) => ({ airliftPlan: null, airliftPlanNote: note });
|
|
1678
|
+
if (!playable)
|
|
1679
|
+
return none(`You hold ${held.length} Airlift card${held.length === 1 ? '' : 's'}, ${free.length < held.length ? 'the plain plan already uses some, and ' : ''}` +
|
|
1680
|
+
`${a.keepCards} ${a.keepCards === 1 ? 'is' : 'are'} kept in reserve (keep_cards): no Airlift plan.`);
|
|
1681
|
+
if (a.gift.cards.length)
|
|
1682
|
+
return none('The plain plan plays a Gift, which lands after an Airlift: no Airlift plan is made beside it.');
|
|
1683
|
+
const guardOn = a.game.settings?.oneArmyStandsGuard !== false;
|
|
1684
|
+
const found = planAirlift({ input: a.setup.input, plain: a.plan, cards: playable, guard: guardOn });
|
|
1685
|
+
if (!found.best)
|
|
1686
|
+
return none(`No Airlift beats the plain plan by its own measure (next income if its conceded borders fall, plus ${STAGING_DISCOUNT} × ` +
|
|
1687
|
+
`a staged capture's bonus next turn, then next income, ` +
|
|
1688
|
+
`fewer concessions, more captures): ${found.considered} tried${found.invalid ? `, ${found.invalid} dropped as orders the submit would refuse` : ''}.`);
|
|
1689
|
+
const best = found.best;
|
|
1690
|
+
const moves = best.plan.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { withCommander: true } : {}) }));
|
|
1691
|
+
const checked = await commanderCheck(a.ctx, {
|
|
1692
|
+
game: a.game,
|
|
1693
|
+
me: a.me,
|
|
1694
|
+
map: a.map,
|
|
1695
|
+
seen: a.seen,
|
|
1696
|
+
turn: a.turn,
|
|
1697
|
+
info: a.info,
|
|
1698
|
+
hand: a.hand,
|
|
1699
|
+
income: a.setup.boardIncome,
|
|
1700
|
+
tripwires: a.setup.trip.tripwires,
|
|
1701
|
+
deploys: best.plan.deploys,
|
|
1702
|
+
moves,
|
|
1703
|
+
// #558: the Airlift orders carry the plain card plays, an advised Order Priority included.
|
|
1704
|
+
orderPriority: playsCardType(a.orders, a.myCards, CARD_ORDER_PRIORITY),
|
|
1705
|
+
...(a.enemyDeploy !== undefined ? { floor: a.enemyDeploy } : {}),
|
|
1706
|
+
killedBy: false,
|
|
1707
|
+
airlifts: best.airlifts.map(({ from, to, armies }) => ({ from, to, armies })),
|
|
1708
|
+
});
|
|
1709
|
+
if (checked?.risk && a.plainCommanderSafe)
|
|
1710
|
+
return none('The best Airlift plan would leave your commander takeable (warapp_submit_turn would refuse it), so none is offered.');
|
|
1711
|
+
const lifts = best.airlifts.map((l, i) => ({ ...l, card: free[i].id }));
|
|
1712
|
+
// #558: the advised Order Delay is discarded only when the plain card choice had to shed it.
|
|
1713
|
+
const orders = alternativeOrders({
|
|
1714
|
+
orders: a.orders,
|
|
1715
|
+
delayOrder: a.delayOrder,
|
|
1716
|
+
playedDelay: a.playedDelay,
|
|
1717
|
+
delayMustGo: a.playedDelay !== undefined && a.cards.discards.some((c) => c.id === a.playedDelay),
|
|
1718
|
+
cardPlays: lifts.map((l) => ({ kind: 'card', card: l.card, from: l.from, to: l.to, armies: l.armies })),
|
|
1719
|
+
deploys: best.plan.deploys.map((d) => ({ kind: 'deploy', territory: d.territoryId, armies: d.armies })),
|
|
1720
|
+
moves: best.plan.moves.map((m) => ({ kind: 'move', from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { commander: true } : {}) })),
|
|
1721
|
+
});
|
|
1722
|
+
const minus = (x, y) => x.filter((v) => !y.includes(v)).sort((p, q) => p - q);
|
|
1723
|
+
const atRisk = (p) => (p.expected.bonusesAtRisk ?? []).map((b) => b.bonusId);
|
|
1724
|
+
return {
|
|
1725
|
+
airliftPlan: {
|
|
1726
|
+
airlifts: lifts.map((l) => ({ from: a.name(l.from), to: a.name(l.to), armies: l.armies, kind: l.kind })),
|
|
1727
|
+
// Owner decision 2026-11-24 (A, DRAFT): an Airlift staged for next turn's capture.
|
|
1728
|
+
...(lifts.some((l) => l.staging)
|
|
1729
|
+
? {
|
|
1730
|
+
staging: lifts.flatMap((l) => l.staging
|
|
1731
|
+
? [{ target: a.name(l.staging.target), from: a.name(l.to), nextTurnAttack: l.staging.attack, defendersSizedFor: l.staging.defenders, bonusValue: l.staging.gain }]
|
|
1732
|
+
: []),
|
|
1733
|
+
}
|
|
1734
|
+
: {}),
|
|
1735
|
+
orders,
|
|
1736
|
+
expected: {
|
|
1737
|
+
captures: best.plan.expected.captures,
|
|
1738
|
+
bonusesCompleted: best.plan.expected.bonusesCompleted,
|
|
1739
|
+
nextIncome: best.plan.expected.nextIncome,
|
|
1740
|
+
...(best.plan.expected.nextIncomeIfConcededFall !== undefined ? { nextIncomeIfConcededFall: best.plan.expected.nextIncomeIfConcededFall } : {}),
|
|
1741
|
+
},
|
|
1742
|
+
delta: {
|
|
1743
|
+
twoTurn: Math.round((best.score.twoTurn - best.plainScore.twoTurn) * 100) / 100,
|
|
1744
|
+
nextIncomeIfConcededFall: best.score.safeIncome - best.plainScore.safeIncome,
|
|
1745
|
+
nextIncome: best.score.nextIncome - best.plainScore.nextIncome,
|
|
1746
|
+
captures: best.score.captures - best.plainScore.captures,
|
|
1747
|
+
borders: { saved: minus(a.plan.conceded, best.plan.conceded), conceded: minus(best.plan.conceded, a.plan.conceded) },
|
|
1748
|
+
bonuses: {
|
|
1749
|
+
completed: minus(best.plan.expected.bonusesCompleted, a.plan.expected.bonusesCompleted),
|
|
1750
|
+
notCompleted: minus(a.plan.expected.bonusesCompleted, best.plan.expected.bonusesCompleted),
|
|
1751
|
+
saved: minus(atRisk(a.plan), atRisk(best.plan)),
|
|
1752
|
+
atRisk: minus(atRisk(best.plan), atRisk(a.plan)),
|
|
1753
|
+
},
|
|
1754
|
+
},
|
|
1755
|
+
cardsSpent: lifts.length,
|
|
1756
|
+
// #558: the Airlift cards the plain plan leaves, less those this plan spends.
|
|
1757
|
+
cardsLeft: cardsLeftAfter({ held: held.length, free: free.length, spent: lifts.length }),
|
|
1758
|
+
keepCards: a.keepCards,
|
|
1759
|
+
considered: best.considered,
|
|
1760
|
+
...(checked ? { commander: { safe: !checked.risk, ...(checked.risk ? { needs: checked.risk.needs } : {}) } } : {}),
|
|
1761
|
+
note: AIRLIFT_PLAN_NOTE,
|
|
1762
|
+
},
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
/** The Bomb card's type id. */
|
|
1766
|
+
const CARD_BOMB = 13;
|
|
1767
|
+
/**
|
|
1768
|
+
* Owner request 2026-11-24 (part B): `bombPlan`, the best plan that plays one Bomb card, beside the plain plan
|
|
1769
|
+
* (`src/analysis/bomb-plan.ts`; the plain plan and its `orders` never change). Only when I hold a Bomb card. Its
|
|
1770
|
+
* orders: the plain card plays and discards, the Bomb play, then the Bomb plan's deploys and moves (the advised Order
|
|
1771
|
+
* Delay left out, as in the Airlift plan). A plan the submit's commander check would refuse while the plain plan
|
|
1772
|
+
* passes it is not offered.
|
|
1773
|
+
*/
|
|
1774
|
+
async function bombPlanView(a) {
|
|
1775
|
+
const used = new Set([...a.cards.plays, ...a.cards.discards].map((c) => c.id));
|
|
1776
|
+
const held = a.myCards.filter((c) => c.type === CARD_BOMB);
|
|
1777
|
+
if (!held.length)
|
|
1778
|
+
return undefined;
|
|
1779
|
+
const free = held.filter((c) => !used.has(c.id));
|
|
1780
|
+
const none = (note) => ({ bombPlan: null, bombPlanNote: note });
|
|
1781
|
+
if (!free.length)
|
|
1782
|
+
return none('The plain plan already plays or discards your Bomb card: no Bomb plan.');
|
|
1783
|
+
const found = planBomb({ input: a.setup.input, plain: a.plan, cards: free.length });
|
|
1784
|
+
if (!found.best)
|
|
1785
|
+
return none(`No Bomb beats the plain plan by its own measure (next income if its conceded borders fall, then next income, fewer ` +
|
|
1786
|
+
`concessions, more captures): ${found.considered} target${found.considered === 1 ? '' : 's'} tried.`);
|
|
1787
|
+
const best = found.best;
|
|
1788
|
+
const checked = await commanderCheck(a.ctx, {
|
|
1789
|
+
game: a.game,
|
|
1790
|
+
me: a.me,
|
|
1791
|
+
map: a.map,
|
|
1792
|
+
seen: a.seen,
|
|
1793
|
+
turn: a.turn,
|
|
1794
|
+
info: a.info,
|
|
1795
|
+
hand: a.hand,
|
|
1796
|
+
income: a.setup.boardIncome,
|
|
1797
|
+
tripwires: a.setup.trip.tripwires,
|
|
1798
|
+
deploys: best.plan.deploys,
|
|
1799
|
+
moves: best.plan.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { withCommander: true } : {}) })),
|
|
1800
|
+
orderPriority: playsCardType(a.orders, a.myCards, CARD_ORDER_PRIORITY),
|
|
1801
|
+
...(a.enemyDeploy !== undefined ? { floor: a.enemyDeploy } : {}),
|
|
1802
|
+
killedBy: false,
|
|
1803
|
+
});
|
|
1804
|
+
if (checked?.risk && a.plainCommanderSafe)
|
|
1805
|
+
return none('The best Bomb plan would leave your commander takeable (warapp_submit_turn would refuse it), so none is offered.');
|
|
1806
|
+
const card = free[0].id;
|
|
1807
|
+
// #558: the advised Order Delay is discarded only when the plain card choice had to shed it.
|
|
1808
|
+
const orders = alternativeOrders({
|
|
1809
|
+
orders: a.orders,
|
|
1810
|
+
delayOrder: a.delayOrder,
|
|
1811
|
+
playedDelay: a.playedDelay,
|
|
1812
|
+
delayMustGo: a.playedDelay !== undefined && a.cards.discards.some((c) => c.id === a.playedDelay),
|
|
1813
|
+
cardPlays: [{ kind: 'card', card, target: best.bomb.target }],
|
|
1814
|
+
deploys: best.plan.deploys.map((d) => ({ kind: 'deploy', territory: d.territoryId, armies: d.armies })),
|
|
1815
|
+
moves: best.plan.moves.map((m) => ({ kind: 'move', from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { commander: true } : {}) })),
|
|
1816
|
+
});
|
|
1817
|
+
const minus = (x, y) => x.filter((v) => !y.includes(v)).sort((p, q) => p - q);
|
|
1818
|
+
return {
|
|
1819
|
+
bombPlan: {
|
|
1820
|
+
bomb: { target: a.name(best.bomb.target), kind: best.bomb.kind, armies: best.bomb.armies, leaves: best.bomb.left },
|
|
1821
|
+
orders,
|
|
1822
|
+
expected: {
|
|
1823
|
+
captures: best.plan.expected.captures,
|
|
1824
|
+
bonusesCompleted: best.plan.expected.bonusesCompleted,
|
|
1825
|
+
nextIncome: best.plan.expected.nextIncome,
|
|
1826
|
+
...(best.plan.expected.nextIncomeIfConcededFall !== undefined ? { nextIncomeIfConcededFall: best.plan.expected.nextIncomeIfConcededFall } : {}),
|
|
1827
|
+
},
|
|
1828
|
+
delta: {
|
|
1829
|
+
nextIncomeIfConcededFall: best.score.safeIncome - best.plainScore.safeIncome,
|
|
1830
|
+
nextIncome: best.score.nextIncome - best.plainScore.nextIncome,
|
|
1831
|
+
captures: best.score.captures - best.plainScore.captures,
|
|
1832
|
+
borders: { saved: minus(a.plan.conceded, best.plan.conceded), conceded: minus(best.plan.conceded, a.plan.conceded) },
|
|
1833
|
+
},
|
|
1834
|
+
cardsSpent: 1,
|
|
1835
|
+
cardsLeft: cardsLeftAfter({ held: held.length, free: free.length, spent: 1 }),
|
|
1836
|
+
considered: found.considered,
|
|
1837
|
+
...(checked ? { commander: { safe: !checked.risk, ...(checked.risk ? { needs: checked.risk.needs } : {}) } } : {}),
|
|
1838
|
+
note: BOMB_PLAN_NOTE,
|
|
1839
|
+
},
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
/** The Emergency Blockade card's type id (the Blockade's is `CARD_BLOCKADE`, from src/cards.ts). */
|
|
1843
|
+
const CARD_EMERGENCY_BLOCKADE = 3;
|
|
1844
|
+
/**
|
|
1845
|
+
* Owner request 2026-11-24 (part B): `blockadePlan`, the best wall plan beside the plain plan, whose `orders` never
|
|
1846
|
+
* change (`src/analysis/blockade-plan.ts`). Only when I hold an Emergency Blockade or a Blockade card: an Emergency
|
|
1847
|
+
* Blockade walls a conceded border before every move (`planWall`, the walled board planned), a Blockade walls a
|
|
1848
|
+
* territory after the attacks while the stress-tested line keeps it mine (`planBlockade`, the plain orders plus the
|
|
1849
|
+
* card); each is worth the bonus its fall would hand an opponent (× 0.8, owner-approved 2026-11-24), and the better
|
|
1850
|
+
* of the two is offered (`card` names it).
|
|
1851
|
+
*/
|
|
1852
|
+
async function blockadePlanView(a) {
|
|
1853
|
+
const used = new Set([...a.cards.plays, ...a.cards.discards].map((c) => c.id));
|
|
1854
|
+
const walls = a.myCards.filter((c) => c.type === CARD_EMERGENCY_BLOCKADE);
|
|
1855
|
+
const blockades = a.myCards.filter((c) => c.type === CARD_BLOCKADE);
|
|
1856
|
+
if (!walls.length && !blockades.length)
|
|
1857
|
+
return undefined;
|
|
1858
|
+
const none = (note) => ({ blockadePlan: null, blockadePlanNote: note });
|
|
1859
|
+
const multiplierOf = (key) => {
|
|
1860
|
+
const raw = a.game.settings?.raw[key];
|
|
1861
|
+
return typeof raw === 'object' && raw !== null ? Number(raw.MultiplyAmount) : Number.NaN;
|
|
1862
|
+
};
|
|
1863
|
+
// Each wall card held and not used by the plain plan: the Emergency Blockade (phase 37, the walled board planned) and
|
|
1864
|
+
// the Blockade (phase 60, owner decision 2026-11-24: the plain orders plus the card); the better plan is offered.
|
|
1865
|
+
const freeWalls = walls.filter((c) => !used.has(c.id));
|
|
1866
|
+
const freeBlockades = blockades.filter((c) => !used.has(c.id));
|
|
1867
|
+
if (!freeWalls.length && !freeBlockades.length)
|
|
1868
|
+
return none('The plain plan already plays or discards your wall cards: no wall plan.');
|
|
1869
|
+
const tries = [];
|
|
1870
|
+
const notes = [];
|
|
1871
|
+
if (freeWalls.length) {
|
|
1872
|
+
const m = multiplierOf('EmergencyBlockadeCard');
|
|
1873
|
+
if (m > 0)
|
|
1874
|
+
tries.push({ kind: 'EmergencyBlockade', card: freeWalls[0].id, held: walls.length, free: freeWalls.length, found: planWall({ input: a.setup.input, plain: a.plan, cards: freeWalls.length, multiplier: m }) });
|
|
1875
|
+
else
|
|
1876
|
+
notes.push("the game's settings give no Emergency Blockade multiplier");
|
|
1877
|
+
}
|
|
1878
|
+
if (freeBlockades.length) {
|
|
1879
|
+
const m = multiplierOf('BlockadeCard');
|
|
1880
|
+
if (m > 0)
|
|
1881
|
+
tries.push({ kind: 'Blockade', card: freeBlockades[0].id, held: blockades.length, free: freeBlockades.length, found: planBlockade({ input: a.setup.input, plain: a.plan, cards: freeBlockades.length, multiplier: m }) });
|
|
1882
|
+
else
|
|
1883
|
+
notes.push("the game's settings give no Blockade multiplier");
|
|
1884
|
+
}
|
|
1885
|
+
const winner = tries
|
|
1886
|
+
.filter((t) => t.found.best)
|
|
1887
|
+
.sort((x, y) => compareScores(x.found.best.score, y.found.best.score))[0];
|
|
1888
|
+
if (!winner)
|
|
1889
|
+
return none(`No wall beats the plain plan (with the bonus a wall denies counted): ${tries.map((t) => `${t.found.considered} ${t.kind === 'Blockade' ? 'Blockade' : 'Emergency Blockade'} target(s) tried`).join(', ') || 'none tried'}${notes.length ? `; ${notes.join('; ')}` : ''}.`);
|
|
1890
|
+
const found = winner.found;
|
|
1891
|
+
const best = found.best;
|
|
1892
|
+
const checked = await commanderCheck(a.ctx, {
|
|
1893
|
+
game: a.game,
|
|
1894
|
+
me: a.me,
|
|
1895
|
+
map: a.map,
|
|
1896
|
+
seen: a.seen,
|
|
1897
|
+
turn: a.turn,
|
|
1898
|
+
info: a.info,
|
|
1899
|
+
hand: a.hand,
|
|
1900
|
+
income: a.setup.boardIncome,
|
|
1901
|
+
tripwires: a.setup.trip.tripwires,
|
|
1902
|
+
deploys: best.plan.deploys,
|
|
1903
|
+
moves: best.plan.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { withCommander: true } : {}) })),
|
|
1904
|
+
orderPriority: playsCardType(a.orders, a.myCards, CARD_ORDER_PRIORITY),
|
|
1905
|
+
...(a.enemyDeploy !== undefined ? { floor: a.enemyDeploy } : {}),
|
|
1906
|
+
killedBy: false,
|
|
1907
|
+
});
|
|
1908
|
+
if (checked?.risk && a.plainCommanderSafe)
|
|
1909
|
+
return none('The best wall plan would leave your commander takeable (warapp_submit_turn would refuse it), so none is offered.');
|
|
1910
|
+
const card = winner.card;
|
|
1911
|
+
// A Blockade adds only its card play to the plain orders (they stand unchanged); an Emergency Blockade's plan has its
|
|
1912
|
+
// own, and (#558) discards the advised Order Delay only when the plain card choice had to shed it.
|
|
1913
|
+
const orders = winner.kind === 'Blockade'
|
|
1914
|
+
? [...a.orders, { kind: 'card', card, target: best.wall.target }]
|
|
1915
|
+
: alternativeOrders({
|
|
1916
|
+
orders: a.orders,
|
|
1917
|
+
delayOrder: a.delayOrder,
|
|
1918
|
+
playedDelay: a.playedDelay,
|
|
1919
|
+
delayMustGo: a.playedDelay !== undefined && a.cards.discards.some((c) => c.id === a.playedDelay),
|
|
1920
|
+
cardPlays: [{ kind: 'card', card, target: best.wall.target }],
|
|
1921
|
+
deploys: best.plan.deploys.map((d) => ({ kind: 'deploy', territory: d.territoryId, armies: d.armies })),
|
|
1922
|
+
moves: best.plan.moves.map((m) => ({ kind: 'move', from: m.from, to: m.to, armies: m.armies, ...(m.commander ? { commander: true } : {}) })),
|
|
1923
|
+
});
|
|
1924
|
+
return {
|
|
1925
|
+
blockadePlan: {
|
|
1926
|
+
card: winner.kind === 'Blockade' ? 'Blockade' : 'Emergency Blockade',
|
|
1927
|
+
wall: {
|
|
1928
|
+
target: a.name(best.wall.target),
|
|
1929
|
+
armies: best.wall.armies,
|
|
1930
|
+
wall: best.wall.wall,
|
|
1931
|
+
...(best.wall.denied ? { denies: { bonusValue: best.wall.denied, player: best.wall.deniedFrom } } : {}),
|
|
1932
|
+
},
|
|
1933
|
+
orders,
|
|
1934
|
+
expected: {
|
|
1935
|
+
captures: best.plan.expected.captures,
|
|
1936
|
+
nextIncome: best.plan.expected.nextIncome,
|
|
1937
|
+
...(best.plan.expected.nextIncomeIfConcededFall !== undefined ? { nextIncomeIfConcededFall: best.plan.expected.nextIncomeIfConcededFall } : {}),
|
|
1938
|
+
},
|
|
1939
|
+
delta: {
|
|
1940
|
+
twoTurn: Math.round((best.score.twoTurn - best.plainScore.twoTurn) * 100) / 100,
|
|
1941
|
+
nextIncomeIfConcededFall: best.score.safeIncome - best.plainScore.safeIncome,
|
|
1942
|
+
nextIncome: best.score.nextIncome - best.plainScore.nextIncome,
|
|
1943
|
+
},
|
|
1944
|
+
cardsSpent: 1,
|
|
1945
|
+
cardsLeft: cardsLeftAfter({ held: winner.held, free: winner.free, spent: 1 }),
|
|
1946
|
+
considered: found.considered,
|
|
1947
|
+
...(checked ? { commander: { safe: !checked.risk, ...(checked.risk ? { needs: checked.risk.needs } : {}) } } : {}),
|
|
1948
|
+
note: WALL_PLAN_NOTE,
|
|
1949
|
+
},
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
const WALL_PLAN_NOTE = 'An alternative to `orders`, never applied: an Emergency Blockade walls a conceded border before every move (the ' +
|
|
1953
|
+
'planner plans the walled board); a Blockade walls a territory after the attacks, the plain orders unchanged, only ' +
|
|
1954
|
+
"while the stress-tested line keeps it yours. Either turns it neutral at its armies × the game's multiplier and is " +
|
|
1955
|
+
'worth the bonus its fall would hand an opponent (× 0.8, owner-approved 2026-11-24), less any bonus of yours it gives ' +
|
|
1956
|
+
'up. The Emergency Blockade play\'s encoding is UNVERIFIED live. Test it with warapp_check_plan.';
|
|
1957
|
+
const BOMB_PLAN_NOTE = 'An alternative to `orders`, never applied: the same planner on the board the Bomb leaves (it runs after the deploys ' +
|
|
1958
|
+
'and before every move; its target keeps half its armies, rounded down), compared by the plain plan\'s own measure. ' +
|
|
1959
|
+
'The Bomb play\'s encoding is UNVERIFIED live. Test it with warapp_check_plan, then pass its `orders` to warapp_submit_turn if you prefer it.';
|
|
1960
|
+
const AIRLIFT_PLAN_NOTE = 'An alternative to `orders`, never applied: the same planner on the board the Airlifts leave (their armies land after ' +
|
|
1961
|
+
'the deploys and before every move, and cannot move again that turn), compared by the plain plan\'s own measure. ' +
|
|
1962
|
+
'Test it with warapp_check_plan, then pass its `orders` to warapp_submit_turn if you prefer it.';
|
|
1650
1963
|
/**
|
|
1651
1964
|
* #274: whether these orders leave my commander takeable by a single-deploy reply (`commanderCheckOn`,
|
|
1652
1965
|
* src/tools/commander-check.ts: the one check, which warapp_check_plan reports too), each reply sized at
|
|
@@ -1920,7 +2233,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1920
2233
|
'withdrawal worth a card, a commander strike) or it is the card that must go (over the hold limit the cards worth ' +
|
|
1921
2234
|
'least in this game leave first; the timing cards are kept longest); never Blockade, Order Delay, Bomb or Emergency ' +
|
|
1922
2235
|
'Blockade — `cards.advice` says where those pay (Order Delay above the calm orders, a Bomb target or hold it, an ' +
|
|
1923
|
-
"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 " +
|
|
2236
|
+
"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 (on yourself when the game's percentage is negative, with `income`: your next income before and after the boost; never a negative card on an opponent nor a positive one on you), an Airlift onto a " +
|
|
1924
2237
|
"border of yours or a teammate's that falls without it, a Gift that completes a teammate's bonus, Spy, Reconnaissance or Surveillance " +
|
|
1925
2238
|
'where the fog hides what the plan needs (never with fog off) — each with an `order` to pass to ' +
|
|
1926
2239
|
"warapp_submit_turn, never added to the orders — save a completing Gift (verified live; the transfers it would strand are dropped) and a Reconnaissance, which go into `orders`), and the warnings flag an opponent's Bomb or Emergency Blockade and the cards in effect. Moves are listed in the " +
|
|
@@ -1964,7 +2277,9 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1964
2277
|
'is watch; a border cap kept; a partner-approved truce exception on this turn makes its territories normal ' +
|
|
1965
2278
|
'targets, listed under the truce as `exceptions`), `advice` says `give-notice` when the endgame or the partner outgrowing you made ' +
|
|
1966
2279
|
'the trust watch, a truce the board shows broken is planned as an ordinary opponent, and `tacit` lists quiet ' +
|
|
1967
|
-
'borders with no agreement (a report, never a truce)
|
|
2280
|
+
'borders with no agreement (a report, never a truce); `coordination` lists the joint attacks recorded with ' +
|
|
2281
|
+
'warapp_record_agreement due this turn, each told in a rationale line ("Agreed with player P … they hit X, you ' +
|
|
2282
|
+
'follow on Y") — report only, the orders never read it. In a game running the Diplomacy 2 mod (mod 191) each ally ' +
|
|
1968
2283
|
'is an enforced truce in any format (`mod: "Diplomacy 2"`): the game skips attacks between allies, so none is ' +
|
|
1969
2284
|
'planned and its threat is 0 this turn, but it still counts for next turn (a break applies at the end of the turn ' +
|
|
1970
2285
|
'it is entered, unseen); `modAlliances` lists the allies read (UNVERIFIED live). The plan never reads what your chat promised ' +
|
|
@@ -1985,6 +2300,25 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
1985
2300
|
'`guess` is a randomized split, weighted by what each border is worth, against an opponent who would read a fixed ' +
|
|
1986
2301
|
'one, and `guessOrders` the plan\'s `orders` with that split — optional (the user chooses; `orders` stay the ' +
|
|
1987
2302
|
"plan's), and a model: one opponent, one deploy, its visible stacks. " +
|
|
2303
|
+
'Holding an Airlift card, `airliftPlan` is an alternative beside the plan (its `orders` never change): the same ' +
|
|
2304
|
+
'planner on the board after the Airlifts (an interior stack flown onto a border the plan concedes, or a conceded ' +
|
|
2305
|
+
"border's armies flown to the border most pressed), the best compared by the plan's own measure (next income if " +
|
|
2306
|
+
'its conceded borders fall, then next income, fewer concessions, more captures) — `airlifts`, `orders` (the Airlift ' +
|
|
2307
|
+
'plays included), `expected`, `delta` (income, captures, borders saved, bonuses kept or completed), `cardsSpent`, ' +
|
|
2308
|
+
'`cardsLeft`; `keep_cards` holds cards back; `null` with `airliftPlanNote` when none beats the plan. Airlifted armies ' +
|
|
2309
|
+
'cannot attack that turn, so a capture is staged for NEXT turn instead (`staging`: an interior stack flown beside a ' +
|
|
2310
|
+
'target the plan does not take whose capture completes a bonus of yours or breaks an opponent\'s, with the target, ' +
|
|
2311
|
+
'`nextTurnAttack` and the bonus value), scored on a two-turn objective — this turn\'s measure plus 0.8 × that bonus ' +
|
|
2312
|
+
'(`delta.twoTurn`) — and only when the staged stack holds against the plan\'s threat at that border. ' +
|
|
2313
|
+
'Holding a Bomb card, `bombPlan` is the same kind of alternative: the planner on the board the Bomb leaves (its target ' +
|
|
2314
|
+
'keeps half its armies, rounded down — an opponent\'s territory beside yours, a held bonus\'s member first, then the ' +
|
|
2315
|
+
'largest stacks; never a player at peace with you) — `bomb`, `orders` (the Bomb play included), `expected`, `delta`; ' +
|
|
2316
|
+
'`null` with `bombPlanNote` when none beats the plan (the Bomb play\'s encoding is unverified live). ' +
|
|
2317
|
+
'Holding an Emergency Blockade, `blockadePlan` walls off a border the plan concedes (neutral at its armies × the ' +
|
|
2318
|
+
"game's multiplier, before every move), worth the bonus its fall would hand an opponent when the wall holds this turn; " +
|
|
2319
|
+
'holding a Blockade, the plain orders plus a Blockade on a territory of yours the attacks leave yours (it walls it ' +
|
|
2320
|
+
'after them), worth the same denial less any bonus of yours it gives up — the better one, with `card`, `wall`, ' +
|
|
2321
|
+
'`orders`, `delta`. ' +
|
|
1988
2322
|
'`reads` (opponent profiles, as warapp_profile_opponents reads them; reported only, the plan never uses them): ' +
|
|
1989
2323
|
'each opponent in contact with a habit at the confidence bar or a label — its labels, `lastAttackTurn` (the last turn it attacked you), those habits with `n` and ' +
|
|
1990
2324
|
'`basis`, `gamesMet` — a likelihood, never a certainty, and never to be quoted to another player. ' +
|
|
@@ -2073,10 +2407,18 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2073
2407
|
'opponent may hold one too and the order ends a player). In a ' +
|
|
2074
2408
|
'two-player game under a cyclic order it is remembered and later turns default to it, alternated; ' +
|
|
2075
2409
|
'omitted, the default is that, else the award of picks, else unknown (`firstMover` says which).'),
|
|
2410
|
+
keep_cards: z.coerce
|
|
2411
|
+
.number()
|
|
2412
|
+
.int()
|
|
2413
|
+
.min(0)
|
|
2414
|
+
.max(100)
|
|
2415
|
+
.optional()
|
|
2416
|
+
.describe('Airlift cards to keep in reserve: `airliftPlan` plays only those held beyond this many (default 0). ' +
|
|
2417
|
+
'Changes nothing when you hold no Airlift.'),
|
|
2076
2418
|
view: viewArg(VIEWS, 'compact (default) gives the plan and orders (the profile as format, phase and standing); "full" adds each ' +
|
|
2077
2419
|
'move\'s reason, the whole profile and the settings the plan assumed.'),
|
|
2078
2420
|
}),
|
|
2079
|
-
}, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, view }) => {
|
|
2421
|
+
}, async ({ game_id, player, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, keep_cards, view }) => {
|
|
2080
2422
|
// The chat comes in the same GameFeed read: the fallback for the unread counts (part A1).
|
|
2081
2423
|
const feed = await ctx.client.getGame(game_id, { settings: true, chat: true });
|
|
2082
2424
|
requireTurnPhase(feed);
|
|
@@ -2228,6 +2570,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2228
2570
|
truces: inForce.map((r) => ({ player: r.player, state: r.state, coveredMine: r.coveredMine, ...(r.endsTurn !== undefined ? { endsTurn: r.endsTurn } : {}) })),
|
|
2229
2571
|
...(effect.diplomacy.length ? { enforced: new Set(effect.diplomacy.map((d) => d.player)) } : {}),
|
|
2230
2572
|
...(sanction.applied ? { sanctionsApplied: true } : {}),
|
|
2573
|
+
// Owner request 2026-11-24: a self-Sanctions boost is measured on the plan's next income.
|
|
2574
|
+
nextIncome: plan.expected.nextIncome,
|
|
2231
2575
|
})
|
|
2232
2576
|
: { view: {}, warnings: [] };
|
|
2233
2577
|
// #412: the decision log — this turn's decision (a what-if plan is only an observation of the board,
|
|
@@ -2464,6 +2808,47 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2464
2808
|
...(advised ? { orderPriority: true } : {}),
|
|
2465
2809
|
});
|
|
2466
2810
|
const guessOrders = guess ? guessOrdersOf(orders, guess) : undefined;
|
|
2811
|
+
// Owner request 2026-11-24: with Airlift cards in hand, the best plan that plays them, ALONGSIDE the plain
|
|
2812
|
+
// plan (whose orders never change): candidates scored by the plain plan's own measure (airlift-plan.ts).
|
|
2813
|
+
const airlift = await airliftPlanView({
|
|
2814
|
+
ctx,
|
|
2815
|
+
game,
|
|
2816
|
+
me,
|
|
2817
|
+
map,
|
|
2818
|
+
seen,
|
|
2819
|
+
turn,
|
|
2820
|
+
info,
|
|
2821
|
+
hand,
|
|
2822
|
+
setup,
|
|
2823
|
+
plan,
|
|
2824
|
+
orders,
|
|
2825
|
+
myCards,
|
|
2826
|
+
cards,
|
|
2827
|
+
playedDelay,
|
|
2828
|
+
gift,
|
|
2829
|
+
delayOrder: advice.view.orderDelay?.order,
|
|
2830
|
+
keepCards: keep_cards ?? 0,
|
|
2831
|
+
plainCommanderSafe: checked?.risk === undefined,
|
|
2832
|
+
enemyDeploy: enemy_deploy,
|
|
2833
|
+
name,
|
|
2834
|
+
});
|
|
2835
|
+
// Owner request 2026-11-24 (B): with a Bomb card in hand, the best plan that plays it, ALONGSIDE the plain plan.
|
|
2836
|
+
const bomb = await bombPlanView({
|
|
2837
|
+
ctx, game, me, map, seen, turn, info, hand, setup, plan, orders, myCards, cards, playedDelay, gift,
|
|
2838
|
+
delayOrder: advice.view.orderDelay?.order,
|
|
2839
|
+
keepCards: 0,
|
|
2840
|
+
plainCommanderSafe: checked?.risk === undefined,
|
|
2841
|
+
enemyDeploy: enemy_deploy,
|
|
2842
|
+
name,
|
|
2843
|
+
});
|
|
2844
|
+
const wallPlan = await blockadePlanView({
|
|
2845
|
+
ctx, game, me, map, seen, turn, info, hand, setup, plan, orders, myCards, cards, playedDelay, gift,
|
|
2846
|
+
delayOrder: advice.view.orderDelay?.order,
|
|
2847
|
+
keepCards: 0,
|
|
2848
|
+
plainCommanderSafe: checked?.risk === undefined,
|
|
2849
|
+
enemyDeploy: enemy_deploy,
|
|
2850
|
+
name,
|
|
2851
|
+
});
|
|
2467
2852
|
// #385: siege_target only means something under goal siege; say so rather than drop it silently.
|
|
2468
2853
|
if (siege_target !== undefined && goal !== 'siege')
|
|
2469
2854
|
warnings.push(`siege_target is ignored: it applies only with goal "siege" (this plan's goal is ${goal ?? 'chosen by the game profile'}).`);
|
|
@@ -2545,6 +2930,12 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2545
2930
|
// #415 task 4b: the unread messages that would block the submit (report only: no order reads them). The
|
|
2546
2931
|
// truces from the ledger, contact from this board, the surrenders this plan read; no request of its own.
|
|
2547
2932
|
const planLedger = ctx.dataDir ? await readLedger(ctx.dataDir, game.id, me.id) : undefined;
|
|
2933
|
+
// Coordination notes due this turn (warapp_record_agreement `coordination`): told, never an order.
|
|
2934
|
+
const coordDue = turn === null ? [] : (planLedger?.coordination ?? []).filter((c) => coordinationDue(c, turn));
|
|
2935
|
+
const coordLines = coordDue.map((c) => coordinationLine(c, (t) => {
|
|
2936
|
+
const n = name(t);
|
|
2937
|
+
return `${n.name} (#${t})`;
|
|
2938
|
+
}));
|
|
2548
2939
|
const blocks = chat
|
|
2549
2940
|
? turnChatBlocks(chat, game, {
|
|
2550
2941
|
meId: me.id,
|
|
@@ -2612,6 +3003,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2612
3003
|
// #298: the contested bonuses pushed all-in or dropped after repeated failed attempts; absent with none.
|
|
2613
3004
|
...(plan.bonusPush ? { bonusPush: plan.bonusPush } : {}),
|
|
2614
3005
|
...(coalition ? { coalition } : {}),
|
|
3006
|
+
...(coordDue.length ? { coordination: coordDue.map((c) => coordinationView(c, game, map, turn ?? 0)) } : {}),
|
|
2615
3007
|
// #276: the guard case first, on or off, with what it means for interior defence.
|
|
2616
3008
|
profile: rung === 'full'
|
|
2617
3009
|
? { guard: guardCase(game.settings), ...plan.profile }
|
|
@@ -2961,8 +3353,12 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
2961
3353
|
? { modAlliances: { read: truces.mod.status === 'read', allies: truces.mod.status === 'read' ? truces.mod.allies.map(playerRef) : null, note: MOD_ALLIANCES_NOTE } }
|
|
2962
3354
|
: {}),
|
|
2963
3355
|
warnings,
|
|
2964
|
-
rationale: plan.rationale,
|
|
3356
|
+
rationale: coordLines.length ? [...plan.rationale, ...coordLines] : plan.rationale,
|
|
2965
3357
|
orders,
|
|
3358
|
+
// Owner request 2026-11-24: only when I hold an Airlift card (no field otherwise).
|
|
3359
|
+
...(airlift ?? {}),
|
|
3360
|
+
...(bomb ?? {}),
|
|
3361
|
+
...(wallPlan ?? {}),
|
|
2966
3362
|
// The border guess, only when there is one; why there is none, full view only.
|
|
2967
3363
|
...(guess
|
|
2968
3364
|
? {
|
|
@@ -3081,11 +3477,17 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
3081
3477
|
'`commander`), Gift (`target` yours, `player`), Diplomacy (`players`: two), Sanctions (`player`), Bomb (`target` ' +
|
|
3082
3478
|
"next to yours, not yours or a teammate's) and Emergency Blockade (`target` yours, never your commander's), encoded " +
|
|
3083
3479
|
'as the client does (the Airlift, Diplomacy and Gift verified live, Reconnaissance accepted live; the others not yet), each refused where war.app would refuse it (a commander is never ' +
|
|
3084
|
-
'gifted or airlifted to a teammate, no Spy
|
|
3480
|
+
'gifted or airlifted to a teammate, no Spy on yourself or a teammate, Sanctions on your own side only when the game\'s ' +
|
|
3481
|
+
'percentage is negative (it then raises the target\'s income: never on an opponent; a positive or unreadable one never on ' +
|
|
3482
|
+
'your side), no Diplomacy between ' +
|
|
3085
3483
|
'teammates); discards any card (`{ kind: "discard", card }`); refuses ' +
|
|
3086
3484
|
'when your hand is over the hold limit and the orders do not play or discard enough cards; in a team game warns ' +
|
|
3087
3485
|
'when they play or discard a card your teammate has already entered (a card named by type is one nobody ' +
|
|
3088
|
-
'entered when there is one).
|
|
3486
|
+
'entered when there is one). An Airlift leaves at least one army behind while One Army Must Stand Guard is on; ' +
|
|
3487
|
+
'once the orders read as committed every Airlift sent is read back from war.app\'s copy of them (the ' +
|
|
3488
|
+
'warapp_get_my_orders read) and reported as `airliftReadBack` — a missing or altered one makes the result an error ' +
|
|
3489
|
+
'naming it, and nothing is resent; a Bomb, Blockade, Emergency Blockade or Sanctions play is read back the same way ' +
|
|
3490
|
+
'(`cardReadBack`: its card and target territory or player; missing or on another target is an error). The ' +
|
|
3089
3491
|
'orders reach the game and cannot be withdrawn here; when the turn resolves, other players see the results. ' +
|
|
3090
3492
|
'Validated against the live board first: deploys on and moves from your own territories, moves to ' +
|
|
3091
3493
|
'adjacent ones, no more armies than a territory has, deploys totalling exactly your income (after any Sanctions on you, ' +
|
|
@@ -3723,6 +4125,8 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
3723
4125
|
'your `committed` true means the orders are in. Do not resend these orders blindly — a second commit for ' +
|
|
3724
4126
|
'the same turn is not known to be safe, and once the turn has resolved they would commit to the next one.';
|
|
3725
4127
|
const unconfirmed = (warning) => ({ status: 'unknown', outcome: 'unconfirmed', ...base, warning });
|
|
4128
|
+
/** The game as read back once my orders show committed (the Airlift read-back reads its players). */
|
|
4129
|
+
let committedGame;
|
|
3726
4130
|
const result = await sendAndVerify({
|
|
3727
4131
|
send: async () => {
|
|
3728
4132
|
// The reply's bool is war.app's "vacation ended" flag — never a success signal.
|
|
@@ -3768,6 +4172,7 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
3768
4172
|
};
|
|
3769
4173
|
}
|
|
3770
4174
|
if (after.players.find((p) => p.id === st.feedPlayerId)?.hasCommittedOrders) {
|
|
4175
|
+
committedGame = after;
|
|
3771
4176
|
return {
|
|
3772
4177
|
status: 'committed',
|
|
3773
4178
|
outcome: 'confirmed',
|
|
@@ -3784,9 +4189,70 @@ export function registerTurnTools(server, ctx, opts = {}) {
|
|
|
3784
4189
|
const withChat = st.chatReviewed ? { ...result, chatReviewed: st.chatReviewed } : result;
|
|
3785
4190
|
const withRisk = st.commanderRisk ? { ...withChat, commanderRiskAccepted: st.commanderRisk } : withChat;
|
|
3786
4191
|
const withExceptions = st.exceptions?.length ? { ...withRisk, exceptionsRecorded: await recordApproved(st, result.outcome === 'confirmed') } : withRisk;
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
4192
|
+
const final = st.breaks?.length ? { ...withExceptions, agreementsBroken: await recordBreaks(st, result.outcome === 'confirmed') } : withExceptions;
|
|
4193
|
+
// Owner request 2026-11-24: the Airlifts sent are read back from war.app's copy of my committed orders
|
|
4194
|
+
// (the warapp_get_my_orders read) and any missing or altered one fails loudly. Nothing is resent. The
|
|
4195
|
+
// player-targeted plays (Sanctions, owner request 2026-11-24) are read back the same way (`cardReadBack`).
|
|
4196
|
+
const lifts = sentAirlifts(st.orders);
|
|
4197
|
+
const aimed = sentTargeted(st.orders, READ_BACK_TARGETED);
|
|
4198
|
+
const aiming = st.orders.some((o) => o.kind === 'card' && READ_BACK_PLAYER_CARDS.has(o.card));
|
|
4199
|
+
if (!lifts.length && !aimed.length && !aiming)
|
|
4200
|
+
return final;
|
|
4201
|
+
if (!committedGame) {
|
|
4202
|
+
const note = result.status === 'resolved'
|
|
4203
|
+
? "The turn resolved at once, so war.app no longer holds the orders to read back: check the card plays in the turn's result on the board."
|
|
4204
|
+
: 'The orders do not read as committed, so the card plays were not read back.';
|
|
4205
|
+
return {
|
|
4206
|
+
...final,
|
|
4207
|
+
...(lifts.length ? { airliftReadBack: { status: 'not-read', note } } : {}),
|
|
4208
|
+
...(aimed.length || aiming ? { cardReadBack: { status: 'not-read', note } } : {}),
|
|
4209
|
+
};
|
|
4210
|
+
}
|
|
4211
|
+
const byInGame = playersByInGameId(committedGame.players);
|
|
4212
|
+
const aimedPlayers = sentPlayerCards(st.orders, (n) => byInGame.get(n)?.id);
|
|
4213
|
+
let read = null;
|
|
4214
|
+
let failure;
|
|
4215
|
+
try {
|
|
4216
|
+
read = committedOrdersOf((await readLatestBoard(ctx, st.gameId)).info, committedGame.players);
|
|
4217
|
+
}
|
|
4218
|
+
catch (e) {
|
|
4219
|
+
failure = failureText(e);
|
|
4220
|
+
}
|
|
4221
|
+
const lifted = checkAirlifts(lifts, read);
|
|
4222
|
+
const hit = checkTargeted(aimed, read);
|
|
4223
|
+
const named = checkPlayerCards(aimedPlayers, read);
|
|
4224
|
+
if (lifted.status === 'mismatch' || hit.status === 'mismatch' || named.status === 'mismatch') {
|
|
4225
|
+
const parts = lifted.status === 'mismatch' ? [mismatchMessage(lifted, st.turnNumber, st.gameId)] : [];
|
|
4226
|
+
const extra = [...targetedMismatchParts(hit), ...playerCardMismatchParts(named)];
|
|
4227
|
+
// #556: what the commit recorded (a truce break, exceptions, …) is said in the error, never dropped.
|
|
4228
|
+
const recorded = recordedWithCommit(final);
|
|
4229
|
+
const message = (parts.length
|
|
4230
|
+
? `${parts[0]}${extra.length ? ` Also: ${extra.join('; ')}.` : ''}`
|
|
4231
|
+
: `Your orders for game ${st.gameId}, turn ${st.turnNumber} are committed, but war.app's copy of them does not match what was sent: ${extra.join('; ')}. Nothing was resent.`) +
|
|
4232
|
+
(recorded ? ` ${recorded}` : '');
|
|
4233
|
+
throw new McpToolError(message, {
|
|
4234
|
+
hint: 'Read the committed orders with warapp_get_my_orders. To correct them, withdraw with warapp_uncommit_turn and ' +
|
|
4235
|
+
'submit again (both confirm-gated); do not resend blindly.',
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
4238
|
+
const unreadNote = (what) => ({ note: `Your committed orders could not be read back${failure ? ` (${failure})` : ''}: check the ${what} with warapp_get_my_orders.` });
|
|
4239
|
+
// Territory-targeted (Bomb) and player-targeted (Sanctions) plays share one `cardReadBack`: one kind alone keeps its
|
|
4240
|
+
// own shape; both together merge their lines (each line names its `target` or its `player`).
|
|
4241
|
+
const cards = aimed.length && (aimedPlayers.length || aiming)
|
|
4242
|
+
? {
|
|
4243
|
+
status: [hit, named].some((x) => x.status === 'unread') ? 'unread' : 'verified',
|
|
4244
|
+
sent: [...hit.sent, ...named.sent],
|
|
4245
|
+
missing: [...hit.missing, ...named.missing],
|
|
4246
|
+
altered: [...hit.altered, ...named.altered],
|
|
4247
|
+
}
|
|
4248
|
+
: aimed.length
|
|
4249
|
+
? hit
|
|
4250
|
+
: named;
|
|
4251
|
+
return {
|
|
4252
|
+
...final,
|
|
4253
|
+
...(lifts.length ? { airliftReadBack: { ...lifted, ...(lifted.status === 'unread' ? unreadNote('Airlifts') : {}) } } : {}),
|
|
4254
|
+
...(aimed.length || aimedPlayers.length || aiming ? { cardReadBack: { ...cards, ...(cards.status === 'unread' ? unreadNote('card plays') : {}) } } : {}),
|
|
4255
|
+
};
|
|
3790
4256
|
},
|
|
3791
4257
|
});
|
|
3792
4258
|
}
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Single source of truth for the server version. release-please bumps the
|
|
2
2
|
// literal on the marked line (registered in release-please-config.json
|
|
3
3
|
// extra-files); every other module imports VERSION from here.
|
|
4
|
-
export const VERSION = '0.
|
|
4
|
+
export const VERSION = '0.14.0'; // x-release-please-version
|