2024-06-15 02:52:45 +02:00
import fs from "fs" ;
2025-04-01 15:49:08 -07:00
import path from "path" ;
2025-08-25 13:37:14 -07:00
import { repoDir } from "../helpers/pathHelper.ts" ;
import { args } from "../helpers/commandLineArguments.ts" ;
import { Inbox } from "../models/inboxModel.ts" ;
2024-05-15 21:55:59 +02:00
2025-08-24 15:30:31 -07:00
export interface IConfig extends IConfigRemovedOptions {
2024-05-15 21:55:59 +02:00
mongodbUrl : string ;
2025-04-05 06:50:57 -07:00
logger : {
files : boolean ;
level : string ; // "fatal" | "error" | "warn" | "info" | "http" | "debug" | "trace";
} ;
2024-05-15 21:55:59 +02:00
myAddress : string ;
2024-05-22 23:32:11 +02:00
httpPort? : number ;
httpsPort? : number ;
2024-06-18 12:24:58 +02:00
myIrcAddresses? : string [ ] ;
2025-02-21 08:29:42 +01:00
NRS? : string [ ] ;
2025-03-23 09:06:08 -07:00
administratorNames? : string [ ] ;
2024-05-15 21:55:59 +02:00
autoCreateAccount? : boolean ;
skipTutorial? : boolean ;
unlockAllScans? : boolean ;
2024-06-11 12:56:51 +02:00
unlockAllShipFeatures? : boolean ;
2024-05-15 21:55:59 +02:00
unlockAllShipDecorations? : boolean ;
unlockAllFlavourItems? : boolean ;
2024-05-29 22:08:41 +02:00
unlockAllSkins? : boolean ;
2024-12-29 21:11:36 +01:00
unlockAllCapturaScenes? : boolean ;
2025-04-11 06:54:07 -07:00
unlockAllDecoRecipes? : boolean ;
2025-06-22 06:55:44 -07:00
fullyStockedVendors? : boolean ;
2025-06-20 04:41:13 -07:00
unlockAllProfitTakerStages? : boolean ;
2025-08-24 15:36:59 -07:00
skipClanKeyCrafting? : boolean ;
2025-03-03 12:48:39 -08:00
noDojoRoomBuildStage? : boolean ;
2025-04-10 07:14:33 -07:00
noDojoDecoBuildStage? : boolean ;
2025-03-06 07:19:01 -08:00
fastDojoRoomDestruction? : boolean ;
2025-02-28 12:35:14 -08:00
noDojoResearchCosts? : boolean ;
noDojoResearchTime? : boolean ;
2025-03-08 01:44:30 -08:00
fastClanAscension? : boolean ;
2025-06-23 04:54:54 -07:00
unlockAllSimarisResearchEntries? : boolean ;
2024-05-28 13:28:35 +02:00
spoofMasteryRank? : number ;
2025-07-01 07:44:13 -07:00
relicRewardItemCountMultiplier? : number ;
2025-06-14 12:58:26 -07:00
nightwaveStandingMultiplier? : number ;
2025-06-23 21:51:48 -07:00
unfaithfulBugFixes ? : {
ignore1999LastRegionPlayed? : boolean ;
fixXtraCheeseTimer? : boolean ;
2025-08-17 13:11:55 -07:00
useAnniversaryTagForOldGoals? : boolean ;
2025-06-23 21:51:48 -07:00
} ;
2025-03-29 15:42:42 -07:00
worldState ? : {
2025-03-15 03:21:54 -07:00
creditBoost? : boolean ;
affinityBoost? : boolean ;
resourceBoost? : boolean ;
2025-07-30 01:50:43 -07:00
tennoLiveRelay? : boolean ;
2025-07-31 02:27:38 -07:00
baroTennoConRelay? : boolean ;
2025-08-27 01:29:38 -07:00
baroAlwaysAvailable? : boolean ;
baroFullyStocked? : boolean ;
varziaFullyStocked? : boolean ;
2025-08-13 07:13:05 -07:00
wolfHunt? : boolean ;
2025-08-16 09:52:58 -07:00
orphixVenom? : boolean ;
2025-08-13 07:13:05 -07:00
longShadow? : boolean ;
hallowedFlame? : boolean ;
2025-08-17 13:11:55 -07:00
anniversary? : number ;
2025-08-13 07:13:05 -07:00
hallowedNightmares? : boolean ;
hallowedNightmaresRewardsOverride? : number ;
proxyRebellion? : boolean ;
proxyRebellionRewardsOverride? : number ;
2025-06-25 08:04:03 -07:00
galleonOfGhouls? : number ;
2025-08-11 08:08:40 -07:00
ghoulEmergenceOverride? : boolean ;
plagueStarOverride? : boolean ;
2025-07-30 05:44:42 -07:00
starDaysOverride? : boolean ;
2025-08-13 07:13:05 -07:00
dogDaysOverride? : boolean ;
dogDaysRewardsOverride? : number ;
2025-08-15 08:14:36 -07:00
bellyOfTheBeast? : boolean ;
bellyOfTheBeastProgressOverride? : number ;
eightClaw? : boolean ;
eightClawProgressOverride? : number ;
2025-08-21 11:07:31 -07:00
thermiaFracturesOverride? : boolean ;
thermiaFracturesProgressOverride? : number ;
2025-06-09 06:54:58 -07:00
eidolonOverride? : string ;
vallisOverride? : string ;
2025-06-19 16:18:17 -07:00
duviriOverride? : string ;
2025-06-07 02:16:19 -07:00
nightwaveOverride? : string ;
2025-06-26 14:32:26 -07:00
allTheFissures? : string ;
2025-08-27 01:29:38 -07:00
varziaOverride? : string ;
2025-06-18 05:51:56 -07:00
circuitGameModes? : string [ ] ;
2025-06-28 09:39:41 -07:00
darvoStockMultiplier? : number ;
2025-03-08 04:28:05 -08:00
} ;
2025-06-14 12:58:26 -07:00
dev ? : {
keepVendorsExpired? : boolean ;
} ;
2024-05-15 21:55:59 +02:00
}
2025-08-24 15:30:31 -07:00
export const configRemovedOptionsKeys = [
2025-08-28 05:50:21 -07:00
"skipAllDialogue" ,
2025-08-24 15:30:31 -07:00
"infiniteCredits" ,
"infinitePlatinum" ,
"infiniteEndo" ,
"infiniteRegalAya" ,
"infiniteHelminthMaterials" ,
"claimingBlueprintRefundsIngredients" ,
"dontSubtractPurchaseCreditCost" ,
"dontSubtractPurchasePlatinumCost" ,
"dontSubtractPurchaseItemCost" ,
"dontSubtractPurchaseStandingCost" ,
"dontSubtractVoidTraces" ,
"dontSubtractConsumables" ,
"universalPolarityEverywhere" ,
"unlockDoubleCapacityPotatoesEverywhere" ,
"unlockExilusEverywhere" ,
"unlockArcanesEverywhere" ,
"noDailyStandingLimits" ,
"noDailyFocusLimit" ,
"noArgonCrystalDecay" ,
"noMasteryRankUpCooldown" ,
"noVendorPurchaseLimits" ,
"noDeathMarks" ,
"noKimCooldowns" ,
"syndicateMissionsRepeatable" ,
"instantFinishRivenChallenge" ,
"instantResourceExtractorDrones" ,
2025-08-27 01:29:38 -07:00
"noResourceExtractorDronesDamage" ,
"baroAlwaysAvailable" ,
2025-08-28 05:50:21 -07:00
"baroFullyStocked" ,
"missionsCanGiveAllRelics" ,
"exceptionalRelicsAlwaysGiveBronzeReward" ,
"flawlessRelicsAlwaysGiveSilverReward" ,
"radiantRelicsAlwaysGiveGoldReward" ,
"disableDailyTribute"
2025-08-24 15:30:31 -07:00
] as const ;
type IConfigRemovedOptions = {
[ K in ( typeof configRemovedOptionsKeys ) [ number ] ] ? : boolean ;
} ;
2025-06-20 18:30:52 -07:00
export const configPath = path . join ( repoDir , args . configPath ? ? "config.json" ) ;
2024-05-15 21:55:59 +02:00
2025-04-05 06:50:57 -07:00
export const config : IConfig = {
mongodbUrl : "mongodb://127.0.0.1:27017/openWF" ,
logger : {
files : true ,
level : "trace"
} ,
myAddress : "localhost"
2024-06-15 02:52:45 +02:00
} ;
2024-12-29 23:34:26 +01:00
2025-04-05 06:50:57 -07:00
export const loadConfig = ( ) : void = > {
2025-06-29 11:54:20 -07:00
const newConfig = JSON . parse ( fs . readFileSync ( configPath , "utf-8" ) ) as IConfig ;
2025-04-05 06:50:57 -07:00
// Set all values to undefined now so if the new config.json omits some fields that were previously present, it's correct in-memory.
for ( const key of Object . keys ( config ) ) {
2025-07-23 07:51:51 -07:00
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2025-04-05 06:50:57 -07:00
( config as any ) [ key ] = undefined ;
2024-12-29 23:34:26 +01:00
}
2025-04-05 06:50:57 -07:00
2025-06-29 11:54:20 -07:00
Object . assign ( config , newConfig ) ;
2024-12-29 23:34:26 +01:00
} ;
2025-07-17 05:04:30 -07:00
export const syncConfigWithDatabase = ( ) : void = > {
// Event messages are deleted after endDate. Since we don't use beginDate/endDate and instead have config toggles, we need to delete the messages once those bools are false.
// Also, for some reason, I can't just do `Inbox.deleteMany(...)`; - it needs this whole circus.
if ( ! config . worldState ? . creditBoost ) {
void Inbox . deleteMany ( { globaUpgradeId : "5b23106f283a555109666672" } ) . then ( ( ) = > { } ) ;
}
if ( ! config . worldState ? . affinityBoost ) {
void Inbox . deleteMany ( { globaUpgradeId : "5b23106f283a555109666673" } ) . then ( ( ) = > { } ) ;
}
if ( ! config . worldState ? . resourceBoost ) {
void Inbox . deleteMany ( { globaUpgradeId : "5b23106f283a555109666674" } ) . then ( ( ) = > { } ) ;
}
if ( ! config . worldState ? . galleonOfGhouls ) {
void Inbox . deleteMany ( { goalTag : "GalleonRobbery" } ) . then ( ( ) = > { } ) ;
}
} ;