@chrischall/warapp-mcp 0.23.2 → 0.25.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/dist/analysis/calibrate.js +54 -0
- package/dist/analysis/cards-in-effect.js +19 -3
- package/dist/analysis/coalition.js +6 -3
- package/dist/analysis/commitments.js +257 -40
- package/dist/analysis/pacts.js +285 -0
- package/dist/analysis/relations.js +10 -0
- package/dist/analysis/stress.js +8 -3
- package/dist/bundle.js +1478 -268
- package/dist/chat.js +73 -0
- package/dist/mod-alliances.js +14 -0
- package/dist/protocol/codec.js +4 -0
- package/dist/protocol/methods.js +29 -3
- package/dist/relations-store.js +83 -18
- package/dist/tools/calibration-harness.js +22 -6
- package/dist/tools/chat-advice.js +2 -2
- package/dist/tools/chat.js +419 -36
- package/dist/tools/check-plan.js +14 -4
- package/dist/tools/commitments.js +40 -8
- package/dist/tools/diplomacy.js +37 -5
- package/dist/tools/mod-alliances.js +13 -1
- package/dist/tools/relations.js +411 -33
- package/dist/tools/turn.js +53 -13
- package/dist/tools/uncommit.js +6 -6
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/tools/check-plan.js
CHANGED
|
@@ -28,8 +28,9 @@ import { loadLiveGame, standInLine, standInOf } from './live-context.js';
|
|
|
28
28
|
import { BRIDGE_NOTE, playerArg, resolveMe } from './live.js';
|
|
29
29
|
import { mapOf } from './map.js';
|
|
30
30
|
import { resolvePlayer, resolveTerritory } from './resolve.js';
|
|
31
|
-
import { BELOW_PLAN_BASIS, boardHistory, bordersBelowPlan, currentTurn, truceRelations, friendsOf, guardOffWarnings, modsWarning, plannerSettings, requirePlayingSeat, requireTurnPhase, turnOrdersArg, } from './turn.js';
|
|
31
|
+
import { BELOW_PLAN_BASIS, boardHistory, bordersBelowPlan, currentTurn, truceRelations, foePacts, friendsOf, guardOffWarnings, modsWarning, plannerSettings, requirePlayingSeat, requireTurnPhase, turnOrdersArg, } from './turn.js';
|
|
32
32
|
import { resolveTeamsFor } from './team-source.js';
|
|
33
|
+
import { pactPairs } from '../analysis/pacts.js';
|
|
33
34
|
import { stressOpponents } from './stress-opponents.js';
|
|
34
35
|
import { observedLowWarning } from '../analysis/opponents.js';
|
|
35
36
|
import { statedShiftWarning } from '../analysis/plan/estimates.js';
|
|
@@ -92,7 +93,8 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
92
93
|
'`movedIn` names each), or every stack attacking at once; a stack you attack moving out ' +
|
|
93
94
|
'first (a dodge: into its own territory, or a neutral or one of yours it can take — `dodges` lists each ' +
|
|
94
95
|
'with the armies that got away and what your strike then hit); two opponents striking one of your ' +
|
|
95
|
-
'territories together (teammates always;
|
|
96
|
+
'territories together (teammates always; two at peace by a pact you are not in — a reported pact, a Diplomacy ' +
|
|
97
|
+
'card or a Diplomacy 2 alliance between them, marked `pact`; any two in a free-for-all when you lead — `jointFalls` gives the ' +
|
|
96
98
|
'armies each such territory needs to hold); and, under Multi-Attack, each stack\'s most damaging chain ' +
|
|
97
99
|
'of captures. Under Local Deployment each deploy is bounded by where its bonus armies may land. Each ' +
|
|
98
100
|
'reply is tried with you moving first and with the opponent moving first unless `first_mover` says ' +
|
|
@@ -429,7 +431,13 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
429
431
|
// PLAN-TEAMS D3: a Diplomacy card in effect that the decoder is sure of is a truce here in any format
|
|
430
432
|
// (T9: the game enforces it). Its player stays among the opponents too: the decoder is unverified.
|
|
431
433
|
// T9 too: a Diplomacy 2 mod alliance (read only in a game that runs the mod) is a truce the game enforces.
|
|
432
|
-
const resolvedTruces = await truceRelations(ctx, {
|
|
434
|
+
const resolvedTruces = await truceRelations(ctx, {
|
|
435
|
+
game, me, turn, graph, board: seen, boards: history.boards, myIncome: income, tracks, diplomacy: effect.diplomacy, diplomacyOthers: effect.diplomacyOthers,
|
|
436
|
+
});
|
|
437
|
+
// #680: two opponents at peace by a pact I am not in (reported, a Diplomacy card, a Diplomacy 2 alliance) are
|
|
438
|
+
// tried striking one territory of mine together, as teammates are (counted in `safe` the same way).
|
|
439
|
+
const opponentIds = new Set(opponents.map((o) => o.id));
|
|
440
|
+
const pacts = pactPairs(foePacts(resolvedTruces?.pacts ?? [], game.players, me)).filter(([x, y]) => opponentIds.has(x) && opponentIds.has(y));
|
|
433
441
|
const truces = resolvedTruces?.relations ?? [];
|
|
434
442
|
const modRead = resolvedTruces?.mod;
|
|
435
443
|
const binding = truces.filter((r) => !friend(r.player) &&
|
|
@@ -467,6 +475,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
467
475
|
...(settings.localDeployments && (settings.bonusArmyPer ?? 0) > 0 ? { perTerritoryIncome: true } : {}),
|
|
468
476
|
leader,
|
|
469
477
|
...(binding.length ? { truces: binding.map((r) => ({ player: r.player, covered: r.coveredMine })) } : {}),
|
|
478
|
+
...(pacts.length ? { pacts } : {}),
|
|
470
479
|
});
|
|
471
480
|
// #274: my commander, by the check warapp_submit_turn refuses on (commander-check.ts): the same
|
|
472
481
|
// opponents, each reply at the larger of its estimate and my income (enemy_deploy only raises it,
|
|
@@ -604,7 +613,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
604
613
|
harmful: d.harmful,
|
|
605
614
|
});
|
|
606
615
|
/** #180: a territory two opponents take together, in a sentence. */
|
|
607
|
-
const jointText = (j) => `Players ${j.opponents[0]} and ${j.opponents[1]} together take territory ${j.territory} (${j.armies} there) with ${j.attackers[0]} from ` +
|
|
616
|
+
const jointText = (j) => `Players ${j.opponents[0]} and ${j.opponents[1]}${j.pact ? ' (at peace by a pact, #680)' : ''} together take territory ${j.territory} (${j.armies} there) with ${j.attackers[0]} from ` +
|
|
608
617
|
`territory ${j.from[0]} and ${j.attackers[1]} from territory ${j.from[1]}: it needs ${j.needs} to hold${j.bonusesLost.length ? `, or bonus${j.bonusesLost.length === 1 ? '' : 'es'} ${j.bonusesLost.map((b) => `${b.id} (${signed(b.value)})`).join(', ')} goes with it` : ''}.`;
|
|
609
618
|
const jointView = (j) => ({
|
|
610
619
|
text: jointText(j),
|
|
@@ -616,6 +625,7 @@ export function registerCheckPlanTool(server, ctx) {
|
|
|
616
625
|
attackers: j.attackers,
|
|
617
626
|
bonusesLost: j.bonusesLost.map((b) => bonusOf(b.id)),
|
|
618
627
|
incomeLost: j.incomeLost,
|
|
628
|
+
...(j.pact ? { pact: true } : {}),
|
|
619
629
|
});
|
|
620
630
|
/** One exposure in a sentence, by id. */
|
|
621
631
|
const exposure = (e) => `Next turn player ${e.opponent} can reach territory ${e.territory} (${e.armies} there) with ${e.attackers} from territory ${e.from} ` +
|
|
@@ -12,8 +12,8 @@ import { McpToolError } from '@chrischall/mcp-utils';
|
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { checkCommitments, MAX_MESSAGE_COMMITMENTS, MAX_NO_ATTACK_TURNS, } from '../analysis/commitments.js';
|
|
14
14
|
import { planTurn } from '../analysis/index.js';
|
|
15
|
-
import { MAX_NOTICE_TURNS } from '../analysis/relations.js';
|
|
16
|
-
import { nextAgreementId, readLedger } from '../relations-store.js';
|
|
15
|
+
import { MAX_NOTICE_TURNS, MAX_PARTIES, PACT_RESTS } from '../analysis/relations.js';
|
|
16
|
+
import { nextAgreementId, nextPactId, readLedger } from '../relations-store.js';
|
|
17
17
|
import { readCachedOrders } from '../trend.js';
|
|
18
18
|
import { currentTurn } from './common.js';
|
|
19
19
|
import { loadLiveGame } from './live-context.js';
|
|
@@ -29,6 +29,14 @@ const scopeArgs = {
|
|
|
29
29
|
territories: z.array(ref).max(MAX_SCOPE_ITEMS).optional().describe("Only these territories (names or ids); omit with `bonuses` for all of the player's."),
|
|
30
30
|
bonuses: z.array(ref).max(MAX_SCOPE_ITEMS).optional().describe("Only these bonuses' territories (names or ids)."),
|
|
31
31
|
};
|
|
32
|
+
/** #685: a pact's other parties: two or more players besides you. */
|
|
33
|
+
const playersArg = z
|
|
34
|
+
.array(ref)
|
|
35
|
+
.min(2)
|
|
36
|
+
.max(MAX_PARTIES - 1)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe(`#685: an n-way truce — the other parties (names or GameFeed ids, 2–${MAX_PARTIES - 1}; you make ${MAX_PARTIES} at most), instead of \`player\`. ` +
|
|
39
|
+
'One pact `p<n>` with you in it. Every party must read the message: a game group holding all of them, or the public channel.');
|
|
32
40
|
const termsArgs = {
|
|
33
41
|
...scopeArgs,
|
|
34
42
|
notice_turns: z.coerce.number().int().min(0).max(MAX_NOTICE_TURNS).optional().describe('Turns of notice before the truce ends (default 1).'),
|
|
@@ -56,7 +64,12 @@ export const commitmentArg = z.discriminatedUnion('kind', [
|
|
|
56
64
|
z
|
|
57
65
|
.object({
|
|
58
66
|
kind: z.literal('notice').describe('I am ending our truce.'),
|
|
59
|
-
agreement: z.string().trim().min(1).max(20).describe('The agreement (e.g. "a1") notice is given on.'),
|
|
67
|
+
agreement: z.string().trim().min(1).max(20).describe('The agreement (e.g. "a1") or pact ("p1") notice is given on.'),
|
|
68
|
+
rest: z
|
|
69
|
+
.enum(PACT_RESTS)
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('A pact only, and required while three or more parties are bound: what becomes of the rest of the truce — ask the owner, it is ' +
|
|
72
|
+
'never decided automatically. `continue`: you leave once your notice has run, the others stay bound; `end`: the whole pact ends then.'),
|
|
60
73
|
ends_turn: z.coerce
|
|
61
74
|
.number()
|
|
62
75
|
.int()
|
|
@@ -68,15 +81,17 @@ export const commitmentArg = z.discriminatedUnion('kind', [
|
|
|
68
81
|
z
|
|
69
82
|
.object({
|
|
70
83
|
kind: z.literal('propose').describe('I propose a truce on these terms.'),
|
|
71
|
-
player: ref.describe('The partner (name or GameFeed id).'),
|
|
84
|
+
player: ref.optional().describe('The partner (name or GameFeed id); or `players` for an n-way truce.'),
|
|
85
|
+
players: playersArg,
|
|
72
86
|
...termsArgs,
|
|
73
87
|
})
|
|
74
88
|
.describe('A truce proposed (or a counter-offer).'),
|
|
75
89
|
z
|
|
76
90
|
.object({
|
|
77
91
|
kind: z.literal('accept').describe('I accept this truce.'),
|
|
78
|
-
agreement: z.string().trim().min(1).max(20).optional().describe('The recorded proposal accepted (e.g. "a1").'),
|
|
92
|
+
agreement: z.string().trim().min(1).max(20).optional().describe('The recorded proposal accepted (e.g. "a1", or a pact "p1").'),
|
|
79
93
|
player: ref.optional().describe('The partner (name or GameFeed id), when no agreement id is given.'),
|
|
94
|
+
players: playersArg,
|
|
80
95
|
...termsArgs,
|
|
81
96
|
})
|
|
82
97
|
.describe('A truce accepted: a recorded proposal (any terms given must match it; those left out are not compared), or terms ' +
|
|
@@ -134,14 +149,28 @@ export function resolveCommitments(game, map, args) {
|
|
|
134
149
|
...(a.turn !== undefined ? { turn: a.turn } : {}),
|
|
135
150
|
};
|
|
136
151
|
case 'notice':
|
|
137
|
-
return {
|
|
152
|
+
return {
|
|
153
|
+
kind: 'notice',
|
|
154
|
+
agreement: a.agreement,
|
|
155
|
+
...(a.ends_turn !== undefined ? { endsTurn: a.ends_turn } : {}),
|
|
156
|
+
...(a.rest !== undefined ? { rest: a.rest } : {}),
|
|
157
|
+
};
|
|
138
158
|
case 'propose':
|
|
139
|
-
|
|
159
|
+
if ((a.player === undefined) === (a.players === undefined))
|
|
160
|
+
throw new McpToolError(`A propose names \`player\` (a two-party truce) or \`players\` (an n-way truce), one of them: ${NOTHING_SENT}.`, {
|
|
161
|
+
hint: 'Give `player` for one partner, or `players` for two or more.',
|
|
162
|
+
});
|
|
163
|
+
return a.players !== undefined
|
|
164
|
+
? { kind: 'propose', players: a.players.map(pid), terms: termsOf(map, a) }
|
|
165
|
+
: { kind: 'propose', with: pid(a.player), terms: termsOf(map, a) };
|
|
140
166
|
case 'accept':
|
|
167
|
+
if (a.player !== undefined && a.players !== undefined)
|
|
168
|
+
throw new McpToolError(`An accept names \`player\` or \`players\`, not both: ${NOTHING_SENT}.`, { hint: 'Give `players` for an n-way truce.' });
|
|
141
169
|
return {
|
|
142
170
|
kind: 'accept',
|
|
143
171
|
...(a.agreement !== undefined ? { agreement: a.agreement } : {}),
|
|
144
172
|
...(a.player !== undefined ? { with: pid(a.player) } : {}),
|
|
173
|
+
...(a.players !== undefined ? { players: a.players.map(pid) } : {}),
|
|
145
174
|
...(termsGiven(a) ? { terms: givenTermsOf(map, a) } : {}),
|
|
146
175
|
};
|
|
147
176
|
}
|
|
@@ -197,6 +226,8 @@ teamsKnown = true) {
|
|
|
197
226
|
players,
|
|
198
227
|
agreements: ledger?.agreements ?? [],
|
|
199
228
|
nextAgreementId: (agreements) => nextAgreementId({ agreements }),
|
|
229
|
+
pacts: ledger?.pacts ?? [],
|
|
230
|
+
nextPactId: (pacts) => nextPactId({ pacts }),
|
|
200
231
|
commitments,
|
|
201
232
|
moves,
|
|
202
233
|
source,
|
|
@@ -209,7 +240,8 @@ teamsKnown = true) {
|
|
|
209
240
|
hint: 'Promise only what the plan does: change or drop the commitment, and drop the promise from the message (an undeclared ' +
|
|
210
241
|
'promise is not allowed). To promise an attack the plan does not make, submit those orders first (warapp_submit_turn); ' +
|
|
211
242
|
'to change a truce, record it with warapp_record_agreement. A proposal, an acceptance or a notice goes to the ' +
|
|
212
|
-
'partner: privately to that player, or to the whole game
|
|
243
|
+
'partner: privately to that player, or to the whole game; on an n-way truce (`players`, a pact "p<n>") to every party — ' +
|
|
244
|
+
'a game group holding all of them, or the whole game. A notice on a pact of three or more needs `rest`: ask the owner.',
|
|
213
245
|
});
|
|
214
246
|
}
|
|
215
247
|
return { turn, source, commitments, checks, players };
|
package/dist/tools/diplomacy.js
CHANGED
|
@@ -14,7 +14,8 @@ import { McpToolError } from '@chrischall/mcp-utils';
|
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { findChokepoints, planTurn } from '../analysis/index.js';
|
|
16
16
|
import { diplomacyFacts, MAX_NOTICE_TURNS, offerChecks, partyRefusal, priceTruce, scopeRefusal, sharedBorder, agreementState, suggestedTerms, TERMINAL_STATUSES, truceEndgame, truceVerdict, } from '../analysis/relations.js';
|
|
17
|
-
import { readLedger } from '../relations-store.js';
|
|
17
|
+
import { ledgerTruces, readLedger } from '../relations-store.js';
|
|
18
|
+
import { atPeaceWith, pactLabel, pactsInForce } from '../analysis/pacts.js';
|
|
18
19
|
import { isTeamGame } from '../teams.js';
|
|
19
20
|
import { bonusNamer, currentTurn, gameIdArg, graphOf, namer, readAnnotations, respond, untrustedDescription, untrustedText, viewArg } from './common.js';
|
|
20
21
|
import { lookupMeta } from './hints.js';
|
|
@@ -80,7 +81,11 @@ export function registerDiplomacyTool(server, ctx, opts = {}) {
|
|
|
80
81
|
'proposed — never parsed from chat), the same price and three checks: do I gain only if they keep it, do I ' +
|
|
81
82
|
'lose if I comply and they do not, do they gain from my compliance; all three true means run warapp_check_plan ' +
|
|
82
83
|
'first. `facts`: true statements about third players you may cite to each neighbour, each with whether it can ' +
|
|
83
|
-
|
|
84
|
+
"see them under the game's fog. #680: `pactsBetweenOthers` lists the pacts between other players binding this " +
|
|
85
|
+
'turn (reported, one you left, a Diplomacy card or a Diplomacy 2 alliance between two others), and a neighbour ' +
|
|
86
|
+
'already at peace with another player carries `atPeaceWith` and a reason saying so — report only, no price reads it. ' +
|
|
87
|
+
'#686: a pact a party broke in view on your boards carries `broken: true` and its `flags`, and no longer counts as peace. ' +
|
|
88
|
+
`Refused outside a free-for-all. ${BRIDGE_NOTE} Sends nothing and records ` +
|
|
84
89
|
'nothing: record an agreement with warapp_record_agreement, and send a message with warapp_send_chat.'),
|
|
85
90
|
_meta: lookupMeta(['truce advice', 'should i make a truce', 'diplomacy', 'price a deal', 'they offered a truce', 'alliance']),
|
|
86
91
|
annotations: readAnnotations('Advise on war.app truces'),
|
|
@@ -254,7 +259,8 @@ export function registerDiplomacyTool(server, ctx, opts = {}) {
|
|
|
254
259
|
continue;
|
|
255
260
|
}
|
|
256
261
|
const border = sharedBorder(graph, board, me.id, partner, chokepoints);
|
|
257
|
-
|
|
262
|
+
// #680: a pact I am in counts per partner, as the same truce recorded apart would.
|
|
263
|
+
const open = ledgerTruces(ledger).find((a) => a.with === partner && !TERMINAL_STATUSES.has(a.status));
|
|
258
264
|
const terms = open ? open.terms : suggestedTerms(border, turn);
|
|
259
265
|
const { priced, verdict, recordState, related: rel } = await price(partner, terms, open?.id);
|
|
260
266
|
built.push({ partner, ...(open ? { agreement: open.id } : {}), border, terms, priced, verdict, recordState, related: rel, facts });
|
|
@@ -267,11 +273,22 @@ export function registerDiplomacyTool(server, ctx, opts = {}) {
|
|
|
267
273
|
: undefined;
|
|
268
274
|
const description = game.description !== undefined ? untrustedText(game.description, DESCRIPTION_MAX) : null;
|
|
269
275
|
// The Diplomacy 2 mod's alliances beside the ledger (the read warapp_plan_turn's setup made; none without the mod).
|
|
270
|
-
const liveAgreements = (ledger
|
|
276
|
+
const liveAgreements = ledgerTruces(ledger).filter((a) => {
|
|
271
277
|
const st = agreementState(a, turn ?? 0, players);
|
|
272
278
|
return st.phase === 'active' || st.phase === 'notice';
|
|
273
279
|
});
|
|
274
280
|
const modView = setup.truces ? modRelationsView(setup.truces.mod, liveAgreements, playerRef) : undefined;
|
|
281
|
+
// #680: the pacts between other players this turn (report only): who each neighbour is already at peace with.
|
|
282
|
+
const pacts = setup.truces?.pacts ?? [];
|
|
283
|
+
const peaceOf = (partner) => {
|
|
284
|
+
// #686: a broken pact no longer counts as peace.
|
|
285
|
+
const with_ = pactsInForce(pacts).filter((k) => k.parties.includes(partner));
|
|
286
|
+
if (!with_.length)
|
|
287
|
+
return undefined;
|
|
288
|
+
return `Player ${partner} is already at peace with ${with_
|
|
289
|
+
.map((k) => `player${k.parties.length > 2 ? 's' : ''} ${k.parties.filter((x) => x !== partner).join(', ')} (${pactLabel(k)})`)
|
|
290
|
+
.join('; ')}: a truce with it does not free it from them, and they may act together (#680, report only).`;
|
|
291
|
+
};
|
|
275
292
|
return respond(view, VIEWS, (rung) => {
|
|
276
293
|
const neighbours = built.map((b) => ({
|
|
277
294
|
player: playerRef(b.partner),
|
|
@@ -291,7 +308,8 @@ export function registerDiplomacyTool(server, ctx, opts = {}) {
|
|
|
291
308
|
terms: { ...termsView(b.terms), source: b.agreement ? 'recorded' : 'suggested' },
|
|
292
309
|
price: priceView(b.priced, rung),
|
|
293
310
|
verdict: b.verdict.verdict,
|
|
294
|
-
reasons: b.verdict.reasons,
|
|
311
|
+
reasons: peaceOf(b.partner) ? [...b.verdict.reasons, peaceOf(b.partner)] : b.verdict.reasons,
|
|
312
|
+
...(atPeaceWith(pacts, b.partner).length ? { atPeaceWith: atPeaceWith(pacts, b.partner).map(playerRef) } : {}),
|
|
295
313
|
record: b.recordState,
|
|
296
314
|
...(habitsOf(b.partner) ? { habits: habitsOf(b.partner) } : {}),
|
|
297
315
|
}),
|
|
@@ -307,6 +325,20 @@ export function registerDiplomacyTool(server, ctx, opts = {}) {
|
|
|
307
325
|
description,
|
|
308
326
|
},
|
|
309
327
|
...(modView ? { modAlliances: modView } : {}),
|
|
328
|
+
...(pacts.length
|
|
329
|
+
? {
|
|
330
|
+
pactsBetweenOthers: pacts.map((k) => ({
|
|
331
|
+
parties: k.parties.map(playerRef),
|
|
332
|
+
source: k.source,
|
|
333
|
+
...(k.agreement ? { agreement: k.agreement } : {}),
|
|
334
|
+
...(k.untilTurn !== undefined ? { untilTurn: k.untilTurn } : {}),
|
|
335
|
+
...(k.endsTurn !== undefined ? { endsTurn: k.endsTurn } : {}),
|
|
336
|
+
// #686: a party broke it in view: it no longer counts (report only).
|
|
337
|
+
...(k.broken ? { broken: true } : {}),
|
|
338
|
+
...(k.flags?.length ? { flags: k.flags.map((f) => ({ ...f, by: playerRef(f.by), against: playerRef(f.against), territories: f.territories.map(name) })) } : {}),
|
|
339
|
+
})),
|
|
340
|
+
}
|
|
341
|
+
: {}),
|
|
310
342
|
income: setup.income,
|
|
311
343
|
neighbours,
|
|
312
344
|
...(offerResult
|
|
@@ -9,7 +9,7 @@ import { z } from 'zod';
|
|
|
9
9
|
import { inGameOf, playersByInGameId } from '../live.js';
|
|
10
10
|
import { Method, writeGameRefreshParams } from '../protocol/methods.js';
|
|
11
11
|
import { readMyOrderList } from '../my-orders.js';
|
|
12
|
-
import { allianceMismatches, allyAttacksIn, breakAlerts, breaksInOrders, diplomacy2From, modPairs, myAllies, readModData, runsDiplomacy2, } from '../mod-alliances.js';
|
|
12
|
+
import { allianceMismatches, allyAttacksIn, breakAlerts, breaksInOrders, diplomacy2From, modPairs, myAllies, othersAlliances, readModData, runsDiplomacy2, } from '../mod-alliances.js';
|
|
13
13
|
import { currentTurn, gameIdArg, readAnnotations, respond, untrustedDescription, untrustedText } from './common.js';
|
|
14
14
|
import { lookupMeta } from './hints.js';
|
|
15
15
|
import { readLatestBoard } from './live-context.js';
|
|
@@ -50,6 +50,18 @@ export async function readModAlliances(ctx, game, me) {
|
|
|
50
50
|
const allies = ids.map(feedOf).filter((x) => x !== null);
|
|
51
51
|
return { status: 'read', state, me: mine, allies, unmapped: ids.length - allies.length, feedOf };
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* #680: the Diplomacy 2 alliances between two other players, by GameFeed id (each pair ascending): pacts between
|
|
55
|
+
* them, report only. Only a read that worked; a player whose in-game id maps to no GameFeed player is left out.
|
|
56
|
+
*/
|
|
57
|
+
export function modPacts(read) {
|
|
58
|
+
if (read.status !== 'read')
|
|
59
|
+
return [];
|
|
60
|
+
return othersAlliances(read.state, read.me).flatMap(([x, y]) => {
|
|
61
|
+
const [a, b] = [read.feedOf(x), read.feedOf(y)];
|
|
62
|
+
return a === null || b === null || a === b ? [] : [[a, b].sort((p, q) => p - q)];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
53
65
|
/** The warnings a turn tool adds for a mod-191 game (none for `no-mod`). */
|
|
54
66
|
export function modAllianceWarnings(read) {
|
|
55
67
|
if (read.status === 'no-mod')
|