Skip to content

Commit 5766d34

Browse files
feat(core): Individual triggers for build items
Contributes to #451
1 parent 8a06a5e commit 5766d34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+753
-343
lines changed

packages/kitten-scientists/source/BonfireManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class BonfireManager implements Automation {
6767
builds: Partial<Record<BonfireItem, BonfireBuildingSetting>> = this.settings.buildings,
6868
) {
6969
const bulkManager = this._bulkManager;
70-
const trigger = this.settings.trigger;
7170

7271
// Get the current metadata for all the referenced buildings.
7372
const metaData: Partial<Record<BonfireItem, BuildingMeta>> = {};
@@ -78,7 +77,7 @@ export class BonfireManager implements Automation {
7877
}
7978

8079
// Let the bulkmanager determine the builds we can make.
81-
const buildList = bulkManager.bulk(builds, metaData, trigger, "Bonfire");
80+
const buildList = bulkManager.bulk(builds, metaData, this.settings.trigger, "Bonfire");
8281

8382
// Build all entries in the build list, where we can build any items.
8483
for (const build of buildList.filter(item => 0 < item.count)) {

packages/kitten-scientists/source/helper/BulkPurchaseHelper.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ export class BulkPurchaseHelper {
7171
/**
7272
* Take a hash of potential builds and determine how many of them can be built.
7373
*
74-
* @param builds All potential builds.
75-
* @param metaData The metadata for the potential builds.
76-
* @param trigger The configured trigger threshold for these builds.
77-
* @param sourceTab The tab these builds originate from.
74+
* @param builds - All potential builds.
75+
* @param metaData - The metadata for the potential builds.
76+
* @param sectionTrigger - The configured trigger threshold for the section of these builds.
77+
* @param sourceTab - The tab these builds originate from.
7878
* @returns All the possible builds.
7979
*/
8080
bulk(
@@ -88,6 +88,7 @@ export class BulkPurchaseHelper {
8888
baseBuilding?: Building;
8989
building?: AllBuildings | BonfireItem;
9090
stage?: number;
91+
trigger: number;
9192
variant?: TimeItemVariant | UnicornItemVariant;
9293
}
9394
>
@@ -104,7 +105,7 @@ export class BulkPurchaseHelper {
104105
| ZiggurathUpgradeInfo
105106
>
106107
>,
107-
trigger: number,
108+
sectionTrigger: number,
108109
sourceTab: TabId,
109110
): Array<BulkBuildListItem> {
110111
const buildsPerformed: Array<BulkBuildListItem> = [];
@@ -172,8 +173,11 @@ export class BulkPurchaseHelper {
172173
.map(price => this._workshopManager.getResource(price.name))
173174
.filter(material => 0 < material.maxValue);
174175
const allMaterialsAboveTrigger =
175-
requiredMaterials.filter(material => material.value / material.maxValue < trigger)
176-
.length === 0;
176+
requiredMaterials.filter(
177+
material =>
178+
material.value / material.maxValue <
179+
(build.trigger < 0 ? sectionTrigger : build.trigger),
180+
).length === 0;
177181

178182
if (allMaterialsAboveTrigger) {
179183
// If the build is for a stage that the building isn't currently at, skip it.

packages/kitten-scientists/source/i18n/en-US.json

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"act.sacrificeUnicorns": "Sacrificed {0} unicorns",
1919
"act.sun.discover": "Kittens have discovered {0}",
2020
"act.sun.discovers": "Kittens have discovered {0} {1} times",
21-
"act.time.activeHeatTransferStart": "Start active Heat Transfer",
2221
"act.time.activeHeatTransferEnd": "End active Heat Transfer",
22+
"act.time.activeHeatTransferStart": "Start active Heat Transfer",
2323
"act.time.getTemporalFlux": "Burn crystals to obtain time flux to maintain time acceleration",
2424
"act.time.skip": "Kittens combust a time crystal, {0} years skipped!",
2525
"act.trade": "Kittens have traded {0} times with {1}",
2626
"act.transcend": "Spent {0} epiphany, Transcended to T-level: {1}",
27-
"blackcoin.buy": "Kittens sold your Relics and bought {0} Blackcoins",
2827
"blackcoin.buy.threshold": "Buy Blackcoins below this price:",
2928
"blackcoin.buy.trigger": "buying Blackcoins (in relics)",
30-
"blackcoin.sell": "Kittens sold your Blackcoins and bought {0} Relics",
29+
"blackcoin.buy": "Kittens sold your Relics and bought {0} Blackcoins",
3130
"blackcoin.sell.threshold": "Sell Blackcoins above this price:",
31+
"blackcoin.sell": "Kittens sold your Blackcoins and bought {0} Relics",
3232
"build.embassies": "Built {0} embassies for {1}",
3333
"build.embassy": "Built {0} embassy for {1}",
3434
"copy": "Copy to clipboard",
@@ -64,16 +64,16 @@
6464
"option.catnip": "Gather Catnip",
6565
"option.chronofurnace": "Turn on Chrono Furnaces",
6666
"option.crypto": "Trade Blackcoin",
67-
"option.elect": "Elect leader",
68-
"option.elect.job": "Job",
6967
"option.elect.job.any": "Any",
68+
"option.elect.job": "Job",
7069
"option.elect.trait": "Trait",
70+
"option.elect": "Elect leader",
7171
"option.embassies": "Build Embassies",
7272
"option.faith.adore": "Adore the Galaxy",
7373
"option.faith.autoPraise": "Praise the Sun",
7474
"option.faith.best.unicorn": "Build Best Unicorn Building First",
75-
"option.faith.refineTimeCrystals": "Refine TCs",
7675
"option.faith.refineTears": "Refine Tears",
76+
"option.faith.refineTimeCrystals": "Refine TCs",
7777
"option.faith.sacrificeAlicorns": "Sacrifice Alicorns",
7878
"option.faith.sacrificeUnicorns": "Sacrifice Unicorns",
7979
"option.faith.transcend": "Transcend",
@@ -92,7 +92,6 @@
9292
"option.time.reset": "Reset Timeline (Danger!)",
9393
"option.time.skip.ignoreOverheat": "Ignore overheat",
9494
"option.time.skip": "Time Skip",
95-
"reset": "Reset",
9695
"reset.after": "Nice to meet you, the cute Kitten Scientists will serve you",
9796
"reset.cancel.activity": "Meoston, We Have a Problem",
9897
"reset.cancel.message": "Timeline Reset canceled",
@@ -111,6 +110,7 @@
111110
"reset.countdown.9": "9 - Sacrificing Unicorns",
112111
"reset.last.message": "See you next poincaré recurrence",
113112
"reset.tip": "You can cancel this reset by disabling \"Enable Kitten Scientists\" at the top of the settings.",
113+
"reset": "Reset",
114114
"resources.consume.set": "Consume rate for {0}",
115115
"resources.consume": "Consume: {0}",
116116
"resources.stock.set": "Stock for {0}",
@@ -221,9 +221,10 @@
221221
"ui.engine": "Enable Kitten Scientists",
222222
"ui.faith": "Religion",
223223
"ui.filter": "Log Filters",
224-
"ui.internals": "Internals",
225-
"ui.internals.interval": "Interval: {0}",
224+
"ui.infinity": "",
226225
"ui.internals.interval.input": "Enter a new interval at which KS should run (in milliseconds):",
226+
"ui.internals.interval": "Interval: {0}",
227+
"ui.internals": "Internals",
227228
"ui.itemsHide": "Hide options",
228229
"ui.itemsShow": "Show options",
229230
"ui.ksColumn": "Display KS in fourth column in UI",
@@ -241,8 +242,16 @@
241242
"ui.time": "Time",
242243
"ui.timeCtrl": "Time Control",
243244
"ui.trade": "Trade",
244-
"ui.trigger.setinteger": "Enter a new trigger value for {0}. Should be in the range of 0 to Infinity (-1).",
245-
"ui.trigger.setpercentage": "Enter a new trigger value for {0}. Should be in the range of 0 to 1.",
245+
"ui.trigger.build.blocked": "\n🛈 The {0} section has no trigger set. This build will not be triggered!",
246+
"ui.trigger.build.inherited": "inherited from section",
247+
"ui.trigger.build.prompt": "Trigger for {0} (Current: {1})",
248+
"ui.trigger.build.promptExplainer": "If you submit an empty value, or a negative value, the section trigger is used instead. If you submit an invalid value, it will be treated as if you hit Cancel.",
249+
"ui.trigger.prompt.percentage": "Enter the new trigger value as a percentage between 0.0 and 100.0.",
250+
"ui.trigger.section.inactive": "∞ (nothing is built automatically)",
251+
"ui.trigger.section.prompt": "Trigger for section {0} (Current: {1})",
252+
"ui.trigger.section.promptExplainer": "If you submit an empty value, or a negative value, the section trigger will be set to infinity (∞), which disables all builds, unless they have their own trigger set.\nIf you submit an invalid value, it will be treated as if you hit Cancel.",
253+
"ui.trigger.setinteger": "Enter a new trigger value for {0}. Should be in the range from 0 up to any number. -1 means infinity.",
254+
"ui.trigger.setpercentage": "Enter a new trigger value for {0}. Should be in the range from 0 to 100.",
246255
"ui.trigger": "Trigger: {0}",
247256
"ui.upgrade.buildings": "Upgrade buildings",
248257
"ui.upgrade.missions": "Start missions",

packages/kitten-scientists/source/settings/BonfireSettings.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Maybe, isNil } from "@oliversalzburg/js-utils/data/nil.js";
22
import { consumeEntriesPedantic } from "../tools/Entries.js";
33
import { Building, Buildings, StagedBuilding, StagedBuildings } from "../types/index.js";
44
import { BuildingUpgradeSettings } from "./BuildingUpgradeSettings.js";
5-
import { Setting, SettingMax, SettingTrigger } from "./Settings.js";
5+
import { Setting, SettingTrigger, SettingTriggerMax } from "./Settings.js";
66

77
/**
88
* One of the building options in the KS menu.
@@ -11,7 +11,7 @@ import { Setting, SettingMax, SettingTrigger } from "./Settings.js";
1111
*/
1212
export type BonfireItem = Building | StagedBuilding;
1313

14-
export class BonfireBuildingSetting extends SettingMax {
14+
export class BonfireBuildingSetting extends SettingTriggerMax {
1515
/**
1616
* In case this is an upgrade of another building, this is the name of the
1717
* base building.
@@ -35,8 +35,14 @@ export class BonfireBuildingSetting extends SettingMax {
3535
return this.#stage;
3636
}
3737

38-
constructor(building: BonfireItem, enabled = false, max = -1, baseStage?: Building | false) {
39-
super(enabled, max);
38+
constructor(
39+
building: BonfireItem,
40+
enabled = false,
41+
trigger = -1,
42+
max = -1,
43+
baseStage?: Building | false,
44+
) {
45+
super(enabled, trigger, max);
4046

4147
this.#building = building;
4248
if (baseStage) {
@@ -62,7 +68,7 @@ export class BonfireSettings extends SettingTrigger {
6268

6369
constructor(
6470
enabled = false,
65-
trigger = 0,
71+
trigger = -1,
6672
gatherCatnip = new Setting(true),
6773
turnOnSteamworks = new Setting(true),
6874
turnOnMagnetos = new Setting(false),
@@ -93,7 +99,7 @@ export class BonfireSettings extends SettingTrigger {
9399
items[item] = new BonfireBuildingSetting(item);
94100
});
95101
StagedBuildings.forEach(item => {
96-
items[item] = new BonfireBuildingSetting(item, false, -1, baseStage[item]);
102+
items[item] = new BonfireBuildingSetting(item, false, -1, -1, baseStage[item]);
97103
});
98104

99105
return items;
@@ -109,6 +115,7 @@ export class BonfireSettings extends SettingTrigger {
109115
consumeEntriesPedantic(this.buildings, settings.buildings, (building, item) => {
110116
building.enabled = item?.enabled ?? building.enabled;
111117
building.max = item?.max ?? building.max;
118+
building.trigger = item?.trigger ?? building.trigger;
112119
});
113120

114121
this.gatherCatnip.enabled = settings.gatherCatnip?.enabled ?? this.gatherCatnip.enabled;

packages/kitten-scientists/source/settings/ReligionSettings.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
ZiggurathUpgrade,
1010
ZiggurathUpgrades,
1111
} from "../types/index.js";
12-
import { Setting, SettingMax, SettingThreshold, SettingTrigger } from "./Settings.js";
12+
import { Setting, SettingThreshold, SettingTrigger, SettingTriggerMax } from "./Settings.js";
1313

1414
export type FaithItem = Exclude<ReligionItem, UnicornItem>;
1515

@@ -38,7 +38,7 @@ export const ReligionOptions = [
3838
] as const;
3939
export type ReligionOption = (typeof ReligionOptions)[number];
4040

41-
export class ReligionSettingsItem extends SettingMax {
41+
export class ReligionSettingsItem extends SettingTriggerMax {
4242
readonly #building: FaithItem | UnicornItem;
4343
readonly #variant: UnicornItemVariant;
4444

@@ -49,13 +49,8 @@ export class ReligionSettingsItem extends SettingMax {
4949
return this.#variant;
5050
}
5151

52-
constructor(
53-
building: FaithItem | UnicornItem,
54-
variant: UnicornItemVariant,
55-
enabled = false,
56-
max = -1,
57-
) {
58-
super(enabled, max);
52+
constructor(building: FaithItem | UnicornItem, variant: UnicornItemVariant, enabled = false) {
53+
super(enabled);
5954
this.#building = building;
6055
this.#variant = variant;
6156
}
@@ -108,7 +103,7 @@ export class ReligionSettings extends SettingTrigger {
108103

109104
constructor(
110105
enabled = false,
111-
trigger = 1,
106+
trigger = -1,
112107
bestUnicornBuilding = new Setting(false),
113108
sacrificeAlicorns = new SettingThreshold(false, 25),
114109
sacrificeUnicorns = new SettingThreshold(false, 1000000),
@@ -164,6 +159,7 @@ export class ReligionSettings extends SettingTrigger {
164159
consumeEntriesPedantic(this.buildings, settings.buildings, (building, item) => {
165160
building.enabled = item?.enabled ?? building.enabled;
166161
building.max = item?.max ?? building.max;
162+
building.trigger = item?.trigger ?? building.trigger;
167163
});
168164

169165
this.bestUnicornBuilding.load(settings.bestUnicornBuilding);

packages/kitten-scientists/source/settings/ResetBonfireSettings.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ export class ResetBonfireBuildingSetting extends SettingThreshold {
2929
return this.#stage;
3030
}
3131

32-
constructor(building: BonfireItem, enabled = false, trigger = -1, baseStage?: Building | false) {
33-
super(enabled, trigger);
32+
constructor(
33+
building: BonfireItem,
34+
enabled = false,
35+
threshold = -1,
36+
baseStage?: Building | false,
37+
) {
38+
super(enabled, threshold);
3439

3540
this.#building = building;
3641
if (baseStage) {

packages/kitten-scientists/source/settings/ResetReligionSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class ResetReligionBuildingSetting extends SettingThreshold {
2424
building: FaithItem | UnicornItem,
2525
variant: UnicornItemVariant,
2626
enabled = false,
27-
trigger = -1,
27+
threshold = -1,
2828
) {
29-
super(enabled, trigger);
29+
super(enabled, threshold);
3030
this.#building = building;
3131
this.#variant = variant;
3232
}

packages/kitten-scientists/source/settings/ResetSpaceSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export class ResetSpaceBuildingSetting extends SettingThreshold {
1010
return this.#building;
1111
}
1212

13-
constructor(building: SpaceBuilding, enabled = false, trigger = -1) {
14-
super(enabled, trigger);
13+
constructor(building: SpaceBuilding, enabled = false, threshold = -1) {
14+
super(enabled, threshold);
1515
this.#building = building;
1616
}
1717
}

packages/kitten-scientists/source/settings/ResetTimeSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export class ResetTimeBuildingSetting extends SettingThreshold {
1515
return this.#variant;
1616
}
1717

18-
constructor(id: TimeItem, variant: TimeItemVariant, enabled = false, trigger = -1) {
19-
super(enabled, trigger);
18+
constructor(id: TimeItem, variant: TimeItemVariant, enabled = false, threshold = -1) {
19+
super(enabled, threshold);
2020
this.#building = id;
2121
this.#variant = variant;
2222
}

packages/kitten-scientists/source/settings/Settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ export class SettingTrigger extends Setting {
7878
export class SettingThreshold extends Setting {
7979
trigger: number;
8080

81-
constructor(enabled = false, trigger = 1) {
81+
constructor(enabled = false, threshold = 1) {
8282
super(enabled);
83-
this.trigger = trigger;
83+
this.trigger = threshold;
8484
}
8585

8686
load(setting: Maybe<Partial<SettingThreshold>>) {

0 commit comments

Comments
 (0)