Improve accuracy when handling client/achievement/statistic

This commit is contained in:
Dev 2024-01-04 21:28:47 +00:00
parent 40e8a8d045
commit 1249b309cf
4 changed files with 21 additions and 9 deletions

View File

@ -36,6 +36,6 @@ export class AchievementCallbacks
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public statistic(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<ICompletedAchievementsResponse>
{
return this.httpResponse.getBody(this.profileController.getCompletedAchievements(sessionID));
return this.httpResponse.getBody(this.achievementController.getAchievementStatistics(sessionID));
}
}

View File

@ -1,5 +1,6 @@
import { inject, injectable } from "tsyringe";
import { ICompletedAchievementsResponse } from "@spt-aki/models/eft/profile/ICompletedAchievementsResponse";
import { IGetAchievementsResponse } from "@spt-aki/models/eft/profile/IGetAchievementsResponse";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
@ -10,7 +11,6 @@ import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
@injectable()
export class AchievementController
{
constructor(
@inject("WinstonLogger") protected logger: ILogger,
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
@ -25,4 +25,22 @@ export class AchievementController
{
return {elements: this.databaseServer.getTables().templates.achievements };
}
/**
* Shows % of 'other' players who've completed each achievement
* @param sessionId Session id
* @returns ICompletedAchievementsResponse
*/
public getAchievementStatistics(sessionId: string): ICompletedAchievementsResponse
{
const achievements = this.databaseServer.getTables().templates.achievements;
const stats = {}
for (const achievement of achievements)
{
stats[achievement.id] = 0;
}
return {elements: stats};
}
}

View File

@ -390,13 +390,6 @@ export class ProfileController
return response;
}
public getCompletedAchievements(sessionId: string): ICompletedAchievementsResponse
{
const profile = this.profileHelper.getFullProfile(sessionId);
return {elements: profile.achievements};
}
public getOtherProfile(sessionId: string, request: IGetOtherProfileRequest): IGetOtherProfileResponse
{
const player = this.profileHelper.getFullProfile(sessionId);

View File

@ -1,4 +1,5 @@
import { IGlobals } from "@spt-aki/models/eft/common/IGlobals";
import { IAchievement } from "@spt-aki/models/eft/common/tables/IAchievement";
import { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase";
import { IBotCore } from "@spt-aki/models/eft/common/tables/IBotCore";
import { IBotType } from "@spt-aki/models/eft/common/tables/IBotType";