@@ -6,30 +6,29 @@ import { TabManager } from "./TabManager.js";
6
6
import type { WorkshopManager } from "./WorkshopManager.js" ;
7
7
import { BulkPurchaseHelper } from "./helper/BulkPurchaseHelper.js" ;
8
8
import { BonfireBuildingSetting } from "./settings/BonfireSettings.js" ;
9
+ import { ReligionSettings , type ReligionSettingsItem } from "./settings/ReligionSettings.js" ;
10
+ import { negativeOneToInfinity } from "./tools/Format.js" ;
11
+ import { cdebug , cwarn } from "./tools/Log.js" ;
12
+ import type { UnsafeButtonModernModel } from "./types/core.js" ;
9
13
import {
10
14
type FaithItem ,
11
15
type ReligionItem ,
12
- ReligionSettings ,
13
- type ReligionSettingsItem ,
14
- type UnicornItem ,
15
- UnicornItems ,
16
- } from "./settings/ReligionSettings.js" ;
17
- import { negativeOneToInfinity } from "./tools/Format.js" ;
18
- import { cwarn } from "./tools/Log.js" ;
19
- import {
20
- type BuildButton ,
21
- type ButtonModernController ,
22
- type ButtonModernModel ,
23
- type ReligionTab ,
24
16
type ReligionUpgrade ,
25
- type ReligionUpgradeInfo ,
26
17
type TranscendenceUpgrade ,
27
- type TranscendenceUpgradeInfo ,
28
- type TransformBtnController ,
18
+ type UnicornItem ,
29
19
UnicornItemVariant ,
20
+ UnicornItems ,
30
21
type ZiggurathUpgrade ,
31
- type ZiggurathUpgradeInfo ,
32
22
} from "./types/index.js" ;
23
+ import type {
24
+ CryptotheologyPanel ,
25
+ CryptotheologyWGT ,
26
+ ReligionTab ,
27
+ TransformBtnController ,
28
+ UnsafeReligionUpgrade ,
29
+ UnsafeTranscendenceUpgrade ,
30
+ UnsafeZiggurathUpgrade ,
31
+ } from "./types/religion.js" ;
33
32
34
33
export class ReligionManager implements Automation {
35
34
private readonly _host : KittenScientists ;
@@ -170,7 +169,7 @@ export class ReligionManager implements Automation {
170
169
needSacrifice < maxSacrifice &&
171
170
! isNil ( this . _host . game . religionTab . sacrificeBtn . model )
172
171
) {
173
- this . _host . game . religionTab . sacrificeBtn . controller . _transform (
172
+ this . _host . game . religionTab . sacrificeBtn ? .controller ? ._transform (
174
173
this . _host . game . religionTab . sacrificeBtn . model ,
175
174
needSacrifice ,
176
175
) ;
@@ -218,7 +217,7 @@ export class ReligionManager implements Automation {
218
217
this . manager . render ( ) ;
219
218
220
219
const metaData : Partial <
221
- Record < FaithItem , ReligionUpgradeInfo | TranscendenceUpgradeInfo | ZiggurathUpgradeInfo >
220
+ Record < FaithItem , UnsafeReligionUpgrade | UnsafeTranscendenceUpgrade | UnsafeZiggurathUpgrade >
222
221
> = this . getBuildMetaData ( builds ) ;
223
222
const sectionTrigger = this . settings . trigger ;
224
223
@@ -436,7 +435,7 @@ export class ReligionManager implements Automation {
436
435
437
436
getBuildMetaData ( builds : Partial < Record < FaithItem , ReligionSettingsItem > > ) {
438
437
const metaData : Partial <
439
- Record < FaithItem , ReligionUpgradeInfo | TranscendenceUpgradeInfo | ZiggurathUpgradeInfo >
438
+ Record < FaithItem , UnsafeReligionUpgrade | UnsafeTranscendenceUpgrade | UnsafeZiggurathUpgrade >
440
439
> = { } ;
441
440
for ( const build of Object . values ( builds ) ) {
442
441
const buildInfo = this . getBuild ( build . building , build . variant ) ;
@@ -470,10 +469,7 @@ export class ReligionManager implements Automation {
470
469
* @param variant The variant of the upgrade.
471
470
* @returns The build information for the upgrade.
472
471
*/
473
- getBuild (
474
- name : ReligionItem | "unicornPasture" ,
475
- variant : UnicornItemVariant ,
476
- ) : ReligionUpgradeInfo | TranscendenceUpgradeInfo | ZiggurathUpgradeInfo | null {
472
+ getBuild ( name : ReligionItem | "unicornPasture" , variant : UnicornItemVariant ) {
477
473
switch ( variant ) {
478
474
case UnicornItemVariant . Ziggurat :
479
475
return this . _host . game . religion . getZU ( name as ZiggurathUpgrade ) ?? null ;
@@ -482,7 +478,7 @@ export class ReligionManager implements Automation {
482
478
case UnicornItemVariant . Cryptotheology :
483
479
return this . _host . game . religion . getTU ( name as TranscendenceUpgrade ) ?? null ;
484
480
}
485
- return null ;
481
+ throw new Error ( `Unknown build: ${ name } ( ${ variant } )` ) ;
486
482
}
487
483
488
484
/**
@@ -492,11 +488,11 @@ export class ReligionManager implements Automation {
492
488
* @param variant The variant of the upgrade.
493
489
* @returns The button to buy the upgrade, or `null`.
494
490
*/
495
- private _getBuildButton (
496
- name : ReligionItem | "unicornPasture" ,
497
- variant : UnicornItemVariant ,
498
- ) : BuildButton < string , ButtonModernModel , ButtonModernController > | null {
499
- let buttons : Array < BuildButton > ;
491
+ private _getBuildButton ( name : ReligionItem | "unicornPasture" , variant : UnicornItemVariant ) {
492
+ let buttons :
493
+ | typeof this . manager . tab . zgUpgradeButtons
494
+ | typeof this . manager . tab . rUpgradeButtons
495
+ | CryptotheologyWGT [ "children" ] ;
500
496
switch ( variant ) {
501
497
case UnicornItemVariant . Ziggurat :
502
498
buttons = this . manager . tab . zgUpgradeButtons ;
@@ -505,7 +501,7 @@ export class ReligionManager implements Automation {
505
501
buttons = this . manager . tab . rUpgradeButtons ;
506
502
break ;
507
503
case UnicornItemVariant . Cryptotheology :
508
- buttons = this . manager . tab . children [ 0 ] . children [ 0 ] . children ;
504
+ buttons = ( this . manager . tab . children [ 0 ] as CryptotheologyPanel ) . children [ 0 ] . children ;
509
505
break ;
510
506
default :
511
507
throw new Error ( `Invalid variant '${ variant } '` ) ;
@@ -516,26 +512,28 @@ export class ReligionManager implements Automation {
516
512
return null ;
517
513
}
518
514
519
- return ( buttons . find ( button => button . id === name ) ?? null ) as BuildButton <
520
- string ,
521
- ButtonModernModel ,
522
- ButtonModernController
523
- > | null ;
515
+ const button = buttons . find ( button => button . id === name ) ?? null ;
516
+
517
+ if ( button === null ) {
518
+ cdebug ( `Couldn't find button for ${ name } ! This will likely create problems.` ) ;
519
+ }
520
+
521
+ return button ;
524
522
}
525
523
526
524
private _transformBtnSacrificeHelper (
527
525
available : number ,
528
526
total : number ,
529
527
controller : TransformBtnController ,
530
- model : ButtonModernModel ,
528
+ model : UnsafeButtonModernModel ,
531
529
) {
532
530
const conversionPercentage = available / total ;
533
531
const percentageInverse = 1 / conversionPercentage ;
534
532
535
533
const customController = new classes . ui . religion . TransformBtnController (
536
534
game ,
537
535
controller . controllerOpts ,
538
- ) as TransformBtnController ;
536
+ ) ;
539
537
540
538
const link = customController . _newLink ( model , percentageInverse ) ;
541
539
return new Promise < boolean > ( resolve => {
@@ -796,9 +794,9 @@ export class ReligionManager implements Automation {
796
794
this . _host . game . religion . transcendenceTier += 1 ;
797
795
798
796
const atheism = mustExist ( this . _host . game . challenges . getChallenge ( "atheism" ) ) ;
799
- atheism . calculateEffects ( atheism , this . _host . game ) ;
797
+ atheism . calculateEffects ?. ( atheism , this . _host . game ) ;
800
798
const blackObelisk = mustExist ( this . _host . game . religion . getTU ( "blackObelisk" ) ) ;
801
- blackObelisk . calculateEffects ( blackObelisk , this . _host . game ) ;
799
+ blackObelisk . calculateEffects ?. ( blackObelisk , this . _host . game ) ;
802
800
803
801
this . _host . game . msg (
804
802
this . _host . engine . i18n ( "$religion.transcend.msg.success" , [
0 commit comments