diff --git a/.eslintrc.json b/.eslintrc.json
index 201db55..a9ce638 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -15,6 +15,7 @@
"ignoreRegExpLiterals": true}],
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/no-unused-vars": "off",
+ "@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/array-type": ["warn", {"default": "array-simple"}],
"@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"],
"@typescript-eslint/consistent-type-assertions": ["warn", {
diff --git a/src/main.ts b/src/main.ts
index 757b685..9aedb3b 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -27,7 +27,7 @@ function startGame (state: GameState, renderer: IRenderer): void {
// run with default config at startup
((): void => {
- const config: GameConfig = new GameConfig();
+ const config = new GameConfig();
// debug values to make the game play faster while testing
config.cfgTitheAmount = 1000;
@@ -36,8 +36,8 @@ function startGame (state: GameState, renderer: IRenderer): void {
config.cfgCredibilityRestoreRate = 5;
config.cfgPastorRecruitRate = 0.5;
- const renderer: IRenderer = new DebugRenderer();
- const state: GameState = config.generateState();
+ const renderer = new DebugRenderer();
+ const state = config.generateState();
// re-run main loop immediately on user clicks
state.onResourceClick.push((): void => {
diff --git a/src/model/GameConfig.ts b/src/model/GameConfig.ts
index f404e82..45ea19f 100644
--- a/src/model/GameConfig.ts
+++ b/src/model/GameConfig.ts
@@ -38,7 +38,7 @@ class GameConfig {
public cfgPastorRecruitRate = 0.01;
public generateState (): GameState {
- const state: GameState = new GameState(this);
+ const state = new GameState(this);
// create player organization
state.addResource('plorg', new PlayerOrg());
diff --git a/src/model/GameState.ts b/src/model/GameState.ts
index 40f4e65..37c7137 100644
--- a/src/model/GameState.ts
+++ b/src/model/GameState.ts
@@ -7,11 +7,11 @@ class GameState {
public now = 0;
- private readonly _versionMaj: number = 0;
- private readonly _versionMin: number = 1;
+ private readonly _versionMaj = 0;
+ private readonly _versionMin = 1;
private _timeSinceSave = 0;
- private readonly _timeBetweenSaves: number = 10000;
+ private readonly _timeBetweenSaves = 10000;
private _resources: { [key: string]: IResource } = { };
private readonly _resourceKeys: string[] = [];
diff --git a/src/model/logging/DebugLogger.ts b/src/model/logging/DebugLogger.ts
index d71f52b..b0b68db 100644
--- a/src/model/logging/DebugLogger.ts
+++ b/src/model/logging/DebugLogger.ts
@@ -6,7 +6,7 @@ class DebugLogger implements ILogger {
}
public msg (text: string): void {
- const p: HTMLElement = document.createElement('p');
+ const p = document.createElement('p');
p.innerText = text;
this._container.appendChild(p);
if (this._container.parentElement !== null) {
diff --git a/src/model/resource/BuildingPermit.ts b/src/model/resource/BuildingPermit.ts
index 9ef6cba..2ed0bd4 100644
--- a/src/model/resource/BuildingPermit.ts
+++ b/src/model/resource/BuildingPermit.ts
@@ -9,7 +9,7 @@ class BuildingPermit extends Research {
public isUnlocked (state: GameState): boolean {
if (this._isUnlocked) return true;
- const compounds: IResource = state.getResource('cmpnd');
+ const compounds = state.getResource('cmpnd');
if (compounds.value > 0) {
this._isUnlocked = true;
}
diff --git a/src/model/resource/Church.ts b/src/model/resource/Church.ts
index 48dcddc..f95d217 100644
--- a/src/model/resource/Church.ts
+++ b/src/model/resource/Church.ts
@@ -13,7 +13,7 @@ class Church extends Infrastructure {
public isUnlocked (state: GameState): boolean {
if (this._isUnlocked) return true;
- const compounds: IResource = state.getResource('cmpnd');
+ const compounds = state.getResource('cmpnd');
if (compounds.value > 0) {
this._isUnlocked = true;
}
diff --git a/src/model/resource/Compound.ts b/src/model/resource/Compound.ts
index 113b133..14025d9 100644
--- a/src/model/resource/Compound.ts
+++ b/src/model/resource/Compound.ts
@@ -10,7 +10,7 @@ class Compound extends Infrastructure {
public isUnlocked (state: GameState): boolean {
if (this._isUnlocked) return true;
- const tents: IResource = state.getResource('tents');
+ const tents = state.getResource('tents');
if (tents.value >= 5) {
this._isUnlocked = true;
}
diff --git a/src/model/resource/House.ts b/src/model/resource/House.ts
index 8e92233..48618d4 100644
--- a/src/model/resource/House.ts
+++ b/src/model/resource/House.ts
@@ -14,7 +14,7 @@ class House extends Infrastructure {
public isUnlocked (state: GameState): boolean {
if (this._isUnlocked) return true;
- const compounds: IResource = state.getResource('cmpnd');
+ const compounds = state.getResource('cmpnd');
if (compounds.value > 0) {
this._isUnlocked = true;
}
diff --git a/src/model/resource/Infrastructure.ts b/src/model/resource/Infrastructure.ts
index 7fb19ff..1ec1e88 100644
--- a/src/model/resource/Infrastructure.ts
+++ b/src/model/resource/Infrastructure.ts
@@ -1,5 +1,5 @@
///
abstract class Infrastructure extends Purchasable {
- public readonly resourceType: ResourceType = ResourceType.infrastructure;
+ public readonly resourceType = ResourceType.infrastructure;
}
diff --git a/src/model/resource/Job.ts b/src/model/resource/Job.ts
index 2144060..206d30f 100644
--- a/src/model/resource/Job.ts
+++ b/src/model/resource/Job.ts
@@ -1,10 +1,10 @@
///
abstract class Job implements IResource {
- public readonly resourceType: ResourceType = ResourceType.job;
- public readonly valueInWholeNumbers: boolean = true;
- public readonly clickText: string = 'Hire';
- public readonly clickDescription: string = 'Promote one of your followers.';
+ public readonly resourceType = ResourceType.job;
+ public readonly valueInWholeNumbers = true;
+ public readonly clickText = 'Hire';
+ public readonly clickDescription = 'Promote one of your followers.';
public value = 0;
public readonly cost: { [key: string]: number } = { };
@@ -49,15 +49,15 @@ abstract class Job implements IResource {
protected _availableJobs (state: GameState): number {
// number of followers minus the number of filled jobs
- const followers: number = state.getResource('plorg').value;
- const hired: number = state.getResources().reduce(
+ const followers = state.getResource('plorg').value;
+ const hired = state.getResources().reduce(
(tot: number, rkey: string): number => {
- const res: IResource = state.getResource(rkey);
+ const res = state.getResource(rkey);
return res.resourceType === ResourceType.job
? tot + res.value
: tot;
}, 0);
- let max: number = followers - hired;
+ let max = followers - hired;
if (max < 0) max = 0;
return max;
}
diff --git a/src/model/resource/MegaChurch.ts b/src/model/resource/MegaChurch.ts
index 498e819..11f6d0f 100644
--- a/src/model/resource/MegaChurch.ts
+++ b/src/model/resource/MegaChurch.ts
@@ -13,7 +13,7 @@ class MegaChurch extends Infrastructure {
public isUnlocked (state: GameState): boolean {
if (this._isUnlocked) return true;
- const permit: IResource = state.getResource('blpmt');
+ const permit = state.getResource('blpmt');
if (permit.value > 0) {
this._isUnlocked = true;
}
diff --git a/src/model/resource/Money.ts b/src/model/resource/Money.ts
index 71b4840..80c4950 100644
--- a/src/model/resource/Money.ts
+++ b/src/model/resource/Money.ts
@@ -1,7 +1,7 @@
///
class Money extends Purchasable {
- public readonly resourceType: ResourceType = ResourceType.consumable;
+ public readonly resourceType = ResourceType.consumable;
private _lastCollectionTime = 0;
@@ -16,7 +16,7 @@ class Money extends Purchasable {
}
public max: (state: GameState) => number = (state: GameState) => {
- let max: number = state.config.cfgStartingMoneyMax;
+ let max = state.config.cfgStartingMoneyMax;
max += state.getResource('cmpnd').value * 500000;
return max;
};
@@ -32,24 +32,24 @@ class Money extends Purchasable {
};
protected _purchaseAmount (state: GameState): number {
- const plorg: IResource = state.getResource('plorg');
+ const plorg = state.getResource('plorg');
if (plorg.value === 0) {
state.log('You have no followers to collect from!');
return 0;
}
- const diff: number = state.now - this._lastCollectionTime;
+ const diff = state.now - this._lastCollectionTime;
if (diff < state.config.cfgTimeBetweenTithes) {
- const lost: number = state.config.cfgTimeBetweenTithes / diff / 3;
+ const lost = state.config.cfgTimeBetweenTithes / diff / 3;
state.getResource('creds').addValue(lost * -1, state);
}
// each follower gives you $10
- const tithings: number = plorg.value * state.config.cfgTitheAmount;
+ const tithings = plorg.value * state.config.cfgTitheAmount;
this._lastCollectionTime = state.now;
return tithings;
}
protected _purchaseLog (amount: number, state: GameState): string {
- const followers: number = state.getResource('plorg').value;
+ const followers = state.getResource('plorg').value;
return `You collected $${state.formatNumber(amount)} from ${state.formatNumber(followers)} followers.`;
}
}
diff --git a/src/model/resource/Passive.ts b/src/model/resource/Passive.ts
index 0f6c376..5d1809d 100644
--- a/src/model/resource/Passive.ts
+++ b/src/model/resource/Passive.ts
@@ -1,18 +1,19 @@
///
abstract class Passive implements IResource {
- public readonly resourceType: ResourceType = ResourceType.passive;
- public readonly valueInWholeNumbers: boolean = false;
- public readonly clickText: null = null;
- public readonly clickDescription: null = null;
+ public readonly resourceType = ResourceType.passive;
+ public readonly valueInWholeNumbers = false;
+ public readonly clickText = null;
+ public readonly clickDescription = null;
public value = 0;
- public readonly cost: null = null;
+ public readonly cost = null;
- public readonly clickAction: null = null;
+ public readonly clickAction = null;
public max: ((state: GameState) => number) | null = null;
public inc: ((state: GameState) => number) | null = null;
- public advanceAction: ((time: number, state: GameState) => void) | null = null;
+ public advanceAction: (
+ (time: number, state: GameState) => void) | null = null;
constructor (
public readonly name: string,
diff --git a/src/model/resource/Pastor.ts b/src/model/resource/Pastor.ts
index 8a56e80..1e243c0 100644
--- a/src/model/resource/Pastor.ts
+++ b/src/model/resource/Pastor.ts
@@ -9,7 +9,7 @@ class Pastor extends Job {
}
public max: (state: GameState) => number = (state) => {
- let max: number = state.getResource('chrch').value * 2;
+ let max = state.getResource('chrch').value * 2;
max += state.getResource('mchch').value * 5;
return max;
};
@@ -23,13 +23,13 @@ class Pastor extends Job {
public advanceAction (time: number, state: GameState): void {
this._timeSinceLastTithe += time;
if (this._timeSinceLastTithe >= state.config.cfgTimeBetweenTithes) {
- const money: IResource = state.getResource('money');
- const plorg: IResource = state.getResource('plorg');
+ const money = state.getResource('money');
+ const plorg = state.getResource('plorg');
// each pastor can collect from up to 100 followers
- let tithed: number = this.value * 100;
+ let tithed = this.value * 100;
if (Math.floor(plorg.value) < tithed)
tithed = Math.floor(plorg.value);
- let collected: number = tithed * state.config.cfgTitheAmount;
+ let collected = tithed * state.config.cfgTitheAmount;
if (money.max !== null && collected > money.max(state) - money.value)
collected = money.max(state) - money.value;
if (collected > 0) {
diff --git a/src/model/resource/PlayerOrg.ts b/src/model/resource/PlayerOrg.ts
index ed4f3a3..8b130c0 100644
--- a/src/model/resource/PlayerOrg.ts
+++ b/src/model/resource/PlayerOrg.ts
@@ -1,14 +1,14 @@
///
class PlayerOrg implements IResource {
- public readonly resourceType: ResourceType = ResourceType.religion;
- public readonly name: string = 'Player';
- public readonly description: string = 'In you they trust.';
- public readonly valueInWholeNumbers: boolean = true;
- public readonly clickText: string = 'Recruit';
- public readonly clickDescription: string = 'Gather new followers.';
+ public readonly resourceType = ResourceType.religion;
+ public readonly name = 'Player';
+ public readonly description = 'In you they trust.';
+ public readonly valueInWholeNumbers = true;
+ public readonly clickText = 'Recruit';
+ public readonly clickDescription = 'Gather new followers.';
public value = 0;
- public readonly cost: null = null;
+ public readonly cost = null;
private _timeSinceLastLost = 0;
private _lastRecruitmentLog = 0;
@@ -16,7 +16,7 @@ class PlayerOrg implements IResource {
private _followerDests: { [key: string]: number } = { };
public max (state: GameState): number {
- let max: number = state.config.cfgStartingPlayerMax;
+ let max = state.config.cfgStartingPlayerMax;
max += state.getResource('tents').value * 2;
max += state.getResource('house').value * 10;
return max;
@@ -44,9 +44,9 @@ class PlayerOrg implements IResource {
}
// chance to fail increases as credibility decreases
- const creds: IResource = state.getResource('creds');
+ const creds = state.getResource('creds');
if (creds.max !== null) {
- const ratio: number = Math.ceil(creds.value) / creds.max(state);
+ const ratio = Math.ceil(creds.value) / creds.max(state);
if (Math.random() > ratio) {
state.log('Your recruitment efforts failed.');
return;
@@ -75,9 +75,9 @@ class PlayerOrg implements IResource {
} else {
// lost followers must return to other faiths
for (let i = 0; i < diff * -1; i++) {
- const dest: [string, IResource] = this._getRandomReligion(state);
+ const dest = this._getRandomReligion(state);
dest[1].addValue(1, state);
- const curFollowers: number = this._followerDests[dest[0]];
+ const curFollowers = this._followerDests[dest[0]];
this._followerDests[dest[0]] = !isNaN(curFollowers)
? curFollowers + 1
: 1;
@@ -96,9 +96,9 @@ class PlayerOrg implements IResource {
if (this.value > 0) {
const creds = state.getResource('creds');
if (creds.max !== null) {
- const ratio: number = Math.ceil(creds.value) / creds.max(state);
+ const ratio = Math.ceil(creds.value) / creds.max(state);
if (Math.random() > ratio) {
- const lost: number = Math.ceil(this.value / 25 * (1 - ratio));
+ const lost = Math.ceil(this.value / 25 * (1 - ratio));
this.addValue(lost * -1, state);
}
}
@@ -115,7 +115,7 @@ class PlayerOrg implements IResource {
let total = 0;
for (const rkey of Object.keys(this._followerDests)) {
if (msg !== '') msg += ', ';
- const religion: IResource = state.getResource(rkey);
+ const religion = state.getResource(rkey);
msg += `${state.formatNumber(this._followerDests[rkey])} to ${religion.name}`;
total += this._followerDests[rkey];
delete this._followerDests[rkey];
@@ -127,7 +127,7 @@ class PlayerOrg implements IResource {
let total = 0;
for (const rkey of Object.keys(this._followerSources)) {
if (msg !== '') msg += ', ';
- const religion: IResource = state.getResource(rkey);
+ const religion = state.getResource(rkey);
msg +=
`${state.formatNumber(this._followerSources[rkey])} from ${religion.name}`;
total += this._followerSources[rkey];
@@ -140,9 +140,9 @@ class PlayerOrg implements IResource {
}
private _getRandomReligion (state: GameState): [string, IResource] {
- const religs: string[] = ['xtian', 'islam', 'hindu',
+ const religs = ['xtian', 'islam', 'hindu',
'buddh', 'sikhi', 'judah', 'other', 'agnos'];
- const source: string = religs[Math.floor(Math.random() * 8)];
+ const source = religs[Math.floor(Math.random() * 8)];
return [source, state.getResource(source)];
}
}
diff --git a/src/model/resource/Purchasable.ts b/src/model/resource/Purchasable.ts
index e943638..42c4229 100644
--- a/src/model/resource/Purchasable.ts
+++ b/src/model/resource/Purchasable.ts
@@ -23,7 +23,7 @@ abstract class Purchasable implements IResource {
public clickAction (state: GameState): void {
if (this.max !== null && this.value >= this.max(state)) return;
if (state.deductCost(this.cost)) {
- const amount: number = this._purchaseAmount(state);
+ const amount = this._purchaseAmount(state);
if (amount > 0) {
this.value += amount;
state.log(this._purchaseLog(amount, state));
@@ -45,15 +45,15 @@ abstract class Purchasable implements IResource {
return this._isUnlocked;
}
- public advanceAction (time: number, state: GameState): void {
+ public advanceAction (_time: number, _state: GameState): void {
return;
}
- protected _purchaseAmount (state: GameState): number {
+ protected _purchaseAmount (_state: GameState): number {
return 1;
}
- protected _purchaseLog (amount: number, state: GameState): string {
+ protected _purchaseLog (amount: number, _state: GameState): string {
return `You purchased ${amount} x ${this.name}.`;
}
}
diff --git a/src/model/resource/Religion.ts b/src/model/resource/Religion.ts
index c513955..5e10791 100644
--- a/src/model/resource/Religion.ts
+++ b/src/model/resource/Religion.ts
@@ -1,16 +1,16 @@
///
class Religion implements IResource {
- public readonly resourceType: ResourceType = ResourceType.religion;
- public readonly valueInWholeNumbers: boolean = true;
- public readonly clickText: null = null;
- public readonly clickDescription: null = null;
- public readonly cost: null = null;
+ public readonly resourceType = ResourceType.religion;
+ public readonly valueInWholeNumbers = true;
+ public readonly clickText = null;
+ public readonly clickDescription = null;
+ public readonly cost = null;
- public readonly max: null = null;
- public readonly inc: null = null;
- public readonly clickAction: null = null;
- public readonly advanceAction: null = null;
+ public readonly max = null;
+ public readonly inc = null;
+ public readonly clickAction = null;
+ public readonly advanceAction = null;
constructor (
public readonly name: string,
diff --git a/src/model/resource/Research.ts b/src/model/resource/Research.ts
index 84c86a4..8d3567f 100644
--- a/src/model/resource/Research.ts
+++ b/src/model/resource/Research.ts
@@ -1,7 +1,7 @@
///
abstract class Research extends Purchasable {
- public readonly resourceType: ResourceType = ResourceType.research;
+ public readonly resourceType = ResourceType.research;
constructor (
public readonly name: string,
@@ -13,5 +13,5 @@ abstract class Research extends Purchasable {
this.clickDescription = 'Complete this research.';
}
- public max: (_state: GameState) => number = (_state) => 1;
+ public max: (state: GameState) => number = (_state) => 1;
}
diff --git a/src/model/resource/Tent.ts b/src/model/resource/Tent.ts
index 5602c69..ca26272 100644
--- a/src/model/resource/Tent.ts
+++ b/src/model/resource/Tent.ts
@@ -10,7 +10,7 @@ class Tent extends Infrastructure {
public max: (state: GameState) => number = (state) => {
// ten extra tents per compound
- let max: number = state.config.cfgStartingTentMax;
+ let max = state.config.cfgStartingTentMax;
max += state.getResource('cmpnd').value * 10;
return max;
};