@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,615 @@
|
|
|
1
|
+
// war.app web-client method ids (the int32 in every frame header) and the
|
|
2
|
+
// parameter writers this server uses. The name is also the `m=` query value of
|
|
3
|
+
// https://war.app/Services?m=<name>&js=1.
|
|
4
|
+
export const Method = {
|
|
5
|
+
/** Exists in the client's method table, but the web client never calls it (open games come from a page). */
|
|
6
|
+
GetOpenGames: 10,
|
|
7
|
+
GetGameDetails: 38,
|
|
8
|
+
GameRefresh: 39,
|
|
9
|
+
GetLatestGameInfo: 40,
|
|
10
|
+
SendChat: 42,
|
|
11
|
+
RegisterChatView: 43,
|
|
12
|
+
GetGameSettings: 48,
|
|
13
|
+
GetMyGames: 50,
|
|
14
|
+
AcceptGame: 60,
|
|
15
|
+
AcceptOpenSeat: 61,
|
|
16
|
+
AcceptOpenAutoGame: 62,
|
|
17
|
+
GetOpenAutoGame: 63,
|
|
18
|
+
DeclineGame: 64,
|
|
19
|
+
Surrender: 67,
|
|
20
|
+
AcceptSurrender: 68,
|
|
21
|
+
GetMapDetails: 73,
|
|
22
|
+
SendOrders: 74,
|
|
23
|
+
SendInProgressOrders: 75,
|
|
24
|
+
SendTerritoryPicks: 76,
|
|
25
|
+
SendInProgressPicks: 77,
|
|
26
|
+
BeginFirstTurn: 78,
|
|
27
|
+
GetTerritoryPicks: 79,
|
|
28
|
+
UnCommit: 80,
|
|
29
|
+
GetTurns: 81,
|
|
30
|
+
Subscribe: 238,
|
|
31
|
+
GameUpdated: 241,
|
|
32
|
+
GetInAppNotifications: 317,
|
|
33
|
+
DeleteInAppNotification: 318,
|
|
34
|
+
AcknowledgeInAppNotifications: 319,
|
|
35
|
+
};
|
|
36
|
+
const NAMES = new Map(Object.entries(Method).map(([name, id]) => [id, name]));
|
|
37
|
+
/** The method's name for a known id, or undefined. */
|
|
38
|
+
export function methodName(id) {
|
|
39
|
+
return NAMES.get(id);
|
|
40
|
+
}
|
|
41
|
+
/** GetMapDetails(mapId) — takes no auth block. */
|
|
42
|
+
export function writeGetMapDetailsParams(w, mapId) {
|
|
43
|
+
w.int32(mapId);
|
|
44
|
+
}
|
|
45
|
+
/** GetTerritoryPicks(auth, gameId, playerId) — the parameters after the auth block. */
|
|
46
|
+
export function writeGetTerritoryPicksParams(w, gameId, playerId) {
|
|
47
|
+
w.int32(gameId).int32(playerId);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `warlight.shared.MyGamesFilterType`, read from the client bundle (its enum names and the client's
|
|
51
|
+
* own descriptions: "Active games", "All Games", "Finished Games", …; 6 is unused). The filter is
|
|
52
|
+
* sent as one byte. #260: the client's default, `Default` with a count of 10, is the dashboard's
|
|
53
|
+
* short list (live: 10 of an account's 41 games, 7 of them finished).
|
|
54
|
+
*/
|
|
55
|
+
export const MyGamesFilterType = {
|
|
56
|
+
ActiveGames: 0,
|
|
57
|
+
ActiveNotEliminated: 1,
|
|
58
|
+
YourTurn: 2,
|
|
59
|
+
All: 3,
|
|
60
|
+
Default: 4,
|
|
61
|
+
YourTurnOrPendingChat: 5,
|
|
62
|
+
ActiveGameOrPendingChat: 7,
|
|
63
|
+
Finished: 8,
|
|
64
|
+
};
|
|
65
|
+
/** The client's sort for its game lists (`MyGamesFilters.get_Default`). */
|
|
66
|
+
export const MY_GAMES_DEFAULT_SORT = 2;
|
|
67
|
+
/** The web client's default filters (`MyGamesFilters.get_Default`), verified through the bridge. */
|
|
68
|
+
export const DEFAULT_MY_GAMES_FILTERS = {
|
|
69
|
+
filterType: MyGamesFilterType.Default,
|
|
70
|
+
count: 10,
|
|
71
|
+
sort: MY_GAMES_DEFAULT_SORT,
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* GetMyGames(auth, …) — verified through the bridge with the default filters: present +
|
|
75
|
+
* MyGamesFilters { byte filterType, int32 count, byte sort } (required), then bool false,
|
|
76
|
+
* int32 0, bool false, bool false (the client's writer sends those four as constants).
|
|
77
|
+
* Other filter values (#260) follow the same writer and are UNVERIFIED live.
|
|
78
|
+
*/
|
|
79
|
+
export function writeGetMyGamesParams(w, filters = DEFAULT_MY_GAMES_FILTERS) {
|
|
80
|
+
w.bool(true).u8(filters.filterType).int32(filters.count).u8(filters.sort);
|
|
81
|
+
w.bool(false).int32(0).bool(false).bool(false);
|
|
82
|
+
}
|
|
83
|
+
/** How many colours war.app's colour list has (`warlight.shared.GameColor` indices 0..435). */
|
|
84
|
+
export const GAME_COLOR_COUNT = 436;
|
|
85
|
+
/**
|
|
86
|
+
* AcceptOpenSeat(auth, …) — read from the client's writer (docs/WEB-PROTOCOL.md,
|
|
87
|
+
* open games): the game id, the colour (a present flag, then the GameColor
|
|
88
|
+
* record — one int32 colour index; war.app refuses an absent colour, verified
|
|
89
|
+
* live as server error 1 "color is null"), the open seat's team, an optional
|
|
90
|
+
* custom-scenario start slot (absent — scenario games are refused), then a bool
|
|
91
|
+
* the client sets when one of the game's mods hooks the join (false: mod games
|
|
92
|
+
* are refused).
|
|
93
|
+
*/
|
|
94
|
+
export function writeAcceptOpenSeatParams(w, p) {
|
|
95
|
+
if (!Number.isInteger(p.color) || p.color < 0 || p.color >= GAME_COLOR_COUNT) {
|
|
96
|
+
throw new RangeError(`war.app colour index out of range: ${p.color} (0..${GAME_COLOR_COUNT - 1})`);
|
|
97
|
+
}
|
|
98
|
+
w.int32(p.gameId)
|
|
99
|
+
.bool(true) // colour present
|
|
100
|
+
.int32(p.color) // GameColor: the colour index
|
|
101
|
+
.int32(p.team)
|
|
102
|
+
.bool(false) // start slot
|
|
103
|
+
.bool(false); // a mod hooks this join
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* An AcceptOpenSeat result: the result-present flag, then a bool and an
|
|
107
|
+
* optional int32. Absent is `undefined` (the client treats it as a plain join).
|
|
108
|
+
*/
|
|
109
|
+
export function readAcceptOpenSeatReturn(body) {
|
|
110
|
+
if (!body.bool())
|
|
111
|
+
return undefined;
|
|
112
|
+
const vacationEnded = body.bool();
|
|
113
|
+
return body.bool() ? { vacationEnded, otherGameId: body.int32() } : { vacationEnded };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Surrender(auth, …) — VERIFIED live 2026-11-12 (issue #30): the game id, the
|
|
117
|
+
* surrender flag (false takes back a pending surrender), then the per-method
|
|
118
|
+
* trailing "ends vacation" bool the client sends as false. No result payload.
|
|
119
|
+
*/
|
|
120
|
+
export function writeSurrenderParams(w, p) {
|
|
121
|
+
w.int32(p.gameId).bool(p.surrender).bool(false);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* AcceptSurrender(auth, …) — accept another player's pending surrender (#317). READ FROM THE CLIENT
|
|
125
|
+
* BUNDLE's writer, NOT VERIFIED LIVE: after the auth block the int32 game id, the int32 in-game id of
|
|
126
|
+
* the surrendering player, the accept flag (false takes an acceptance back), then the per-method
|
|
127
|
+
* "a mod hooks this method" bool, sent false. No result payload: the outcome is read from game state.
|
|
128
|
+
*/
|
|
129
|
+
export function writeAcceptSurrenderParams(w, p) {
|
|
130
|
+
w.int32(p.gameId).int32(p.playerId).bool(p.accept).bool(false);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* BeginFirstTurn(auth, gameId) — the web client's Begin button in a game whose
|
|
134
|
+
* first turn is a speed race (MoveOrder `NoLuckCycle`): war.app withholds the
|
|
135
|
+
* board until it is pressed, and pressing it starts the player's first-turn
|
|
136
|
+
* timer. READ FROM THE CLIENT'S WRITER, NOT VERIFIED LIVE: after the auth block
|
|
137
|
+
* the client writes the game id alone (no trailing bools). The reply is a
|
|
138
|
+
* present flag then the player's GameStanding (this server reads the board back
|
|
139
|
+
* with GetLatestGameInfo instead of decoding it).
|
|
140
|
+
*/
|
|
141
|
+
export function writeBeginFirstTurnParams(w, gameId) {
|
|
142
|
+
w.int32(gameId);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* UnCommit(auth, gameId) — withdraws the account's committed orders for the
|
|
146
|
+
* current turn ("Modify orders" in the client). VERIFIED FROM THE CLIENT
|
|
147
|
+
* BUNDLE's writer, not yet against a live capture: after the auth block only
|
|
148
|
+
* the int32 game id — no trailing bools — and no result payload.
|
|
149
|
+
*/
|
|
150
|
+
export function writeUnCommitParams(w, gameId) {
|
|
151
|
+
w.int32(gameId);
|
|
152
|
+
}
|
|
153
|
+
/** The page size the client always asks GetInAppNotifications for. */
|
|
154
|
+
export const NOTIFICATIONS_PAGE_SIZE = 30;
|
|
155
|
+
/**
|
|
156
|
+
* GetInAppNotifications(auth, start, count) — the client's notifications screen (#311). READ FROM THE
|
|
157
|
+
* CLIENT BUNDLE's writer, NOT VERIFIED LIVE: after the auth block the int32 start index (the paging
|
|
158
|
+
* offset), then the int32 page size (the client always sends 30). Reply: GetInAppNotificationsReturn.
|
|
159
|
+
*/
|
|
160
|
+
export function writeGetInAppNotificationsParams(w, start, count = NOTIFICATIONS_PAGE_SIZE) {
|
|
161
|
+
w.int32(start).int32(count);
|
|
162
|
+
}
|
|
163
|
+
/** A notification id as war.app sends it back: decimal text. */
|
|
164
|
+
export const NOTIFICATION_ID = /^\d{1,20}$/;
|
|
165
|
+
/**
|
|
166
|
+
* AcknowledgeInAppNotifications(auth, ids) — marks notifications read (#311). READ FROM THE CLIENT
|
|
167
|
+
* BUNDLE's writer, NOT VERIFIED LIVE: after the auth block a present list (int32 count) of the ids, each
|
|
168
|
+
* a string of decimal text. No result payload: the effect is read back from a later list.
|
|
169
|
+
*/
|
|
170
|
+
export function writeAcknowledgeInAppNotificationsParams(w, ids) {
|
|
171
|
+
if (ids.length === 0)
|
|
172
|
+
throw new RangeError('no notification ids');
|
|
173
|
+
for (const id of ids)
|
|
174
|
+
if (!NOTIFICATION_ID.test(id))
|
|
175
|
+
throw new RangeError(`not a notification id: ${JSON.stringify(id)}`);
|
|
176
|
+
w.bool(true).list(ids, (ww, id) => ww.string(id));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* DeleteInAppNotification(auth, id) — deletes one notification (#311), the client's Delete button. READ
|
|
180
|
+
* FROM THE CLIENT BUNDLE's writer, NOT VERIFIED LIVE: after the auth block one string, the id as decimal
|
|
181
|
+
* text. No result payload; the client treats server error 699 (`InAppNotificationKeyNotFound`) as already
|
|
182
|
+
* deleted. The effect is read back from a later list.
|
|
183
|
+
*/
|
|
184
|
+
export function writeDeleteInAppNotificationParams(w, id) {
|
|
185
|
+
if (!NOTIFICATION_ID.test(id))
|
|
186
|
+
throw new RangeError(`not a notification id: ${JSON.stringify(id)}`);
|
|
187
|
+
w.string(id);
|
|
188
|
+
}
|
|
189
|
+
/** The server error DeleteInAppNotification answers for an id it does not hold: already deleted. */
|
|
190
|
+
export const NOTIFICATION_NOT_FOUND = 699;
|
|
191
|
+
/**
|
|
192
|
+
* DeclineGame(auth, gameId, modHook) — the lobby's Decline button, which is also how a seated
|
|
193
|
+
* player leaves a game still `WaitingForPlayers` (#217). READ FROM THE CLIENT BUNDLE's writer,
|
|
194
|
+
* NOT VERIFIED LIVE: after the auth block the int32 game id, then one bool the client sets when
|
|
195
|
+
* one of the game's mods hooks the decline (sent false: mod games are refused).
|
|
196
|
+
*/
|
|
197
|
+
export function writeDeclineGameParams(w, gameId) {
|
|
198
|
+
w.int32(gameId).bool(false);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A DeclineGame reply: one bool (no present flag), which the client reads as "the chat messages
|
|
202
|
+
* you sent to this game were removed". `undefined` when the reply carries nothing. Never a
|
|
203
|
+
* success signal: the leave is read back from game state.
|
|
204
|
+
*/
|
|
205
|
+
export function readDeclineGameReturn(body) {
|
|
206
|
+
return body.remaining > 0 ? body.bool() : undefined;
|
|
207
|
+
}
|
|
208
|
+
/** GetLatestGameInfo(auth, gameId) — the parameters after the auth block. */
|
|
209
|
+
export function writeGetLatestGameInfoParams(w, gameId) {
|
|
210
|
+
w.int32(gameId);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* SendTerritoryPicks(auth, gameId, picks) — verified through the bridge: the
|
|
214
|
+
* game id, a present int list of territory ids in priority order, then two
|
|
215
|
+
* bools the client sends as false.
|
|
216
|
+
*/
|
|
217
|
+
export function writeSendTerritoryPicksParams(w, gameId, territoryIds) {
|
|
218
|
+
w.int32(gameId)
|
|
219
|
+
.bool(true)
|
|
220
|
+
.list(territoryIds, (ww, id) => ww.int32(id))
|
|
221
|
+
.bool(false)
|
|
222
|
+
.bool(false);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* A GetTerritoryPicks result: the result-present flag, then an int32-count list
|
|
226
|
+
* of territory ids in priority order. Absent or null is "no picks".
|
|
227
|
+
*/
|
|
228
|
+
export function readTerritoryPicks(body) {
|
|
229
|
+
if (!body.bool())
|
|
230
|
+
return [];
|
|
231
|
+
return body.list((r) => r.int32()) ?? [];
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Subscribe(topics) — sent on the push socket, not through `/Services`, and
|
|
235
|
+
* with NO auth block (verified live): a present list of topic strings
|
|
236
|
+
* (`Game.<id>`), then a null string.
|
|
237
|
+
*/
|
|
238
|
+
export function writeSubscribeParams(w, topics) {
|
|
239
|
+
w.bool(true)
|
|
240
|
+
.list(topics, (ww, t) => ww.string(t))
|
|
241
|
+
.string(null);
|
|
242
|
+
}
|
|
243
|
+
/** The push topic for a game's updates. */
|
|
244
|
+
export const gameTopic = (gameId) => `Game.${gameId}`;
|
|
245
|
+
/**
|
|
246
|
+
* A Subscribe result: present flag, then a dict topic → error code
|
|
247
|
+
* (EnumSerialization_ErrorTypes, int32). Absent or null means every topic
|
|
248
|
+
* was accepted; an entry is a refused topic.
|
|
249
|
+
*/
|
|
250
|
+
export function readSubscribeResult(body) {
|
|
251
|
+
if (!body.bool())
|
|
252
|
+
return new Map();
|
|
253
|
+
const d = body.dict((r) => r.string() ?? '', (r) => r.int32());
|
|
254
|
+
return d ?? new Map();
|
|
255
|
+
}
|
|
256
|
+
/** SendChat channel for the whole game (any other value is a team channel: the sender's team). */
|
|
257
|
+
export const CHAT_CHANNEL_PUBLIC = -1;
|
|
258
|
+
/** The "last seen" chat marker a client that has seen nothing sends (`-1`, as text). */
|
|
259
|
+
export const NO_CHAT_MARKER = '-1';
|
|
260
|
+
/**
|
|
261
|
+
* GameRefresh(auth, …) per docs/WEB-PROTOCOL.md (read from the client's serializer; UNVERIFIED live):
|
|
262
|
+
* game id, the chat and non-chat flags, the public and team "last seen" markers (decimal text; a
|
|
263
|
+
* client that has seen nothing sends `-1`), the lobby flag, then two optional dicts (game-group chat
|
|
264
|
+
* views; absent). Reply: `GameDetailsAndChat`, the chat list first.
|
|
265
|
+
*/
|
|
266
|
+
export function writeGameRefreshParams(w, p) {
|
|
267
|
+
w.int32(p.gameId)
|
|
268
|
+
.bool(p.chat)
|
|
269
|
+
.bool(p.nonChat)
|
|
270
|
+
.string(NO_CHAT_MARKER)
|
|
271
|
+
.string(NO_CHAT_MARKER)
|
|
272
|
+
.bool(p.lobby)
|
|
273
|
+
.bool(false)
|
|
274
|
+
.bool(false);
|
|
275
|
+
}
|
|
276
|
+
/** A chat read mark: a message id as decimal text, or `-1` (the client's "no mark"). */
|
|
277
|
+
export const CHAT_MARK = /^(-1|\d{1,20})$/;
|
|
278
|
+
function writeMarkDict(w, marks) {
|
|
279
|
+
if (!marks || marks.size === 0) {
|
|
280
|
+
w.bool(false);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
w.bool(true).dict(marks, (ww, k) => ww.int32(k), (ww, v) => ww.string(v));
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* RegisterChatView(auth, …) — marks a game's chat read (#311). READ FROM THE CLIENT BUNDLE's writer, NOT
|
|
287
|
+
* VERIFIED LIVE: the int32 game id, the public and team marks (strings of decimal text: the highest message
|
|
288
|
+
* id seen on that channel; the client sends `-1` for a channel it is not marking), then two optional dicts
|
|
289
|
+
* (present flag, int32 count, int32 key, string mark): per private counterpart (in-game id), and per game
|
|
290
|
+
* group. No result payload: the effect is read back from GetMyGames' unread flags.
|
|
291
|
+
*/
|
|
292
|
+
export function writeRegisterChatViewParams(w, p) {
|
|
293
|
+
const marks = [p.publicMark, p.teamMark, ...(p.privateMarks?.values() ?? []), ...(p.groupMarks?.values() ?? [])];
|
|
294
|
+
for (const m of marks)
|
|
295
|
+
if (m !== undefined && !CHAT_MARK.test(m))
|
|
296
|
+
throw new RangeError(`not a chat mark: ${JSON.stringify(m)}`);
|
|
297
|
+
w.int32(p.gameId)
|
|
298
|
+
.string(p.publicMark ?? NO_CHAT_MARKER)
|
|
299
|
+
.string(p.teamMark ?? NO_CHAT_MARKER);
|
|
300
|
+
writeMarkDict(w, p.privateMarks);
|
|
301
|
+
writeMarkDict(w, p.groupMarks);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* SendChat(auth, …) per docs/WEB-PROTOCOL.md (read from the client's
|
|
305
|
+
* serializer; the owner verifies it live): game id, text, channel, optional
|
|
306
|
+
* private recipient, optional game-group id (absent), two marker strings
|
|
307
|
+
* (absent), two optional "last seen" dicts (absent). An optional int32 is a
|
|
308
|
+
* present flag then the value.
|
|
309
|
+
*/
|
|
310
|
+
export function writeSendChatParams(w, p) {
|
|
311
|
+
w.int32(p.gameId).string(p.text).int32(p.channel ?? CHAT_CHANNEL_PUBLIC);
|
|
312
|
+
if (p.recipient === undefined)
|
|
313
|
+
w.bool(false);
|
|
314
|
+
else
|
|
315
|
+
w.bool(true).int32(p.recipient);
|
|
316
|
+
w.bool(false) // game-group id
|
|
317
|
+
.string(null)
|
|
318
|
+
.string(null)
|
|
319
|
+
.bool(false)
|
|
320
|
+
.bool(false);
|
|
321
|
+
}
|
|
322
|
+
// ---------------------------------------------------------------------------
|
|
323
|
+
// Orders (SendOrders, method 74).
|
|
324
|
+
//
|
|
325
|
+
// VERIFIED 2026-11-12: these layouts match a live client turn commit byte for byte
|
|
326
|
+
// (docs/WEB-PROTOCOL.md, Orders; pinned by golden tests in tests/protocol/methods.test.ts).
|
|
327
|
+
// writeSendOrdersParams assembles a whole turn commit from them.
|
|
328
|
+
/** AttackTransfer mode byte. */
|
|
329
|
+
export const AttackTransferMode = { Attack: 1, Transfer: 2, AttackTransfer: 3 };
|
|
330
|
+
const ORDER_TAG_ATTACK_TRANSFER = 1;
|
|
331
|
+
const ORDER_TAG_DEPLOY = 2;
|
|
332
|
+
function writeOrderBase(w, playerId) {
|
|
333
|
+
// playerId, no result, no standing updates
|
|
334
|
+
w.int32(playerId).bool(false).bool(false);
|
|
335
|
+
}
|
|
336
|
+
/** Encode a Deploy order (layout verified against a live turn commit). */
|
|
337
|
+
export function writeDeployOrder(w, o) {
|
|
338
|
+
w.u8(ORDER_TAG_DEPLOY)
|
|
339
|
+
.int32(o.territoryId)
|
|
340
|
+
.bool(o.flag ?? false)
|
|
341
|
+
.int32(o.armies);
|
|
342
|
+
writeOrderBase(w, o.playerId);
|
|
343
|
+
}
|
|
344
|
+
/** The special-unit tag of a Commander (`warlight.shared.Commander`, from the bundle; docs/WEB-PROTOCOL.md). */
|
|
345
|
+
const SPECIAL_UNIT_COMMANDER = 1;
|
|
346
|
+
/**
|
|
347
|
+
* Encode an AttackTransfer order. The layout is verified against a live turn commit (mode 3, no
|
|
348
|
+
* options); the option bytes (mode 1/2, byPercent, attackTeammates, a commander in the Armies)
|
|
349
|
+
* follow the client bundle's writer and are UNVERIFIED live (#165).
|
|
350
|
+
*/
|
|
351
|
+
export function writeAttackTransferOrder(w, o) {
|
|
352
|
+
w.u8(ORDER_TAG_ATTACK_TRANSFER)
|
|
353
|
+
.bool(o.attackTeammates ?? false)
|
|
354
|
+
.u8(o.mode ?? AttackTransferMode.AttackTransfer)
|
|
355
|
+
.bool(o.byPercent ?? false)
|
|
356
|
+
.int32(o.from)
|
|
357
|
+
// Armies: not fogged, count, then the special units (count byte; each a tag, a GUID, an owner)
|
|
358
|
+
.bool(false)
|
|
359
|
+
.int32(o.armies);
|
|
360
|
+
if (o.commander)
|
|
361
|
+
w.u8(1).u8(SPECIAL_UNIT_COMMANDER).guid(o.commander.id).int32(o.commander.owner);
|
|
362
|
+
else
|
|
363
|
+
w.u8(0);
|
|
364
|
+
w.int32(o.to);
|
|
365
|
+
writeOrderBase(w, o.playerId);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The card plays this server can encode, by order tag. VERIFIED 2026-11-12
|
|
369
|
+
* (docs/PLAN-CARDS-PUSH.md): Reinforcement (5) live, golden-pinned; Order Priority, Order Delay
|
|
370
|
+
* and Blockade follow the same layout with the fields read from the client. The targeted cards
|
|
371
|
+
* (Spy 6, Airlift 12, Gift 13, Diplomacy 14, Sanctions 15, Reconnaissance 16, Surveillance 17;
|
|
372
|
+
* PLAN-TEAMS part D) are read from the bundle's `GameOrderPlayCard<X>` writers and golden-pinned,
|
|
373
|
+
* but UNVERIFIED live (V9): no commit carrying one has been sent. Bomb (20, `GameOrderPlayCardBomb`)
|
|
374
|
+
* and Emergency Blockade (8, `GameOrderPlayCardAbandon`) likewise: each writes one int32 territory.
|
|
375
|
+
*/
|
|
376
|
+
const CardPlayTag = {
|
|
377
|
+
EmergencyBlockade: 8,
|
|
378
|
+
Reinforcement: 5,
|
|
379
|
+
Spy: 6,
|
|
380
|
+
OrderPriority: 10,
|
|
381
|
+
OrderDelay: 11,
|
|
382
|
+
Airlift: 12,
|
|
383
|
+
Gift: 13,
|
|
384
|
+
Diplomacy: 14,
|
|
385
|
+
Sanctions: 15,
|
|
386
|
+
Reconnaissance: 16,
|
|
387
|
+
Surveillance: 17,
|
|
388
|
+
Blockade: 18,
|
|
389
|
+
Bomb: 20,
|
|
390
|
+
};
|
|
391
|
+
/** The card plays that take targets (PLAN-TEAMS part D): `warapp_submit_turn` resolves their fields. */
|
|
392
|
+
export const TARGETED_CARD_PLAYS = new Set([
|
|
393
|
+
'Spy',
|
|
394
|
+
'Airlift',
|
|
395
|
+
'Gift',
|
|
396
|
+
'Diplomacy',
|
|
397
|
+
'Sanctions',
|
|
398
|
+
'Reconnaissance',
|
|
399
|
+
'Surveillance',
|
|
400
|
+
'Bomb',
|
|
401
|
+
'EmergencyBlockade',
|
|
402
|
+
]);
|
|
403
|
+
/**
|
|
404
|
+
* The card plays whose encoding is read from the bundle but not yet sent live (V9): the preview warns
|
|
405
|
+
* and the result carries `cardPlayCheck`. Airlift left it once verified live 2026-11-16 (#296).
|
|
406
|
+
*/
|
|
407
|
+
export const UNVERIFIED_CARD_PLAYS = new Set([...TARGETED_CARD_PLAYS].filter((kind) => kind !== 'Airlift'));
|
|
408
|
+
function need(v, card, what) {
|
|
409
|
+
if (v === undefined)
|
|
410
|
+
throw new Error(`A ${card} card play needs ${what}.`);
|
|
411
|
+
return v;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Encode a play-card order: the tag, the card's own fields in the order the bundle's writer puts
|
|
415
|
+
* them, the card instance GUID in .NET byte order, then the player id and two false bools.
|
|
416
|
+
* Blockade, Emergency Blockade, Bomb, Reconnaissance: the territory. Spy, Sanctions: the player. Surveillance: the bonus.
|
|
417
|
+
* Gift: the recipient, then the territory. Diplomacy: the two players. Airlift: a present
|
|
418
|
+
* `Armies` (not fogged, the count, the special units: none, or my commander — as an AttackTransfer
|
|
419
|
+
* writes it), the from
|
|
420
|
+
* territory, a legacy army count the client leaves 0, the to territory. Throws when a card's
|
|
421
|
+
* fields are missing.
|
|
422
|
+
*/
|
|
423
|
+
export function writeCardPlayOrder(w, o) {
|
|
424
|
+
w.u8(CardPlayTag[o.card]);
|
|
425
|
+
switch (o.card) {
|
|
426
|
+
case 'Blockade':
|
|
427
|
+
case 'EmergencyBlockade':
|
|
428
|
+
case 'Bomb':
|
|
429
|
+
case 'Reconnaissance':
|
|
430
|
+
w.int32(need(o.target, o.card, 'a target territory'));
|
|
431
|
+
break;
|
|
432
|
+
case 'Spy':
|
|
433
|
+
case 'Sanctions':
|
|
434
|
+
w.int32(need(o.player, o.card, 'a target player'));
|
|
435
|
+
break;
|
|
436
|
+
case 'Surveillance':
|
|
437
|
+
w.int32(need(o.bonus, o.card, 'a target bonus'));
|
|
438
|
+
break;
|
|
439
|
+
case 'Gift': {
|
|
440
|
+
const player = need(o.player, o.card, 'a recipient player');
|
|
441
|
+
w.int32(player).int32(need(o.target, o.card, 'a territory'));
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
case 'Diplomacy': {
|
|
445
|
+
const [a, b] = need(o.players, o.card, 'two players');
|
|
446
|
+
w.int32(a).int32(b);
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
case 'Airlift':
|
|
450
|
+
if (o.from === undefined || o.to === undefined || o.armies === undefined) {
|
|
451
|
+
throw new Error('An Airlift card play needs from, to and armies.');
|
|
452
|
+
}
|
|
453
|
+
w.bool(true).bool(false).int32(o.armies);
|
|
454
|
+
if (o.commander)
|
|
455
|
+
w.u8(1).u8(SPECIAL_UNIT_COMMANDER).guid(o.commander.id).int32(o.commander.owner);
|
|
456
|
+
else
|
|
457
|
+
w.u8(0);
|
|
458
|
+
w.int32(o.from).int32(0).int32(o.to);
|
|
459
|
+
break;
|
|
460
|
+
default:
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
w.guid(o.cardId);
|
|
464
|
+
writeOrderBase(w, o.playerId);
|
|
465
|
+
}
|
|
466
|
+
const ORDER_TAG_DISCARD = 9;
|
|
467
|
+
/**
|
|
468
|
+
* Encode a discard order (`GameOrderDiscard`): tag 9, the card instance GUID in
|
|
469
|
+
* .NET byte order, then the order base. VERIFIED against the client bundle's
|
|
470
|
+
* writer (the tag, the GUID, the order base), not yet against a live commit.
|
|
471
|
+
*/
|
|
472
|
+
export function writeDiscardOrder(w, o) {
|
|
473
|
+
w.u8(ORDER_TAG_DISCARD);
|
|
474
|
+
w.guid(o.cardId);
|
|
475
|
+
writeOrderBase(w, o.playerId);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* The `warlight.shared.TurnPhase` each order runs in. war.app refuses a turn
|
|
479
|
+
* whose orders are out of phase order with error 10 `OrdersInIncorrectOrder`
|
|
480
|
+
* (VERIFIED live 2026-11-12: `[OrderPriority, Reinforcement, deploys]` was
|
|
481
|
+
* accepted, `[Reinforcement, OrderPriority, …]` refused). Order Delay runs in
|
|
482
|
+
* the attack/transfer phase (50) — VERIFIED live 2026-11-12: placed with Order
|
|
483
|
+
* Priority (phase 12) it was refused with error 10. Discards run first (phase 10,
|
|
484
|
+
* from the bundle's `GameOrderDiscard.Vd`).
|
|
485
|
+
*/
|
|
486
|
+
export const TurnPhase = {
|
|
487
|
+
Discards: 10,
|
|
488
|
+
OrderPriorityCards: 12,
|
|
489
|
+
/** Spy, Reconnaissance and Surveillance (bundle, UNVERIFIED live). */
|
|
490
|
+
SpyingCards: 15,
|
|
491
|
+
ReinforcementCards: 20,
|
|
492
|
+
Deploys: 25,
|
|
493
|
+
/** Bundle (`GameOrderPlayCardBomb`), UNVERIFIED live: after the deploys, before every move. */
|
|
494
|
+
BombCards: 30,
|
|
495
|
+
/** Bundle (`GameOrderPlayCardAbandon`), UNVERIFIED live: the Emergency Blockade, before Airlift and the attacks. */
|
|
496
|
+
EmergencyBlockadeCards: 37,
|
|
497
|
+
/** Bundle, UNVERIFIED live: after the deploys, before the attacks. */
|
|
498
|
+
AirliftCards: 43,
|
|
499
|
+
/** Bundle, UNVERIFIED live. */
|
|
500
|
+
GiftCards: 47,
|
|
501
|
+
Attacks: 50,
|
|
502
|
+
BlockadeCards: 60,
|
|
503
|
+
/** Bundle, UNVERIFIED live. */
|
|
504
|
+
DiplomacyCards: 75,
|
|
505
|
+
/** Bundle, UNVERIFIED live. */
|
|
506
|
+
SanctionsCards: 80,
|
|
507
|
+
};
|
|
508
|
+
const CARD_PHASE = {
|
|
509
|
+
OrderPriority: TurnPhase.OrderPriorityCards,
|
|
510
|
+
OrderDelay: TurnPhase.Attacks,
|
|
511
|
+
Reinforcement: TurnPhase.ReinforcementCards,
|
|
512
|
+
Blockade: TurnPhase.BlockadeCards,
|
|
513
|
+
Bomb: TurnPhase.BombCards,
|
|
514
|
+
EmergencyBlockade: TurnPhase.EmergencyBlockadeCards,
|
|
515
|
+
Spy: TurnPhase.SpyingCards,
|
|
516
|
+
Reconnaissance: TurnPhase.SpyingCards,
|
|
517
|
+
Surveillance: TurnPhase.SpyingCards,
|
|
518
|
+
Airlift: TurnPhase.AirliftCards,
|
|
519
|
+
Gift: TurnPhase.GiftCards,
|
|
520
|
+
Diplomacy: TurnPhase.DiplomacyCards,
|
|
521
|
+
Sanctions: TurnPhase.SanctionsCards,
|
|
522
|
+
};
|
|
523
|
+
/** The turn phase an order runs in. */
|
|
524
|
+
export function turnPhaseOf(o) {
|
|
525
|
+
if (o.kind === 'deploy')
|
|
526
|
+
return TurnPhase.Deploys;
|
|
527
|
+
if (o.kind === 'move')
|
|
528
|
+
return TurnPhase.Attacks;
|
|
529
|
+
if (o.kind === 'discard')
|
|
530
|
+
return TurnPhase.Discards;
|
|
531
|
+
return CARD_PHASE[o.card];
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Turn-phase order, and within one phase the card plays after the other orders (so an Order
|
|
535
|
+
* Delay, phase 50, follows every AttackTransfer: the shape of the 2026-11-12 live commit that
|
|
536
|
+
* verified phase 50). The phase is VERIFIED; an Order Delay ahead of a move in phase 50 is
|
|
537
|
+
* UNVERIFIED live (the client bundle lets a player raise it among the moves and its validator
|
|
538
|
+
* refuses only a phase that goes down, but no such commit has been sent), so it is written there
|
|
539
|
+
* only when its order asks (`beforeMove`, #186; docs/WEB-PROTOCOL.md).
|
|
540
|
+
*/
|
|
541
|
+
function compareTurnOrders(a, b) {
|
|
542
|
+
return turnPhaseOf(a) - turnPhaseOf(b) || Number(a.kind === 'card') - Number(b.kind === 'card');
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* The orders in the sequence SendOrders writes them: turn-phase order ({@link compareTurnOrders}),
|
|
546
|
+
* then each Order Delay that names a `beforeMove` short of the move count lifted out and written
|
|
547
|
+
* just above that move (#186 — the bundle's Order Delay order carries no position field, so its
|
|
548
|
+
* place in the list is its position; UNVERIFIED live). Several placed above one move keep their
|
|
549
|
+
* given order. Throws on a `beforeMove` on any other card, or one outside 0..moves.
|
|
550
|
+
*/
|
|
551
|
+
function sendOrderSequence(orders) {
|
|
552
|
+
const moveCount = orders.filter((o) => o.kind === 'move').length;
|
|
553
|
+
const placed = new Map();
|
|
554
|
+
for (const o of orders) {
|
|
555
|
+
if (o.kind !== 'card' || o.beforeMove === undefined)
|
|
556
|
+
continue;
|
|
557
|
+
if (o.card !== 'OrderDelay')
|
|
558
|
+
throw new Error(`Only an Order Delay takes a position among the moves, not ${o.card}.`);
|
|
559
|
+
if (!Number.isInteger(o.beforeMove) || o.beforeMove < 0 || o.beforeMove > moveCount) {
|
|
560
|
+
throw new Error(`Order Delay beforeMove ${o.beforeMove} is outside the turn's ${moveCount} moves (0–${moveCount}).`);
|
|
561
|
+
}
|
|
562
|
+
if (o.beforeMove < moveCount)
|
|
563
|
+
placed.set(o, o.beforeMove);
|
|
564
|
+
}
|
|
565
|
+
const sorted = orders.filter((o) => !placed.has(o)).sort(compareTurnOrders);
|
|
566
|
+
if (!placed.size)
|
|
567
|
+
return sorted;
|
|
568
|
+
const out = [];
|
|
569
|
+
let move = 0;
|
|
570
|
+
for (const o of sorted) {
|
|
571
|
+
if (o.kind === 'move') {
|
|
572
|
+
for (const [card, at] of placed)
|
|
573
|
+
if (at === move)
|
|
574
|
+
out.push(card);
|
|
575
|
+
move++;
|
|
576
|
+
}
|
|
577
|
+
out.push(o);
|
|
578
|
+
}
|
|
579
|
+
return out;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* SendOrders(auth, …) — verified against a live turn commit: the game id, a
|
|
583
|
+
* present order list (int32 count, then per order a present flag and the
|
|
584
|
+
* order), the turn number (GameFeed `numberOfTurns` + 1), then two bools the
|
|
585
|
+
* client sends as false. Orders are written in turn-phase order (a stable
|
|
586
|
+
* sort, so orders of one phase keep their given order, card plays after
|
|
587
|
+
* the rest): discards, Order Priority and Reinforcement plays, then every deploy, then
|
|
588
|
+
* the moves (AttackTransfers, mode 3 unless the move sets another) followed by any Order Delay
|
|
589
|
+
* plays (or one written above a chosen move, `beforeMove`, UNVERIFIED live: {@link sendOrderSequence}),
|
|
590
|
+
* then any Blockade plays. The targeted cards (UNVERIFIED live, V9) take the bundle's phases: Spy,
|
|
591
|
+
* Reconnaissance and Surveillance with the early cards (15), Bomb (30), Emergency Blockade (37), Airlift
|
|
592
|
+
* (43) and Gift (47) between the deploys and the moves, Diplomacy (75) and Sanctions (80) last.
|
|
593
|
+
*/
|
|
594
|
+
export function writeSendOrdersParams(w, gameId, playerId, orders, turnNumber) {
|
|
595
|
+
const sorted = sendOrderSequence(orders);
|
|
596
|
+
w.int32(gameId).bool(true).int32(sorted.length);
|
|
597
|
+
for (const o of sorted) {
|
|
598
|
+
w.bool(true);
|
|
599
|
+
if (o.kind === 'card') {
|
|
600
|
+
const { kind: _kind, beforeMove: _beforeMove, ...play } = o;
|
|
601
|
+
writeCardPlayOrder(w, { playerId, ...play });
|
|
602
|
+
}
|
|
603
|
+
else if (o.kind === 'discard') {
|
|
604
|
+
writeDiscardOrder(w, { playerId, cardId: o.cardId });
|
|
605
|
+
}
|
|
606
|
+
else if (o.kind === 'deploy') {
|
|
607
|
+
writeDeployOrder(w, { playerId, territoryId: o.territoryId, armies: o.armies });
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
const { kind: _kind, ...move } = o;
|
|
611
|
+
writeAttackTransferOrder(w, { playerId, ...move });
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
w.int32(turnNumber).bool(false).bool(false);
|
|
615
|
+
}
|