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

38 lines
1.1 KiB
TypeScript
Raw Normal View History

/// <reference path="./Purchasable.ts" />
2021-08-20 17:12:32 -05:00
class Money extends Purchasable {
2021-08-21 17:06:51 -05:00
private _lastCollectionTime: number = 0;
public cost: { [key: string]: number } = { };
2021-08-20 17:12:32 -05:00
constructor (
public value: number,
) {
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.';
}
public isUnlocked (state: GameState): boolean {
return true;
2021-08-20 17:12:32 -05:00
}
2021-08-21 12:45:58 -05:00
protected _incrementAmount (state: GameState): number {
const plorg: IResource = state.getResource('plorg');
if (plorg.value === 0) {
state.log('You have no followers to collect from!');
return 0;
}
2021-08-21 17:06:51 -05:00
if (state.now - this._lastCollectionTime < 30000) {
this.cost.creds = 0.05;
state.deductCost(this.cost);
delete this.cost.creds;
}
2021-08-21 12:45:58 -05:00
// each follower gives you $10
const tithings: number = plorg.value * 10;
state.log(`You collected $${state.formatNumber(tithings)} from ${state.formatNumber(plorg.value)} followers.`);
2021-08-21 17:06:51 -05:00
this._lastCollectionTime = state.now;
2021-08-21 12:45:58 -05:00
return tithings;
}
2021-08-20 17:12:32 -05:00
}