figuring out class dependencies
This commit is contained in:
parent
8c67935390
commit
b92661e934
|
@ -0,0 +1,10 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang='en'>
|
||||||
|
<head>
|
||||||
|
<title>irreligio.us</title>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<script src='js/irreligious.js'></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,20 @@
|
||||||
|
/// <reference path="./model/GameConfig.ts" />
|
||||||
|
|
||||||
|
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));
|
||||||
|
})();
|
|
@ -0,0 +1,18 @@
|
||||||
|
/// <reference path="./IResource.ts" />
|
||||||
|
/// <reference path="./resource/Religion.ts" />
|
||||||
|
|
||||||
|
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 () {}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
enum ResourceType {
|
||||||
|
Religion
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IResource {
|
||||||
|
name: string,
|
||||||
|
description: string,
|
||||||
|
resourceType: ResourceType,
|
||||||
|
value: number,
|
||||||
|
max: number
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
class Resource {
|
|
||||||
public name: string;
|
|
||||||
}
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/// <reference path="../GameConfig.ts" />
|
||||||
|
/// <reference path="../IResource.ts" />
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,6 @@
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "ES5",
|
"target": "ES5",
|
||||||
"module": "amd"
|
"module": "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue