diff --git a/src/util/Banner.ts b/src/util/Banner.ts index 0cc9e99..98a1b14 100644 --- a/src/util/Banner.ts +++ b/src/util/Banner.ts @@ -1,6 +1,7 @@ import fs from 'fs'; -import { resolve } from 'path'; +import {resolve} from 'path'; import Logger from './Logger'; + const c = new Logger("Banner"); type Banner = { @@ -18,15 +19,21 @@ function r(...args: string[]) { export default class Banners { public static config: Banner[]; - public static init(){ + public static init() { Banners.readConfig(); } - private static readConfig(){ + private static readConfig() { let config: Banner[]; - const defaultConfig: Banner[] = [ - { - gachaId: 1001, + + const defaultConfig: Banner[] = []; + + // TODO: figure where is GachaBasicInfoConfigExcelTable. Temporary hardcode + const bannersID = [1001, 2001, 2002, 3001, 3002, 4001] + + for (let i = 0; i < bannersID.length; i++) { + defaultConfig.push({ + gachaId: bannersID[i], detailWebview: "", rateUpItems4: [ 1001, 1103 @@ -35,13 +42,13 @@ export default class Banners { 1102 ], costItemId: 101 // Star Rail Pass - } as Banner - ]; + } as Banner) + } try { config = JSON.parse(fs.readFileSync(r('../../banners.json')).toString()); - - for(const [index, gachaBanner] of Object.entries(config)){ + + for (const [index, gachaBanner] of Object.entries(config)) { const missing = Object.keys(defaultConfig[0]).filter(key => !gachaBanner.hasOwnProperty(key)); if (missing.length > 0) { c.log(`Missing ${missing.join(', ')}, using default values.`); @@ -54,7 +61,7 @@ export default class Banners { Banners.updateConfig(defaultConfig); } } - + private static updateConfig(config: Banner[]) { this.config = config; fs.writeFileSync(r('../../banners.json'), JSON.stringify(config, null, 2));