@chrischall/warapp-mcp 0.0.0 → 0.2.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 +4 -4
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +211 -9
- package/dist/analysis/accept-surrender.js +56 -0
- package/dist/analysis/award.js +159 -0
- package/dist/analysis/bonuses.js +98 -0
- package/dist/analysis/breach.js +62 -0
- package/dist/analysis/calibrate.js +239 -0
- package/dist/analysis/card-support.js +329 -0
- package/dist/analysis/card-threats.js +234 -0
- package/dist/analysis/cards-in-effect.js +130 -0
- package/dist/analysis/chains.js +59 -0
- package/dist/analysis/chokepoints.js +140 -0
- package/dist/analysis/combat.js +231 -0
- package/dist/analysis/commander-safety.js +149 -0
- package/dist/analysis/commitments.js +338 -0
- package/dist/analysis/exchange.js +155 -0
- package/dist/analysis/finished-game.js +136 -0
- package/dist/analysis/game-lessons.js +217 -0
- package/dist/analysis/graph.js +82 -0
- package/dist/analysis/guard-off.js +54 -0
- package/dist/analysis/guess.js +351 -0
- package/dist/analysis/headroom.js +241 -0
- package/dist/analysis/hold-diff.js +64 -0
- package/dist/analysis/how-lost.js +130 -0
- package/dist/analysis/index.js +14 -0
- package/dist/analysis/local-deploy.js +179 -0
- package/dist/analysis/lookahead.js +108 -0
- package/dist/analysis/opponent-profile.js +552 -0
- package/dist/analysis/opponents.js +1253 -0
- package/dist/analysis/outlook.js +695 -0
- package/dist/analysis/overrides.js +60 -0
- package/dist/analysis/picks.js +1879 -0
- package/dist/analysis/plan/after-leftover.js +140 -0
- package/dist/analysis/plan/cap-spend.js +242 -0
- package/dist/analysis/plan/captures.js +1195 -0
- package/dist/analysis/plan/commander.js +236 -0
- package/dist/analysis/plan/completed.js +29 -0
- package/dist/analysis/plan/conceded-out.js +131 -0
- package/dist/analysis/plan/estimates.js +715 -0
- package/dist/analysis/plan/guard-off.js +232 -0
- package/dist/analysis/plan/holds.js +1631 -0
- package/dist/analysis/plan/leftover.js +760 -0
- package/dist/analysis/plan/move-order.js +319 -0
- package/dist/analysis/plan/orders.js +317 -0
- package/dist/analysis/plan/relations.js +702 -0
- package/dist/analysis/plan/report.js +672 -0
- package/dist/analysis/plan/shared.js +1405 -0
- package/dist/analysis/plan/stand-still.js +823 -0
- package/dist/analysis/plan/state.js +44 -0
- package/dist/analysis/plan/strike.js +1416 -0
- package/dist/analysis/plan/targets.js +651 -0
- package/dist/analysis/plan/team.js +299 -0
- package/dist/analysis/plan/threats.js +1001 -0
- package/dist/analysis/plan/transfers.js +328 -0
- package/dist/analysis/plan/util.js +5 -0
- package/dist/analysis/plan/vacated.js +285 -0
- package/dist/analysis/planner.js +2927 -0
- package/dist/analysis/player-record.js +144 -0
- package/dist/analysis/player.js +268 -0
- package/dist/analysis/profile.js +347 -0
- package/dist/analysis/relations.js +1030 -0
- package/dist/analysis/schedule.js +88 -0
- package/dist/analysis/since-last.js +50 -0
- package/dist/analysis/static-seats.js +71 -0
- package/dist/analysis/stress.js +584 -0
- package/dist/analysis/team-brief.js +151 -0
- package/dist/analysis/tripwire.js +644 -0
- package/dist/analysis/turn-sim.js +259 -0
- package/dist/analysis/whereabouts.js +1112 -0
- package/dist/board.js +105 -0
- package/dist/bundle.js +121082 -36148
- package/dist/calibration-source.js +75 -0
- package/dist/cards.js +435 -0
- package/dist/chat-cursor.js +135 -0
- package/dist/chat.js +265 -0
- package/dist/client.js +439 -0
- package/dist/config.js +62 -0
- package/dist/direct/link.js +102 -0
- package/dist/direct/session.js +267 -0
- package/dist/direct/transport.js +424 -0
- package/dist/finished-store.js +357 -0
- package/dist/guess-salt.js +65 -0
- package/dist/hosted.js +24 -0
- package/dist/index.js +33 -0
- package/dist/join-color.js +140 -0
- package/dist/lessons-store.js +356 -0
- package/dist/live.js +287 -0
- package/dist/map-details.js +127 -0
- package/dist/map-stats.js +160 -0
- package/dist/map-store.js +242 -0
- package/dist/move-order.js +141 -0
- package/dist/my-games.js +218 -0
- package/dist/normalize.js +443 -0
- package/dist/notifications.js +143 -0
- package/dist/open-games.js +537 -0
- package/dist/outlook-log.js +165 -0
- package/dist/path-lock.js +22 -0
- package/dist/pick-list.js +193 -0
- package/dist/player-record-store.js +231 -0
- package/dist/player-states.js +31 -0
- package/dist/profile-store.js +727 -0
- package/dist/protocol/bundle.js +375 -0
- package/dist/protocol/codec.js +556 -0
- package/dist/protocol/decoded.js +12 -0
- package/dist/protocol/interp.js +1904 -0
- package/dist/protocol/methods.js +615 -0
- package/dist/protocol/rpc.js +202 -0
- package/dist/push/listener.js +393 -0
- package/dist/push/packets.js +66 -0
- package/dist/push/socketio.js +333 -0
- package/dist/push/websocket.js +179 -0
- package/dist/redact.js +62 -0
- package/dist/relations-store.js +242 -0
- package/dist/replay.js +227 -0
- package/dist/scalars.js +28 -0
- package/dist/scout.js +346 -0
- package/dist/stats.js +291 -0
- package/dist/strategy/card-clock.js +185 -0
- package/dist/strategy/map-notes.js +128 -0
- package/dist/strategy/notes.js +2223 -0
- package/dist/surrender-pending.js +126 -0
- package/dist/team-cards.js +84 -0
- package/dist/team-orders.js +150 -0
- package/dist/teams.js +19 -0
- package/dist/tools/accept-surrender.js +311 -0
- package/dist/tools/award.js +206 -0
- package/dist/tools/begin-turn.js +162 -0
- package/dist/tools/board.js +77 -0
- package/dist/tools/card-advice.js +256 -0
- package/dist/tools/card-effects.js +49 -0
- package/dist/tools/card-plays.js +434 -0
- package/dist/tools/card-support-advice.js +140 -0
- package/dist/tools/chat-inbox.js +158 -0
- package/dist/tools/chat-read-mark.js +179 -0
- package/dist/tools/chat.js +525 -0
- package/dist/tools/check-plan.js +689 -0
- package/dist/tools/commander-check.js +103 -0
- package/dist/tools/commitments.js +216 -0
- package/dist/tools/common.js +143 -0
- package/dist/tools/diplomacy.js +342 -0
- package/dist/tools/end-of-game.js +384 -0
- package/dist/tools/game.js +151 -0
- package/dist/tools/guess-view.js +56 -0
- package/dist/tools/healthcheck.js +90 -0
- package/dist/tools/hints.js +34 -0
- package/dist/tools/how-lost.js +154 -0
- package/dist/tools/index.js +152 -0
- package/dist/tools/join-game.js +327 -0
- package/dist/tools/leave-game.js +181 -0
- package/dist/tools/live-context.js +339 -0
- package/dist/tools/live.js +404 -0
- package/dist/tools/map-details.js +88 -0
- package/dist/tools/map-stats.js +130 -0
- package/dist/tools/map.js +141 -0
- package/dist/tools/my-games.js +193 -0
- package/dist/tools/notifications.js +484 -0
- package/dist/tools/open-games.js +104 -0
- package/dist/tools/opponents.js +163 -0
- package/dist/tools/order-options.js +135 -0
- package/dist/tools/past-games.js +94 -0
- package/dist/tools/picks.js +305 -0
- package/dist/tools/profile-hook.js +156 -0
- package/dist/tools/profile-opponents.js +121 -0
- package/dist/tools/profile-reads.js +99 -0
- package/dist/tools/push.js +445 -0
- package/dist/tools/relations.js +611 -0
- package/dist/tools/resolve.js +45 -0
- package/dist/tools/route.js +36 -0
- package/dist/tools/scout.js +87 -0
- package/dist/tools/session.js +163 -0
- package/dist/tools/strategy.js +257 -0
- package/dist/tools/stress-opponents.js +83 -0
- package/dist/tools/surrender-pending.js +74 -0
- package/dist/tools/surrender.js +247 -0
- package/dist/tools/survival.js +189 -0
- package/dist/tools/team-brief.js +266 -0
- package/dist/tools/team-source.js +222 -0
- package/dist/tools/team.js +178 -0
- package/dist/tools/turn.js +2825 -0
- package/dist/tools/uncommit.js +160 -0
- package/dist/tools/where.js +300 -0
- package/dist/tools/write-kit.js +164 -0
- package/dist/transport-bridge.js +33 -0
- package/dist/trend.js +577 -0
- package/dist/version.js +4 -0
- package/manifest.json +194 -4
- package/mint.yaml +106 -14
- package/package.json +11 -6
- package/server.json +40 -3
- package/skills/warapp-api/SKILL.md +95 -4
- package/skills/warapp-api/references/scout.mjs +348 -0
- package/skills/warapp-api/scripts/warapp.sh +69 -8
- package/skills/warapp-mcp/SKILL.md +1096 -21
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// warapp_begin_turn: press Begin in a game whose first turn is a speed race
|
|
2
|
+
// (MoveOrder "No-luck cycle"), with the web client's BeginFirstTurn (method 78),
|
|
3
|
+
// gated on the user's confirmation. war.app withholds the board until Begin is
|
|
4
|
+
// pressed, and pressing it starts the player's first-turn timer — so the agent
|
|
5
|
+
// should call this only when it is ready to plan and submit straight away.
|
|
6
|
+
// The game is read from GameFeed first and the live board checked (a board
|
|
7
|
+
// already visible means Begin was pressed); the outcome is read back from the
|
|
8
|
+
// live board, never from the reply.
|
|
9
|
+
import { CONFIRM_INJECTION_RULE, toolAnnotations } from '@chrischall/mcp-utils';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { parseGameId } from '../client.js';
|
|
12
|
+
import { readLatestGameInfo, standingFromInfo } from '../live.js';
|
|
13
|
+
import { Method, writeBeginFirstTurnParams, writeGetLatestGameInfoParams } from '../protocol/methods.js';
|
|
14
|
+
import { gameIdArg, shownAccount, UNTRUSTED_PREVIEW_NOTE, untrustedText } from './common.js';
|
|
15
|
+
import { mintMeta } from './hints.js';
|
|
16
|
+
import { requireApprovedAccount, SPEED_FIRST_TURN_MOVE_ORDER, writeAccount } from './live-context.js';
|
|
17
|
+
import { defineGatedWrite, mySeat, refuse, requireMe, requirePlaying, sendAndVerify } from './write-kit.js';
|
|
18
|
+
const PLAYING = 'Playing';
|
|
19
|
+
const DISTRIBUTING = 'DistributingTerritories';
|
|
20
|
+
/**
|
|
21
|
+
* The BeginFirstTurn error the web client ignores (it refreshes as on success);
|
|
22
|
+
* read from the bundle, its meaning is not verified.
|
|
23
|
+
*/
|
|
24
|
+
const IGNORED_ERROR = 4;
|
|
25
|
+
const gameLabel = (game) => game.name ?? `game ${game.id}`;
|
|
26
|
+
/** Refuse a game that is not waiting for this account's Begin (judged from GameFeed). */
|
|
27
|
+
function beginnable(game, me) {
|
|
28
|
+
if (game.state === 'Finished') {
|
|
29
|
+
refuse(`Game ${game.id} is already over, so there is no first turn to begin.`, 'Check warapp_get_game.');
|
|
30
|
+
}
|
|
31
|
+
if (game.state !== PLAYING && game.state !== DISTRIBUTING) {
|
|
32
|
+
refuse(`Game ${game.id} has not started yet (game state: ${game.state}), so there is no first turn to begin.`, 'A lobby starts when its seats fill; check warapp_get_game.');
|
|
33
|
+
}
|
|
34
|
+
if ((game.numberOfTurns ?? 0) > 0) {
|
|
35
|
+
refuse(`Game ${game.id} is past its first turn (turn ${(game.numberOfTurns ?? 0) + 1}), so there is nothing to begin.`, 'Plan the turn with warapp_plan_turn.');
|
|
36
|
+
}
|
|
37
|
+
const order = game.settings?.moveOrder;
|
|
38
|
+
if (order !== undefined && order !== SPEED_FIRST_TURN_MOVE_ORDER) {
|
|
39
|
+
refuse(`Game ${game.id} does not race its first turn (move order: ${order}), so it has no Begin button.`, 'Only games with the "No-luck cycle" move order need Begin. Read the board with warapp_get_live_board.');
|
|
40
|
+
}
|
|
41
|
+
requirePlaying(game, mySeat(game, me));
|
|
42
|
+
}
|
|
43
|
+
/** The live board, or undefined while war.app withholds it. */
|
|
44
|
+
async function liveBoard(ctx, gameId) {
|
|
45
|
+
const env = await ctx.rpc.call('GetLatestGameInfo', Method.GetLatestGameInfo, (w) => writeGetLatestGameInfoParams(w, gameId));
|
|
46
|
+
return standingFromInfo(readLatestGameInfo(await ctx.bundle(), env.body)) ?? undefined;
|
|
47
|
+
}
|
|
48
|
+
export function registerBeginTurnTool(server, ctx) {
|
|
49
|
+
defineGatedWrite(server, {
|
|
50
|
+
title: 'Begin the first turn of a war.app speed game',
|
|
51
|
+
_meta: mintMeta('change', ['begin first turn', 'press begin', 'start my first turn']),
|
|
52
|
+
}, {
|
|
53
|
+
name: 'warapp_begin_turn',
|
|
54
|
+
description: 'Press Begin in a war.app (Warzone) game whose first turn is a speed race (move order "No-luck ' +
|
|
55
|
+
'cycle": whoever commits their first orders fastest moves first). war.app hides the board until ' +
|
|
56
|
+
'Begin is pressed, and pressing it STARTS YOUR TURN TIMER — call this only when ready to plan and ' +
|
|
57
|
+
'submit at once (warapp_plan_turn, then warapp_submit_turn; in manual distribution, the picks). ' +
|
|
58
|
+
'Refuses games past their first turn, games without the speed first turn, games you are not ' +
|
|
59
|
+
'playing, and games whose board is already visible; reads the board back to report `begun`. ' +
|
|
60
|
+
`The BeginFirstTurn encoding is read from the war.app client, not yet verified live. ${CONFIRM_INJECTION_RULE}`,
|
|
61
|
+
annotations: toolAnnotations({
|
|
62
|
+
title: 'Begin the first turn of a war.app speed game',
|
|
63
|
+
readOnly: false,
|
|
64
|
+
destructive: true,
|
|
65
|
+
idempotent: false,
|
|
66
|
+
openWorld: true,
|
|
67
|
+
}),
|
|
68
|
+
inputSchema: z.object({ game_id: gameIdArg }),
|
|
69
|
+
async plan({ game_id }) {
|
|
70
|
+
const gameId = parseGameId(game_id);
|
|
71
|
+
const me = await requireMe(ctx);
|
|
72
|
+
const game = await ctx.client.getGame(gameId, { settings: true, map: false });
|
|
73
|
+
beginnable(game, me);
|
|
74
|
+
if (await liveBoard(ctx, gameId)) {
|
|
75
|
+
refuse(`Your first turn in game ${gameId} has already begun: the board is visible.`, 'Plan and submit now with warapp_plan_turn and warapp_submit_turn — the turn timer is running.');
|
|
76
|
+
}
|
|
77
|
+
const name = gameLabel(game);
|
|
78
|
+
const picking = game.state === DISTRIBUTING;
|
|
79
|
+
const warning = picking
|
|
80
|
+
? `Begin STARTS YOUR PICK TIMER in game ${gameId}: the players who pick fastest get their picks in a conflict. ` +
|
|
81
|
+
'Choose and submit your picks straight after.'
|
|
82
|
+
: `Begin STARTS YOUR FIRST-TURN TIMER in game ${gameId}: the players who commit fastest move first. ` +
|
|
83
|
+
'Plan and submit straight after (warapp_plan_turn, then warapp_submit_turn).';
|
|
84
|
+
// The sentences name the game by id only; its name (its creator's words) goes,
|
|
85
|
+
// delimited, in `game.name`.
|
|
86
|
+
return {
|
|
87
|
+
gate: {
|
|
88
|
+
action: 'warapp.begin_first_turn',
|
|
89
|
+
summary: `Press Begin in war.app game ${gameId} — this starts your turn timer`,
|
|
90
|
+
account: writeAccount(me),
|
|
91
|
+
target: gameId,
|
|
92
|
+
payload: { method: 'BeginFirstTurn', gameId },
|
|
93
|
+
willSend: { game: gameId },
|
|
94
|
+
preview: {
|
|
95
|
+
warning,
|
|
96
|
+
account: shownAccount(game.players.find((p) => p.id === me)?.name, me),
|
|
97
|
+
game: { id: gameId, name: game.name === undefined ? null : untrustedText(game.name), state: game.state, turn: 1 },
|
|
98
|
+
untrusted: UNTRUSTED_PREVIEW_NOTE,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
state: { gameId, name, picking, me },
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
async execute({ gameId, name, picking, me }) {
|
|
105
|
+
await requireApprovedAccount(ctx, writeAccount(me));
|
|
106
|
+
const game = { id: gameId, name };
|
|
107
|
+
const notReadBack = (ignored, readFailure) => ({
|
|
108
|
+
status: 'unconfirmed',
|
|
109
|
+
outcome: 'unconfirmed',
|
|
110
|
+
game,
|
|
111
|
+
warning: (ignored
|
|
112
|
+
? `war.app answered Begin with error ${IGNORED_ERROR} (the web client ignores it)`
|
|
113
|
+
: 'war.app accepted Begin') +
|
|
114
|
+
`, but the board could not be read back${readFailure ? ` (${readFailure})` : ' yet'}. ` +
|
|
115
|
+
'Check warapp_get_live_board shortly — your timer is probably running; do not press Begin ' +
|
|
116
|
+
'again blindly.',
|
|
117
|
+
});
|
|
118
|
+
return sendAndVerify({
|
|
119
|
+
send: async () => {
|
|
120
|
+
await ctx.rpc.call('BeginFirstTurn', Method.BeginFirstTurn, (w) => writeBeginFirstTurnParams(w, gameId));
|
|
121
|
+
},
|
|
122
|
+
// The web client ignores this error and refreshes as on success: read the board back,
|
|
123
|
+
// and judge from it alone (#130).
|
|
124
|
+
refused: (e) => (e.code === IGNORED_ERROR ? 'ignore' : undefined),
|
|
125
|
+
unanswered: (failure) => ({
|
|
126
|
+
status: 'unknown',
|
|
127
|
+
outcome: 'unknown',
|
|
128
|
+
game,
|
|
129
|
+
warning: `war.app did not confirm Begin (${failure}), so it may ` +
|
|
130
|
+
'already have gone through and your timer may be running. Check warapp_get_live_board; do not ' +
|
|
131
|
+
'press Begin again blindly.',
|
|
132
|
+
}),
|
|
133
|
+
readBack: () => liveBoard(ctx, gameId),
|
|
134
|
+
// Nothing was read: never conclude the board is hidden from a failed read (#130).
|
|
135
|
+
unreadable: (failure, ignored) => notReadBack(ignored !== undefined, failure),
|
|
136
|
+
classify: (territories, ignored) => {
|
|
137
|
+
if (!territories && ignored) {
|
|
138
|
+
return {
|
|
139
|
+
status: 'not_begun',
|
|
140
|
+
outcome: 'not_applied',
|
|
141
|
+
game,
|
|
142
|
+
warning: `war.app answered Begin with error ${IGNORED_ERROR} (the web client ignores it; its meaning is not ` +
|
|
143
|
+
'verified) and the board is still hidden, so Begin did not take effect as far as can be read. ' +
|
|
144
|
+
'Check warapp_get_live_board before pressing Begin again.',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (!territories)
|
|
148
|
+
return notReadBack(false, undefined);
|
|
149
|
+
return {
|
|
150
|
+
status: 'begun',
|
|
151
|
+
outcome: 'confirmed',
|
|
152
|
+
game,
|
|
153
|
+
territoriesVisible: territories.length,
|
|
154
|
+
next: picking
|
|
155
|
+
? 'Your pick timer is running: choose and submit your picks now (warapp_submit_picks).'
|
|
156
|
+
: 'Your turn timer is running: plan and submit now (warapp_plan_turn, then warapp_submit_turn).',
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { analyzePlayer } from '../analysis/index.js';
|
|
3
|
+
import { toBoardState } from '../live.js';
|
|
4
|
+
import { gameIdArg, graphOf, readAnnotations, respond, untrustedDescription, viewArg } from './common.js';
|
|
5
|
+
import { lookupMeta } from './hints.js';
|
|
6
|
+
import { loadLiveTerritories } from './live-context.js';
|
|
7
|
+
import { mapOf } from './map.js';
|
|
8
|
+
import { resolvePlayer } from './resolve.js';
|
|
9
|
+
const VIEWS = ['compact', 'full'];
|
|
10
|
+
const COMPACT_THREATS = 15;
|
|
11
|
+
export function registerBoardTool(server, client, live) {
|
|
12
|
+
server.registerTool('warapp_analyze_board', {
|
|
13
|
+
title: 'Analyze a war.app board for a player',
|
|
14
|
+
description: untrustedDescription('Advise one player in an in-progress war.app (Warzone) game from the current board: their territories and ' +
|
|
15
|
+
'armies, income (base + held bonuses), the bonuses they are closest to completing (missing territories, ' +
|
|
16
|
+
'who holds them, armies needed at the game\'s kill rates), and visible enemy threats on their borders, ' +
|
|
17
|
+
'with the assumptions behind the numbers. Uses GameFeed\'s board when it sends one, else the live board ' +
|
|
18
|
+
'read through your signed-in war.app tab (as warapp_get_live_board) — a lobby has none. For map-only ' +
|
|
19
|
+
'analysis use warapp_get_map. Read-only; it never submits orders.'),
|
|
20
|
+
_meta: lookupMeta(['warzone advice', 'analyze my board', 'what should i attack', 'my income']),
|
|
21
|
+
annotations: readAnnotations('Analyze a war.app board'),
|
|
22
|
+
inputSchema: z.object({
|
|
23
|
+
game_id: gameIdArg,
|
|
24
|
+
player: z
|
|
25
|
+
.union([z.string(), z.number()])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('The player to advise: a name (or part of one) or player id — usually your own war.app name. Omit to list the players.'),
|
|
28
|
+
limit: z.coerce.number().int().min(1).max(100).optional().describe('Max bonuses in closestBonuses (default 10).'),
|
|
29
|
+
view: viewArg(VIEWS, `compact (default) labels owners by player name and keeps the top ${COMPACT_THREATS} threats; ` +
|
|
30
|
+
'"full" is the whole analysis with player ids and every threat.'),
|
|
31
|
+
}),
|
|
32
|
+
}, async ({ game_id, player, limit, view }) => {
|
|
33
|
+
const game = await client.getGame(game_id, { settings: true });
|
|
34
|
+
const map = mapOf(game);
|
|
35
|
+
const me = resolvePlayer(game.players, player);
|
|
36
|
+
const standing = game.standing ?? toBoardState(await loadLiveTerritories(live, game), game.players);
|
|
37
|
+
const a = analyzePlayer(graphOf(map), standing, me.id, game.settings, limit !== undefined ? { limit } : {});
|
|
38
|
+
const nameOf = (id) => game.players.find((p) => p.id === id)?.name ?? `player ${id}`;
|
|
39
|
+
const ownerLabel = (o) => o.kind === 'player' ? nameOf(o.playerId) : o.kind === 'unknown' ? 'unknown' : o.kind;
|
|
40
|
+
const territoryName = (id) => map.territories.find((t) => t.id === id)?.name ?? String(id);
|
|
41
|
+
return respond(view, VIEWS, (rung) => {
|
|
42
|
+
if (rung === 'full') {
|
|
43
|
+
return { player: { id: me.id, name: me.name }, players: game.players.map((p) => ({ id: p.id, name: p.name })), ...a };
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
player: { id: me.id, name: me.name },
|
|
47
|
+
boardVerified: a.boardVerified,
|
|
48
|
+
territoryCount: a.territoryCount,
|
|
49
|
+
armies: a.armies,
|
|
50
|
+
income: a.income,
|
|
51
|
+
closestBonuses: a.closestBonuses.map((b) => ({
|
|
52
|
+
bonusId: b.bonusId,
|
|
53
|
+
name: b.name,
|
|
54
|
+
value: b.value,
|
|
55
|
+
owned: `${b.ownedCount} of ${b.territoryCount}`,
|
|
56
|
+
missing: b.missing.map((m) => ({
|
|
57
|
+
territoryId: m.territoryId,
|
|
58
|
+
name: m.name,
|
|
59
|
+
owner: ownerLabel(m.owner),
|
|
60
|
+
armies: m.armies,
|
|
61
|
+
armiesToTake: m.armiesToTake,
|
|
62
|
+
})),
|
|
63
|
+
armiesNeeded: b.armiesNeeded,
|
|
64
|
+
armiesNeededComplete: b.armiesNeededComplete,
|
|
65
|
+
})),
|
|
66
|
+
threats: a.threats.slice(0, COMPACT_THREATS).map((t) => ({
|
|
67
|
+
territoryId: t.territoryId,
|
|
68
|
+
name: t.name,
|
|
69
|
+
player: nameOf(t.playerId),
|
|
70
|
+
armies: t.armies,
|
|
71
|
+
borders: t.adjacentTo.map(territoryName),
|
|
72
|
+
})),
|
|
73
|
+
assumptions: a.assumptions,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// The card advice warapp_plan_turn adds to a plan (#163): the game around the hand (team, fog,
|
|
2
|
+
// players), the team's hand, Order Delay's place, my Bomb and Emergency Blockade, the
|
|
3
|
+
// opponents' Bomb and Emergency Blockade when they can hold one, the cards in effect
|
|
4
|
+
// (Diplomacy, Sanctions), and (PLAN-TEAMS D2) where to play my Diplomacy, Sanctions, Airlift and
|
|
5
|
+
// Gift. Read-only; everything here is advice — of these only the advised Order Delay is added to the
|
|
6
|
+
// orders; my Bomb and Emergency Blockade and the D2 cards carry an `order` to pass to warapp_submit_turn.
|
|
7
|
+
import { adviseOrderDelay, CARD_ORDER_DELAY, CARD_REINFORCEMENT, isMyCard, readActiveCards } from '../cards.js';
|
|
8
|
+
import { bombAdvice, bombExposure, wallOffer, wallThreats } from '../analysis/card-threats.js';
|
|
9
|
+
import { supportAdvice } from './card-support-advice.js';
|
|
10
|
+
import { inGameId } from '../live.js';
|
|
11
|
+
import { capturePieceValue, cardClock } from '../strategy/card-clock.js';
|
|
12
|
+
import { isTeamGame, teammatesOf as teamOf } from '../teams.js';
|
|
13
|
+
const CARD_BOMB = 13;
|
|
14
|
+
const CARD_EMERGENCY_BLOCKADE = 3;
|
|
15
|
+
/** The game around my hand, for the card policy; in a team game with `me`, my in-game id (V8). */
|
|
16
|
+
export function cardGame(game, me) {
|
|
17
|
+
const team = isTeamGame(game.players);
|
|
18
|
+
let id;
|
|
19
|
+
if (team && me) {
|
|
20
|
+
try {
|
|
21
|
+
id = inGameId(me);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// No in-game id: every card counts as mine, as before.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
players: game.players.length,
|
|
29
|
+
team,
|
|
30
|
+
...(game.settings?.fog !== undefined ? { fog: game.settings.fog } : {}),
|
|
31
|
+
...(id !== undefined ? { me: id } : {}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** My teammates (never me), by GameFeed player. Empty outside a team game. */
|
|
35
|
+
const teammatesOf = (game, me) => teamOf(game.players, me);
|
|
36
|
+
/**
|
|
37
|
+
* The in-game ids whose cards are my hand: mine, and in a team game my teammates' (a team shares
|
|
38
|
+
* one hand; how war.app keys it is unverified, #163).
|
|
39
|
+
*/
|
|
40
|
+
export const handOwners = (game, me) => [
|
|
41
|
+
inGameId(me),
|
|
42
|
+
...teammatesOf(game, me).flatMap((p) => {
|
|
43
|
+
try {
|
|
44
|
+
return [inGameId(p)];
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return []; // not a GameFeed player id: no in-game id to read cards under
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
];
|
|
51
|
+
/** In a team game: the hand and the limit are the team's (said once in the plan's warnings). */
|
|
52
|
+
export const TEAM_HAND = "This is a team game: the hand and the card limit are the team's, shared with your teammates. The hand shown " +
|
|
53
|
+
"gathers every card under you and your teammates on the live board; how war.app keys a team's hand is not yet " +
|
|
54
|
+
'verified, so check the hand in the game before shedding cards.';
|
|
55
|
+
/** A card setting's `MultiplyAmount` (Blockade, Emergency Blockade), when the game sets one. */
|
|
56
|
+
function multiplier(settings, key) {
|
|
57
|
+
const r = settings?.raw[key];
|
|
58
|
+
if (typeof r !== 'object' || r === null)
|
|
59
|
+
return undefined;
|
|
60
|
+
const m = Number(r.MultiplyAmount);
|
|
61
|
+
return Number.isFinite(m) && m > 0 ? m : undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether an opponent can hold `card` this turn: the card is in play and the card clock lets it
|
|
65
|
+
* be in a hand by `turn` (unknown turn: yes).
|
|
66
|
+
*/
|
|
67
|
+
export function opponentCanHold(settings, card, turn) {
|
|
68
|
+
const entry = cardClock(settings)?.cards.find((c) => c.card === card);
|
|
69
|
+
if (!entry)
|
|
70
|
+
return false;
|
|
71
|
+
const first = entry.firstPlayableTurn.fastest;
|
|
72
|
+
return first !== null && (turn === null || turn >= first);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The card advice and warnings for a plan. Pure apart from reading the decoded board; the plan's
|
|
76
|
+
* orders are never changed.
|
|
77
|
+
*/
|
|
78
|
+
export function adviseCards(input) {
|
|
79
|
+
const { game, me, turn, hand, choice, plan, label } = input;
|
|
80
|
+
const view = {};
|
|
81
|
+
const warnings = [];
|
|
82
|
+
// V8: in a team game a card read under a teammate's id is theirs to play (unverified), never advised to me.
|
|
83
|
+
const own = hand.filter((c) => isMyCard(c, cardGame(game, me).me));
|
|
84
|
+
const gone = new Set([...choice.plays, ...choice.discards].map((c) => c.id));
|
|
85
|
+
const held = (type) => own.find((c) => c.type === type && !gone.has(c.id));
|
|
86
|
+
const friends = new Set(teammatesOf(game, me).map((p) => p.id));
|
|
87
|
+
const cb = {
|
|
88
|
+
graph: input.graph,
|
|
89
|
+
board: input.board,
|
|
90
|
+
me: me.id,
|
|
91
|
+
friends,
|
|
92
|
+
...(input.truceCovered?.size ? { noBomb: input.truceCovered } : {}),
|
|
93
|
+
deploys: plan.deploys,
|
|
94
|
+
moves: plan.moves,
|
|
95
|
+
enemyDeploy: plan.enemyDeploy,
|
|
96
|
+
...(input.settings ? { settings: input.settings } : {}),
|
|
97
|
+
};
|
|
98
|
+
const moveLabel = (k) => {
|
|
99
|
+
const m = plan.moves[k - 1];
|
|
100
|
+
return `${label(m.from)} → ${label(m.to)}`;
|
|
101
|
+
};
|
|
102
|
+
// Order Delay: above every order that is not urgent, when an attack the opponent can answer is planned.
|
|
103
|
+
// #163: an Order Delay that must leave the hand is played where the plan can use it, not discarded.
|
|
104
|
+
const keepDelay = { ...choice, discards: choice.discards.filter((c) => c.type !== CARD_ORDER_DELAY) };
|
|
105
|
+
const delay = adviseOrderDelay(own, keepDelay, plan.moves, plan.moveSlots);
|
|
106
|
+
if (delay) {
|
|
107
|
+
const insteadOfDiscard = choice.discards.some((c) => c.id === delay.card.id);
|
|
108
|
+
view.orderDelay = {
|
|
109
|
+
card: delay.card.id,
|
|
110
|
+
before: delay.before,
|
|
111
|
+
attacks: delay.attacks,
|
|
112
|
+
order: { kind: 'card', card: delay.card.id, before: delay.before },
|
|
113
|
+
...(insteadOfDiscard ? { insteadOfDiscard: true } : {}),
|
|
114
|
+
};
|
|
115
|
+
if (insteadOfDiscard)
|
|
116
|
+
warnings.push('The Order Delay that had to leave the hand is played (below) instead of discarded.');
|
|
117
|
+
warnings.push(`Play Order Delay above move ${delay.before}${delay.before <= plan.moves.length ? ` (${moveLabel(delay.before)})` : ''}: ` +
|
|
118
|
+
`${delay.attacks.map(moveLabel).join(', ')} ${delay.attacks.length === 1 ? 'is an attack' : 'are attacks'} the opponent can answer first, ` +
|
|
119
|
+
'and the orders after the card wait until the opponent has moved. The orders carry it (the card with `before`): ' +
|
|
120
|
+
'war.app accepts a card placed among the moves (verified live); that the later moves then wait for the ' +
|
|
121
|
+
"opponent's is read from the client, not yet seen in a replay. Drop it from the orders to keep the card.");
|
|
122
|
+
}
|
|
123
|
+
const cards = game.settings?.cards ?? [];
|
|
124
|
+
// My Bomb: a target where halving the stack changes the turn, else hold it.
|
|
125
|
+
const bombCard = held(CARD_BOMB);
|
|
126
|
+
if (bombCard) {
|
|
127
|
+
const a = bombAdvice(cb);
|
|
128
|
+
view.bomb = {
|
|
129
|
+
target: a.target ?? null,
|
|
130
|
+
kind: a.kind ?? null,
|
|
131
|
+
why: a.why,
|
|
132
|
+
...(a.target !== undefined ? { order: { kind: 'card', card: bombCard.id, target: a.target } } : {}),
|
|
133
|
+
};
|
|
134
|
+
warnings.push(a.target !== undefined
|
|
135
|
+
? `${a.why.replace(/^Bomb (\d+):/, (_, t) => `Bomb ${label(Number(t))}:`)} Advice only, not in the orders: pass \`cards.advice.bomb.order\` to warapp_submit_turn to play it (the encoding is read from the client, not yet verified live).`
|
|
136
|
+
: a.why);
|
|
137
|
+
}
|
|
138
|
+
// An opponent's Bomb: the borders that hold only while unbombed.
|
|
139
|
+
if (cards.includes('Bomb') && opponentCanHold(game.settings, 'Bomb', turn)) {
|
|
140
|
+
const exposed = bombExposure(cb);
|
|
141
|
+
if (exposed.length) {
|
|
142
|
+
warnings.push(`If an opponent plays a Bomb, ${exposed
|
|
143
|
+
.map((e) => `${label(e.territory)}${e.commander ? ' (your commander)' : ''} (${e.armies} → ${e.bombed}) falls to player ${e.player}'s ~${e.reach}`)
|
|
144
|
+
.join('; ')}: a bomb halves a stack after the deploys and before any move. Spread the stack over two territories, ` +
|
|
145
|
+
'or deploy one step back and move up (the bomb lands before the move).');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const ebMultiplier = multiplier(game.settings, 'EmergencyBlockadeCard');
|
|
149
|
+
if (cards.includes('EmergencyBlockade') || cards.includes('Emergency Blockade')) {
|
|
150
|
+
// An opponent's Emergency Blockade: planned attacks that would die against the wall.
|
|
151
|
+
if (ebMultiplier !== undefined && opponentCanHold(game.settings, 'Emergency Blockade', turn)) {
|
|
152
|
+
for (const w of wallThreats(cb, ebMultiplier)) {
|
|
153
|
+
warnings.push(`The attack on ${label(w.target)} (${w.attackers} armies) would die against an Emergency Blockade: player ${w.player} can turn it ` +
|
|
154
|
+
`into a neutral of (its armies + its deploy) × ${ebMultiplier} ≈ ${w.wall} before the attacks.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// My Emergency Blockade: a conceded border where the wall kills more than I give up.
|
|
158
|
+
const wallCard = held(CARD_EMERGENCY_BLOCKADE);
|
|
159
|
+
if (wallCard) {
|
|
160
|
+
const offer = ebMultiplier !== undefined ? wallOffer(cb, ebMultiplier, plan.conceded) : undefined;
|
|
161
|
+
if (offer) {
|
|
162
|
+
view.emergencyBlockade = { ...offer, order: { kind: 'card', card: wallCard.id, target: offer.territory } };
|
|
163
|
+
warnings.push(`Consider an Emergency Blockade on ${label(offer.territory)}: the plan concedes it, and its ${offer.givesUp} armies × ${ebMultiplier} make a ` +
|
|
164
|
+
`wall of ${offer.wall} that player ${offer.player}'s ~${offer.reach} would lose ~${offer.kills} attacking — if it attacks; if not, ` +
|
|
165
|
+
'the territory and its armies are given away. Advice only, not in the orders: pass `cards.advice.emergencyBlockade.order` ' +
|
|
166
|
+
'to warapp_submit_turn to play it (the encoding is read from the client, not yet verified live).');
|
|
167
|
+
}
|
|
168
|
+
else if (ebMultiplier === undefined) {
|
|
169
|
+
warnings.push('You hold an Emergency Blockade, but the game does not say its multiplier, so no wall is sized for it.');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// The cards in effect (unverified decoding): Diplomacy protecting a player, Sanctions on me.
|
|
174
|
+
const active = readActiveCards(input.info);
|
|
175
|
+
if (active.length) {
|
|
176
|
+
const byInGame = new Map(game.players.flatMap((p) => {
|
|
177
|
+
try {
|
|
178
|
+
return [[inGameId(p), p]];
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
const feed = (id) => (id === undefined ? undefined : byInGame.get(id)?.id);
|
|
185
|
+
view.active = active.map((a) => ({
|
|
186
|
+
card: a.card,
|
|
187
|
+
...(a.players ? { players: a.players.map((p) => feed(p) ?? p) } : {}),
|
|
188
|
+
...(a.target !== undefined ? { target: feed(a.target) ?? a.target } : {}),
|
|
189
|
+
...(a.playedBy !== undefined ? { playedBy: feed(a.playedBy) ?? a.playedBy } : {}),
|
|
190
|
+
...(a.expiresAfterTurn !== undefined ? { expiresAfterTurn: a.expiresAfterTurn } : {}),
|
|
191
|
+
...(a.untilTurn !== undefined ? { untilTurn: a.untilTurn } : {}),
|
|
192
|
+
}));
|
|
193
|
+
const owner = (t) => {
|
|
194
|
+
const o = input.board.territories.find((x) => x.territoryId === t)?.owner;
|
|
195
|
+
return o?.kind === 'player' ? o.playerId : undefined;
|
|
196
|
+
};
|
|
197
|
+
for (const a of view.active) {
|
|
198
|
+
const until = a.untilTurn !== undefined ? ` (until turn ${a.untilTurn})` : '';
|
|
199
|
+
if (a.card === 'Diplomacy' && a.players?.includes(me.id)) {
|
|
200
|
+
const other = a.players.find((p) => p !== me.id);
|
|
201
|
+
const hit = plan.moves.filter((m) => m.kind === 'attack' && other !== undefined && owner(m.to) === other);
|
|
202
|
+
warnings.push(`Diplomacy is in effect between you and player ${other}${until}: neither can attack the other.` +
|
|
203
|
+
(other !== undefined && input.enforced?.has(other)
|
|
204
|
+
? ' The plan honours it (T9): no hold against that player and no attack on it.'
|
|
205
|
+
: hit.length
|
|
206
|
+
? ` The plan's attacks on ${hit.map((m) => label(m.to)).join(', ')} would do nothing — drop or redirect them.`
|
|
207
|
+
: ''));
|
|
208
|
+
}
|
|
209
|
+
if (a.card === 'Sanctions' && a.target === me.id) {
|
|
210
|
+
const pct = game.settings?.raw.SanctionsCard?.Percentage;
|
|
211
|
+
const cut = typeof pct === 'number' ? ` by ${Math.round(pct * 100)}%` : '';
|
|
212
|
+
if (!input.sanctionsApplied)
|
|
213
|
+
warnings.push(`Sanctions are on you${until}: your income is cut${cut}, which the modelled income does not apply — deploy what the game shows ` +
|
|
214
|
+
'(warapp_submit_turn takes a lower total when Sanctions are in the game).');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
warnings.push('Active cards are read from the live board by an unverified decoder (#163): check them in the game.');
|
|
218
|
+
}
|
|
219
|
+
// PLAN-TEAMS D2: my Diplomacy, Sanctions, Airlift and Gift — advice only, each with its order.
|
|
220
|
+
const atPeace = new Set((view.active ?? []).flatMap((a) => (a.card === 'Diplomacy' && a.players?.includes(me.id) ? a.players.filter((p) => p !== me.id) : [])));
|
|
221
|
+
const support = supportAdvice({ game, me, plan, cards: own.filter((c) => !gone.has(c.id)), cb, atPeace, truces: input.truces ?? [] });
|
|
222
|
+
Object.assign(view, support.view);
|
|
223
|
+
warnings.push(...support.warnings);
|
|
224
|
+
return { view, warnings };
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* #127: the planner's `cardPieceValue` — what a turn with a capture earns in card pieces
|
|
228
|
+
* (`capturePieceValue`), a progressive Reinforcement card valued at the one in my hand. Empty when the
|
|
229
|
+
* game does not say (no Reinforcement card in play, or a progressive one and none in hand).
|
|
230
|
+
*/
|
|
231
|
+
export function cardPieceOption(settings, hand) {
|
|
232
|
+
const inHand = hand.find((c) => c.type === CARD_REINFORCEMENT && c.armies !== undefined && c.armies > 0)?.armies;
|
|
233
|
+
const v = capturePieceValue(settings, inHand);
|
|
234
|
+
return v.armies !== null && v.armies > 0 ? { cardPieceValue: v.armies } : {};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* #164: an opponent's Reinforcement card for the threat model: the first turn one can be in a hand
|
|
238
|
+
* (the card clock's fastest), the armies it adds (a fixed card's `FixedArmies`, else the
|
|
239
|
+
* Reinforcement card in my hand as it is worth now) and the capturing turns each further card
|
|
240
|
+
* takes. `undefined` when no Reinforcement card is in play or what it adds is unknown.
|
|
241
|
+
*/
|
|
242
|
+
export function opponentReinforcement(settings, hand) {
|
|
243
|
+
const entry = cardClock(settings)?.cards.find((c) => c.card === 'Reinforcement');
|
|
244
|
+
const first = entry?.firstPlayableTurn.fastest;
|
|
245
|
+
if (!entry || first === null || first === undefined)
|
|
246
|
+
return undefined;
|
|
247
|
+
const raw = settings.raw.ReinforcementCard;
|
|
248
|
+
const fixed = typeof raw === 'object' && raw !== null ? Number(raw.FixedArmies) : NaN;
|
|
249
|
+
const inHand = hand.find((c) => c.type === CARD_REINFORCEMENT && c.armies !== undefined && c.armies > 0)?.armies;
|
|
250
|
+
const armies = Number.isFinite(fixed) && fixed > 0 ? Math.floor(fixed) : inHand;
|
|
251
|
+
if (armies === undefined || armies <= 0)
|
|
252
|
+
return undefined;
|
|
253
|
+
const after = entry.cardsAfter.fastest;
|
|
254
|
+
const turnsPerCard = after && after.length >= 2 ? Math.max(1, after[1] - after[0]) : null;
|
|
255
|
+
return { firstTurn: first, armies, turnsPerCard };
|
|
256
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// PLAN-TEAMS D3: the cards in effect on the live board that warapp_plan_turn and warapp_check_plan
|
|
2
|
+
// rely on — a Diplomacy card between me and a player (T9) and Sanctions on me — read by the
|
|
3
|
+
// unverified active-card decoder (`readActiveCards`, #163) and kept only when `cardsInEffect` is
|
|
4
|
+
// sure of them. Never throws: an unreadable board means no card.
|
|
5
|
+
import { cardsInEffect, sanctionedIncome } from '../analysis/cards-in-effect.js';
|
|
6
|
+
import { readActiveCards } from '../cards.js';
|
|
7
|
+
import { playersByInGameId } from '../live.js';
|
|
8
|
+
/** {@link cardsInEffect} for `me` in `game` from a decoded LatestGameInfo; empty when nothing reads. */
|
|
9
|
+
export function boardCardsInEffect(game, me, turn, info) {
|
|
10
|
+
let active = [];
|
|
11
|
+
try {
|
|
12
|
+
active = readActiveCards(info);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
active = [];
|
|
16
|
+
}
|
|
17
|
+
const players = new Map();
|
|
18
|
+
for (const [inGame, p] of playersByInGameId(game.players))
|
|
19
|
+
players.set(inGame, { id: p.id, ...(p.team !== undefined ? { team: p.team } : {}), ...(p.state !== undefined ? { state: p.state } : {}) });
|
|
20
|
+
return cardsInEffect({ active, players, me: me.id, turn, settings: game.settings });
|
|
21
|
+
}
|
|
22
|
+
/** The warning every plan relying on a decoded card carries. */
|
|
23
|
+
export const CARDS_IN_EFFECT_UNVERIFIED = 'The cards in effect are read from the live board by an unverified decoder (#163, PLAN-TEAMS D3): check them in the game.';
|
|
24
|
+
/**
|
|
25
|
+
* My income this turn under the Sanctions on me (the client bundle's rule), with the warning that says
|
|
26
|
+
* so — or the income unchanged and why not, under Local Deployment (how the cut is taken from the
|
|
27
|
+
* bonus pools is not modelled).
|
|
28
|
+
*/
|
|
29
|
+
export function sanctionMyIncome(income, effect, opts) {
|
|
30
|
+
if (!effect.sanctionsOnMe.length)
|
|
31
|
+
return { income, applied: false, warnings: [] };
|
|
32
|
+
const pcts = effect.sanctionsOnMe.map((s) => s.percentage);
|
|
33
|
+
const pctText = pcts.map((p) => `${Math.round(p * 100)}%`).join(' then ');
|
|
34
|
+
const until = Math.max(...effect.sanctionsOnMe.map((s) => s.untilTurn));
|
|
35
|
+
if (opts.localDeployments)
|
|
36
|
+
return {
|
|
37
|
+
income,
|
|
38
|
+
applied: false,
|
|
39
|
+
warnings: [
|
|
40
|
+
`Sanctions are on you (${pctText}, until turn ${until}): under Local Deployment the plan does not know which pools the cut comes from, so it plans on ${income} — deploy what the game shows.`,
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
const cut = sanctionedIncome(income, pcts);
|
|
44
|
+
return {
|
|
45
|
+
income: cut,
|
|
46
|
+
applied: true,
|
|
47
|
+
warnings: [`Sanctions are on you (${pctText}, until turn ${until}): the plan's income is ${cut}, not ${income} (the client's rule, rounded to the nearest).`],
|
|
48
|
+
};
|
|
49
|
+
}
|