feat: use character data from database

This commit is contained in:
Axel Cocat 2022-01-02 18:36:16 +01:00
parent 028d0390f4
commit ac26336bc3
16 changed files with 159543 additions and 162 deletions

View file

@ -0,0 +1,27 @@
import * as fs from "fs";
const fsp = fs.promises;
import * as path from "path";
export class CharacterCustomization {
private data: { [key: number]: { [key: number]: any } };
public async loadData(): Promise<void> {
this.data = {};
const races = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11];
const genders = [0, 1];
for (const race of races) {
this.data[race] = {};
for (const gender of genders) {
const buffer = await fsp.readFile(path.join(process.cwd(), `data/meta/charactercustomization2/${race}_${gender}.json`));
const customizationData = JSON.parse(buffer.toString());
this.data[race][gender] = customizationData;
}
}
}
public getCharacterCustomizationData(race: number, gender: number): any {
return this.data[race][gender];
}
}