more work on resources

This commit is contained in:
Rudis Muiznieks 2021-08-20 17:12:32 -05:00
parent 9aa7a3b3a9
commit 88bc020f1a
6 changed files with 54 additions and 9 deletions

View File

@ -1,5 +1,6 @@
/// <reference path="./GameState.ts" />
/// <reference path="./IResource.ts" />
/// <reference path="./resource/Money.ts" />
/// <reference path="./resource/PlayerOrganization.ts" />
/// <reference path="./resource/Religion.ts" />
class GameConfig {
@ -18,6 +19,9 @@ class GameConfig {
public generateState(): GameState {
const state = new GameState();
// create player organization
state.addResource('plorg', new PlayerOrganization());
// create world religions
state.addResource('xtian', new Religion(
'Christianity', 'God, Jesus, Bible, churches.',
@ -51,6 +55,9 @@ class GameConfig {
'Non-Religious', 'Atheists and agnostics.',
this.relNoneShare * this.worldPopulation));
// add crafting resources
state.addResource('money', new Money(0, 1000));
return state;
}
}

View File

@ -1,12 +1,14 @@
enum ResourceType {
Religion
Religion,
Consumable
}
interface IResource {
name: string,
description: string,
resourceType: ResourceType,
value: number,
max?: number,
unlocked: boolean
name: string;
description: string;
resourceType: ResourceType;
value: number;
max?: number;
unlocked: boolean;
}

View File

@ -0,0 +1,14 @@
/// <reference path="../IResource.ts" />
class Consumable implements IResource {
public readonly resourceType = ResourceType.Consumable;
constructor (
public readonly name: string,
public readonly description: string,
public value: number,
public unlocked: boolean,
public max?: number,
) {
}
}

View File

@ -0,0 +1,11 @@
/// <reference path="./Consumable.ts" />
class Money extends Consumable {
constructor (
public value: number,
public max: number
) {
super('Money', 'Used to purchase goods and services.',
value, true, max);
}
}

View File

@ -0,0 +1,11 @@
/// <reference path="../IResource.ts" />
class PlayerOrganization implements IResource {
public readonly name = 'Player';
public readonly description = 'In you they trust.';
public readonly resourceType = ResourceType.Religion;
public readonly max?: number = null;
public readonly unlocked = true;
public value = 0;
}

View File

@ -8,7 +8,7 @@ class Religion implements IResource {
constructor (
public readonly name: string,
public readonly description: string,
public readonly value: number,
public value: number,
) {
}
}