Add --max-soldiers to fill garrison and heal wounded

Sets civic.garrison.workers to max capacity and clears wounded count.
Available as CLI flag and in the interactive menu.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Julian Tabel
2026-02-27 16:04:32 +01:00
parent 3a84335cda
commit 5bc9c5fed4
2 changed files with 45 additions and 2 deletions

View File

@@ -94,6 +94,33 @@ function listResources(data) {
}
}
function maxSoldiers(data) {
const garrison = data.civic?.garrison;
if (!garrison || !garrison.max) {
return "No garrison found in save.";
}
const lines = [];
const oldWorkers = garrison.workers ?? 0;
const max = garrison.max;
const oldWounded = garrison.wounded ?? 0;
if (oldWorkers < max) {
garrison.workers = max;
lines.push(` Soldiers: ${oldWorkers} -> ${max} (max)`);
} else {
lines.push(` Soldiers: already at max (${max})`);
}
if (oldWounded > 0) {
garrison.wounded = 0;
lines.push(` Wounded: ${oldWounded} -> 0 (healed)`);
}
if (lines.length === 0) return "Garrison already at full strength.";
return `Garrison:\n${lines.join("\n")}`;
}
function setGeology(data) {
// Max bonus depends on White Hole achievement: top = 30 + level * 5
const whLevel = data.stats?.achieve?.whitehole?.l ?? 0;
@@ -160,7 +187,7 @@ function main() {
}
}
const hasAction = flags.has("--max-resources") || flags.has("--max-time") || flags.has("--max-geology") || flags.has("--list") || craftedValue !== null;
const hasAction = flags.has("--max-resources") || flags.has("--max-time") || flags.has("--max-geology") || flags.has("--max-soldiers") || flags.has("--list") || craftedValue !== null;
if (flags.has("--help")) {
console.log(`Usage: node index.js [options] [save-string]
@@ -172,6 +199,7 @@ Options:
--max-resources Set all capped resources to their max
--set-crafted=N Set all unlimited (crafted) resources to N
--only=a,b,c Only affect listed resources (comma-separated names or keys)
--max-soldiers Fill garrison to max and heal all wounded
--max-geology Set 4 geology resource bonuses at max values
--max-time Set accelerated time (AT) to 8 hours
--no-copy Print result instead of copying to clipboard
@@ -194,7 +222,7 @@ Save string can be passed as argument, piped via stdin, or read from clipboard.`
if (flags.has("--list")) {
listResources(data);
if (!flags.has("--max-resources") && !flags.has("--max-geology") && !flags.has("--max-time") && craftedValue === null) {
if (!flags.has("--max-resources") && !flags.has("--max-soldiers") && !flags.has("--max-geology") && !flags.has("--max-time") && craftedValue === null) {
process.exit(0);
}
}
@@ -209,6 +237,10 @@ Save string can be passed as argument, piped via stdin, or read from clipboard.`
}
}
if (flags.has("--max-soldiers")) {
console.log(maxSoldiers(data));
}
if (flags.has("--max-geology")) {
console.log(setGeology(data));
}
@@ -314,6 +346,7 @@ async function interactiveMode() {
choices: [
{ value: "max-resources", name: "Max capped resources" },
{ value: "set-crafted", name: "Set crafted resources" },
{ value: "max-soldiers", name: "Max soldiers & heal wounded" },
{ value: "max-geology", name: "Max geology bonuses" },
{ value: "max-time", name: "Max accelerated time" },
{ value: "list", name: "List all resources" },
@@ -353,6 +386,15 @@ async function interactiveMode() {
continue;
}
if (action === "max-soldiers") {
const result = maxSoldiers(data);
console.log(result);
if (!result.includes("No garrison") && !result.includes("already at")) {
modified = true;
}
continue;
}
if (action === "max-geology") {
console.log(setGeology(data));
modified = true;