diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..0016c3d --- /dev/null +++ b/public/index.html @@ -0,0 +1,10 @@ + + + + irreligio.us + + + + + + diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..5e6e61e --- /dev/null +++ b/src/main.ts @@ -0,0 +1,20 @@ +/// + +let globalStartTime = 0; + +function gameLoop (config: GameConfig): void { + // figure out how much actual time has passed + const elapsedTime = globalStartTime > 0 + ? (new Date()).getTime() - globalStartTime : 0; + + // run again in 1sec + globalStartTime = (new Date()).getTime(); + setTimeout(() => gameLoop(config), 1000); +} + +// run with default config at startup +(() => { + const config = new GameConfig(); + if (document.readyState !== 'loading') gameLoop(config); + else document.addEventListener('DOMContentLoaded', () => gameLoop(config)); +})(); diff --git a/src/model/GameConfig.ts b/src/model/GameConfig.ts new file mode 100644 index 0000000..e5d751f --- /dev/null +++ b/src/model/GameConfig.ts @@ -0,0 +1,18 @@ +/// +/// + +class GameConfig { + public worldPopulation: number = 790000000; + + // religion configs + public relChristianityShare: number = 0.325; + public relIslamShare: number = 0.215; + public relHinduismShare: number = 0.16; + public relBuddhismShare: number = 0.06; + public relSikhismShare: number = 0.04; + public relJudaismShare: number = 0.02; + public relOtherShare:number = 0.02; + public relNoneShare: number = 0.16; + + constructor () {} +} diff --git a/src/model/IResource.ts b/src/model/IResource.ts new file mode 100644 index 0000000..fc3e6a4 --- /dev/null +++ b/src/model/IResource.ts @@ -0,0 +1,11 @@ +enum ResourceType { + Religion +} + +interface IResource { + name: string, + description: string, + resourceType: ResourceType, + value: number, + max: number +} diff --git a/src/model/Resource.ts b/src/model/Resource.ts deleted file mode 100644 index ee1474b..0000000 --- a/src/model/Resource.ts +++ /dev/null @@ -1,3 +0,0 @@ -class Resource { - public name: string; -} diff --git a/src/model/resource/Religion.ts b/src/model/resource/Religion.ts new file mode 100644 index 0000000..4f22198 --- /dev/null +++ b/src/model/resource/Religion.ts @@ -0,0 +1,20 @@ +/// +/// + +class Religion implements IResource { + public readonly description: string; + public readonly resourceType: ResourceType = ResourceType.Religion; + + public value: number; + public max: number; + + constructor ( + config: GameConfig, + public readonly name: string, + populationShare: number + ) { + this.description = name; + this.max = config.worldPopulation; + this.value = config.worldPopulation * populationShare; + } +} diff --git a/tsconfig.json b/tsconfig.json index 2507836..d0e2d28 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "ES5", - "module": "amd" + "module": "none" } }