add skills page

This commit is contained in:
smthbh 2025-04-17 15:22:22 -04:00
parent e7db6ed004
commit 0cdb71885c
4 changed files with 216 additions and 235 deletions

View file

@ -4,7 +4,7 @@ import { RowDataPacket } from "mysql2/promise";
import { Armory } from "../Armory";
import { IRealmConfig } from "../Config";
import { IEmblem, Utils } from "../Utils";
import { IAchievement as IAchievementDbc } from "../data/DbcReader";
import { IAchievement as IAchievementDbc, ISkillDbc } from "../data/DbcReader";
interface ICharacterData {
guid: number;
@ -72,6 +72,13 @@ interface IArenaTeam {
emblem?: IEmblem;
}
interface ISkills {
id: number;
skill: string;
value: number;
max: number ;
}
const ItemClassGem = 3;
const SpellMechanicMounted = 21;
const RaceDisplayName = {
@ -108,6 +115,7 @@ export class CharacterController {
private itemSocketBonuses: { [key: number]: number };
private mountSpells: number[];
private mountBySpellId: { [key: number]: IMount };
private skillById: { [key: number]: ISkillDbc };
private achievementById: { [key: number]: IAchievementDbc };
public constructor(armory: Armory) {
@ -180,6 +188,11 @@ export class CharacterController {
for await (const achievement of this.armory.dbc.achievement()) {
this.achievementById[achievement.id] = achievement;
}
this.skillById = {};
for await (const skill of this.armory.dbc.skill()) {
this.skillById[skill.id] = skill;
}
}
public async character(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
@ -993,7 +1006,7 @@ export class CharacterController {
return talents;
}
private async getSkills(realm: string, character: number): Promise<number[][]> {
private async getSkills(realm: string, character: number): Promise<ISkills[]> {
const [rows] = await this.armory.getCharactersDb(realm).query({
sql: `
SELECT skill, value, max
@ -1004,9 +1017,14 @@ export class CharacterController {
timeout: this.armory.config.dbQueryTimeout,
});
const skills: number[][] = [[], []];
const skills: { id: number, skill: string; value: number; max: number }[] = [];
for (const row of rows as RowDataPacket[]) {
skills[0].push(row.skill, row.value, row.max);
skills.push({
id: row.skill,
skill: this.skillById[row.skill].name,
value: row.value,
max: row.max,
});
}
return skills;

View file

@ -65,6 +65,16 @@ export interface IMountXDisplayDbc {
mountId: number;
}
export interface ISkillDbc {
id: number;
categoryId: number;
skillCostId: number;
name: string;
spellIcon: number;
altVerb: string;
canLink: number;
}
export interface ISpellDbc {
id: number;
mechanic: number;
@ -313,6 +323,7 @@ export const DbcFiles = {
itemDisplayInfo: path.join(dir, "ItemDisplayInfo_3.3.5_12340.csv"),
mount: path.join(dir, "Mount_9.2.0_41462.csv"),
mountDisplay: path.join(dir, "MountXDisplay_9.2.0_41462.csv"),
skill: path.join(dir, "Skills.csv"),
spell: path.join(dir, "Spell_3.3.5_12340.csv"),
spellItemEnchantment: path.join(dir, "SpellItemEnchantment_3.3.5_12340.csv"),
spellIcon: path.join(dir, "SpellIcon_3.3.5_12340.csv"),
@ -331,6 +342,7 @@ const dbcFields = {
itemDisplayInfo: ["id", "inventoryIcon0"],
mount: ["id", "sourceSpellId"],
mountDisplay: ["id", "creatureDisplayInfoId", "mountId"],
skill: ["id", "name"],
spell: ["id", "mechanic", "spellIconId"],
spellItemEnchantment: ["id", "srcItemId"],
spellIcon: ["id", "textureFilename"],
@ -361,6 +373,7 @@ export class DbcManager {
private _itemDisplayInfo: IItemDisplayInfoDbc[];
private _mount: IMountDbc[];
private _mountDisplay: IMountXDisplayDbc[];
private _skill: ISkillDbc[];
private _spell: ISpellDbc[];
private _spellItemEnchantment: ISpellItemEnchantmentDbc[];
private _spellIcon: ISpellIcon[];
@ -384,6 +397,7 @@ export class DbcManager {
this._itemDisplayInfo = await this.read<IItemDisplayInfoDbc>(DbcFiles.itemDisplayInfo, dbcFields.itemDisplayInfo).toArray();
this._mount = await this.read<IMountDbc>(DbcFiles.mount, dbcFields.mount).toArray();
this._mountDisplay = await this.read<IMountXDisplayDbc>(DbcFiles.mountDisplay, dbcFields.mountDisplay).toArray();
this._skill = await this.read<ISkillDbc>(DbcFiles.skill).toArray();
this._spell = await this.read<ISpellDbc>(DbcFiles.spell, dbcFields.spell).toArray();
this._spellItemEnchantment = await this.read<ISpellItemEnchantmentDbc>(
DbcFiles.spellItemEnchantment,
@ -434,6 +448,10 @@ export class DbcManager {
return this.getLoadedDataOrRead(DbcFiles.mountDisplay, this._mountDisplay, dbcFields.mountDisplay);
}
public skill() {
return this.getLoadedDataOrRead(DbcFiles.skill, this._skill, dbcFields.skill);
}
public spell() {
return this.getLoadedDataOrRead(DbcFiles.spell, this._spell, dbcFields.spell);
}