broke credibility hit out into its own inc value

This commit is contained in:
Rudis Muiznieks 2021-09-12 22:47:06 -05:00
parent 0b6e263cc7
commit 208e441086
3 changed files with 25 additions and 15 deletions

View File

@ -1,8 +1,8 @@
/// <reference path="./model/GameConfig.ts" /> /// <reference path="./model/GameConfig.ts" />
/// <reference path="./render/DebugRenderer.ts" /> /// <reference path="./render/DebugRenderer.ts" />
const versionMajor = 2; const versionMajor = 3;
const versionMinor = 1; const versionMinor = 0;
let globalStartTime = 0; let globalStartTime = 0;
let globalTimeout: number | null = null; let globalTimeout: number | null = null;

View File

@ -47,16 +47,19 @@ class Money extends Resource {
const tithings = const tithings =
((state.resource.pastors?.value ?? 0) * ((state.resource.pastors?.value ?? 0) *
(state.resource.followers?.value ?? 0) * (state.resource.followers?.value ?? 0) *
(state.config.cfgTitheAmount ?? 0) * (state.config.cfgTitheAmount ?? 0)) /
Credibility.ratio(state)) /
state.config.cfgTimeBetweenTithes; state.config.cfgTimeBetweenTithes;
// credibility hit
const credibility = tithings - tithings * Credibility.ratio(state);
// salaries // salaries
const compoundManagers = const compoundManagers =
(state.resource.compoundManagers?.value ?? 0) * (state.resource.compoundManagers?.value ?? 0) *
(state.config.cfgSalary.compoundManagers ?? 0); (state.config.cfgSalary.compoundManagers ?? 0);
if (tithings > 0) inc.pastors = tithings; if (tithings > 0) inc.pastors = tithings;
if (credibility > 0) inc.credibility = credibility * -1;
if (compoundManagers > 0) inc.compoundManagers = compoundManagers * -1; if (compoundManagers > 0) inc.compoundManagers = compoundManagers * -1;
return inc; return inc;

View File

@ -111,18 +111,21 @@ class DebugRenderer implements IRenderer {
if (el.className !== 'resource') el.className = 'resource'; if (el.className !== 'resource') el.className = 'resource';
const elV = el.getElementsByClassName('resource-value')[0]; const elV = el.getElementsByClassName('resource-value')[0];
const elT = el.getElementsByClassName('resource-max')[0]; const elT = el.getElementsByClassName('resource-max')[0];
const value = resource.valueInWholeNumbers const value = formatNumber(
? Math.floor(resource.value) resource.valueInWholeNumbers
: resource.value; ? Math.floor(resource.value)
: resource.value
);
const max = const max =
resource.max !== undefined ? resource.max(state) : undefined; resource.max !== undefined ? resource.max(state) : undefined;
elV.innerHTML = formatNumber(value); if (elV.innerHTML !== value) elV.innerHTML = value;
elT.innerHTML = const maxStr =
max !== undefined max !== undefined
? ` / ${formatNumber( ? ` / ${formatNumber(
resource.valueInWholeNumbers ? Math.floor(max) : max resource.valueInWholeNumbers ? Math.floor(max) : max
)}` )}`
: ''; : '';
if (elT.innerHTML !== maxStr) elT.innerHTML = maxStr;
if (resource.userActions !== undefined) { if (resource.userActions !== undefined) {
for (let i = 0; i < resource.userActions.length; i++) { for (let i = 0; i < resource.userActions.length; i++) {
const elB = document.getElementById(`resource-btn-${rkey}-${i}`); const elB = document.getElementById(`resource-btn-${rkey}-${i}`);
@ -139,17 +142,21 @@ class DebugRenderer implements IRenderer {
const inc = resourceNumberSum(resInc); const inc = resourceNumberSum(resInc);
const elI = el.getElementsByClassName('resource-inc')[0]; const elI = el.getElementsByClassName('resource-inc')[0];
if (inc !== 0) { if (inc !== 0) {
elI.innerHTML = ` ${inc > 0 ? '+' : ''}${formatNumber(inc)}/s`; const incStr = ` ${inc > 0 ? '+' : ''}${formatNumber(inc)}/s`;
elI.setAttribute('title', this._getIncDetails(resource, state)); if (elI.innerHTML !== incStr) {
elI.innerHTML = incStr;
elI.setAttribute('title', this._getIncDetails(resource, state));
}
} else if (elI.innerHTML !== '') { } else if (elI.innerHTML !== '') {
elI.innerHTML = ''; elI.innerHTML = '';
elI.removeAttribute('title'); elI.removeAttribute('title');
} }
} }
if (this._handleClick) { const elC = el.getElementsByClassName('resource-cost');
const elC = el.getElementsByClassName('resource-cost'); if (elC.length > 0) {
if (elC.length > 0) { const costStr = this._getCostStr(resource, state);
elC[0].innerHTML = this._getCostStr(resource, state); if (elC[0].innerHTML !== costStr) {
elC[0].innerHTML = costStr;
} }
} }
} else { } else {