2022-07-12 11:42:38 +01:00
|
|
|
import fs from 'fs';
|
|
|
|
|
|
|
|
export interface ConfigFile {
|
|
|
|
shopName: string;
|
|
|
|
shopNickname: string;
|
2022-07-13 18:09:13 +01:00
|
|
|
regionName: string;
|
|
|
|
serverIp?: string;
|
2022-07-17 10:41:26 +01:00
|
|
|
gameOptions: GameOptions;
|
2022-07-17 15:14:23 +01:00
|
|
|
unix?: UnixOptions;
|
2022-07-17 15:01:48 +01:00
|
|
|
notices?: string[];
|
2022-07-18 11:08:13 +01:00
|
|
|
sentryDsn?: string;
|
2022-07-17 15:14:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface UnixOptions {
|
|
|
|
setuid: number;
|
|
|
|
setgid: number;
|
2022-07-17 10:41:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface GameOptions {
|
2022-07-21 01:18:11 +10:00
|
|
|
// If set to 1, all scratch rewards will be granted to players (including cars)
|
|
|
|
grantAllScratchRewards: number;
|
|
|
|
|
|
|
|
// If set to 1, gives the player a random colour for each of the special cars.
|
|
|
|
// If set to 2, allows the player to pick any of the colours (more cluttered)
|
|
|
|
grantBonusScratchCars: number;
|
|
|
|
|
|
|
|
// If set to 1, all gift cars (i.e. S2000, S660, etc. will be fully tuned.)
|
|
|
|
// If set to 0, they will be left at their default tune (i.e. stock, basic tune, etc.)
|
|
|
|
giftCarsFullyTuned: number,
|
|
|
|
|
2022-07-17 10:41:26 +01:00
|
|
|
// Amount of full-tunes to grant to newly registered cards
|
|
|
|
grantFullTuneTicketToNewUsers: number;
|
2022-07-12 11:42:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Config {
|
|
|
|
private static cfg: ConfigFile;
|
|
|
|
|
|
|
|
static load() {
|
|
|
|
console.log('Loading config file...');
|
|
|
|
let cfg = fs.readFileSync('./config.json', 'utf-8');
|
|
|
|
let json = JSON.parse(cfg);
|
|
|
|
this.cfg = json as ConfigFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
static getConfig(): ConfigFile {
|
2022-07-13 18:09:13 +01:00
|
|
|
if (!this.cfg)
|
|
|
|
this.load();
|
|
|
|
|
2022-07-12 11:42:38 +01:00
|
|
|
return this.cfg;
|
|
|
|
}
|
|
|
|
}
|