From f5ce2a4c64c73921acc15b50886630baec425847 Mon Sep 17 00:00:00 2001 From: Brad Date: Mon, 7 Apr 2025 15:29:49 -0400 Subject: [PATCH] Update CharacterController.ts --- src/armory/controllers/CharacterController.ts | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/armory/controllers/CharacterController.ts b/src/armory/controllers/CharacterController.ts index cbef2b8..cc3be3c 100644 --- a/src/armory/controllers/CharacterController.ts +++ b/src/armory/controllers/CharacterController.ts @@ -257,6 +257,31 @@ export class CharacterController { }); } + public async skills(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const charName = req.params.name; + + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } + + const charData = await this.getCharacterData(realm, charName); + if (charData === null) { + // Could not find character + return next(404); + } + + res.render("character-skills.hbs", { + title: `Armory - ${charData.name} - Skills`, + ...this.makeSharedDataObject(realm, charData), + data: { + skills: await this.getSkills(realm.name, charData.guid), + }, + }); + } + public async achievements(req: express.Request, res: express.Response, next: express.NextFunction): Promise { const realmName = req.params.realm; const charName = req.params.name; @@ -968,6 +993,25 @@ export class CharacterController { return talents; } + private async getSkills(realm: string, character: number): Promise { + const [rows] = await this.armory.getCharactersDb(realm).query({ + sql: ` + SELECT skill, value, max + FROM character_skills + WHERE guid = ? + `, + values: [character], + timeout: this.armory.config.dbQueryTimeout, + }); + + const skills: number[][] = [[], []]; + for (const row of rows as RowDataPacket[]) { + skills[0].push(row.skill, row.value, row.max); + } + + return skills; + } + private async getTalentTrees(classId: number) { const items = await this.armory.dbc .talentTab()