diff --git a/packages/userscript/source/BonfireManager.ts b/packages/userscript/source/BonfireManager.ts index f8be80d62..2dec782ae 100644 --- a/packages/userscript/source/BonfireManager.ts +++ b/packages/userscript/source/BonfireManager.ts @@ -113,7 +113,7 @@ export class BonfireManager implements Automation { // We need to perform the process like this to avoid UI confirmations // for selling items. // Sell all pastures (to regain the resources). - button.controller.sellInternal(button.model, 0); + button.controller.sellInternal!(button.model, 0); // Manually update the metadata, as we bypassed the full selling logic. pastureMeta.on = 0; pastureMeta.val = 0; @@ -145,7 +145,7 @@ export class BonfireManager implements Automation { const prices = mustExist(aqueductMeta.stages)[1].prices; if (this._bulkManager.singleBuildPossible(aqueductMeta, prices, 1)) { const button = mustExist(this.getBuildButton("aqueduct", 0)); - button.controller.sellInternal(button.model, 0); + button.controller.sellInternal!(button.model, 0); aqueductMeta.on = 0; aqueductMeta.val = 0; aqueductMeta.stage = 1; @@ -206,7 +206,7 @@ export class BonfireManager implements Automation { const prices = mustExist(libraryMeta.stages)[1].prices; if (this._bulkManager.singleBuildPossible(libraryMeta, prices, 1)) { const button = mustExist(this.getBuildButton("library", 0)); - button.controller.sellInternal(button.model, 0); + button.controller.sellInternal!(button.model, 0); libraryMeta.on = 0; libraryMeta.val = 0; libraryMeta.stage = 1; @@ -235,7 +235,7 @@ export class BonfireManager implements Automation { const prices = mustExist(amphitheatreMeta.stages)[1].prices; if (this._bulkManager.singleBuildPossible(amphitheatreMeta, prices, 1)) { const button = mustExist(this.getBuildButton("amphitheatre", 0)); - button.controller.sellInternal(button.model, 0); + button.controller.sellInternal!(button.model, 0); amphitheatreMeta.on = 0; amphitheatreMeta.val = 0; amphitheatreMeta.stage = 1; @@ -257,7 +257,7 @@ export class BonfireManager implements Automation { const steamworks = this._host.gamePage.bld.getBuildingExt("steamworks"); if (steamworks.meta.val && steamworks.meta.on === 0) { const button = mustExist(this.getBuildButton("steamworks")); - button.controller.onAll(button.model); + button.controller.onAll!(button.model); } } diff --git a/packages/userscript/source/ReligionManager.ts b/packages/userscript/source/ReligionManager.ts index c3ca21a89..9d475f277 100644 --- a/packages/userscript/source/ReligionManager.ts +++ b/packages/userscript/source/ReligionManager.ts @@ -18,6 +18,7 @@ import { ReligionUpgrades, TranscendenceUpgradeInfo, TranscendenceUpgrades, + TransformBtnController, UnicornItemVariant, ZiggurathUpgradeInfo, ZiggurathUpgrades, @@ -47,34 +48,22 @@ export class ReligionManager implements Automation { this._bonfireManager = bonfireManager; } - tick(context: TickContext) { + async tick(context: TickContext) { if (!this.settings.enabled) { return; } this._autoBuild(); - const faith = this._workshopManager.getResource("faith"); - const faithLevel = faith.value / faith.maxValue; - // enough faith, and then TAP (transcende, adore, praise) - if (this.settings.transcend.enabled && this.settings.autoPraise.trigger - 0.02 <= faithLevel) { - this._autoTranscend(); + if (this.settings.refineTears.enabled) { + await this._autoTears(); } - // Praise (faith → worhsip) - if (this.settings.autoPraise.trigger <= faithLevel) { - // Adore the galaxy (worship → epiphany) - if ( - this.settings.adore.enabled && - mustExist(this._host.gamePage.religion.getRU("apocripha")).on - ) { - this._autoAdore(this.settings.adore.trigger); - } - - if (this.settings.autoPraise.enabled) { - this._autoPraise(); - } + if (this.settings.refineTimeCrystals.enabled) { + await this._autoTCs(); } + + this._autoTAP(); } load(settings: ReligionSettings) { @@ -156,7 +145,7 @@ export class ReligionManager implements Automation { // Sacrifice some unicorns to get the tears to buy the building. if (needSacrifice < maxSacrifice) { - this._host.gamePage.religionTab.sacrificeBtn.controller._transform( + this._host.gamePage.religionTab.sacrificeBtn.controller._transform!( this._host.gamePage.religionTab.sacrificeBtn.model, needSacrifice ); @@ -200,147 +189,6 @@ export class ReligionManager implements Automation { this._buildReligionBuildings(builds); } - private _autoAdore(trigger: number) { - const faith = this._workshopManager.getResource("faith"); - - const worship = this._host.gamePage.religion.faith; - const epiphany = this._host.gamePage.religion.faithRatio; - const transcendenceReached = mustExist(this._host.gamePage.religion.getRU("transcendence")).on; - const transcendenceTierCurrent = transcendenceReached - ? this._host.gamePage.religion.transcendenceTier - : 0; - // game version: 1.4.8.1 - // solarRevolutionLimit is increased by black obelisks. - const maxSolarRevolution = 10 + this._host.gamePage.getEffect("solarRevolutionLimit"); - // The absolute value at which to trigger adoring the galaxy. - const triggerSolarRevolution = maxSolarRevolution * trigger; - // How much epiphany we'll get from converting our worship. - const epiphanyIncrease = - (worship / 1000000) * transcendenceTierCurrent * transcendenceTierCurrent * 1.01; - // How much epiphany we'll have after adoring. - const epiphanyAfterAdore = epiphany + epiphanyIncrease; - // How much worship we'll have after adoring. - const worshipAfterAdore = - 0.01 + faith.value * (1 + this._host.gamePage.getUnlimitedDR(epiphanyAfterAdore, 0.1) * 0.1); - // How much solar revolution bonus we'll have after adoring. - const solarRevolutionAfterAdore = this._host.gamePage.getLimitedDR( - this._host.gamePage.getUnlimitedDR(worshipAfterAdore, 1000) / 100, - maxSolarRevolution - ); - // After adoring the galaxy, we want a single praise to be able to reach the trigger - // level of solar revolution bonus. - if (triggerSolarRevolution <= solarRevolutionAfterAdore) { - // Perform the actual adoration. - this._host.gamePage.religion._resetFaithInternal(1.01); - - // Log the action. - this._host.engine.iactivity( - "act.adore", - [ - this._host.gamePage.getDisplayValueExt(worship), - this._host.gamePage.getDisplayValueExt(epiphanyIncrease), - ], - "ks-adore" - ); - this._host.engine.storeForSummary("adore", epiphanyIncrease); - // TODO: Not sure what the point of updating these values would be - // We're at the end of the branch. - //epiphany = this._host.gamePage.religion.faithRatio; - //worship = this._host.gamePage.religion.faith; - } - } - - private _autoTranscend() { - let epiphany = this._host.gamePage.religion.faithRatio; - const transcendenceReached = mustExist(this._host.gamePage.religion.getRU("transcendence")).on; - let transcendenceTierCurrent = transcendenceReached - ? this._host.gamePage.religion.transcendenceTier - : 0; - - // Transcend - if (transcendenceReached) { - // How much our adoration ratio increases from transcending. - const adoreIncreaceRatio = Math.pow( - (transcendenceTierCurrent + 2) / (transcendenceTierCurrent + 1), - 2 - ); - // The amount of worship needed to upgrade to the next level. - const needNextLevel = - this._host.gamePage.religion._getTranscendTotalPrice(transcendenceTierCurrent + 1) - - this._host.gamePage.religion._getTranscendTotalPrice(transcendenceTierCurrent); - - // We want to determine the ideal value for when to trancend. - // TODO: How exactly this works isn't understood yet. - const x = needNextLevel; - const k = adoreIncreaceRatio; - const epiphanyRecommend = - ((1 - k + Math.sqrt(80 * (k * k - 1) * x + (k - 1) * (k - 1))) * k) / - (40 * (k + 1) * (k + 1) * (k - 1)) + - x + - x / (k * k - 1); - - if (epiphanyRecommend <= epiphany) { - // code copy from kittens game's religion.js: this._host.gamePage.religion.transcend() - // this._host.gamePage.religion.transcend() need confirm by player - // game version: 1.4.8.1 - // ======================================================================================================== - // DO TRANSCEND START - // ======================================================================================================== - this._host.gamePage.religion.faithRatio -= needNextLevel; - this._host.gamePage.religion.tcratio += needNextLevel; - this._host.gamePage.religion.transcendenceTier += 1; - - const atheism = mustExist(this._host.gamePage.challenges.getChallenge("atheism")); - atheism.calculateEffects(atheism, this._host.gamePage); - const blackObelisk = mustExist(this._host.gamePage.religion.getTU("blackObelisk")); - blackObelisk.calculateEffects(blackObelisk, this._host.gamePage); - - this._host.gamePage.msg( - this._host.engine.i18n("$religion.transcend.msg.success", [ - this._host.gamePage.religion.transcendenceTier, - ]) - ); - // ======================================================================================================== - // DO TRANSCEND END - // ======================================================================================================== - - epiphany = this._host.gamePage.religion.faithRatio; - transcendenceTierCurrent = this._host.gamePage.religion.transcendenceTier; - this._host.engine.iactivity( - "act.transcend", - [this._host.gamePage.getDisplayValueExt(needNextLevel), transcendenceTierCurrent], - "ks-transcend" - ); - this._host.engine.storeForSummary("transcend", 1); - } - } - } - - private _autoPraise() { - const faith = this._workshopManager.getResource("faith"); - let apocryphaBonus; - if (!this._host.gamePage.religion.getFaithBonus) { - apocryphaBonus = this._host.gamePage.religion.getApocryphaBonus(); - } else { - apocryphaBonus = this._host.gamePage.religion.getFaithBonus(); - } - - // Determine how much worship we'll gain and log it. - const worshipIncrease = faith.value * (1 + apocryphaBonus); - this._host.engine.storeForSummary("praise", worshipIncrease); - this._host.engine.iactivity( - "act.praise", - [ - this._host.gamePage.getDisplayValueExt(faith.value), - this._host.gamePage.getDisplayValueExt(worshipIncrease), - ], - "ks-praise" - ); - - // Now finally praise the sun. - this._host.gamePage.religion.praise(); - } - private _buildReligionBuildings(builds: Partial>): void { // Render the tab to make sure that the buttons actually exist in the DOM. Otherwise we can't click them. this.manager.render(); @@ -652,4 +500,216 @@ export class ReligionManager implements Automation { return null; } + + private async _autoTears() { + const tears = this._workshopManager.getResource("tears"); + const available = this._workshopManager.getValueAvailable("tears"); + if ( + this.settings.refineTears.trigger <= available && + this.settings.refineTears.trigger <= tears.value + ) { + const controller = new classes.ui.religion.RefineTearsBtnController(this._host.gamePage); + + await new Promise(resolve => + controller.buyItem(this._host.gamePage.religionTab.refineBtn.model, undefined, resolve) + ); + + this._host.engine.iactivity("act.refineTears", [], "ks-faith"); + this._host.engine.storeForSummary( + this._host.engine.i18n("$resources.tears.title"), + 1, + "refine" + ); + } + } + + private async _autoTCs() { + const timeCrystals = this._workshopManager.getResource("timeCrystal"); + const available = this._workshopManager.getValueAvailable("timeCrystal"); + if ( + this.settings.refineTimeCrystals.trigger <= available && + this.settings.refineTimeCrystals.trigger <= timeCrystals.value + ) { + const controller = this._host.gamePage.religionTab.refineTCBtn + .controller as TransformBtnController; + const model = this._host.gamePage.religionTab.refineTCBtn.model; + await new Promise(resolve => + controller.buyItem(this._host.gamePage.religionTab.refineTCBtn.model, undefined, resolve) + ); + + const cost = mustExist(model.prices?.[0]).val; + + this._host.engine.iactivity("act.refineTCs", [cost], "ks-faith"); + this._host.engine.storeForSummary( + this._host.engine.i18n("$resources.timeCrystal.title"), + cost, + "refine" + ); + } + } + + private _autoTAP() { + const faith = this._workshopManager.getResource("faith"); + const faithLevel = faith.value / faith.maxValue; + // enough faith, and then TAP (transcend, adore, praise) + if (this.settings.transcend.enabled && this.settings.autoPraise.trigger - 0.02 <= faithLevel) { + this._autoTranscend(); + } + + // Praise (faith → worship) + if (this.settings.autoPraise.trigger <= faithLevel) { + // Adore the galaxy (worship → epiphany) + if ( + this.settings.adore.enabled && + mustExist(this._host.gamePage.religion.getRU("apocripha")).on + ) { + this._autoAdore(this.settings.adore.trigger); + } + + if (this.settings.autoPraise.enabled) { + this._autoPraise(); + } + } + } + + private _autoAdore(trigger: number) { + const faith = this._workshopManager.getResource("faith"); + + const worship = this._host.gamePage.religion.faith; + const epiphany = this._host.gamePage.religion.faithRatio; + const transcendenceReached = mustExist(this._host.gamePage.religion.getRU("transcendence")).on; + const transcendenceTierCurrent = transcendenceReached + ? this._host.gamePage.religion.transcendenceTier + : 0; + // game version: 1.4.8.1 + // solarRevolutionLimit is increased by black obelisks. + const maxSolarRevolution = 10 + this._host.gamePage.getEffect("solarRevolutionLimit"); + // The absolute value at which to trigger adoring the galaxy. + const triggerSolarRevolution = maxSolarRevolution * trigger; + // How much epiphany we'll get from converting our worship. + const epiphanyIncrease = + (worship / 1000000) * transcendenceTierCurrent * transcendenceTierCurrent * 1.01; + // How much epiphany we'll have after adoring. + const epiphanyAfterAdore = epiphany + epiphanyIncrease; + // How much worship we'll have after adoring. + const worshipAfterAdore = + 0.01 + faith.value * (1 + this._host.gamePage.getUnlimitedDR(epiphanyAfterAdore, 0.1) * 0.1); + // How much solar revolution bonus we'll have after adoring. + const solarRevolutionAfterAdore = this._host.gamePage.getLimitedDR( + this._host.gamePage.getUnlimitedDR(worshipAfterAdore, 1000) / 100, + maxSolarRevolution + ); + // After adoring the galaxy, we want a single praise to be able to reach the trigger + // level of solar revolution bonus. + if (triggerSolarRevolution <= solarRevolutionAfterAdore) { + // Perform the actual adoration. + this._host.gamePage.religion._resetFaithInternal(1.01); + + // Log the action. + this._host.engine.iactivity( + "act.adore", + [ + this._host.gamePage.getDisplayValueExt(worship), + this._host.gamePage.getDisplayValueExt(epiphanyIncrease), + ], + "ks-adore" + ); + this._host.engine.storeForSummary("adore", epiphanyIncrease); + // TODO: Not sure what the point of updating these values would be + // We're at the end of the branch. + //epiphany = this._host.gamePage.religion.faithRatio; + //worship = this._host.gamePage.religion.faith; + } + } + + private _autoTranscend() { + let epiphany = this._host.gamePage.religion.faithRatio; + const transcendenceReached = mustExist(this._host.gamePage.religion.getRU("transcendence")).on; + let transcendenceTierCurrent = transcendenceReached + ? this._host.gamePage.religion.transcendenceTier + : 0; + + // Transcend + if (transcendenceReached) { + // How much our adoration ratio increases from transcending. + const adoreIncreaceRatio = Math.pow( + (transcendenceTierCurrent + 2) / (transcendenceTierCurrent + 1), + 2 + ); + // The amount of worship needed to upgrade to the next level. + const needNextLevel = + this._host.gamePage.religion._getTranscendTotalPrice(transcendenceTierCurrent + 1) - + this._host.gamePage.religion._getTranscendTotalPrice(transcendenceTierCurrent); + + // We want to determine the ideal value for when to trancend. + // TODO: How exactly this works isn't understood yet. + const x = needNextLevel; + const k = adoreIncreaceRatio; + const epiphanyRecommend = + ((1 - k + Math.sqrt(80 * (k * k - 1) * x + (k - 1) * (k - 1))) * k) / + (40 * (k + 1) * (k + 1) * (k - 1)) + + x + + x / (k * k - 1); + + if (epiphanyRecommend <= epiphany) { + // code copy from kittens game's religion.js: this._host.gamePage.religion.transcend() + // this._host.gamePage.religion.transcend() need confirm by player + // game version: 1.4.8.1 + // ======================================================================================================== + // DO TRANSCEND START + // ======================================================================================================== + this._host.gamePage.religion.faithRatio -= needNextLevel; + this._host.gamePage.religion.tcratio += needNextLevel; + this._host.gamePage.religion.transcendenceTier += 1; + + const atheism = mustExist(this._host.gamePage.challenges.getChallenge("atheism")); + atheism.calculateEffects(atheism, this._host.gamePage); + const blackObelisk = mustExist(this._host.gamePage.religion.getTU("blackObelisk")); + blackObelisk.calculateEffects(blackObelisk, this._host.gamePage); + + this._host.gamePage.msg( + this._host.engine.i18n("$religion.transcend.msg.success", [ + this._host.gamePage.religion.transcendenceTier, + ]) + ); + // ======================================================================================================== + // DO TRANSCEND END + // ======================================================================================================== + + epiphany = this._host.gamePage.religion.faithRatio; + transcendenceTierCurrent = this._host.gamePage.religion.transcendenceTier; + this._host.engine.iactivity( + "act.transcend", + [this._host.gamePage.getDisplayValueExt(needNextLevel), transcendenceTierCurrent], + "ks-transcend" + ); + this._host.engine.storeForSummary("transcend", 1); + } + } + } + + private _autoPraise() { + const faith = this._workshopManager.getResource("faith"); + let apocryphaBonus; + if (!this._host.gamePage.religion.getFaithBonus) { + apocryphaBonus = this._host.gamePage.religion.getApocryphaBonus(); + } else { + apocryphaBonus = this._host.gamePage.religion.getFaithBonus(); + } + + // Determine how much worship we'll gain and log it. + const worshipIncrease = faith.value * (1 + apocryphaBonus); + this._host.engine.storeForSummary("praise", worshipIncrease); + this._host.engine.iactivity( + "act.praise", + [ + this._host.gamePage.getDisplayValueExt(faith.value), + this._host.gamePage.getDisplayValueExt(worshipIncrease), + ], + "ks-praise" + ); + + // Now finally praise the sun. + this._host.gamePage.religion.praise(); + } } diff --git a/packages/userscript/source/TimeControlManager.ts b/packages/userscript/source/TimeControlManager.ts index 067696f79..42777956e 100644 --- a/packages/userscript/source/TimeControlManager.ts +++ b/packages/userscript/source/TimeControlManager.ts @@ -433,7 +433,7 @@ export class TimeControlManager { if (0 < willSkip) { const shatter = this._host.gamePage.timeTab.cfPanel.children[0].children[0]; // check? this._host.engine.iactivity("act.time.skip", [willSkip], "ks-timeSkip"); - shatter.controller.doShatterAmt(shatter.model, willSkip); + shatter.controller.doShatterAmt!(shatter.model, willSkip); this._host.engine.storeForSummary("time.skip", willSkip); } } diff --git a/packages/userscript/source/TimeManager.ts b/packages/userscript/source/TimeManager.ts index 9d3e84ab4..7b7eba53f 100644 --- a/packages/userscript/source/TimeManager.ts +++ b/packages/userscript/source/TimeManager.ts @@ -165,7 +165,7 @@ export class TimeManager { let fixed = 0; const btn = this.manager.tab.vsPanel.children[0].children[0]; //check? // doFixCryochamber will check resources - while (btn.controller.doFixCryochamber(btn.model)) { + while (btn.controller.doFixCryochamber!(btn.model)) { ++fixed; } if (0 < fixed) { diff --git a/packages/userscript/source/helper/ActivitySummary.ts b/packages/userscript/source/helper/ActivitySummary.ts index 37d610b78..11448ee5f 100644 --- a/packages/userscript/source/helper/ActivitySummary.ts +++ b/packages/userscript/source/helper/ActivitySummary.ts @@ -10,6 +10,7 @@ export type ActivitySummarySection = | "craft" | "faith" | "other" + | "refine" | "research" | "trade" | "upgrade"; @@ -137,6 +138,18 @@ export class ActivitySummary { }); } + // Ziggurats + if (this._sections.has("refine")) { + const section = mustExist(this._sections.get("refine")); + section.forEach((amount, name) => { + summary.push( + this._host.engine.i18n("summary.refine", [ + this._host.gamePage.getDisplayValueExt(amount), + ucfirst(name), + ]) + ); + }); + } // Order of the sun. if (this._sections.has("faith")) { const section = mustExist(this._sections.get("faith")); diff --git a/packages/userscript/source/helper/BulkPurchaseHelper.ts b/packages/userscript/source/helper/BulkPurchaseHelper.ts index 967b54ec6..7a7aa7370 100644 --- a/packages/userscript/source/helper/BulkPurchaseHelper.ts +++ b/packages/userscript/source/helper/BulkPurchaseHelper.ts @@ -447,11 +447,11 @@ export class BulkPurchaseHelper { amount = meta.limitBuild - meta.val; } - if ((model.enabled && button.controller.hasResources(model)) || this._host.gamePage.devMode) { - while (button.controller.hasResources(model) && amount > 0) { - model.prices = button.controller.getPrices(model); - button.controller.payPrice(model); - button.controller.incrementValue(model); + if ((model.enabled && button.controller.hasResources!(model)) || this._host.gamePage.devMode) { + while (button.controller.hasResources!(model) && amount > 0) { + model.prices = button.controller.getPrices!(model); + button.controller.payPrice!(model); + button.controller.incrementValue!(model); counter++; amount--; } diff --git a/packages/userscript/source/i18n/i18nData.json b/packages/userscript/source/i18n/i18nData.json index b35370f4b..e6f49452f 100644 --- a/packages/userscript/source/i18n/i18nData.json +++ b/packages/userscript/source/i18n/i18nData.json @@ -13,6 +13,8 @@ "act.observe": "Kitten Scientists have observed a star", "act.praise": "Praised the sun! Accumulated {0} faith to {1} worship", "act.promote": "Kittens' leader has been promoted to rank {0}", + "act.refineTCs": "Refined {0} time crystals", + "act.refineTears": "Refined tears into BLS", "act.sun.discover": "Kittens have discovered {0}", "act.sun.discovers": "Kittens have discovered {0} {1} times", "act.time.skip": "Kittens combust a time crystal, {0} years skipped!", @@ -54,6 +56,8 @@ "option.faith.adore": "Auto Adore the Galaxy", "option.faith.best.unicorn.desc": "Include auto Sacrifice Unicorns if tears are not enough to build the best unicorn building", "option.faith.best.unicorn": "Build Best Unicorn Building First", + "option.faith.refineTears": "Refine Tears", + "option.faith.refineTCs": "Refine TCs", "option.faith.transcend": "Auto Transcend", "option.festival": "Hold festivals", "option.fix.cry": "Fix Cryochamber", @@ -119,6 +123,7 @@ "summary.hunt": "Sent adorable kitten hunters on {0} hunts", "summary.praise": "Accumulated {0} worship by praising the sun", "summary.promote": "Promoted our leader {0} times", + "summary.refine": "Refined {0} {1}", "summary.separator": " and ", "summary.show": "Show activity", "summary.stars": "Observed {0} stars", @@ -203,6 +208,8 @@ "act.observe": "小猫珂学家观测到一颗流星", "act.praise": "赞美太阳! 转化 {0} 信仰为 {1} 虔诚", "act.promote": "领袖被提拔到 {0} 级", + "act.refineTCs": "Refined {0} time crystals", + "act.refineTears": "Refined tears into BLS", "act.sun.discover": "小猫在 {0} 方面获得顿悟", "act.sun.discovers": "小猫在 {0} 方面获得 {1} 次顿悟", "act.time.skip": "燃烧时间水晶, 跳过接下来的 {0} 年!", @@ -244,6 +251,8 @@ "option.faith.adore": "赞美群星", "option.faith.best.unicorn.desc": "当眼泪不够建造最佳独角兽建筑时也会自动献祭独角兽", "option.faith.best.unicorn": "优先最佳独角兽建筑", + "option.faith.refineTears": "Refine Tears", + "option.faith.refineTCs": "Refine TCs", "option.faith.transcend": "自动超越", "option.festival": "举办节日", "option.fix.cry": "修复冷冻仓", @@ -309,6 +318,7 @@ "summary.hunt": "派出了 {0} 批可爱的小猫猎人", "summary.praise": "通过赞美太阳积累了 {0} 虔诚", "summary.promote": "提拔领袖 {0} 次", + "summary.refine": "Refined {0} {1}", "summary.separator": " ", "summary.show": "总结", "summary.stars": "观测了 {0} 颗流星", diff --git a/packages/userscript/source/settings/ReligionSettings.ts b/packages/userscript/source/settings/ReligionSettings.ts index b91271fda..1c254a8bf 100644 --- a/packages/userscript/source/settings/ReligionSettings.ts +++ b/packages/userscript/source/settings/ReligionSettings.ts @@ -72,6 +72,16 @@ export class ReligionSettings extends SettingTrigger { */ bestUnicornBuilding: Setting; + /** + * Refine tears into BLS. + */ + refineTears: SettingTrigger; + + /** + * Refine time crystals into relics. + */ + refineTimeCrystals: SettingTrigger; + /** * Praise the sun. */ @@ -303,15 +313,19 @@ export class ReligionSettings extends SettingTrigger { ), }, bestUnicornBuilding = new Setting(false), + refineTears = new SettingTrigger(false, 10000), + refineTimeCrystals = new SettingTrigger(false, 15000), autoPraise = new SettingTrigger(true, 0.98), adore = new SettingTrigger(false, 0.75), transcend = new Setting(false) ) { super(enabled, trigger); this.buildings = buildings; - this.adore = adore; - this.autoPraise = autoPraise; this.bestUnicornBuilding = bestUnicornBuilding; + this.refineTears = refineTears; + this.refineTimeCrystals = refineTimeCrystals; + this.autoPraise = autoPraise; + this.adore = adore; this.transcend = transcend; } @@ -327,13 +341,12 @@ export class ReligionSettings extends SettingTrigger { building.max = item?.max ?? building.max; }); - this.adore.enabled = settings.adore?.enabled ?? this.adore.enabled; - this.autoPraise.enabled = settings.autoPraise?.enabled ?? this.autoPraise.enabled; - this.bestUnicornBuilding.enabled = - settings.bestUnicornBuilding?.enabled ?? this.bestUnicornBuilding.enabled; - this.transcend.enabled = settings.transcend?.enabled ?? this.transcend.enabled; - this.adore.trigger = settings.adore?.trigger ?? this.adore.trigger; - this.autoPraise.trigger = settings.autoPraise?.trigger ?? this.autoPraise.trigger; + this.bestUnicornBuilding.load(settings.bestUnicornBuilding); + this.refineTears.load(settings.refineTears); + this.refineTimeCrystals.load(settings.refineTimeCrystals); + this.autoPraise.load(settings.autoPraise); + this.adore.load(settings.adore); + this.transcend.load(settings.transcend); } static fromLegacyOptions(subject: LegacyStorage) { diff --git a/packages/userscript/source/types/gamePage.ts b/packages/userscript/source/types/gamePage.ts index b6a4a4923..88be5cf1d 100644 --- a/packages/userscript/source/types/gamePage.ts +++ b/packages/userscript/source/types/gamePage.ts @@ -255,9 +255,7 @@ export type GamePage = { */ _resetFaithInternal: (bonusRatio: number) => void; }; - religionTab: { - sacrificeBtn: BuildButton; - }; + religionTab: ReligionTab; resetAutomatic: () => void; resPool: { get: (name: Resource) => ResourceInfo; diff --git a/packages/userscript/source/types/index.ts b/packages/userscript/source/types/index.ts index bd0a3b993..02e2068e8 100644 --- a/packages/userscript/source/types/index.ts +++ b/packages/userscript/source/types/index.ts @@ -146,15 +146,16 @@ export type ButtonModel = { export type BuildButton = { children: Array; controller: { - _transform: (model: unknown, value: unknown) => void; - getPrices: (model: unknown) => Array; - hasResources: (model: unknown) => boolean; // Probably generic - doFixCryochamber: (model: unknown) => boolean; // Fix broken cryochambers - doShatterAmt: (model: unknown, amt: number) => void; // Shatter TC button - incrementValue: (model: unknown) => void; - onAll: (model: unknown) => void; // Turn on all (steamworks) - payPrice: (model: unknown) => void; - sellInternal: (model: unknown, end: number) => void; // Sell button + _transform?: (model: unknown, value: unknown) => void; + buyItem?: (model: ButtonModel, event: unknown, callback: (success: boolean) => void) => void; + getPrices?: (model: unknown) => Array; + hasResources?: (model: unknown) => boolean; // Probably generic + doFixCryochamber?: (model: unknown) => boolean; // Fix broken cryochambers + doShatterAmt?: (model: unknown, amt: number) => void; // Shatter TC button + incrementValue?: (model: unknown) => void; + onAll?: (model: unknown) => void; // Turn on all (steamworks) + payPrice?: (model: unknown) => void; + sellInternal?: (model: unknown, end: number) => void; // Sell button }; domNode: HTMLDivElement; id: T; @@ -211,11 +212,27 @@ export type PolicyBtnController = { buyItem: (model: ButtonModel, event: unknown, callback: (success: boolean) => void) => void; }; +export type RefineTearsBtnController = { + new (game: GamePage): RefineTearsBtnController; + buyItem: (model: ButtonModel, event: unknown, callback: (success: boolean) => void) => void; +}; + export type TechButtonController = { new (game: GamePage): TechButtonController; buyItem: (model: ButtonModel, event: unknown, callback: (success: boolean) => void) => void; }; +export type TransformBtnController = { + new (game: GamePage): TransformBtnController; + buyItem: ( + model: ButtonModel, + event: Event, + callback: (success: boolean) => void, + amt?: number + ) => void; + _transform: (model: ButtonModel, amt: number) => boolean; +}; + export type ClassList = { diplomacy: { ui: { @@ -224,6 +241,10 @@ export type ClassList = { }; ui: { PolicyBtnController: PolicyBtnController; + religion: { + RefineTearsBtnController: RefineTearsBtnController; + TransformBtnController: TransformBtnController; + }; }; }; diff --git a/packages/userscript/source/types/religion.ts b/packages/userscript/source/types/religion.ts index 76c1ffccf..2c9f4a68e 100644 --- a/packages/userscript/source/types/religion.ts +++ b/packages/userscript/source/types/religion.ts @@ -1,11 +1,26 @@ import { BuildButton, GamePage, GameTab, Price } from "."; export type ReligionTab = GameTab & { + /** + * Refine tears. + */ + refineBtn: BuildButton; + + /** + * Refine time crystals. + */ + refineTCBtn: BuildButton; + /** * Religion upgrade (Order of the sun) buttons. */ rUpgradeButtons: Array>; + /** + * Sacrifice unicorns. + */ + sacrificeBtn: BuildButton; + /** * Ziggurath upgrade buttons. */ diff --git a/packages/userscript/source/ui/ReligionSettingsUi.ts b/packages/userscript/source/ui/ReligionSettingsUi.ts index 21561ec76..9d5c0c278 100644 --- a/packages/userscript/source/ui/ReligionSettingsUi.ts +++ b/packages/userscript/source/ui/ReligionSettingsUi.ts @@ -205,63 +205,91 @@ export class ReligionSettingsUi extends SettingsSectionUi { this.addChild(listBuildings); const listAddition = new SettingsList(this._host, { + children: [ + new HeaderListItem(this._host, "Additional options"), + new SettingTriggerListItem( + this._host, + this._host.engine.i18n("option.faith.refineTears"), + this.setting.refineTears, + "integer", + { + onCheck: () => + this._host.engine.imessage("status.sub.enable", [ + this._host.engine.i18n("option.faith.refineTears"), + ]), + onUnCheck: () => + this._host.engine.imessage("status.sub.disable", [ + this._host.engine.i18n("option.faith.refineTears"), + ]), + } + ), + new SettingTriggerListItem( + this._host, + this._host.engine.i18n("option.faith.refineTCs"), + this.setting.refineTimeCrystals, + "integer", + { + onCheck: () => + this._host.engine.imessage("status.sub.enable", [ + this._host.engine.i18n("option.faith.refineTCs"), + ]), + onUnCheck: () => + this._host.engine.imessage("status.sub.disable", [ + this._host.engine.i18n("option.faith.refineTCs"), + ]), + } + ), + new SettingListItem( + this._host, + this._host.engine.i18n("option.faith.transcend"), + this.setting.transcend, + { + onCheck: () => + this._host.engine.imessage("status.sub.enable", [ + this._host.engine.i18n("option.faith.transcend"), + ]), + onUnCheck: () => + this._host.engine.imessage("status.sub.disable", [ + this._host.engine.i18n("option.faith.transcend"), + ]), + } + ), + new SettingTriggerListItem( + this._host, + this._host.engine.i18n("option.faith.adore"), + this.setting.adore, + "percentage", + { + onCheck: () => + this._host.engine.imessage("status.sub.enable", [ + this._host.engine.i18n("option.faith.adore"), + ]), + onUnCheck: () => + this._host.engine.imessage("status.sub.disable", [ + this._host.engine.i18n("option.faith.adore"), + ]), + } + ), + new SettingTriggerListItem( + this._host, + this._host.engine.i18n("option.praise"), + this.setting.autoPraise, + "percentage", + { + onCheck: () => + this._host.engine.imessage("status.sub.enable", [ + this._host.engine.i18n("option.praise"), + ]), + onUnCheck: () => + this._host.engine.imessage("status.sub.disable", [ + this._host.engine.i18n("option.praise"), + ]), + } + ), + ], hasDisableAll: false, hasEnableAll: false, }); - listAddition.addChild(new HeaderListItem(this._host, "Additional options")); - - const nodeTranscend = new SettingListItem( - this._host, - this._host.engine.i18n("option.faith.transcend"), - this.setting.transcend, - { - onCheck: () => - this._host.engine.imessage("status.sub.enable", [ - this._host.engine.i18n("option.faith.transcend"), - ]), - onUnCheck: () => - this._host.engine.imessage("status.sub.disable", [ - this._host.engine.i18n("option.faith.transcend"), - ]), - } - ); - listAddition.addChild(nodeTranscend); - - const nodeAdore = new SettingTriggerListItem( - this._host, - this._host.engine.i18n("option.faith.adore"), - this.setting.adore, - "percentage", - { - onCheck: () => - this._host.engine.imessage("status.sub.enable", [ - this._host.engine.i18n("option.faith.adore"), - ]), - onUnCheck: () => - this._host.engine.imessage("status.sub.disable", [ - this._host.engine.i18n("option.faith.adore"), - ]), - } - ); - listAddition.addChild(nodeAdore); - - const nodeAutoPraise = new SettingTriggerListItem( - this._host, - this._host.engine.i18n("option.praise"), - this.setting.autoPraise, - "percentage", - { - onCheck: () => - this._host.engine.imessage("status.sub.enable", [ - this._host.engine.i18n("option.praise"), - ]), - onUnCheck: () => - this._host.engine.imessage("status.sub.disable", [ - this._host.engine.i18n("option.praise"), - ]), - } - ); - listAddition.addChild(nodeAutoPraise); this.addChild(listAddition); }