track difficulty and characteristic for scoresaber scores
This commit is contained in:
parent
0a87877373
commit
2852e0c0ed
@ -52,8 +52,8 @@ export class ScoreService {
|
||||
}
|
||||
|
||||
const { score: scoreToken, leaderboard: leaderboardToken } = playerScore;
|
||||
const score = getScoreSaberScoreFromToken(scoreToken, leaderboardToken, scoreToken.leaderboardPlayerInfo.id);
|
||||
const leaderboard = getScoreSaberLeaderboardFromToken(leaderboardToken);
|
||||
const score = getScoreSaberScoreFromToken(scoreToken, leaderboard, scoreToken.leaderboardPlayerInfo.id);
|
||||
const playerInfo = score.playerInfo;
|
||||
|
||||
// Not ranked
|
||||
@ -124,7 +124,8 @@ export class ScoreService {
|
||||
* @param score the score to track
|
||||
* @param leaderboard the leaderboard to track
|
||||
*/
|
||||
public static async trackScoreSaberScore({ score, leaderboard }: ScoreSaberPlayerScoreToken) {
|
||||
public static async trackScoreSaberScore({ score, leaderboard: leaderboardToken }: ScoreSaberPlayerScoreToken) {
|
||||
const leaderboard = getScoreSaberLeaderboardFromToken(leaderboardToken);
|
||||
const playerId = score.leaderboardPlayerInfo.id;
|
||||
const playerName = score.leaderboardPlayerInfo.name;
|
||||
const player: PlayerDocument | null = await PlayerModel.findById(playerId);
|
||||
@ -164,6 +165,8 @@ export class ScoreService {
|
||||
playerId: playerId,
|
||||
leaderboardId: leaderboard.id,
|
||||
score: scoreToken.score,
|
||||
difficulty: leaderboard.difficulty.difficulty,
|
||||
characteristic: leaderboard.difficulty.characteristic,
|
||||
})
|
||||
) {
|
||||
console.log(
|
||||
@ -328,13 +331,13 @@ export class ScoreService {
|
||||
);
|
||||
|
||||
for (const token of leaderboardScores.playerScores) {
|
||||
const score = getScoreSaberScoreFromToken(token.score, token.leaderboard, playerId);
|
||||
if (score == undefined) {
|
||||
const leaderboard = getScoreSaberLeaderboardFromToken(token.leaderboard);
|
||||
if (leaderboard == undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const leaderboard = getScoreSaberLeaderboardFromToken(token.leaderboard);
|
||||
if (leaderboard == undefined) {
|
||||
const score = getScoreSaberScoreFromToken(token.score, leaderboard, playerId);
|
||||
if (score == undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ import { getModelForClass, modelOptions, plugin, Prop, ReturnModelType, Severity
|
||||
import Score from "../score";
|
||||
import { Modifier } from "../../../score/modifier";
|
||||
import ScoreSaberScoreToken from "../../../types/token/scoresaber/score-saber-score-token";
|
||||
import ScoreSaberLeaderboardToken from "../../../types/token/scoresaber/score-saber-leaderboard-token";
|
||||
import ScoreSaberLeaderboard from "../../../leaderboard/impl/scoresaber-leaderboard";
|
||||
import { type ScoreSaberLeaderboardPlayerInfoToken } from "../../../types/token/scoresaber/score-saber-leaderboard-player-info-token";
|
||||
import { Document } from "mongoose";
|
||||
@ -82,7 +81,7 @@ export type ScoreSaberScore = InstanceType<typeof ScoreSaberScorePublic>;
|
||||
*/
|
||||
export function getScoreSaberScoreFromToken(
|
||||
token: ScoreSaberScoreToken,
|
||||
leaderboard: ScoreSaberLeaderboardToken | ScoreSaberLeaderboard,
|
||||
leaderboard: ScoreSaberLeaderboard,
|
||||
playerId?: string
|
||||
): ScoreSaberScore {
|
||||
const modifiers: Modifier[] =
|
||||
@ -100,6 +99,8 @@ export function getScoreSaberScoreFromToken(
|
||||
return {
|
||||
playerId: playerId || token.leaderboardPlayerInfo.id,
|
||||
leaderboardId: leaderboard.id,
|
||||
difficulty: leaderboard.difficulty.difficulty,
|
||||
characteristic: leaderboard.difficulty.characteristic,
|
||||
score: token.baseScore,
|
||||
accuracy: (token.baseScore / leaderboard.maxScore) * 100,
|
||||
rank: token.rank,
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Modifier } from "../../score/modifier";
|
||||
import { AdditionalScoreData } from "../additional-score-data/additional-score-data";
|
||||
import { type Leaderboards } from "../../leaderboard";
|
||||
import { prop } from "@typegoose/typegoose";
|
||||
import { type MapDifficulty } from "@ssr/score/map-difficulty";
|
||||
import { type MapCharacteristic } from "@ssr/types/map-characteristic";
|
||||
|
||||
/**
|
||||
* The model for a score.
|
||||
@ -15,11 +16,22 @@ export default class Score {
|
||||
|
||||
/**
|
||||
* The id of the player who set the score.
|
||||
* @private
|
||||
*/
|
||||
@prop({ required: true, index: true })
|
||||
public readonly playerId!: string;
|
||||
|
||||
/**
|
||||
* The map difficulty played in the score.
|
||||
*/
|
||||
@prop({ required: true })
|
||||
public readonly difficulty!: MapDifficulty;
|
||||
|
||||
/**
|
||||
* The characteristic of the map.
|
||||
*/
|
||||
@prop({ required: true })
|
||||
public readonly characteristic!: MapCharacteristic;
|
||||
|
||||
/**
|
||||
* The base score for the score.
|
||||
* @private
|
||||
|
Reference in New Issue
Block a user