@chrischall/warapp-mcp 0.0.0 → 0.1.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.
Files changed (177) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +199 -8
  4. package/dist/analysis/award.js +159 -0
  5. package/dist/analysis/bonuses.js +98 -0
  6. package/dist/analysis/breach.js +62 -0
  7. package/dist/analysis/card-support.js +329 -0
  8. package/dist/analysis/card-threats.js +234 -0
  9. package/dist/analysis/cards-in-effect.js +130 -0
  10. package/dist/analysis/chains.js +59 -0
  11. package/dist/analysis/chokepoints.js +140 -0
  12. package/dist/analysis/combat.js +231 -0
  13. package/dist/analysis/commander-safety.js +149 -0
  14. package/dist/analysis/commitments.js +338 -0
  15. package/dist/analysis/exchange.js +155 -0
  16. package/dist/analysis/graph.js +82 -0
  17. package/dist/analysis/guard-off.js +54 -0
  18. package/dist/analysis/guess.js +351 -0
  19. package/dist/analysis/headroom.js +241 -0
  20. package/dist/analysis/hold-diff.js +64 -0
  21. package/dist/analysis/how-lost.js +130 -0
  22. package/dist/analysis/index.js +14 -0
  23. package/dist/analysis/local-deploy.js +159 -0
  24. package/dist/analysis/lookahead.js +108 -0
  25. package/dist/analysis/opponent-profile.js +551 -0
  26. package/dist/analysis/opponents.js +1245 -0
  27. package/dist/analysis/outlook.js +633 -0
  28. package/dist/analysis/overrides.js +60 -0
  29. package/dist/analysis/picks.js +1879 -0
  30. package/dist/analysis/plan/after-leftover.js +140 -0
  31. package/dist/analysis/plan/cap-spend.js +242 -0
  32. package/dist/analysis/plan/captures.js +1195 -0
  33. package/dist/analysis/plan/commander.js +236 -0
  34. package/dist/analysis/plan/completed.js +29 -0
  35. package/dist/analysis/plan/conceded-out.js +131 -0
  36. package/dist/analysis/plan/estimates.js +715 -0
  37. package/dist/analysis/plan/guard-off.js +232 -0
  38. package/dist/analysis/plan/holds.js +1631 -0
  39. package/dist/analysis/plan/leftover.js +760 -0
  40. package/dist/analysis/plan/move-order.js +319 -0
  41. package/dist/analysis/plan/orders.js +317 -0
  42. package/dist/analysis/plan/relations.js +702 -0
  43. package/dist/analysis/plan/report.js +672 -0
  44. package/dist/analysis/plan/shared.js +1218 -0
  45. package/dist/analysis/plan/stand-still.js +823 -0
  46. package/dist/analysis/plan/state.js +44 -0
  47. package/dist/analysis/plan/strike.js +1416 -0
  48. package/dist/analysis/plan/targets.js +651 -0
  49. package/dist/analysis/plan/team.js +299 -0
  50. package/dist/analysis/plan/threats.js +927 -0
  51. package/dist/analysis/plan/transfers.js +328 -0
  52. package/dist/analysis/plan/util.js +5 -0
  53. package/dist/analysis/plan/vacated.js +285 -0
  54. package/dist/analysis/planner.js +2922 -0
  55. package/dist/analysis/player-record.js +144 -0
  56. package/dist/analysis/player.js +268 -0
  57. package/dist/analysis/profile.js +347 -0
  58. package/dist/analysis/relations.js +1030 -0
  59. package/dist/analysis/schedule.js +88 -0
  60. package/dist/analysis/since-last.js +50 -0
  61. package/dist/analysis/static-seats.js +71 -0
  62. package/dist/analysis/stress.js +577 -0
  63. package/dist/analysis/team-brief.js +151 -0
  64. package/dist/analysis/tripwire.js +644 -0
  65. package/dist/analysis/turn-sim.js +259 -0
  66. package/dist/analysis/whereabouts.js +1109 -0
  67. package/dist/board.js +105 -0
  68. package/dist/bundle.js +117959 -36172
  69. package/dist/cards.js +435 -0
  70. package/dist/chat-cursor.js +135 -0
  71. package/dist/chat.js +192 -0
  72. package/dist/client.js +361 -0
  73. package/dist/config.js +62 -0
  74. package/dist/direct/link.js +102 -0
  75. package/dist/direct/session.js +267 -0
  76. package/dist/direct/transport.js +424 -0
  77. package/dist/guess-salt.js +65 -0
  78. package/dist/hosted.js +24 -0
  79. package/dist/index.js +33 -0
  80. package/dist/join-color.js +140 -0
  81. package/dist/live.js +278 -0
  82. package/dist/map-stats.js +152 -0
  83. package/dist/map-store.js +204 -0
  84. package/dist/move-order.js +141 -0
  85. package/dist/my-games.js +180 -0
  86. package/dist/normalize.js +411 -0
  87. package/dist/open-games.js +537 -0
  88. package/dist/outlook-log.js +138 -0
  89. package/dist/path-lock.js +22 -0
  90. package/dist/pick-list.js +193 -0
  91. package/dist/player-record-store.js +229 -0
  92. package/dist/player-states.js +31 -0
  93. package/dist/profile-store.js +677 -0
  94. package/dist/protocol/bundle.js +375 -0
  95. package/dist/protocol/codec.js +556 -0
  96. package/dist/protocol/decoded.js +12 -0
  97. package/dist/protocol/interp.js +1904 -0
  98. package/dist/protocol/methods.js +531 -0
  99. package/dist/protocol/rpc.js +202 -0
  100. package/dist/push/listener.js +393 -0
  101. package/dist/push/packets.js +66 -0
  102. package/dist/push/socketio.js +333 -0
  103. package/dist/push/websocket.js +179 -0
  104. package/dist/redact.js +62 -0
  105. package/dist/relations-store.js +242 -0
  106. package/dist/replay.js +215 -0
  107. package/dist/scalars.js +28 -0
  108. package/dist/scout.js +346 -0
  109. package/dist/stats.js +269 -0
  110. package/dist/strategy/card-clock.js +185 -0
  111. package/dist/strategy/map-notes.js +128 -0
  112. package/dist/strategy/notes.js +2168 -0
  113. package/dist/team-cards.js +84 -0
  114. package/dist/team-orders.js +150 -0
  115. package/dist/teams.js +19 -0
  116. package/dist/tools/award.js +206 -0
  117. package/dist/tools/begin-turn.js +162 -0
  118. package/dist/tools/board.js +77 -0
  119. package/dist/tools/card-advice.js +256 -0
  120. package/dist/tools/card-effects.js +49 -0
  121. package/dist/tools/card-plays.js +434 -0
  122. package/dist/tools/card-support-advice.js +140 -0
  123. package/dist/tools/chat-inbox.js +146 -0
  124. package/dist/tools/chat.js +483 -0
  125. package/dist/tools/check-plan.js +688 -0
  126. package/dist/tools/commander-check.js +102 -0
  127. package/dist/tools/commitments.js +216 -0
  128. package/dist/tools/common.js +143 -0
  129. package/dist/tools/diplomacy.js +342 -0
  130. package/dist/tools/game.js +126 -0
  131. package/dist/tools/guess-view.js +56 -0
  132. package/dist/tools/healthcheck.js +90 -0
  133. package/dist/tools/hints.js +34 -0
  134. package/dist/tools/how-lost.js +154 -0
  135. package/dist/tools/index.js +142 -0
  136. package/dist/tools/join-game.js +327 -0
  137. package/dist/tools/leave-game.js +181 -0
  138. package/dist/tools/live-context.js +339 -0
  139. package/dist/tools/live.js +404 -0
  140. package/dist/tools/map-stats.js +117 -0
  141. package/dist/tools/map.js +133 -0
  142. package/dist/tools/my-games.js +123 -0
  143. package/dist/tools/open-games.js +104 -0
  144. package/dist/tools/opponents.js +151 -0
  145. package/dist/tools/order-options.js +135 -0
  146. package/dist/tools/picks.js +292 -0
  147. package/dist/tools/profile-hook.js +156 -0
  148. package/dist/tools/profile-opponents.js +121 -0
  149. package/dist/tools/profile-reads.js +99 -0
  150. package/dist/tools/push.js +385 -0
  151. package/dist/tools/relations.js +611 -0
  152. package/dist/tools/resolve.js +45 -0
  153. package/dist/tools/route.js +36 -0
  154. package/dist/tools/scout.js +87 -0
  155. package/dist/tools/session.js +163 -0
  156. package/dist/tools/strategy.js +200 -0
  157. package/dist/tools/stress-opponents.js +83 -0
  158. package/dist/tools/surrender.js +240 -0
  159. package/dist/tools/survival.js +189 -0
  160. package/dist/tools/team-brief.js +266 -0
  161. package/dist/tools/team-source.js +222 -0
  162. package/dist/tools/team.js +182 -0
  163. package/dist/tools/turn.js +2761 -0
  164. package/dist/tools/uncommit.js +160 -0
  165. package/dist/tools/where.js +275 -0
  166. package/dist/tools/write-kit.js +158 -0
  167. package/dist/transport-bridge.js +33 -0
  168. package/dist/trend.js +452 -0
  169. package/dist/version.js +4 -0
  170. package/manifest.json +174 -4
  171. package/mint.yaml +101 -14
  172. package/package.json +11 -6
  173. package/server.json +40 -3
  174. package/skills/warapp-api/SKILL.md +95 -4
  175. package/skills/warapp-api/references/scout.mjs +348 -0
  176. package/skills/warapp-api/scripts/warapp.sh +69 -8
  177. package/skills/warapp-mcp/SKILL.md +969 -21
@@ -0,0 +1,299 @@
1
+ import { carriesTeam } from '../../teams.js';
2
+ import { neighborsOf } from '../graph.js';
3
+ import { simulateTurn } from '../turn-sim.js';
4
+ import { isCyclicMoveOrder } from './shared.js';
5
+ import { teammateAt } from './state.js';
6
+ import { byNum } from './util.js';
7
+ /**
8
+ * PLAN-TEAMS C3.4: the opponents my teammates' entered orders attack this turn, each with the teammates
9
+ * attacking it (sorted). Read from `board.teammateOrders` (V5: whether war.app sends a teammate's orders
10
+ * before they commit is unverified live): a move that is not transfer-only into a territory the board
11
+ * shows a foe holding. Empty in a no-team game, or with no teammate orders read.
12
+ */
13
+ export function teamFocusOf(board, allies, foe) {
14
+ const out = new Map();
15
+ if (!allies.size || !board.teammateOrders?.length)
16
+ return out;
17
+ const owner = new Map(board.territories.map((t) => [t.territoryId, t.owner]));
18
+ for (const entry of board.teammateOrders) {
19
+ if (!allies.has(entry.playerId) || !entry.orders)
20
+ continue;
21
+ for (const m of entry.orders.moves) {
22
+ if (m.mode === 'transfer')
23
+ continue;
24
+ const o = owner.get(m.to);
25
+ if (o?.kind !== 'player' || !foe(o.playerId))
26
+ continue;
27
+ const mates = out.get(o.playerId) ?? [];
28
+ if (!mates.includes(entry.playerId))
29
+ mates.push(entry.playerId);
30
+ out.set(o.playerId, mates.sort(byNum));
31
+ }
32
+ }
33
+ return out;
34
+ }
35
+ /** The teammates visibly holding a member of `ts` (none in a no-team game), sorted. */
36
+ export function teammatesIn(pc, ts) {
37
+ const ids = new Set();
38
+ for (const t of ts)
39
+ if (teammateAt(pc, t))
40
+ ids.add(pc.territories.get(t).owner.playerId);
41
+ return [...ids].sort(byNum);
42
+ }
43
+ /** Every positive bonus I share with a teammate, by bonus id (empty in a no-team game). */
44
+ export function sharedBonuses(pc) {
45
+ if (!pc.allies.size)
46
+ return [];
47
+ const out = [];
48
+ for (const b of [...pc.g.map.bonuses].sort((x, y) => x.id - y.id)) {
49
+ if (b.value <= 0)
50
+ continue;
51
+ const ts = pc.bonusTs.get(b.id) ?? [];
52
+ const mine = ts.filter((t) => pc.mineSet.has(t)).sort(byNum);
53
+ if (!mine.length)
54
+ continue;
55
+ const mates = teammatesIn(pc, ts);
56
+ if (!mates.length)
57
+ continue;
58
+ const teammates = mates.map((player) => ({
59
+ player,
60
+ territories: ts
61
+ .filter((t) => {
62
+ const o = pc.territories.get(t)?.owner;
63
+ return o?.kind === 'player' && o.playerId === player;
64
+ })
65
+ .sort(byNum),
66
+ }));
67
+ const others = ts.filter((t) => !pc.mineSet.has(t) && !teammateAt(pc, t)).sort(byNum);
68
+ const counts = [{ player: pc.me, n: mine.length }, ...teammates.map((m) => ({ player: m.player, n: m.territories.length }))];
69
+ const most = Math.max(...counts.map((c) => c.n));
70
+ const top = counts.filter((c) => c.n === most);
71
+ out.push({ bonusId: b.id, value: b.value, mine, teammates, others, nearer: top.length === 1 ? top[0].player : null });
72
+ }
73
+ return out;
74
+ }
75
+ /** The teammate orders read for my teammates (V5), by player id; none with nothing read. */
76
+ function mateOrders(pc) {
77
+ const out = new Map();
78
+ for (const e of pc.board.teammateOrders ?? [])
79
+ if (pc.allies.has(e.playerId) && e.orders)
80
+ out.set(e.playerId, e.orders);
81
+ return out;
82
+ }
83
+ /** The armies a teammate's move sends from a territory holding `there`: a percentage of what can move, rounded. */
84
+ const sentBy = (m, there, guard) => m.percent ? Math.round((Math.min(100, Math.max(0, m.armies)) / 100) * Math.max(0, there - guard)) : m.armies;
85
+ /** My idle armies on `x` once the plan's orders are made: what it may still send beyond what holds it. */
86
+ function idleAt(pc, v, x) {
87
+ const { ps, hd } = v;
88
+ if (!pc.mineSet.has(x) || ps.locked.has(x) || hd.conceded.has(x) || pc.myCommanders.has(x))
89
+ return 0;
90
+ // No-Split: a territory that already issues an order sends nothing more.
91
+ if (pc.noSplit && ps.moves.some((m) => m.from === x))
92
+ return 0;
93
+ const gone = (n) => ps.captured.has(n);
94
+ const keep = Math.max(hd.keepFor(x, gone), hd.twoStepKeep(x, gone), ps.coverKeep.get(x) ?? 0, ps.centralKeep.get(x) ?? 0);
95
+ return Math.max(0, (ps.avail.get(x) ?? 0) - keep);
96
+ }
97
+ /**
98
+ * PLAN-TEAMS C3.5: the teammates' borders my idle armies would make hold, by territory id. Each source's idle
99
+ * armies are allotted once (G3): the borders are served in order of the armies they need, fewest first (then
100
+ * by id), each from its sources with the most left, and a border its sources can no longer cover is left out
101
+ * — so no two offers count the same armies. The trade-off: fewest first holds the most borders, not the most
102
+ * worth, so a teammate's big border may be left out for several small ones (the worth of a teammate's border
103
+ * is theirs to judge; it is advice, never in `orders`).
104
+ */
105
+ export function teamSupport(pc, v) {
106
+ const orders = mateOrders(pc);
107
+ if (!orders.size)
108
+ return [];
109
+ const short = [];
110
+ const gone = (n) => v.ps.captured.has(n);
111
+ for (const t of [...pc.territories.keys()].sort(byNum)) {
112
+ const st = pc.territories.get(t);
113
+ if (st.owner.kind !== 'player' || st.armies === null)
114
+ continue;
115
+ const mate = st.owner.playerId;
116
+ const theirs = orders.get(mate);
117
+ if (!theirs)
118
+ continue;
119
+ const deployed = theirs.deploys.filter((d) => d.territoryId === t).reduce((n, d) => n + d.armies, 0);
120
+ const there = st.armies + deployed;
121
+ const out_ = theirs.moves.filter((m) => m.from === t).reduce((n, m) => n + sentBy(m, there, pc.guard), 0);
122
+ // Armies moved in are left out: they may land after the attack (as the planner counts my own).
123
+ const armies = Math.max(0, there - out_);
124
+ const th = v.threats.threatAt(t, gone);
125
+ if (!th)
126
+ continue;
127
+ const units = pc.unitsAt(t);
128
+ if ((pc.toTake(armies + units) ?? Infinity) > th.threat)
129
+ continue;
130
+ // Positive: toTake is monotone, and what stands there does not hold.
131
+ const need = v.threats.holdArmies(th.threat) - armies - units;
132
+ short.push({ territory: t, teammate: mate, armies, threat: th.threat, player: th.player, need });
133
+ }
134
+ // What each of my territories still has idle, spent as borders are served.
135
+ const left = new Map();
136
+ const idle = (x) => {
137
+ if (!left.has(x))
138
+ left.set(x, idleAt(pc, v, x));
139
+ return left.get(x);
140
+ };
141
+ const out = [];
142
+ for (const b of [...short].sort((x, y) => x.need - y.need || x.territory - y.territory)) {
143
+ const sources = [...neighborsOf(pc.g, b.territory)]
144
+ .map((x) => ({ territory: x, armies: idle(x) }))
145
+ .filter((x) => x.armies > 0)
146
+ .sort((a, c) => c.armies - a.armies || a.territory - c.territory);
147
+ const from = [];
148
+ let rest = b.need;
149
+ for (const x of sources) {
150
+ if (rest <= 0)
151
+ break;
152
+ // No-Split: a move sends the whole stack.
153
+ const k = pc.noSplit ? x.armies : Math.min(x.armies, rest);
154
+ from.push({ territory: x.territory, armies: k });
155
+ rest -= k;
156
+ }
157
+ if (rest > 0)
158
+ continue;
159
+ for (const f of from)
160
+ left.set(f.territory, idle(f.territory) - f.armies);
161
+ out.push({ ...b, from });
162
+ }
163
+ return out.sort((x, y) => x.territory - y.territory);
164
+ }
165
+ /** The turn simulator's settings from the planner's. */
166
+ function simSettings(s) {
167
+ return {
168
+ ...(s.offensiveKillRate !== undefined ? { offensiveKillRate: s.offensiveKillRate } : {}),
169
+ ...(s.defensiveKillRate !== undefined ? { defensiveKillRate: s.defensiveKillRate } : {}),
170
+ ...(s.luckModifier !== undefined ? { luckModifier: s.luckModifier } : {}),
171
+ ...(s.roundingMode !== undefined ? { roundingMode: s.roundingMode } : {}),
172
+ ...(s.oneArmyStandsGuard !== undefined ? { oneArmyStandsGuard: s.oneArmyStandsGuard } : {}),
173
+ ...(s.multiAttack !== undefined ? { multiAttack: s.multiAttack } : {}),
174
+ };
175
+ }
176
+ /**
177
+ * PLAN-TEAMS C3.6: the targets my teammate and I take only together, from their entered attacks and mine
178
+ * (the plan's, else my idle armies beside it), each resolved on the turn simulator in both orders.
179
+ */
180
+ export function jointCaptures(pc, v) {
181
+ const orders = mateOrders(pc);
182
+ if (!orders.size)
183
+ return [];
184
+ const settings = simSettings(pc.s);
185
+ const teams = new Map();
186
+ for (const p of pc.game.players ?? [])
187
+ if (carriesTeam(p.team))
188
+ teams.set(p.id, p.team);
189
+ const friendly = (o) => o === pc.me || (typeof o === 'number' && pc.allies.has(o));
190
+ const targets = new Map();
191
+ for (const [player, o] of [...orders].sort((a, b) => a[0] - b[0]))
192
+ for (const m of o.moves) {
193
+ if (m.mode === 'transfer')
194
+ continue;
195
+ const st = pc.territories.get(m.to);
196
+ if (st?.owner.kind !== 'player' || !pc.foe(st.owner.playerId) || st.armies === null)
197
+ continue;
198
+ targets.set(m.to, [...(targets.get(m.to) ?? []), { player, move: m }]);
199
+ }
200
+ const myDeploys = v.deploys.filter((d) => d.armies > 0).map((d) => ({ player: pc.me, territoryId: d.territoryId, armies: d.armies }));
201
+ const cyclic = isCyclicMoveOrder(pc.game.moveOrder);
202
+ const out = [];
203
+ for (const t of [...targets.keys()].sort(byNum)) {
204
+ const owner = pc.territories.get(t).owner.playerId;
205
+ const theirs = targets.get(t);
206
+ const mates = [...new Set(theirs.map((x) => x.player))].sort(byNum);
207
+ const planned = v.ps.moves.filter((m) => m.kind === 'attack' && m.to === t).map((m) => ({ from: m.from, armies: m.armies }));
208
+ const mine = planned.length
209
+ ? planned
210
+ : [...neighborsOf(pc.g, t)]
211
+ .sort(byNum)
212
+ .map((x) => ({ from: x, armies: idleAt(pc, v, x) }))
213
+ .filter((x) => x.armies > 0);
214
+ if (!mine.length)
215
+ continue;
216
+ const mateDeploys = mates.flatMap((p) => orders.get(p).deploys.map((d) => ({ player: p, territoryId: d.territoryId, armies: d.armies })));
217
+ const mateOrdersSim = mates.map((p) => ({
218
+ player: p,
219
+ orders: theirs
220
+ .filter((x) => x.player === p)
221
+ .map(({ move: m }) => ({
222
+ from: m.from,
223
+ to: m.to,
224
+ armies: m.armies,
225
+ ...(m.mode === 'attack' ? { mode: 'attack-only' } : {}),
226
+ ...(m.percent ? { byPercent: true } : {}),
227
+ ...(m.commander ? { withCommander: true } : {}),
228
+ })),
229
+ }));
230
+ const myOrders = { player: pc.me, orders: mine.map((x) => ({ from: x.from, to: t, armies: x.armies, mode: 'attack-only' })) };
231
+ const reinforce = { player: owner, territoryId: t, armies: Math.max(0, Math.floor(pc.deployOf(owner))) };
232
+ let exact = true;
233
+ const run = (who, moveOrder, reinforced) => {
234
+ const r = simulateTurn({
235
+ graph: pc.g,
236
+ board: pc.board,
237
+ deploys: [...(who !== 'theirs' ? myDeploys : []), ...(who !== 'mine' ? mateDeploys : []), ...(reinforced && reinforce.armies > 0 ? [reinforce] : [])],
238
+ orders: [...(who !== 'theirs' ? [myOrders] : []), ...(who !== 'mine' ? mateOrdersSim : [])],
239
+ moveOrder,
240
+ settings,
241
+ ...(teams.size ? { teams } : {}),
242
+ });
243
+ exact &&= r.exact;
244
+ const o = r.territories.get(t)?.owner;
245
+ return friendly(o) ? o : null;
246
+ };
247
+ // Neither of us alone: the teammate's attack, then mine, each without the other.
248
+ if (run('theirs', mates, false) !== null || run('mine', [pc.me], false) !== null)
249
+ continue;
250
+ const orderings = [[pc.me, ...mates], [...mates, pc.me]];
251
+ const cases = orderings.map((order) => {
252
+ const by = run('both', order, false);
253
+ return { first: order[0], captured: by !== null, by, capturedIfReinforced: run('both', order, true) !== null };
254
+ });
255
+ if (!cases.some((c) => c.captured))
256
+ continue;
257
+ const taking = cases.filter((c) => c.captured);
258
+ out.push({
259
+ target: t,
260
+ owner,
261
+ teammate: theirs.map(({ player, move: m }) => ({ player, from: m.from, armies: m.armies, ...(m.percent ? { percent: true } : {}) })),
262
+ mine,
263
+ inPlan: planned.length > 0,
264
+ cases,
265
+ ...(cyclic ? { mustGoFirst: taking.length === 1 ? taking[0].first : null } : {}),
266
+ exact,
267
+ });
268
+ }
269
+ return out;
270
+ }
271
+ /** The plan's team section, or undefined when there is nothing to report. */
272
+ export function teamReport(pc, v) {
273
+ const shared = sharedBonuses(pc);
274
+ const support = v ? teamSupport(pc, v) : [];
275
+ const joint = v ? jointCaptures(pc, v) : [];
276
+ if (!shared.length && !support.length && !joint.length)
277
+ return undefined;
278
+ return {
279
+ sharedBonuses: shared,
280
+ ...(support.length ? { support } : {}),
281
+ ...(joint.length ? { jointCaptures: joint } : {}),
282
+ };
283
+ }
284
+ /** "player 11" / "players 11 and 12". */
285
+ const playersText = (ids) => ids.length === 1 ? `player ${ids[0]}` : `players ${ids.slice(0, -1).join(', ')} and ${ids[ids.length - 1]}`;
286
+ /**
287
+ * PLAN-TEAMS C3.4: the rationale line for `c`, a capture of a player my teammate attacks this turn, ranked
288
+ * above `d`, an option that is otherwise equal.
289
+ */
290
+ export function teamFocusLine(pc, c, d) {
291
+ const what = (o) => o.target !== undefined
292
+ ? `${pc.label(o.target)}${o.owner !== undefined ? ` (player ${o.owner})` : ''}`
293
+ : o.kind === 'hold'
294
+ ? `the hold on ${pc.label(o.id)}`
295
+ : `bonus ${pc.bonusName(o.id)}`;
296
+ const mates = pc.teamFocus.get(c.owner) ?? [];
297
+ return (`Team focus (PLAN-TEAMS C3.4): ${what(c)} ranks above ${what(d)}, which is otherwise equal: my teammate ` +
298
+ `(${playersText(mates)}) attacks player ${c.owner} this turn in the orders they have entered (read from the live board, unverified).`);
299
+ }