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

57 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-08-21 17:06:51 -05:00
private _lastCollectionTime: number = 0;
2021-08-21 19:02:57 -05:00
public resourceType: ResourceType = ResourceType.Consumable;
2021-08-21 17:06:51 -05:00
public cost: { [key: string]: number } = { };
2021-08-20 17:12:32 -05:00
constructor (
public value: number,
private readonly _baseTitheAmount: number,
private readonly _baseCryptoReturnAmount: 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._baseMax = 500000;
}
public isUnlocked (state: GameState): boolean {
return true;
2021-08-20 17:12:32 -05:00
}
2021-08-21 19:02:57 -05:00
public inc (state: GameState): number {
// crypto currency
return state.getResource('crpto').value * this._baseCryptoReturnAmount;
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;
if (diff < 30000) {
const lost: number = 30000 / diff / 3;
state.getResource('creds').value -= lost;
2021-08-21 17:06:51 -05:00
}
2021-08-21 12:45:58 -05:00
// each follower gives you $10
const tithings: number = plorg.value * this._baseTitheAmount;
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
}
public max (state: GameState): number | null {
let max: number = this._baseMax;
max += state.getResource('cmpnd').value * 500000;
return max;
}
2021-08-20 17:12:32 -05:00
}