From bb6d86ebbdf6bb6c804a99a001cdf22d8a0c882e Mon Sep 17 00:00:00 2001 From: Holly Date: Sun, 27 Nov 2022 15:59:43 +0000 Subject: [PATCH] MatchScoreData type --- server/interfaces/MatchScoreData.ts | 19 +++++++++++++++++++ server/interfaces/PlayerScore.ts | 3 ++- server/objects/Match.ts | 12 ++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 server/interfaces/MatchScoreData.ts diff --git a/server/interfaces/MatchScoreData.ts b/server/interfaces/MatchScoreData.ts new file mode 100644 index 0000000..d79787d --- /dev/null +++ b/server/interfaces/MatchScoreData.ts @@ -0,0 +1,19 @@ +export interface MatchScoreData { + time:number, + id:number, + count300:number, + count100:number, + count50:number, + countGeki:number, + countKatu:number, + countMiss:number, + totalScore:number, + maxCombo:number, + currentCombo:number, + perfect:boolean, + currentHp:number, + tagByte:number, + usingScoreV2:boolean, + comboPortion:number, + bonusPortion:number +} \ No newline at end of file diff --git a/server/interfaces/PlayerScore.ts b/server/interfaces/PlayerScore.ts index 1417702..b9d64d6 100644 --- a/server/interfaces/PlayerScore.ts +++ b/server/interfaces/PlayerScore.ts @@ -1,5 +1,6 @@ import { Slot } from "../objects/Slot"; import { User } from "../objects/User"; +import { MatchScoreData } from "./MatchScoreData"; export interface PlayerScore { player:User, @@ -7,5 +8,5 @@ export interface PlayerScore { score:number, isCurrentlyFailed:boolean, hasFailed:boolean, - _raw:any + _raw?:MatchScoreData } \ No newline at end of file diff --git a/server/objects/Match.ts b/server/objects/Match.ts index 655dceb..f72eafa 100644 --- a/server/objects/Match.ts +++ b/server/objects/Match.ts @@ -10,6 +10,7 @@ import { Team } from "../enums/Team"; import { MatchStartSkipData } from "../interfaces/MatchStartSkipData"; import { Mods } from "../enums/Mods"; import { PlayerScore } from "../interfaces/PlayerScore"; +import { MatchScoreData } from "../interfaces/MatchScoreData"; const osu = require("osu-packet"); @@ -512,7 +513,7 @@ export class Match { score: 0, isCurrentlyFailed: false, hasFailed: false, - _raw: {} + _raw: undefined, }); } } @@ -586,7 +587,7 @@ export class Match { } for (let _playerScore of this.playerScores) { - if (_playerScore.player?.id === slot.player?.id) { + if (_playerScore.player?.id === slot.player?.id && _playerScore._raw !== undefined) { const score = _playerScore._raw; queryData.push(`${slot.player?.id}|${score.totalScore}|${score.maxCombo}|${score.count300}|${score.count100}|${score.count50}|${score.countGeki}|${score.countKatu}|${score.countMiss}|${(score.currentHp == 254) ? 1 : 0}${(this.specialModes === 1) ? `|${slot.mods}` : ""}|${score.usingScoreV2 ? 1 : 0}${score.usingScoreV2 ? `|${score.comboPortion}|${score.bonusPortion}` : ""}`); break; @@ -613,15 +614,14 @@ export class Match { this.playerScores = undefined; } - // TODO: Interface type for matchScoreData - updatePlayerScore(user:User, matchScoreData:any) { + updatePlayerScore(user:User, matchScoreData:MatchScoreData) { const osuPacketWriter = new osu.Bancho.Writer; - if (user.matchSlot === undefined || this.playerScores === undefined) { + if (user.matchSlot === undefined || user.matchSlot.player === undefined || this.playerScores === undefined) { return; } - matchScoreData.id = user.matchSlot; + matchScoreData.id = user.matchSlot.player.id; // Update playerScores for (let playerScore of this.playerScores) {