Began refactoring Corporation implementation into separate modules (and converted to TypeScript). Rebalanced material starting prices and market properties (demand, competition, market price)

This commit is contained in:
danielyxie
2018-12-09 05:36:18 -08:00
parent 12743614a3
commit 6973dd8fca
18 changed files with 3648 additions and 3280 deletions
+44
View File
@@ -0,0 +1,44 @@
import * as numeral from 'numeral';
import 'numeral/locales/bg';
import 'numeral/locales/cs';
import 'numeral/locales/da-dk';
import 'numeral/locales/de';
import 'numeral/locales/en-au';
import 'numeral/locales/en-gb';
import 'numeral/locales/es';
import 'numeral/locales/fr';
import 'numeral/locales/hu';
import 'numeral/locales/it';
import 'numeral/locales/lv';
import 'numeral/locales/no';
import 'numeral/locales/pl';
import 'numeral/locales/ru';
/* eslint-disable class-methods-use-this */
class NumeralFormatter {
// Default Locale
defaultLocale: string = "en";
constructor() {
this.defaultLocale = 'en';
}
updateLocale(l: string): boolean {
if (numeral.locale(l) == null) {
console.warn(`Invalid locale for numeral: ${l}`);
numeral.locale(this.defaultLocale);
return false;
}
return true;
}
format(n: number, format: string): string {
// numeraljs doesnt properly format numbers that are too big or too small
if (Math.abs(n) < 1e-6) { n = 0; }
return numeral(n).format(format);
}
}
export const numeralWrapper = new NumeralFormatter();