Fixed missing category error

This commit is contained in:
Pax1601
2024-11-08 20:42:31 +01:00
parent 4e84a97367
commit a89861128c

View File

@@ -8,7 +8,7 @@ export class UnitDatabase {
constructor() {}
load(url: string) {
load(url: string, category?: string) {
if (url !== "") {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
@@ -18,6 +18,12 @@ export class UnitDatabase {
var status = xhr.status;
if (status === 200) {
const newBlueprints = xhr.response as { [key: string]: UnitBlueprint };
for (let unit in newBlueprints) {
if (!newBlueprints[unit].category) {
if (category) newBlueprints[unit].category = category
else console.warn(`No category provided for ${unit}`)
}
}
this.blueprints = { ...this.blueprints, ...newBlueprints };
UnitDatabaseLoadedEvent.dispatch();
} else {