This repository has been archived on 2022-01-16. You can view files and clone it, but cannot push or open issues or pull requests.
irreligious/src/model/resource/Money.ts

56 lines
1.7 KiB
TypeScript
Raw Normal View History

/// <reference path="./Purchasable.ts" />
2021-08-20 17:12:32 -05:00
class Money extends Purchasable {
2021-09-05 14:45:37 -05:00
public readonly resourceType: ResourceType = ResourceType.consumable;
2021-08-21 17:06:51 -05:00
2021-09-04 22:21:14 -05:00
private _lastCollectionTime = 0;
2021-08-21 17:06:51 -05:00
2021-08-20 17:12:32 -05:00
constructor (
2021-08-22 11:07:49 -05:00
public value: number
2021-08-20 17:12:32 -05:00
) {
super('Money', 'Used to purchase goods and services.');
2021-08-21 12:45:58 -05:00
this.clickText = 'Collect Tithes';
this.clickDescription = 'Voluntary contributions from followers.';
this.valueInWholeNumbers = false;
this._isUnlocked = true;
}
2021-09-05 14:45:37 -05:00
public max: (state: GameState) => number = (state: GameState) => {
let max: number = state.config.cfgStartingMoneyMax;
max += state.getResource('cmpnd').value * 500000;
return max;
2021-09-05 14:45:37 -05:00
};
2021-09-05 14:45:37 -05:00
public inc: (state: GameState) => number = (state) => {
2021-09-04 22:21:14 -05:00
let inc = 0;
2021-08-22 11:07:49 -05:00
2021-08-21 19:02:57 -05:00
// crypto currency
2021-08-22 11:07:49 -05:00
inc += state.getResource('crpto').value
* state.config.cfgCryptoReturnAmount;
return inc;
2021-09-05 14:45:37 -05:00
};
2021-08-21 19:02:57 -05:00
protected _purchaseAmount (state: GameState): number {
2021-08-21 12:45:58 -05:00
const plorg: IResource = state.getResource('plorg');
if (plorg.value === 0) {
state.log('You have no followers to collect from!');
return 0;
}
2021-08-21 19:02:57 -05:00
const diff: number = state.now - this._lastCollectionTime;
2021-08-22 11:07:49 -05:00
if (diff < state.config.cfgTimeBetweenTithes) {
const lost: number = state.config.cfgTimeBetweenTithes / diff / 3;
state.getResource('creds').addValue(lost * -1, state);
2021-08-21 17:06:51 -05:00
}
2021-08-21 12:45:58 -05:00
// each follower gives you $10
2021-08-22 11:07:49 -05:00
const tithings: number = plorg.value * state.config.cfgTitheAmount;
2021-08-21 17:06:51 -05:00
this._lastCollectionTime = state.now;
2021-08-21 12:45:58 -05:00
return tithings;
}
2021-08-21 21:06:29 -05:00
protected _purchaseLog (amount: number, state: GameState): string {
const followers: number = state.getResource('plorg').value;
2021-08-22 09:02:12 -05:00
return `You collected $${state.formatNumber(amount)} from ${state.formatNumber(followers)} followers.`;
2021-08-21 21:06:29 -05:00
}
2021-08-20 17:12:32 -05:00
}