Update CharacterController.ts

This commit is contained in:
Brad 2025-04-07 15:29:49 -04:00 committed by GitHub
parent f7985f84c6
commit f5ce2a4c64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -257,6 +257,31 @@ export class CharacterController {
});
}
public async skills(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
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<void> {
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<number[][]> {
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()