esim-cli 2026.1201.186 → 2026.1201.187
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/dist/esim.js +194 -33
- package/dist/index.js +194 -33
- package/package.json +1 -1
package/dist/esim.js
CHANGED
|
@@ -20665,6 +20665,12 @@ var lawLine = (law) => [
|
|
|
20665
20665
|
typeof law.proposal === "string" && law.proposal ? law.proposal : undefined
|
|
20666
20666
|
].filter(Boolean).join(" · ");
|
|
20667
20667
|
var tally = (law) => `yes ${String(law.yes ?? 0)} no ${String(law.no ?? 0)}${Array.isArray(law.voters) ? ` of ${law.voters.length} voters` : ""}`;
|
|
20668
|
+
function lawVotingView(data) {
|
|
20669
|
+
if (!isObject2(data) || !isObject2(data.voting))
|
|
20670
|
+
return data;
|
|
20671
|
+
const voting = Object.fromEntries(Object.entries(data.voting).map(([key, value]) => [key, typeof value === "boolean" ? value ? "yes" : "no" : value]));
|
|
20672
|
+
return { ...data, voting };
|
|
20673
|
+
}
|
|
20668
20674
|
function voteView(data) {
|
|
20669
20675
|
if (!isObject2(data) || typeof data.id !== "number")
|
|
20670
20676
|
return writeView2(data);
|
|
@@ -20682,7 +20688,7 @@ function voteView(data) {
|
|
|
20682
20688
|
proposer: _proposer,
|
|
20683
20689
|
...rest
|
|
20684
20690
|
} = data;
|
|
20685
|
-
return writeView2({ law: lawLine(data), tally: tally(data), ...rest });
|
|
20691
|
+
return writeView2(lawVotingView({ law: lawLine(data), tally: tally(data), ...rest }));
|
|
20686
20692
|
}
|
|
20687
20693
|
function lawListView(data) {
|
|
20688
20694
|
if (!isObject2(data) || !Array.isArray(data.items))
|
|
@@ -20722,6 +20728,24 @@ async function ownLawBallot(ctx, id) {
|
|
|
20722
20728
|
throw error;
|
|
20723
20729
|
}
|
|
20724
20730
|
}
|
|
20731
|
+
async function lawVoting(ctx, law, self, ballot) {
|
|
20732
|
+
const settled = law.status !== "ACTIVE";
|
|
20733
|
+
if (!settled && law.votingEndsAt)
|
|
20734
|
+
await ctx.call("clock");
|
|
20735
|
+
const votingClosed = settled || law.votingEndsAt !== undefined && Date.parse(law.votingEndsAt) <= ctx.now;
|
|
20736
|
+
const eligible = self !== undefined && law.voters.some((voter) => voter.citizen.id === self);
|
|
20737
|
+
const hasVoted = ballot !== null;
|
|
20738
|
+
const reason = settled ? `This law has settled (${law.status}).` : votingClosed ? "Voting has closed." : hasVoted ? "You have already voted." : self === undefined ? "Sign in to check your voting eligibility." : !eligible ? "You are not eligible to vote on this law." : undefined;
|
|
20739
|
+
return { settled, votingClosed, eligible, hasVoted, canVote: reason === undefined, reason };
|
|
20740
|
+
}
|
|
20741
|
+
var lawPageSize = 15;
|
|
20742
|
+
var lawListCommand = (page, args) => [
|
|
20743
|
+
"esim law list",
|
|
20744
|
+
"--page",
|
|
20745
|
+
String(page),
|
|
20746
|
+
...["country", "type", "status"].flatMap((key) => typeof args[key] === "string" ? [`--${key}`, shellWord(args[key])] : []),
|
|
20747
|
+
...args.votable ? ["--votable"] : []
|
|
20748
|
+
].join(" ");
|
|
20725
20749
|
var fiscalLawTypes = new Set([
|
|
20726
20750
|
"PRINT_MONEY",
|
|
20727
20751
|
"DONATE_MONEY",
|
|
@@ -20884,14 +20908,16 @@ var congress = [
|
|
|
20884
20908
|
session: false,
|
|
20885
20909
|
args: [
|
|
20886
20910
|
countryFlag,
|
|
20887
|
-
flag("type", string2().transform((value) => value.toUpperCase().replaceAll("-", "_"))
|
|
20911
|
+
flag("type", string2().transform((value) => value.toUpperCase().replaceAll("-", "_")), {
|
|
20912
|
+
source: "Common types include DECLARE_WAR, CEASE_FIRE_ACCEPT, MPP_PROPOSAL, PROPOSE_NAP, CHANGE_TAX, DONATE_MONEY and PROPOSE_REFERENDUM."
|
|
20913
|
+
}),
|
|
20888
20914
|
flag("status", _enum(["any", "active", "accepted", "accepted-success", "accepted-failed", "rejected"]), { default: "any" }),
|
|
20889
20915
|
flag("page", exports_coerce.number().int().min(1).max(2147483647), { default: 1 }),
|
|
20890
20916
|
votable
|
|
20891
20917
|
],
|
|
20892
|
-
examples: ["esim law list --status active", "esim law list --country Poland --page 2"],
|
|
20918
|
+
examples: ["esim law list --status active", "esim law list --country Poland --page 2", "esim law list --type DECLARE_WAR"],
|
|
20893
20919
|
operations: ["get-geography", "list-laws", "me"],
|
|
20894
|
-
output: { items: "Registry entries", page: "Page number", total: "Matching laws", next: "
|
|
20920
|
+
output: { items: "Registry entries", page: "Page number", total: "Matching laws", next: "Law details and nearby pages" },
|
|
20895
20921
|
view: lawListView,
|
|
20896
20922
|
empty: (data) => isObject2(data) && Array.isArray(data.items) && !data.items.length ? lawsEmpty(String(data.showing)) : undefined,
|
|
20897
20923
|
async run(ctx, args) {
|
|
@@ -20907,7 +20933,8 @@ var congress = [
|
|
|
20907
20933
|
const self = await viewerPid(ctx);
|
|
20908
20934
|
const items = page.items.map((item) => registryLaw(item, world, self));
|
|
20909
20935
|
const anyStatus = args.status === "any" && args.type === undefined && !args.votable;
|
|
20910
|
-
|
|
20936
|
+
const first = items[0];
|
|
20937
|
+
return listHeader(ctx, { ...page, items, next: first ? next({ run: `esim law show ${first.id}`, note: "Replace the ID to inspect another law." }, page.page * lawPageSize < page.total ? { run: lawListCommand(page.page + 1, args), note: "Next page" } : undefined, page.page > 1 ? { run: lawListCommand(page.page - 1, args), note: "Previous page" } : undefined) : anyStatus ? [{ run: "esim law --help", note: "Lists the commands that propose each kind of law." }, { run: "esim congress" }] : [{ run: "esim law list" }] }, country ? { country: ref(country) } : {});
|
|
20911
20938
|
}
|
|
20912
20939
|
}),
|
|
20913
20940
|
politicalCommand({
|
|
@@ -20916,15 +20943,27 @@ var congress = [
|
|
|
20916
20943
|
session: false,
|
|
20917
20944
|
args: [objectId("id")],
|
|
20918
20945
|
examples: ["esim law show 1"],
|
|
20919
|
-
|
|
20920
|
-
|
|
20946
|
+
view: lawVotingView,
|
|
20947
|
+
operations: ["get-geography", "get-law", "get-own-law-ballot", "me", "clock"],
|
|
20948
|
+
output: {
|
|
20949
|
+
effect: "Server's current effect preview",
|
|
20950
|
+
ballot: "Your ballot",
|
|
20951
|
+
voting: "Settlement, eligibility and whether you have voted",
|
|
20952
|
+
next: "Available ballot commands"
|
|
20953
|
+
},
|
|
20921
20954
|
async run(ctx, args) {
|
|
20922
20955
|
const id = number4(args.id);
|
|
20923
20956
|
const world = await geography(ctx);
|
|
20924
20957
|
const item = await ctx.call("get-law", { id });
|
|
20925
20958
|
const self = await viewerPid(ctx);
|
|
20926
20959
|
const ballot = authenticated(ctx) ? await ownLawBallot(ctx, id) : null;
|
|
20927
|
-
|
|
20960
|
+
const voting = await lawVoting(ctx, item, self, ballot);
|
|
20961
|
+
return {
|
|
20962
|
+
...registryLaw(item, world, self),
|
|
20963
|
+
ballot,
|
|
20964
|
+
voting,
|
|
20965
|
+
next: voting.canVote ? voteChoices(undefined, `esim law vote ${id}`) : []
|
|
20966
|
+
};
|
|
20928
20967
|
}
|
|
20929
20968
|
}),
|
|
20930
20969
|
politicalCommand({
|
|
@@ -20932,7 +20971,7 @@ var congress = [
|
|
|
20932
20971
|
summary: "Cast a vote on a registered law.",
|
|
20933
20972
|
args: [objectId("id"), yesNo, dryRun],
|
|
20934
20973
|
examples: ["esim law vote 1 yes --dry-run"],
|
|
20935
|
-
operations: ["get-geography", "get-law", "get-own-law-ballot", "cast-law-ballot", "get-country", "get-country-treasury"],
|
|
20974
|
+
operations: ["get-geography", "get-law", "get-own-law-ballot", "cast-law-ballot", "get-country", "get-country-treasury", "me", "clock"],
|
|
20936
20975
|
confirmWith: ["esim law list --status active"],
|
|
20937
20976
|
confirmUsing: (args) => [`esim law show ${args.id}`],
|
|
20938
20977
|
output: {
|
|
@@ -20940,8 +20979,9 @@ var congress = [
|
|
|
20940
20979
|
effect: "Server's current effect preview",
|
|
20941
20980
|
status: "Law status",
|
|
20942
20981
|
failReason: "Reason enactment failed",
|
|
20982
|
+
voting: "Settlement, eligibility and whether you have voted",
|
|
20943
20983
|
changed: "Ballot and law status before → after",
|
|
20944
|
-
next: "Law details"
|
|
20984
|
+
next: "Law details or the available vote"
|
|
20945
20985
|
},
|
|
20946
20986
|
view: voteView,
|
|
20947
20987
|
async run(ctx, args) {
|
|
@@ -20951,14 +20991,24 @@ var congress = [
|
|
|
20951
20991
|
const before = await ctx.call("get-law", { id });
|
|
20952
20992
|
const ballot = await ownLawBallot(ctx, id);
|
|
20953
20993
|
const follow = { run: `esim law show ${id}` };
|
|
20954
|
-
if (args["dry-run"])
|
|
20994
|
+
if (args["dry-run"]) {
|
|
20995
|
+
const self = await viewerPid(ctx);
|
|
20996
|
+
const voting = await lawVoting(ctx, before, self, ballot);
|
|
20997
|
+
if (voting.reason !== undefined) {
|
|
20998
|
+
const code = voting.votingClosed ? "closed" : voting.hasVoted ? "already_voted" : "forbidden";
|
|
20999
|
+
const eligibility = voting.eligible ? "yes" : "no";
|
|
21000
|
+
const alreadyVoted = voting.hasVoted ? "yes" : "no";
|
|
21001
|
+
return refuse2(ctx, code, `${voting.reason} Eligible: ${eligibility}. Already voted: ${alreadyVoted}.`, { law: { id, status: before.status }, voting, ballot }, follow.run);
|
|
21002
|
+
}
|
|
20955
21003
|
return {
|
|
20956
|
-
...registryLaw(before, world),
|
|
21004
|
+
...registryLaw(before, world, self),
|
|
20957
21005
|
dryRun: true,
|
|
20958
21006
|
ballot,
|
|
20959
|
-
|
|
20960
|
-
|
|
21007
|
+
voting,
|
|
21008
|
+
changed: { ballot: [null, ballotWord(yes)] },
|
|
21009
|
+
next: [{ run: `esim law vote ${id} ${yes ? "yes" : "no"}` }, follow]
|
|
20961
21010
|
};
|
|
21011
|
+
}
|
|
20962
21012
|
const nation = before.country;
|
|
20963
21013
|
const tax = before.taxCategory?.kind ?? "wage";
|
|
20964
21014
|
const product = before.taxCategory?.item;
|
|
@@ -32595,7 +32645,7 @@ var visualWorld = [
|
|
|
32595
32645
|
summary: "Read the worldwide country rankings and the selected metric total",
|
|
32596
32646
|
args: [flag("metric", countryMetric, { default: "people" })],
|
|
32597
32647
|
paged: true,
|
|
32598
|
-
operations: ["list-country-rankings"],
|
|
32648
|
+
operations: ["list-country-rankings", "countries"],
|
|
32599
32649
|
examples: [
|
|
32600
32650
|
"esim country stats",
|
|
32601
32651
|
"esim country stats --metric land --limit 10",
|
|
@@ -32604,13 +32654,22 @@ var visualWorld = [
|
|
|
32604
32654
|
output: {
|
|
32605
32655
|
metric: "Selected statistic",
|
|
32606
32656
|
totalScore: "Worldwide sum for this statistic",
|
|
32607
|
-
items: "Rank, country, and
|
|
32657
|
+
items: "Rank, country, score, and current president",
|
|
32608
32658
|
nextCursor: "Cursor for more countries"
|
|
32609
32659
|
},
|
|
32610
32660
|
async run(ctx, args) {
|
|
32611
32661
|
const metric = countryMetric.parse(args.metric);
|
|
32612
|
-
const ranking = await ctx.call("list-country-rankings", { metric, all: true });
|
|
32613
|
-
const
|
|
32662
|
+
const [ranking, countries] = await Promise.all([ctx.call("list-country-rankings", { metric, all: true }), ctx.call("countries")]);
|
|
32663
|
+
const presidents = new Map(countries.map((entry) => [
|
|
32664
|
+
entry.id,
|
|
32665
|
+
entry.leader === null ? null : { id: entry.leader, name: entry.leaderName ?? null }
|
|
32666
|
+
]));
|
|
32667
|
+
const rows = ranking.entries.map((entry, index) => ({
|
|
32668
|
+
rank: index + 1,
|
|
32669
|
+
country: ref(entry),
|
|
32670
|
+
score: entry.score,
|
|
32671
|
+
president: presidents.get(entry.id) ?? null
|
|
32672
|
+
}));
|
|
32614
32673
|
return { metric, totalScore: ranking.totalScore, ...localPoliticalPage(args, rows), total: ranking.total };
|
|
32615
32674
|
}
|
|
32616
32675
|
}),
|
|
@@ -34132,6 +34191,42 @@ var gift = [
|
|
|
34132
34191
|
// commands/war.ts
|
|
34133
34192
|
var command25 = define("battle");
|
|
34134
34193
|
var confirm2 = ["esim war"];
|
|
34194
|
+
var declarationCost = 3000;
|
|
34195
|
+
var battleCommand = (id) => ({ run: `esim battle show ${id}` });
|
|
34196
|
+
var lawCommand = (id) => ({ run: `esim law show ${id}` });
|
|
34197
|
+
var uniqueCommands = (entries) => [...new Map(entries.map((entry) => [entry.run, entry])).values()];
|
|
34198
|
+
function targetReason(entry) {
|
|
34199
|
+
switch (entry.reason) {
|
|
34200
|
+
case "已有战役或败方主动权仍在冷却":
|
|
34201
|
+
return entry.battle === undefined ? "The losing side is still on initiative cooldown." : `Battle #${entry.battle} is already active.`;
|
|
34202
|
+
case "本国尚未取得战争主动权":
|
|
34203
|
+
return "The defending country has not gained the initiative yet.";
|
|
34204
|
+
case "停战已获批准":
|
|
34205
|
+
return "Peace has already been approved.";
|
|
34206
|
+
default:
|
|
34207
|
+
return entry.reason;
|
|
34208
|
+
}
|
|
34209
|
+
}
|
|
34210
|
+
async function declarationBorder(ctx, world, nation, target) {
|
|
34211
|
+
const control = new Map((await ctx.call("list-lands")).map((land) => [land.id, land.owner]));
|
|
34212
|
+
const owned = world.lands.filter((land) => control.get(land.id) === nation);
|
|
34213
|
+
if (owned.some((land) => land.neighbors.some((id) => control.get(id) === target)))
|
|
34214
|
+
return "land";
|
|
34215
|
+
if (owned.some((land) => land.openWaters) && world.lands.some((land) => land.openWaters && control.get(land.id) === target)) {
|
|
34216
|
+
return "sailor_week_required";
|
|
34217
|
+
}
|
|
34218
|
+
return "none";
|
|
34219
|
+
}
|
|
34220
|
+
async function activeAlliance(ctx, nation, target) {
|
|
34221
|
+
let cursor = null;
|
|
34222
|
+
do {
|
|
34223
|
+
const page = await ctx.call("list-alliances", { nation, ...cursor ? { cursor } : {} });
|
|
34224
|
+
if (page.items.some((entry) => entry.accepted && (entry.from === target || entry.to === target) && entry.endsAt !== undefined && Date.parse(entry.endsAt) > ctx.now))
|
|
34225
|
+
return true;
|
|
34226
|
+
cursor = page.nextCursor;
|
|
34227
|
+
} while (cursor);
|
|
34228
|
+
return false;
|
|
34229
|
+
}
|
|
34135
34230
|
var open2 = (entry) => entry.status === "ACTIVE";
|
|
34136
34231
|
var proposal3 = (entry, world, self) => ({
|
|
34137
34232
|
id: entry.id,
|
|
@@ -34184,7 +34279,7 @@ var war = [
|
|
|
34184
34279
|
...Array.isArray(result.proposals) && !result.proposals.length ? { proposals: "none" } : {}
|
|
34185
34280
|
};
|
|
34186
34281
|
},
|
|
34187
|
-
output: { country: "Selected country", wars: "Recent wars", proposals: "Recent proposals", civilPetition: "Latest civil war petition", can: "Available actions", next: "
|
|
34282
|
+
output: { country: "Selected country", wars: "Recent wars", proposals: "Recent proposals", civilPetition: "Latest civil war petition", can: "Available actions", next: "Related battles, laws and available war actions" },
|
|
34188
34283
|
async run(ctx, args) {
|
|
34189
34284
|
const { nation, own, country, world, president, account } = await offices(ctx, args);
|
|
34190
34285
|
const view = await ctx.call("list-wars", { country: nation });
|
|
@@ -34208,7 +34303,8 @@ var war = [
|
|
|
34208
34303
|
opponent: countryRef(world, attacker === nation ? defender : attacker),
|
|
34209
34304
|
status: entry.endedAt ? "ended" : entry.peacePending ? "peace_pending" : "active",
|
|
34210
34305
|
initiative: entry.endedAt || entry.peacePending ? undefined : Date.parse(entry.startedAt) + 86400000 > ctx.now ? "attack" : "both",
|
|
34211
|
-
battle: activeBattleId ? battleRef(activeBattleId)
|
|
34306
|
+
battle: activeBattleId == null ? undefined : battleRef(activeBattleId),
|
|
34307
|
+
next: next(activeBattleId == null ? undefined : battleCommand(activeBattleId), ...view.proposals.filter((item) => item.warId === entry.id && item.lawId != null).slice(0, 3).flatMap((item) => item.lawId == null ? [] : [lawCommand(item.lawId)]), president && nation === own && !entry.endedAt && !entry.peacePending ? { run: `esim war propose peace ${attacker === nation ? defender : attacker} --dry-run` } : undefined)
|
|
34212
34308
|
};
|
|
34213
34309
|
});
|
|
34214
34310
|
const civilPetition = await observe(async () => petition(await ctx.call("get-civil-petition", { nation })));
|
|
@@ -34217,7 +34313,10 @@ var war = [
|
|
|
34217
34313
|
wars,
|
|
34218
34314
|
civilPetition,
|
|
34219
34315
|
proposals: proposals.map((entry) => ({ ...proposal3(entry, world, pid(account)), canVote: canVote(entry) })),
|
|
34220
|
-
next:
|
|
34316
|
+
next: next(...uniqueCommands([
|
|
34317
|
+
...wars.flatMap((entry) => entry.next),
|
|
34318
|
+
...proposals.flatMap((entry) => entry.lawId == null ? [] : [lawCommand(entry.lawId)])
|
|
34319
|
+
]), nation === own ? { run: "esim war targets" } : undefined, ...!wars.length && !proposals.length && nation === own ? [{ run: "esim battle list" }, president ? { run: "esim war propose --help" } : undefined] : []),
|
|
34221
34320
|
can: [
|
|
34222
34321
|
...president && nation === own ? ["war propose", "war attack"] : [],
|
|
34223
34322
|
...proposals.some(canVote) ? ["law vote"] : [],
|
|
@@ -34251,21 +34350,23 @@ var war = [
|
|
|
34251
34350
|
const target = battleRegion(world, entry.region);
|
|
34252
34351
|
return {
|
|
34253
34352
|
...target,
|
|
34254
|
-
adjacent: entry.adjacent.map((region) => battleRegion(world, region)),
|
|
34255
|
-
war: { id: entry.war, name: `War ${entry.war}` },
|
|
34256
|
-
battle: entry.battle == null ? null : battleRef(entry.battle),
|
|
34257
34353
|
canStart: entry.canStart,
|
|
34354
|
+
reason: targetReason(entry),
|
|
34258
34355
|
errorCode: entry.errorCode,
|
|
34259
|
-
|
|
34356
|
+
war: { id: entry.war, name: `War ${entry.war}` },
|
|
34357
|
+
battle: entry.battle == null ? null : battleRef(entry.battle),
|
|
34358
|
+
adjacent: entry.adjacent.map((region) => battleRegion(world, region))
|
|
34260
34359
|
};
|
|
34261
34360
|
});
|
|
34262
34361
|
const empty = !page.items.length;
|
|
34263
34362
|
return {
|
|
34264
34363
|
...page,
|
|
34265
34364
|
...empty ? { country: countryRef(world, typeof named === "number" ? named : undefined) } : {},
|
|
34266
|
-
next: empty ? [{ run: "esim war" }, { run: "esim battle list --kind war" }] : next(...
|
|
34267
|
-
|
|
34268
|
-
|
|
34365
|
+
next: empty ? [{ run: "esim war" }, { run: "esim battle list --kind war" }] : next(...uniqueCommands([
|
|
34366
|
+
...page.items.flatMap((entry) => entry.canStart || entry.battle === null ? [] : [battleCommand(number4(entry.battle.id))]),
|
|
34367
|
+
...page.items.filter((entry) => entry.canStart).map((entry) => ({ run: `esim war attack ${entry.region.id} --dry-run` })),
|
|
34368
|
+
{ run: "esim war" }
|
|
34369
|
+
]))
|
|
34269
34370
|
};
|
|
34270
34371
|
}
|
|
34271
34372
|
}),
|
|
@@ -34273,11 +34374,18 @@ var war = [
|
|
|
34273
34374
|
path: ["war", "propose"],
|
|
34274
34375
|
summary: "Submit a declaration of war or a peace proposal as president.",
|
|
34275
34376
|
session: true,
|
|
34276
|
-
args: [positional("kind", true, _enum(["declare", "peace"])), positional("country")],
|
|
34277
|
-
|
|
34278
|
-
|
|
34377
|
+
args: [{ ...positional("kind", true, _enum(["declare", "peace"])), source: "declare or peace" }, positional("country"), dryRun],
|
|
34378
|
+
help: [
|
|
34379
|
+
"declare opens a declaration for your congress. Your treasury pays 30 GOLD if the law is enacted.",
|
|
34380
|
+
"peace asks the other country's congress and president to approve a ceasefire in an active war.",
|
|
34381
|
+
"Use a country name or ID from esim country stats. Use esim war to find wartime counterparts."
|
|
34382
|
+
],
|
|
34383
|
+
examples: ["esim war propose declare 1 --dry-run", "esim war propose peace 1 --dry-run"],
|
|
34384
|
+
operations: [...officeReads, "propose-war", "list-wars", "list-lands", "list-alliances", "get-country-treasury", "clock"],
|
|
34279
34385
|
confirmWith: confirm2,
|
|
34280
34386
|
output: {
|
|
34387
|
+
dryRun: "Read-only preview",
|
|
34388
|
+
quote: "Target, fee, approval body and current blockers",
|
|
34281
34389
|
proposal: "Submitted proposal: number, kind, countries, tally and closing time",
|
|
34282
34390
|
voters: "Who votes on it",
|
|
34283
34391
|
changed: "New proposal",
|
|
@@ -34287,8 +34395,61 @@ var war = [
|
|
|
34287
34395
|
async run(ctx, args) {
|
|
34288
34396
|
const state = await offices(ctx);
|
|
34289
34397
|
const { president, world, nation } = state;
|
|
34290
|
-
|
|
34398
|
+
if (!args["dry-run"])
|
|
34399
|
+
requireOffice(ctx, state, president, "the presidency", "esim war");
|
|
34291
34400
|
const target = choose(world.countries, String(args.country), "country");
|
|
34401
|
+
if (args["dry-run"]) {
|
|
34402
|
+
const kind = args.kind === "peace" ? "peace" : "declare";
|
|
34403
|
+
const declaring = kind === "declare";
|
|
34404
|
+
const view = await ctx.call("list-wars", { country: nation });
|
|
34405
|
+
const war = view.wars.find((entry) => !entry.endedAt && [entry.attacker, entry.defender].includes(target.id));
|
|
34406
|
+
const pending = view.proposals.find((entry) => open2(entry) && [entry.proposer, entry.targetCountry].includes(target.id));
|
|
34407
|
+
const approvalCountry = declaring ? nation : target.id;
|
|
34408
|
+
const blockers = [];
|
|
34409
|
+
const approvalBlockers = [];
|
|
34410
|
+
const unchecked = [];
|
|
34411
|
+
if (!president)
|
|
34412
|
+
blockers.push("Only your country's president can submit this proposal.");
|
|
34413
|
+
if (target.id === nation)
|
|
34414
|
+
blockers.push("Choose a foreign country.");
|
|
34415
|
+
else if (declaring && war)
|
|
34416
|
+
blockers.push(`War #${war.id} between these countries is already active.`);
|
|
34417
|
+
else if (!declaring && !war)
|
|
34418
|
+
blockers.push("These countries have no active war.");
|
|
34419
|
+
else if (!declaring && war?.peacePending)
|
|
34420
|
+
blockers.push("Peace has already been approved and will take effect after the active battle.");
|
|
34421
|
+
if (pending && target.id !== nation)
|
|
34422
|
+
blockers.push("A diplomatic proposal between these countries is already awaiting a vote.");
|
|
34423
|
+
if (declaring && blockers.length === 0) {
|
|
34424
|
+
await ctx.call("clock");
|
|
34425
|
+
if (await activeAlliance(ctx, nation, target.id))
|
|
34426
|
+
blockers.push("These countries have an active alliance.");
|
|
34427
|
+
const border = await declarationBorder(ctx, world, nation, target.id);
|
|
34428
|
+
if (border === "none")
|
|
34429
|
+
blockers.push("These countries do not share a land border and each must control an open-water region to declare during Sailor Week.");
|
|
34430
|
+
if (border === "sailor_week_required")
|
|
34431
|
+
unchecked.push("An open-water declaration requires an active Sailor Week. Active status is unverified.");
|
|
34432
|
+
}
|
|
34433
|
+
const balance = declaring ? await treasuryGold(ctx, world, nation) : undefined;
|
|
34434
|
+
if (balance && balance.minor < declarationCost)
|
|
34435
|
+
approvalBlockers.push("Your treasury cannot currently cover the declaration fee.");
|
|
34436
|
+
const canPropose = blockers.length ? false : unchecked.length ? null : true;
|
|
34437
|
+
return {
|
|
34438
|
+
dryRun: true,
|
|
34439
|
+
quote: {
|
|
34440
|
+
kind,
|
|
34441
|
+
target: countryRef(world, target.id),
|
|
34442
|
+
canPropose,
|
|
34443
|
+
blockers,
|
|
34444
|
+
approvalBlockers,
|
|
34445
|
+
unchecked,
|
|
34446
|
+
costOnApproval: gold(declaring ? declarationCost : 0),
|
|
34447
|
+
treasuryBalance: balance,
|
|
34448
|
+
voters: voters(world, approvalCountry, declaring ? state.schedule.seats.length : undefined, declaring ? "congress" : "congress and president")
|
|
34449
|
+
},
|
|
34450
|
+
next: next(war?.activeBattleId == null ? undefined : battleCommand(war.activeBattleId), pending?.lawId == null ? undefined : lawCommand(pending.lawId), canPropose && !approvalBlockers.length ? { run: `esim war propose ${kind} ${target.id}` } : undefined, war && declaring ? { run: `esim war propose peace ${target.id} --dry-run` } : undefined, { run: "esim war" })
|
|
34451
|
+
};
|
|
34452
|
+
}
|
|
34292
34453
|
const result = await attempt(ctx, () => ctx.call("propose-war", {}, { kind: String(args.kind), targetCountry: target.id }), async () => {
|
|
34293
34454
|
const view = await ctx.call("list-wars", { country: nation });
|
|
34294
34455
|
const involved = (entry) => [entry.attacker, entry.defender].includes(target.id);
|
|
@@ -37066,7 +37227,7 @@ function saveCredentials(store, credentials) {
|
|
|
37066
37227
|
}
|
|
37067
37228
|
|
|
37068
37229
|
// version.ts
|
|
37069
|
-
var version2 = "2026.1201.
|
|
37230
|
+
var version2 = "2026.1201.187";
|
|
37070
37231
|
var installKind = version2 === "dev" ? "source" : typeof ESIM_CLI_EXECUTABLE === "boolean" && ESIM_CLI_EXECUTABLE ? "executable" : "npm";
|
|
37071
37232
|
var npmLatestUrl = "https://registry.npmjs.org/esim-cli/latest";
|
|
37072
37233
|
var releaseUrl = (release) => `https://github.com/CorrectRoadH/open-esim/releases/download/cli-v${release}`;
|
package/dist/index.js
CHANGED
|
@@ -20661,6 +20661,12 @@ var lawLine = (law) => [
|
|
|
20661
20661
|
typeof law.proposal === "string" && law.proposal ? law.proposal : undefined
|
|
20662
20662
|
].filter(Boolean).join(" · ");
|
|
20663
20663
|
var tally = (law) => `yes ${String(law.yes ?? 0)} no ${String(law.no ?? 0)}${Array.isArray(law.voters) ? ` of ${law.voters.length} voters` : ""}`;
|
|
20664
|
+
function lawVotingView(data) {
|
|
20665
|
+
if (!isObject2(data) || !isObject2(data.voting))
|
|
20666
|
+
return data;
|
|
20667
|
+
const voting = Object.fromEntries(Object.entries(data.voting).map(([key, value]) => [key, typeof value === "boolean" ? value ? "yes" : "no" : value]));
|
|
20668
|
+
return { ...data, voting };
|
|
20669
|
+
}
|
|
20664
20670
|
function voteView(data) {
|
|
20665
20671
|
if (!isObject2(data) || typeof data.id !== "number")
|
|
20666
20672
|
return writeView2(data);
|
|
@@ -20678,7 +20684,7 @@ function voteView(data) {
|
|
|
20678
20684
|
proposer: _proposer,
|
|
20679
20685
|
...rest
|
|
20680
20686
|
} = data;
|
|
20681
|
-
return writeView2({ law: lawLine(data), tally: tally(data), ...rest });
|
|
20687
|
+
return writeView2(lawVotingView({ law: lawLine(data), tally: tally(data), ...rest }));
|
|
20682
20688
|
}
|
|
20683
20689
|
function lawListView(data) {
|
|
20684
20690
|
if (!isObject2(data) || !Array.isArray(data.items))
|
|
@@ -20718,6 +20724,24 @@ async function ownLawBallot(ctx, id) {
|
|
|
20718
20724
|
throw error;
|
|
20719
20725
|
}
|
|
20720
20726
|
}
|
|
20727
|
+
async function lawVoting(ctx, law, self, ballot) {
|
|
20728
|
+
const settled = law.status !== "ACTIVE";
|
|
20729
|
+
if (!settled && law.votingEndsAt)
|
|
20730
|
+
await ctx.call("clock");
|
|
20731
|
+
const votingClosed = settled || law.votingEndsAt !== undefined && Date.parse(law.votingEndsAt) <= ctx.now;
|
|
20732
|
+
const eligible = self !== undefined && law.voters.some((voter) => voter.citizen.id === self);
|
|
20733
|
+
const hasVoted = ballot !== null;
|
|
20734
|
+
const reason = settled ? `This law has settled (${law.status}).` : votingClosed ? "Voting has closed." : hasVoted ? "You have already voted." : self === undefined ? "Sign in to check your voting eligibility." : !eligible ? "You are not eligible to vote on this law." : undefined;
|
|
20735
|
+
return { settled, votingClosed, eligible, hasVoted, canVote: reason === undefined, reason };
|
|
20736
|
+
}
|
|
20737
|
+
var lawPageSize = 15;
|
|
20738
|
+
var lawListCommand = (page, args) => [
|
|
20739
|
+
"esim law list",
|
|
20740
|
+
"--page",
|
|
20741
|
+
String(page),
|
|
20742
|
+
...["country", "type", "status"].flatMap((key) => typeof args[key] === "string" ? [`--${key}`, shellWord(args[key])] : []),
|
|
20743
|
+
...args.votable ? ["--votable"] : []
|
|
20744
|
+
].join(" ");
|
|
20721
20745
|
var fiscalLawTypes = new Set([
|
|
20722
20746
|
"PRINT_MONEY",
|
|
20723
20747
|
"DONATE_MONEY",
|
|
@@ -20880,14 +20904,16 @@ var congress = [
|
|
|
20880
20904
|
session: false,
|
|
20881
20905
|
args: [
|
|
20882
20906
|
countryFlag,
|
|
20883
|
-
flag("type", string2().transform((value) => value.toUpperCase().replaceAll("-", "_"))
|
|
20907
|
+
flag("type", string2().transform((value) => value.toUpperCase().replaceAll("-", "_")), {
|
|
20908
|
+
source: "Common types include DECLARE_WAR, CEASE_FIRE_ACCEPT, MPP_PROPOSAL, PROPOSE_NAP, CHANGE_TAX, DONATE_MONEY and PROPOSE_REFERENDUM."
|
|
20909
|
+
}),
|
|
20884
20910
|
flag("status", _enum(["any", "active", "accepted", "accepted-success", "accepted-failed", "rejected"]), { default: "any" }),
|
|
20885
20911
|
flag("page", exports_coerce.number().int().min(1).max(2147483647), { default: 1 }),
|
|
20886
20912
|
votable
|
|
20887
20913
|
],
|
|
20888
|
-
examples: ["esim law list --status active", "esim law list --country Poland --page 2"],
|
|
20914
|
+
examples: ["esim law list --status active", "esim law list --country Poland --page 2", "esim law list --type DECLARE_WAR"],
|
|
20889
20915
|
operations: ["get-geography", "list-laws", "me"],
|
|
20890
|
-
output: { items: "Registry entries", page: "Page number", total: "Matching laws", next: "
|
|
20916
|
+
output: { items: "Registry entries", page: "Page number", total: "Matching laws", next: "Law details and nearby pages" },
|
|
20891
20917
|
view: lawListView,
|
|
20892
20918
|
empty: (data) => isObject2(data) && Array.isArray(data.items) && !data.items.length ? lawsEmpty(String(data.showing)) : undefined,
|
|
20893
20919
|
async run(ctx, args) {
|
|
@@ -20903,7 +20929,8 @@ var congress = [
|
|
|
20903
20929
|
const self = await viewerPid(ctx);
|
|
20904
20930
|
const items = page.items.map((item) => registryLaw(item, world, self));
|
|
20905
20931
|
const anyStatus = args.status === "any" && args.type === undefined && !args.votable;
|
|
20906
|
-
|
|
20932
|
+
const first = items[0];
|
|
20933
|
+
return listHeader(ctx, { ...page, items, next: first ? next({ run: `esim law show ${first.id}`, note: "Replace the ID to inspect another law." }, page.page * lawPageSize < page.total ? { run: lawListCommand(page.page + 1, args), note: "Next page" } : undefined, page.page > 1 ? { run: lawListCommand(page.page - 1, args), note: "Previous page" } : undefined) : anyStatus ? [{ run: "esim law --help", note: "Lists the commands that propose each kind of law." }, { run: "esim congress" }] : [{ run: "esim law list" }] }, country ? { country: ref(country) } : {});
|
|
20907
20934
|
}
|
|
20908
20935
|
}),
|
|
20909
20936
|
politicalCommand({
|
|
@@ -20912,15 +20939,27 @@ var congress = [
|
|
|
20912
20939
|
session: false,
|
|
20913
20940
|
args: [objectId("id")],
|
|
20914
20941
|
examples: ["esim law show 1"],
|
|
20915
|
-
|
|
20916
|
-
|
|
20942
|
+
view: lawVotingView,
|
|
20943
|
+
operations: ["get-geography", "get-law", "get-own-law-ballot", "me", "clock"],
|
|
20944
|
+
output: {
|
|
20945
|
+
effect: "Server's current effect preview",
|
|
20946
|
+
ballot: "Your ballot",
|
|
20947
|
+
voting: "Settlement, eligibility and whether you have voted",
|
|
20948
|
+
next: "Available ballot commands"
|
|
20949
|
+
},
|
|
20917
20950
|
async run(ctx, args) {
|
|
20918
20951
|
const id = number4(args.id);
|
|
20919
20952
|
const world = await geography(ctx);
|
|
20920
20953
|
const item = await ctx.call("get-law", { id });
|
|
20921
20954
|
const self = await viewerPid(ctx);
|
|
20922
20955
|
const ballot = authenticated(ctx) ? await ownLawBallot(ctx, id) : null;
|
|
20923
|
-
|
|
20956
|
+
const voting = await lawVoting(ctx, item, self, ballot);
|
|
20957
|
+
return {
|
|
20958
|
+
...registryLaw(item, world, self),
|
|
20959
|
+
ballot,
|
|
20960
|
+
voting,
|
|
20961
|
+
next: voting.canVote ? voteChoices(undefined, `esim law vote ${id}`) : []
|
|
20962
|
+
};
|
|
20924
20963
|
}
|
|
20925
20964
|
}),
|
|
20926
20965
|
politicalCommand({
|
|
@@ -20928,7 +20967,7 @@ var congress = [
|
|
|
20928
20967
|
summary: "Cast a vote on a registered law.",
|
|
20929
20968
|
args: [objectId("id"), yesNo, dryRun],
|
|
20930
20969
|
examples: ["esim law vote 1 yes --dry-run"],
|
|
20931
|
-
operations: ["get-geography", "get-law", "get-own-law-ballot", "cast-law-ballot", "get-country", "get-country-treasury"],
|
|
20970
|
+
operations: ["get-geography", "get-law", "get-own-law-ballot", "cast-law-ballot", "get-country", "get-country-treasury", "me", "clock"],
|
|
20932
20971
|
confirmWith: ["esim law list --status active"],
|
|
20933
20972
|
confirmUsing: (args) => [`esim law show ${args.id}`],
|
|
20934
20973
|
output: {
|
|
@@ -20936,8 +20975,9 @@ var congress = [
|
|
|
20936
20975
|
effect: "Server's current effect preview",
|
|
20937
20976
|
status: "Law status",
|
|
20938
20977
|
failReason: "Reason enactment failed",
|
|
20978
|
+
voting: "Settlement, eligibility and whether you have voted",
|
|
20939
20979
|
changed: "Ballot and law status before → after",
|
|
20940
|
-
next: "Law details"
|
|
20980
|
+
next: "Law details or the available vote"
|
|
20941
20981
|
},
|
|
20942
20982
|
view: voteView,
|
|
20943
20983
|
async run(ctx, args) {
|
|
@@ -20947,14 +20987,24 @@ var congress = [
|
|
|
20947
20987
|
const before = await ctx.call("get-law", { id });
|
|
20948
20988
|
const ballot = await ownLawBallot(ctx, id);
|
|
20949
20989
|
const follow = { run: `esim law show ${id}` };
|
|
20950
|
-
if (args["dry-run"])
|
|
20990
|
+
if (args["dry-run"]) {
|
|
20991
|
+
const self = await viewerPid(ctx);
|
|
20992
|
+
const voting = await lawVoting(ctx, before, self, ballot);
|
|
20993
|
+
if (voting.reason !== undefined) {
|
|
20994
|
+
const code = voting.votingClosed ? "closed" : voting.hasVoted ? "already_voted" : "forbidden";
|
|
20995
|
+
const eligibility = voting.eligible ? "yes" : "no";
|
|
20996
|
+
const alreadyVoted = voting.hasVoted ? "yes" : "no";
|
|
20997
|
+
return refuse2(ctx, code, `${voting.reason} Eligible: ${eligibility}. Already voted: ${alreadyVoted}.`, { law: { id, status: before.status }, voting, ballot }, follow.run);
|
|
20998
|
+
}
|
|
20951
20999
|
return {
|
|
20952
|
-
...registryLaw(before, world),
|
|
21000
|
+
...registryLaw(before, world, self),
|
|
20953
21001
|
dryRun: true,
|
|
20954
21002
|
ballot,
|
|
20955
|
-
|
|
20956
|
-
|
|
21003
|
+
voting,
|
|
21004
|
+
changed: { ballot: [null, ballotWord(yes)] },
|
|
21005
|
+
next: [{ run: `esim law vote ${id} ${yes ? "yes" : "no"}` }, follow]
|
|
20957
21006
|
};
|
|
21007
|
+
}
|
|
20958
21008
|
const nation = before.country;
|
|
20959
21009
|
const tax = before.taxCategory?.kind ?? "wage";
|
|
20960
21010
|
const product = before.taxCategory?.item;
|
|
@@ -32591,7 +32641,7 @@ var visualWorld = [
|
|
|
32591
32641
|
summary: "Read the worldwide country rankings and the selected metric total",
|
|
32592
32642
|
args: [flag("metric", countryMetric, { default: "people" })],
|
|
32593
32643
|
paged: true,
|
|
32594
|
-
operations: ["list-country-rankings"],
|
|
32644
|
+
operations: ["list-country-rankings", "countries"],
|
|
32595
32645
|
examples: [
|
|
32596
32646
|
"esim country stats",
|
|
32597
32647
|
"esim country stats --metric land --limit 10",
|
|
@@ -32600,13 +32650,22 @@ var visualWorld = [
|
|
|
32600
32650
|
output: {
|
|
32601
32651
|
metric: "Selected statistic",
|
|
32602
32652
|
totalScore: "Worldwide sum for this statistic",
|
|
32603
|
-
items: "Rank, country, and
|
|
32653
|
+
items: "Rank, country, score, and current president",
|
|
32604
32654
|
nextCursor: "Cursor for more countries"
|
|
32605
32655
|
},
|
|
32606
32656
|
async run(ctx, args) {
|
|
32607
32657
|
const metric = countryMetric.parse(args.metric);
|
|
32608
|
-
const ranking = await ctx.call("list-country-rankings", { metric, all: true });
|
|
32609
|
-
const
|
|
32658
|
+
const [ranking, countries] = await Promise.all([ctx.call("list-country-rankings", { metric, all: true }), ctx.call("countries")]);
|
|
32659
|
+
const presidents = new Map(countries.map((entry) => [
|
|
32660
|
+
entry.id,
|
|
32661
|
+
entry.leader === null ? null : { id: entry.leader, name: entry.leaderName ?? null }
|
|
32662
|
+
]));
|
|
32663
|
+
const rows = ranking.entries.map((entry, index) => ({
|
|
32664
|
+
rank: index + 1,
|
|
32665
|
+
country: ref(entry),
|
|
32666
|
+
score: entry.score,
|
|
32667
|
+
president: presidents.get(entry.id) ?? null
|
|
32668
|
+
}));
|
|
32610
32669
|
return { metric, totalScore: ranking.totalScore, ...localPoliticalPage(args, rows), total: ranking.total };
|
|
32611
32670
|
}
|
|
32612
32671
|
}),
|
|
@@ -34128,6 +34187,42 @@ var gift = [
|
|
|
34128
34187
|
// commands/war.ts
|
|
34129
34188
|
var command25 = define("battle");
|
|
34130
34189
|
var confirm2 = ["esim war"];
|
|
34190
|
+
var declarationCost = 3000;
|
|
34191
|
+
var battleCommand = (id) => ({ run: `esim battle show ${id}` });
|
|
34192
|
+
var lawCommand = (id) => ({ run: `esim law show ${id}` });
|
|
34193
|
+
var uniqueCommands = (entries) => [...new Map(entries.map((entry) => [entry.run, entry])).values()];
|
|
34194
|
+
function targetReason(entry) {
|
|
34195
|
+
switch (entry.reason) {
|
|
34196
|
+
case "已有战役或败方主动权仍在冷却":
|
|
34197
|
+
return entry.battle === undefined ? "The losing side is still on initiative cooldown." : `Battle #${entry.battle} is already active.`;
|
|
34198
|
+
case "本国尚未取得战争主动权":
|
|
34199
|
+
return "The defending country has not gained the initiative yet.";
|
|
34200
|
+
case "停战已获批准":
|
|
34201
|
+
return "Peace has already been approved.";
|
|
34202
|
+
default:
|
|
34203
|
+
return entry.reason;
|
|
34204
|
+
}
|
|
34205
|
+
}
|
|
34206
|
+
async function declarationBorder(ctx, world, nation, target) {
|
|
34207
|
+
const control = new Map((await ctx.call("list-lands")).map((land) => [land.id, land.owner]));
|
|
34208
|
+
const owned = world.lands.filter((land) => control.get(land.id) === nation);
|
|
34209
|
+
if (owned.some((land) => land.neighbors.some((id) => control.get(id) === target)))
|
|
34210
|
+
return "land";
|
|
34211
|
+
if (owned.some((land) => land.openWaters) && world.lands.some((land) => land.openWaters && control.get(land.id) === target)) {
|
|
34212
|
+
return "sailor_week_required";
|
|
34213
|
+
}
|
|
34214
|
+
return "none";
|
|
34215
|
+
}
|
|
34216
|
+
async function activeAlliance(ctx, nation, target) {
|
|
34217
|
+
let cursor = null;
|
|
34218
|
+
do {
|
|
34219
|
+
const page = await ctx.call("list-alliances", { nation, ...cursor ? { cursor } : {} });
|
|
34220
|
+
if (page.items.some((entry) => entry.accepted && (entry.from === target || entry.to === target) && entry.endsAt !== undefined && Date.parse(entry.endsAt) > ctx.now))
|
|
34221
|
+
return true;
|
|
34222
|
+
cursor = page.nextCursor;
|
|
34223
|
+
} while (cursor);
|
|
34224
|
+
return false;
|
|
34225
|
+
}
|
|
34131
34226
|
var open2 = (entry) => entry.status === "ACTIVE";
|
|
34132
34227
|
var proposal3 = (entry, world, self) => ({
|
|
34133
34228
|
id: entry.id,
|
|
@@ -34180,7 +34275,7 @@ var war = [
|
|
|
34180
34275
|
...Array.isArray(result.proposals) && !result.proposals.length ? { proposals: "none" } : {}
|
|
34181
34276
|
};
|
|
34182
34277
|
},
|
|
34183
|
-
output: { country: "Selected country", wars: "Recent wars", proposals: "Recent proposals", civilPetition: "Latest civil war petition", can: "Available actions", next: "
|
|
34278
|
+
output: { country: "Selected country", wars: "Recent wars", proposals: "Recent proposals", civilPetition: "Latest civil war petition", can: "Available actions", next: "Related battles, laws and available war actions" },
|
|
34184
34279
|
async run(ctx, args) {
|
|
34185
34280
|
const { nation, own, country, world, president, account } = await offices(ctx, args);
|
|
34186
34281
|
const view = await ctx.call("list-wars", { country: nation });
|
|
@@ -34204,7 +34299,8 @@ var war = [
|
|
|
34204
34299
|
opponent: countryRef(world, attacker === nation ? defender : attacker),
|
|
34205
34300
|
status: entry.endedAt ? "ended" : entry.peacePending ? "peace_pending" : "active",
|
|
34206
34301
|
initiative: entry.endedAt || entry.peacePending ? undefined : Date.parse(entry.startedAt) + 86400000 > ctx.now ? "attack" : "both",
|
|
34207
|
-
battle: activeBattleId ? battleRef(activeBattleId)
|
|
34302
|
+
battle: activeBattleId == null ? undefined : battleRef(activeBattleId),
|
|
34303
|
+
next: next(activeBattleId == null ? undefined : battleCommand(activeBattleId), ...view.proposals.filter((item) => item.warId === entry.id && item.lawId != null).slice(0, 3).flatMap((item) => item.lawId == null ? [] : [lawCommand(item.lawId)]), president && nation === own && !entry.endedAt && !entry.peacePending ? { run: `esim war propose peace ${attacker === nation ? defender : attacker} --dry-run` } : undefined)
|
|
34208
34304
|
};
|
|
34209
34305
|
});
|
|
34210
34306
|
const civilPetition = await observe(async () => petition(await ctx.call("get-civil-petition", { nation })));
|
|
@@ -34213,7 +34309,10 @@ var war = [
|
|
|
34213
34309
|
wars,
|
|
34214
34310
|
civilPetition,
|
|
34215
34311
|
proposals: proposals.map((entry) => ({ ...proposal3(entry, world, pid(account)), canVote: canVote(entry) })),
|
|
34216
|
-
next:
|
|
34312
|
+
next: next(...uniqueCommands([
|
|
34313
|
+
...wars.flatMap((entry) => entry.next),
|
|
34314
|
+
...proposals.flatMap((entry) => entry.lawId == null ? [] : [lawCommand(entry.lawId)])
|
|
34315
|
+
]), nation === own ? { run: "esim war targets" } : undefined, ...!wars.length && !proposals.length && nation === own ? [{ run: "esim battle list" }, president ? { run: "esim war propose --help" } : undefined] : []),
|
|
34217
34316
|
can: [
|
|
34218
34317
|
...president && nation === own ? ["war propose", "war attack"] : [],
|
|
34219
34318
|
...proposals.some(canVote) ? ["law vote"] : [],
|
|
@@ -34247,21 +34346,23 @@ var war = [
|
|
|
34247
34346
|
const target = battleRegion(world, entry.region);
|
|
34248
34347
|
return {
|
|
34249
34348
|
...target,
|
|
34250
|
-
adjacent: entry.adjacent.map((region) => battleRegion(world, region)),
|
|
34251
|
-
war: { id: entry.war, name: `War ${entry.war}` },
|
|
34252
|
-
battle: entry.battle == null ? null : battleRef(entry.battle),
|
|
34253
34349
|
canStart: entry.canStart,
|
|
34350
|
+
reason: targetReason(entry),
|
|
34254
34351
|
errorCode: entry.errorCode,
|
|
34255
|
-
|
|
34352
|
+
war: { id: entry.war, name: `War ${entry.war}` },
|
|
34353
|
+
battle: entry.battle == null ? null : battleRef(entry.battle),
|
|
34354
|
+
adjacent: entry.adjacent.map((region) => battleRegion(world, region))
|
|
34256
34355
|
};
|
|
34257
34356
|
});
|
|
34258
34357
|
const empty = !page.items.length;
|
|
34259
34358
|
return {
|
|
34260
34359
|
...page,
|
|
34261
34360
|
...empty ? { country: countryRef(world, typeof named === "number" ? named : undefined) } : {},
|
|
34262
|
-
next: empty ? [{ run: "esim war" }, { run: "esim battle list --kind war" }] : next(...
|
|
34263
|
-
|
|
34264
|
-
|
|
34361
|
+
next: empty ? [{ run: "esim war" }, { run: "esim battle list --kind war" }] : next(...uniqueCommands([
|
|
34362
|
+
...page.items.flatMap((entry) => entry.canStart || entry.battle === null ? [] : [battleCommand(number4(entry.battle.id))]),
|
|
34363
|
+
...page.items.filter((entry) => entry.canStart).map((entry) => ({ run: `esim war attack ${entry.region.id} --dry-run` })),
|
|
34364
|
+
{ run: "esim war" }
|
|
34365
|
+
]))
|
|
34265
34366
|
};
|
|
34266
34367
|
}
|
|
34267
34368
|
}),
|
|
@@ -34269,11 +34370,18 @@ var war = [
|
|
|
34269
34370
|
path: ["war", "propose"],
|
|
34270
34371
|
summary: "Submit a declaration of war or a peace proposal as president.",
|
|
34271
34372
|
session: true,
|
|
34272
|
-
args: [positional("kind", true, _enum(["declare", "peace"])), positional("country")],
|
|
34273
|
-
|
|
34274
|
-
|
|
34373
|
+
args: [{ ...positional("kind", true, _enum(["declare", "peace"])), source: "declare or peace" }, positional("country"), dryRun],
|
|
34374
|
+
help: [
|
|
34375
|
+
"declare opens a declaration for your congress. Your treasury pays 30 GOLD if the law is enacted.",
|
|
34376
|
+
"peace asks the other country's congress and president to approve a ceasefire in an active war.",
|
|
34377
|
+
"Use a country name or ID from esim country stats. Use esim war to find wartime counterparts."
|
|
34378
|
+
],
|
|
34379
|
+
examples: ["esim war propose declare 1 --dry-run", "esim war propose peace 1 --dry-run"],
|
|
34380
|
+
operations: [...officeReads, "propose-war", "list-wars", "list-lands", "list-alliances", "get-country-treasury", "clock"],
|
|
34275
34381
|
confirmWith: confirm2,
|
|
34276
34382
|
output: {
|
|
34383
|
+
dryRun: "Read-only preview",
|
|
34384
|
+
quote: "Target, fee, approval body and current blockers",
|
|
34277
34385
|
proposal: "Submitted proposal: number, kind, countries, tally and closing time",
|
|
34278
34386
|
voters: "Who votes on it",
|
|
34279
34387
|
changed: "New proposal",
|
|
@@ -34283,8 +34391,61 @@ var war = [
|
|
|
34283
34391
|
async run(ctx, args) {
|
|
34284
34392
|
const state = await offices(ctx);
|
|
34285
34393
|
const { president, world, nation } = state;
|
|
34286
|
-
|
|
34394
|
+
if (!args["dry-run"])
|
|
34395
|
+
requireOffice(ctx, state, president, "the presidency", "esim war");
|
|
34287
34396
|
const target = choose(world.countries, String(args.country), "country");
|
|
34397
|
+
if (args["dry-run"]) {
|
|
34398
|
+
const kind = args.kind === "peace" ? "peace" : "declare";
|
|
34399
|
+
const declaring = kind === "declare";
|
|
34400
|
+
const view = await ctx.call("list-wars", { country: nation });
|
|
34401
|
+
const war = view.wars.find((entry) => !entry.endedAt && [entry.attacker, entry.defender].includes(target.id));
|
|
34402
|
+
const pending = view.proposals.find((entry) => open2(entry) && [entry.proposer, entry.targetCountry].includes(target.id));
|
|
34403
|
+
const approvalCountry = declaring ? nation : target.id;
|
|
34404
|
+
const blockers = [];
|
|
34405
|
+
const approvalBlockers = [];
|
|
34406
|
+
const unchecked = [];
|
|
34407
|
+
if (!president)
|
|
34408
|
+
blockers.push("Only your country's president can submit this proposal.");
|
|
34409
|
+
if (target.id === nation)
|
|
34410
|
+
blockers.push("Choose a foreign country.");
|
|
34411
|
+
else if (declaring && war)
|
|
34412
|
+
blockers.push(`War #${war.id} between these countries is already active.`);
|
|
34413
|
+
else if (!declaring && !war)
|
|
34414
|
+
blockers.push("These countries have no active war.");
|
|
34415
|
+
else if (!declaring && war?.peacePending)
|
|
34416
|
+
blockers.push("Peace has already been approved and will take effect after the active battle.");
|
|
34417
|
+
if (pending && target.id !== nation)
|
|
34418
|
+
blockers.push("A diplomatic proposal between these countries is already awaiting a vote.");
|
|
34419
|
+
if (declaring && blockers.length === 0) {
|
|
34420
|
+
await ctx.call("clock");
|
|
34421
|
+
if (await activeAlliance(ctx, nation, target.id))
|
|
34422
|
+
blockers.push("These countries have an active alliance.");
|
|
34423
|
+
const border = await declarationBorder(ctx, world, nation, target.id);
|
|
34424
|
+
if (border === "none")
|
|
34425
|
+
blockers.push("These countries do not share a land border and each must control an open-water region to declare during Sailor Week.");
|
|
34426
|
+
if (border === "sailor_week_required")
|
|
34427
|
+
unchecked.push("An open-water declaration requires an active Sailor Week. Active status is unverified.");
|
|
34428
|
+
}
|
|
34429
|
+
const balance = declaring ? await treasuryGold(ctx, world, nation) : undefined;
|
|
34430
|
+
if (balance && balance.minor < declarationCost)
|
|
34431
|
+
approvalBlockers.push("Your treasury cannot currently cover the declaration fee.");
|
|
34432
|
+
const canPropose = blockers.length ? false : unchecked.length ? null : true;
|
|
34433
|
+
return {
|
|
34434
|
+
dryRun: true,
|
|
34435
|
+
quote: {
|
|
34436
|
+
kind,
|
|
34437
|
+
target: countryRef(world, target.id),
|
|
34438
|
+
canPropose,
|
|
34439
|
+
blockers,
|
|
34440
|
+
approvalBlockers,
|
|
34441
|
+
unchecked,
|
|
34442
|
+
costOnApproval: gold(declaring ? declarationCost : 0),
|
|
34443
|
+
treasuryBalance: balance,
|
|
34444
|
+
voters: voters(world, approvalCountry, declaring ? state.schedule.seats.length : undefined, declaring ? "congress" : "congress and president")
|
|
34445
|
+
},
|
|
34446
|
+
next: next(war?.activeBattleId == null ? undefined : battleCommand(war.activeBattleId), pending?.lawId == null ? undefined : lawCommand(pending.lawId), canPropose && !approvalBlockers.length ? { run: `esim war propose ${kind} ${target.id}` } : undefined, war && declaring ? { run: `esim war propose peace ${target.id} --dry-run` } : undefined, { run: "esim war" })
|
|
34447
|
+
};
|
|
34448
|
+
}
|
|
34288
34449
|
const result = await attempt(ctx, () => ctx.call("propose-war", {}, { kind: String(args.kind), targetCountry: target.id }), async () => {
|
|
34289
34450
|
const view = await ctx.call("list-wars", { country: nation });
|
|
34290
34451
|
const involved = (entry) => [entry.attacker, entry.defender].includes(target.id);
|
|
@@ -37143,7 +37304,7 @@ function saveCredentials(store, credentials) {
|
|
|
37143
37304
|
}
|
|
37144
37305
|
|
|
37145
37306
|
// version.ts
|
|
37146
|
-
var version2 = "2026.1201.
|
|
37307
|
+
var version2 = "2026.1201.187";
|
|
37147
37308
|
var installKind = version2 === "dev" ? "source" : typeof ESIM_CLI_EXECUTABLE === "boolean" && ESIM_CLI_EXECUTABLE ? "executable" : "npm";
|
|
37148
37309
|
var npmLatestUrl = "https://registry.npmjs.org/esim-cli/latest";
|
|
37149
37310
|
var releaseVersion = /^\d+\.\d+\.\d+$/;
|