diff --git a/buildEvolve.js b/buildEvolve.js index fb3baebe4..22c7ee8cb 100644 --- a/buildEvolve.js +++ b/buildEvolve.js @@ -1,7 +1,7 @@ require("esbuild") .build({ logLevel: "info", - entryPoints: ["./src/main.js"], + entryPoints: ["./src/main-repaired.js"], bundle: true, minify: true, outfile: "evolve/main.js", diff --git a/buildEvolveDebug.js b/buildEvolveDebug.js index 984cd2ba1..e5a467bf7 100644 --- a/buildEvolveDebug.js +++ b/buildEvolveDebug.js @@ -1,7 +1,7 @@ require("esbuild") .build({ logLevel: "debug", - entryPoints: ["./src/main.js"], + entryPoints: ["./src/main-repaired.js"], bundle: true, minify: false, sourcemap : true, diff --git a/src/main-repaired.js b/src/main-repaired.js new file mode 100644 index 000000000..4712f9444 --- /dev/null +++ b/src/main-repaired.js @@ -0,0 +1,2 @@ +import './repair-terrifying-trade.js'; +import './main.js'; diff --git a/src/repair-terrifying-trade.js b/src/repair-terrifying-trade.js new file mode 100644 index 000000000..d86444e0c --- /dev/null +++ b/src/repair-terrifying-trade.js @@ -0,0 +1,22 @@ +import { global } from './vars.js'; +import { cleanAddTrait } from './races.js'; + +/** + * Repair an invalid Trade state left by an imitated Terrifying trait. + * + * Affected saves can retain researched Trade technology and Trade Posts while + * Terrifying is active. cleanAddTrait() owns the canonical transition into + * purgatory, including route, queue, and market cleanup. + */ +export function repairTerrifyingTrade(){ + const imitatedTerrifying = global.race?.imitation && global.race?.terrifying && ( + global.race?.iTraits?.terrifying === 0 || global.race?.srace === 'balorg' + ); + const activeLocalTrade = global.tech?.trade || global.city?.trade; + + if (imitatedTerrifying && activeLocalTrade){ + cleanAddTrait('terrifying'); + } +} + +repairTerrifyingTrade(); \ No newline at end of file