diff --git a/src/model/GameConfig.ts b/src/model/GameConfig.ts index bb1f5db..0d6d875 100644 --- a/src/model/GameConfig.ts +++ b/src/model/GameConfig.ts @@ -77,6 +77,14 @@ class GameConfig { tents: { followers: 2 }, }; + public cfgBuySpeed: { [key in ResourceKey]?: ResourceNumber } = { + compoundManagers: { + churches: 0.01, + houses: 0.02, + tents: 0.05, + }, + }; + public cfgCredibilityFollowerLossRatio = 0.04; public cfgCredibilityFollowerLossTime = 10000; public cfgCredibilityRestoreRate = 0.25; diff --git a/src/model/resource/Church.ts b/src/model/resource/Church.ts index aa9c753..a7c0cc6 100644 --- a/src/model/resource/Church.ts +++ b/src/model/resource/Church.ts @@ -18,8 +18,18 @@ class Church extends Infrastructure { } public max: (state: GameState) => number = (state) => - (state.resource.compounds?.value ?? 0) * - (state.config.cfgCapacity.compounds?.churches ?? 0); + Math.floor( + (state.resource.compounds?.value ?? 0) * + (state.config.cfgCapacity.compounds?.churches ?? 0) + ); + + public inc: (state: GameState) => number = (state) => { + // compound managers + return ( + (state.resource.compoundManagers?.value ?? 0) * + (state.config.cfgBuySpeed.compoundManagers?.churches ?? 0) + ); + }; public isUnlocked(state: GameState): boolean { if (this._isUnlocked) return true; diff --git a/src/model/resource/CompoundManager.ts b/src/model/resource/CompoundManager.ts index 7941f5c..9b42f3b 100644 --- a/src/model/resource/CompoundManager.ts +++ b/src/model/resource/CompoundManager.ts @@ -11,9 +11,9 @@ class CompoundManager extends Job { } public max: (state: GameState) => number = (state) => { - return ( + return Math.floor( (state.resource.compounds?.value ?? 0) * - (state.config.cfgCapacity.compounds?.compoundManagers ?? 0) + (state.config.cfgCapacity.compounds?.compoundManagers ?? 0) ); }; diff --git a/src/model/resource/House.ts b/src/model/resource/House.ts index ae69ca0..2a98362 100644 --- a/src/model/resource/House.ts +++ b/src/model/resource/House.ts @@ -16,8 +16,18 @@ class House extends Infrastructure { } public max: (state: GameState) => number = (state) => - (state.resource.compounds?.value ?? 0) * - (state.config.cfgCapacity.compounds?.houses ?? 0); + Math.floor( + (state.resource.compounds?.value ?? 0) * + (state.config.cfgCapacity.compounds?.houses ?? 0) + ); + + public inc: (state: GameState) => number = (state) => { + // compound managers + return ( + (state.resource.compoundManagers?.value ?? 0) * + (state.config.cfgBuySpeed.compoundManagers?.houses ?? 0) + ); + }; public isUnlocked(state: GameState): boolean { if (this._isUnlocked) return true; diff --git a/src/model/resource/IResource.ts b/src/model/resource/IResource.ts index e9b7bbb..289f04c 100644 --- a/src/model/resource/IResource.ts +++ b/src/model/resource/IResource.ts @@ -19,8 +19,6 @@ interface IResource { addValue: (amount: number, state: GameState) => void; isUnlocked: (state: GameState) => boolean; - emitConfig?: () => { [key: string]: string | number | boolean }; - restoreConfig?: (config: { - [key: string]: string | number | boolean; - }) => void; + emitConfig?: () => ResourceConfigValues; + restoreConfig?: (config: ResourceConfigValues) => void; } diff --git a/src/model/resource/Pastor.ts b/src/model/resource/Pastor.ts index e535fe9..976d787 100644 --- a/src/model/resource/Pastor.ts +++ b/src/model/resource/Pastor.ts @@ -19,7 +19,7 @@ class Pastor extends Job { max += (state.resource.megaChurches?.value ?? 0) * (state.config.cfgCapacity.megaChurches?.pastors ?? 0); - return max; + return Math.floor(max); }; public isUnlocked(state: GameState): boolean { diff --git a/src/model/resource/Purchasable.ts b/src/model/resource/Purchasable.ts index f41c3a2..b403294 100644 --- a/src/model/resource/Purchasable.ts +++ b/src/model/resource/Purchasable.ts @@ -64,6 +64,16 @@ abstract class Purchasable implements IResource { return; } + public emitConfig: () => ResourceConfigValues = () => { + return { isUnlocked: this._isUnlocked }; + }; + + public restoreConfig: (config: ResourceConfigValues) => void = (config) => { + if (typeof config.isUnlocked === 'boolean') { + this._isUnlocked = config.isUnlocked; + } + }; + protected _purchaseLog(amount: number, _state: GameState): string { let verb = 'purchased'; if (amount < 0) { diff --git a/src/model/resource/SharedTypes.ts b/src/model/resource/SharedTypes.ts index 92551c1..1ba92f4 100644 --- a/src/model/resource/SharedTypes.ts +++ b/src/model/resource/SharedTypes.ts @@ -42,10 +42,12 @@ type ResourceAction = { performAction: (state: GameState) => void; }; +type ResourceConfigValues = { [key: string]: string | number | boolean }; + type ResourceConfig = { value: number; cost?: ResourceNumber; - config?: { [key: string]: string | number | boolean }; + config?: ResourceConfigValues; }; type SaveData = { diff --git a/src/model/resource/Tent.ts b/src/model/resource/Tent.ts index deff908..e806292 100644 --- a/src/model/resource/Tent.ts +++ b/src/model/resource/Tent.ts @@ -21,6 +21,11 @@ class Tent extends Infrastructure { max += (state.resource.compounds?.value ?? 0) * (state.config.cfgCapacity.compounds?.tents ?? 0); - return max; + return Math.floor(max); }; + + public inc: (state: GameState) => number = (state) => + // compound managers + (state.resource.compoundManagers?.value ?? 0) * + (state.config.cfgBuySpeed.compoundManagers?.tents ?? 0); } diff --git a/src/render/DebugRenderer.ts b/src/render/DebugRenderer.ts index 1be2d6e..e40d32b 100644 --- a/src/render/DebugRenderer.ts +++ b/src/render/DebugRenderer.ts @@ -115,10 +115,14 @@ class DebugRenderer implements IRenderer { const value = resource.valueInWholeNumbers ? Math.floor(resource.value) : resource.value; + const max = + resource.max !== undefined ? resource.max(state) : undefined; elV.innerHTML = formatNumber(value); elT.innerHTML = - resource.max !== undefined - ? ` / ${formatNumber(resource.max(state))}` + max !== undefined + ? ` / ${formatNumber( + resource.valueInWholeNumbers ? Math.floor(max) : max + )}` : ''; if (resource.userActions !== undefined) { for (let i = 0; i < resource.userActions.length; i++) {