-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathscore-json.ts
More file actions
134 lines (114 loc) · 3.39 KB
/
score-json.ts
File metadata and controls
134 lines (114 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.
import BeatmapExtendedJson from './beatmap-extended-json';
import BeatmapsetJson from './beatmapset-json';
import Rank from './rank';
import { RulesetId } from './ruleset';
import ScoreModJson from './score-mod-json';
import UserJson from './user-json';
import WithBeatmapOwners from './with-beatmap-owners';
export interface ScoreCurrentUserPinJson {
is_pinned: boolean;
score_id: number;
}
export type ScoreStatisticsAttribute =
| 'combo_break'
| 'good'
| 'great'
| 'ignore_hit'
| 'ignore_miss'
| 'large_bonus'
| 'large_tick_hit'
| 'large_tick_miss'
| 'legacy_combo_increase'
| 'meh'
| 'miss'
| 'ok'
| 'perfect'
| 'slider_tail_hit'
| 'small_bonus'
| 'small_tick_hit'
| 'small_tick_miss';
interface Match {
pass: boolean;
slot: number;
team: 'blue' | 'none' | 'red';
}
interface PpWeight {
percentage: number;
pp: number;
}
interface ScoreJsonAttributesLegacyMatch {
type: 'legacy_match_score';
}
interface ScoreJsonAttributesSolo {
classic_total_score: number;
preserve: boolean;
processed: boolean;
ranked: boolean;
type: 'solo_score';
}
interface ScoreJsonAttributesMultiplayer extends ScoreJsonAttributesSolo {
playlist_item_id: number;
room_id: number;
solo_score_id: number;
}
type ScoreJsonAttributes = {
accuracy: number;
beatmap_id: number;
best_id: number | null;
build_id: number | null;
ended_at: string;
has_replay: boolean;
id: number;
is_perfect_combo: boolean;
legacy_perfect: boolean;
legacy_score_id: number | null;
legacy_total_score: number;
max_combo: number;
maximum_statistics: Partial<Record<ScoreStatisticsAttribute, number>>;
mods: ScoreModJson[];
passed: boolean;
pp: number | null;
rank: Rank;
ruleset_id: RulesetId;
started_at: string | null;
statistics: Partial<Record<ScoreStatisticsAttribute, number>>;
total_score: number;
total_score_without_mods?: number;
user_id: number;
} & (ScoreJsonAttributesLegacyMatch | ScoreJsonAttributesSolo | ScoreJsonAttributesMultiplayer);
interface ScoreMetadata {
pp_delta: number;
rank_delta: number;
}
export interface ScoreJsonDefaultIncludes {
current_user_attributes: {
pin?: ScoreCurrentUserPinJson;
};
}
export interface ScoreJsonAvailableIncludes {
beatmap: BeatmapExtendedJson;
beatmapset: BeatmapsetJson;
match: Match;
metadata: ScoreMetadata | null;
rank_country: number;
rank_global: number;
user: UserJson;
weight: PpWeight;
}
type ScoreJson = ScoreJsonAttributes & ScoreJsonDefaultIncludes & Partial<ScoreJsonAvailableIncludes>;
export default ScoreJson;
export type ScoreJsonForBeatmap = ScoreJson & Required<Pick<ScoreJson, 'user'>>;
export type ScoreJsonForShow = ScoreJson
& Required<Pick<ScoreJson, 'beatmapset' | 'rank_global' | 'user'>>
& {
beatmap: WithBeatmapOwners<BeatmapExtendedJson>;
type: 'solo_score';
};
export type ScoreJsonForUser = ScoreJson & Required<Pick<ScoreJson, 'beatmap' | 'beatmapset'>>;
export type ScoreJsonForTopPlays = ScoreJson & Required<Pick<ScoreJson, 'beatmap' | 'beatmapset' | 'user'>>;
export function isScoreJsonForUser(score: ScoreJson): score is ScoreJsonForUser {
return score.beatmap != null && score.beatmapset != null;
}
export type LegacyMatchScoreJson = ScoreJson & Required<Pick<ScoreJson, 'match'>>;