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:
@@ -58,6 +58,7 @@ node index.js --max-resources --no-copy
|
|||||||
| `--max-resources` | Set all capped resources (`max > 0`) to their max |
|
| `--max-resources` | Set all capped resources (`max > 0`) to their max |
|
||||||
| `--set-crafted=N` | Set all unlimited/crafted resources (`max == -1`) to N |
|
| `--set-crafted=N` | Set all unlimited/crafted resources (`max == -1`) to N |
|
||||||
| `--only=a,b,c` | Only affect listed resources (comma-separated, case-insensitive). Matches resource names (e.g. `Food`) or internal keys (e.g. `food`). Applies to `--max-resources` and `--set-crafted`. |
|
| `--only=a,b,c` | Only affect listed resources (comma-separated, case-insensitive). Matches resource names (e.g. `Food`) or internal keys (e.g. `food`). Applies to `--max-resources` and `--set-crafted`. |
|
||||||
|
| `--max-soldiers` | Fill garrison to max capacity and heal all wounded soldiers |
|
||||||
| `--no-copy` | Print the edited save to stdout instead of clipboard |
|
| `--no-copy` | Print the edited save to stdout instead of clipboard |
|
||||||
| `--help` | Show help |
|
| `--help` | Show help |
|
||||||
|
|
||||||
|
|||||||
46
index.js
46
index.js
@@ -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) {
|
function setGeology(data) {
|
||||||
// Max bonus depends on White Hole achievement: top = 30 + level * 5
|
// Max bonus depends on White Hole achievement: top = 30 + level * 5
|
||||||
const whLevel = data.stats?.achieve?.whitehole?.l ?? 0;
|
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")) {
|
if (flags.has("--help")) {
|
||||||
console.log(`Usage: node index.js [options] [save-string]
|
console.log(`Usage: node index.js [options] [save-string]
|
||||||
@@ -172,6 +199,7 @@ Options:
|
|||||||
--max-resources Set all capped resources to their max
|
--max-resources Set all capped resources to their max
|
||||||
--set-crafted=N Set all unlimited (crafted) resources to N
|
--set-crafted=N Set all unlimited (crafted) resources to N
|
||||||
--only=a,b,c Only affect listed resources (comma-separated names or keys)
|
--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-geology Set 4 geology resource bonuses at max values
|
||||||
--max-time Set accelerated time (AT) to 8 hours
|
--max-time Set accelerated time (AT) to 8 hours
|
||||||
--no-copy Print result instead of copying to clipboard
|
--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")) {
|
if (flags.has("--list")) {
|
||||||
listResources(data);
|
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);
|
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")) {
|
if (flags.has("--max-geology")) {
|
||||||
console.log(setGeology(data));
|
console.log(setGeology(data));
|
||||||
}
|
}
|
||||||
@@ -314,6 +346,7 @@ async function interactiveMode() {
|
|||||||
choices: [
|
choices: [
|
||||||
{ value: "max-resources", name: "Max capped resources" },
|
{ value: "max-resources", name: "Max capped resources" },
|
||||||
{ value: "set-crafted", name: "Set crafted 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-geology", name: "Max geology bonuses" },
|
||||||
{ value: "max-time", name: "Max accelerated time" },
|
{ value: "max-time", name: "Max accelerated time" },
|
||||||
{ value: "list", name: "List all resources" },
|
{ value: "list", name: "List all resources" },
|
||||||
@@ -353,6 +386,15 @@ async function interactiveMode() {
|
|||||||
continue;
|
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") {
|
if (action === "max-geology") {
|
||||||
console.log(setGeology(data));
|
console.log(setGeology(data));
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user