Skip to content

Commit

Permalink
fix: Update app to handle SchaleDB removal of common.json
Browse files Browse the repository at this point in the history
  • Loading branch information
OrkunKocyigit committed Oct 6, 2023
1 parent 6d57e77 commit 7ce85a7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 61 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ba-armory",
"version": "1.3.10",
"version": "1.3.11",
"type": "module",
"scripts": {
"format": "prettier --write ./src",
Expand Down
47 changes: 0 additions & 47 deletions src/app/entities/common.ts

This file was deleted.

48 changes: 48 additions & 0 deletions src/app/entities/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,63 @@
export interface Config {
links: Link[];
build: number;
Regions: Region[];
Changelog: Changelog[];
TypeEffectiveness: TypeEffectiveness;
GachaGroups: GachaGroup[];
}

export interface Changelog {
date: string;
contents: string[];
}

export interface GachaGroup {
Id: number;
ItemList: Array<number[]>;
}

export interface Region {
Name: string;
StudentMaxLevel: number;
WeaponMaxLevel: number;
BondMaxLevel: number;
EquipmentMaxLevel: number[];
CampaignMax: number;
CampaignExtra: boolean;
Events: number[];
Event701Max: number[];
ChaserMax: number;
BloodMax: number;
FindGiftMax: number;
SchoolDungeonMax: number;
FurnitureSetMax: number;
FurnitureTemplateMax: number;
CurrentGacha: CurrentGacha[];
CurrentEvents: CurrentEvent[];
CurrentRaid: CurrentRAID[];
}

export interface CurrentEvent {
event: number;
start: number;
end: number;
}

export interface CurrentGacha {
characters: number[];
start: number;
end: number;
}

export interface CurrentRAID {
type: string;
raid: number;
terrain?: string;
start: number;
end: number;
}

export interface TypeEffectiveness {
Normal: WeaponType;
Explosion: WeaponType;
Expand Down
12 changes: 3 additions & 9 deletions src/app/services/data.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { plainToClassFromExist, plainToInstance } from 'class-transformer';

import { Injectable } from '@angular/core';
import { Common } from '../entities/common';
import { Deck, ELIGMA_ID, EQUIPMENT_OFFSET, FURNITURE_OFFSET } from '../entities/deck';
import { ArmorType, BulletType, EquipmentCategory, ItemCategory, Reward, SkillType, StuffCategory, Terrain } from '../entities/enum';
import { Equipment } from '../entities/equipment';
Expand Down Expand Up @@ -33,7 +32,6 @@ export class DataService {
stages: Stage = new Stage();

config: Config;
common: Common;
localization: Localization;
i18n: I18N;

Expand Down Expand Up @@ -76,15 +74,11 @@ export class DataService {

setConfig(json: any) {
this.config = json;
}

setCommon(json: any) {
this.common = json;

const region = this.common.regions[this.region];
const region = this.config.Regions[this.region];

this.studentLevelMax = region.studentlevel_max;
this.weaponLevelMax = region.weaponlevel_max;
this.studentLevelMax = region.StudentMaxLevel;
this.weaponLevelMax = region.WeaponMaxLevel;
}

setStudents(json: any[]) {
Expand Down
5 changes: 1 addition & 4 deletions src/app/services/preload.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ export class PreloadService {

const language = this.dataService.language;
const configSource = `${environment.CDN_BASE}/data/config.min.json`;
const commonSource = `${environment.CDN_BASE}/data/common.min.json`;
const itemsSource = `${environment.CDN_BASE}/data/${language}/items.min.json`;
const equipmentsSource = `${environment.CDN_BASE}/data/${language}/equipment.min.json`;
const studentsSource = `${environment.CDN_BASE}/data/${language}/students.min.json`;
const stagesSource = `${environment.CDN_BASE}/data/stages.min.json`;
const localizationSource = `${environment.CDN_BASE}/data/${language}/localization.min.json`;
const i18nSource = `./assets/i18n/${language}.json`;

const [config, common, items, equipments, students, stages, localization, i18n] = await Promise.all([
const [config, items, equipments, students, stages, localization, i18n] = await Promise.all([
this.fetchJson(configSource),
this.fetchJson(commonSource),
this.fetchJson(itemsSource),
this.fetchJson(equipmentsSource),
this.fetchJson(studentsSource),
Expand All @@ -51,7 +49,6 @@ export class PreloadService {
]);

this.dataService.setConfig(config);
this.dataService.setCommon(common);
this.dataService.setItems(items);
this.dataService.setEquipments(equipments);
this.dataService.setStudents(students);
Expand Down

0 comments on commit 7ce85a7

Please sign in to comment.