From d4238d446a92494807e88e84aac475210a44907d Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Sun, 22 Aug 2021 14:29:49 -0500 Subject: [PATCH] bug fixes --- src/model/resource/Pastor.ts | 3 ++- src/model/resource/PlayerOrg.ts | 22 ++++++++++++---------- src/render/DebugRenderer.ts | 3 ++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/model/resource/Pastor.ts b/src/model/resource/Pastor.ts index d009240..054635d 100644 --- a/src/model/resource/Pastor.ts +++ b/src/model/resource/Pastor.ts @@ -24,7 +24,8 @@ class Pastor extends Job { const plorg: IResource = state.getResource('plorg'); // each pastor can collect from up to 100 followers let tithed: number = this.value * 100; - if (plorg.value < tithed) tithed = plorg.value; + if (Math.floor(plorg.value) < tithed) + tithed = Math.floor(plorg.value); let collected: number = tithed * state.config.cfgTitheAmount; if (collected > money.max(state) - money.value) collected = money.max(state) - money.value; diff --git a/src/model/resource/PlayerOrg.ts b/src/model/resource/PlayerOrg.ts index 50bce33..77d57a3 100644 --- a/src/model/resource/PlayerOrg.ts +++ b/src/model/resource/PlayerOrg.ts @@ -108,28 +108,30 @@ class PlayerOrg implements IResource { && (Object.keys(this._followerSources).length > 0 || Object.keys(this._followerDests).length > 0)) { if (Object.keys(this._followerDests).length > 0) { - let msg: string; + let msg: string = ''; + let total: number = 0; for (const rkey of Object.keys(this._followerDests)) { - if (msg === undefined) msg = 'You lost '; - else msg += ' and '; + if (msg !== '') msg += ', '; const religion: IResource = state.getResource(rkey); msg += - `${state.formatNumber(this._followerDests[rkey])} followers to ${religion.name}`; + `${state.formatNumber(this._followerDests[rkey])} to ${religion.name}`; + total += this._followerDests[rkey]; delete this._followerDests[rkey]; } - state.log(msg); + state.log(`You lost ${state.formatNumber(total)} followers: ${msg}`); } if (Object.keys(this._followerSources).length > 0) { - let msg: string; + let msg: string = ''; + let total: number = 0; for (const rkey of Object.keys(this._followerSources)) { - if (msg === undefined) msg = 'You gained '; - else msg += ' and '; + if (msg !== '') msg += ', '; const religion: IResource = state.getResource(rkey); msg += - `${state.formatNumber(this._followerSources[rkey])} followers from ${religion.name}`; + `${state.formatNumber(this._followerSources[rkey])} from ${religion.name}`; + total += this._followerSources[rkey]; delete this._followerSources[rkey]; } - state.log(msg); + state.log(`You gained ${state.formatNumber(total)} followers: ${msg}`); } this._lastRecruitmentLog = state.now; } diff --git a/src/render/DebugRenderer.ts b/src/render/DebugRenderer.ts index fcdfd04..5571821 100644 --- a/src/render/DebugRenderer.ts +++ b/src/render/DebugRenderer.ts @@ -85,7 +85,8 @@ class DebugRenderer implements IRenderer { document.getElementById('dbg-btn-reset') .addEventListener('click', (): void => { state.reset(); - this._handleClick = true; + document.getElementById('irreligious-game').innerHTML = ''; + this._initialized = false; }); } for (const rkey of rkeys) {