more work on resources
This commit is contained in:
parent
9aa7a3b3a9
commit
88bc020f1a
|
@ -1,5 +1,6 @@
|
||||||
/// <reference path="./GameState.ts" />
|
/// <reference path="./GameState.ts" />
|
||||||
/// <reference path="./IResource.ts" />
|
/// <reference path="./resource/Money.ts" />
|
||||||
|
/// <reference path="./resource/PlayerOrganization.ts" />
|
||||||
/// <reference path="./resource/Religion.ts" />
|
/// <reference path="./resource/Religion.ts" />
|
||||||
|
|
||||||
class GameConfig {
|
class GameConfig {
|
||||||
|
@ -18,6 +19,9 @@ class GameConfig {
|
||||||
public generateState(): GameState {
|
public generateState(): GameState {
|
||||||
const state = new GameState();
|
const state = new GameState();
|
||||||
|
|
||||||
|
// create player organization
|
||||||
|
state.addResource('plorg', new PlayerOrganization());
|
||||||
|
|
||||||
// create world religions
|
// create world religions
|
||||||
state.addResource('xtian', new Religion(
|
state.addResource('xtian', new Religion(
|
||||||
'Christianity', 'God, Jesus, Bible, churches.',
|
'Christianity', 'God, Jesus, Bible, churches.',
|
||||||
|
@ -51,6 +55,9 @@ class GameConfig {
|
||||||
'Non-Religious', 'Atheists and agnostics.',
|
'Non-Religious', 'Atheists and agnostics.',
|
||||||
this.relNoneShare * this.worldPopulation));
|
this.relNoneShare * this.worldPopulation));
|
||||||
|
|
||||||
|
// add crafting resources
|
||||||
|
state.addResource('money', new Money(0, 1000));
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
enum ResourceType {
|
enum ResourceType {
|
||||||
Religion
|
Religion,
|
||||||
|
Consumable
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IResource {
|
interface IResource {
|
||||||
name: string,
|
name: string;
|
||||||
description: string,
|
description: string;
|
||||||
resourceType: ResourceType,
|
|
||||||
value: number,
|
resourceType: ResourceType;
|
||||||
max?: number,
|
value: number;
|
||||||
unlocked: boolean
|
max?: number;
|
||||||
|
unlocked: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ class Religion implements IResource {
|
||||||
constructor (
|
constructor (
|
||||||
public readonly name: string,
|
public readonly name: string,
|
||||||
public readonly description: string,
|
public readonly description: string,
|
||||||
public readonly value: number,
|
public value: number,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue