tangled
alpha
login
or
join now
keii.dev
/
osu-web
the browser-facing portion of osu!
0
fork
atom
overview
issues
pulls
pipelines
Consider beatmap ruleset for legacy match game
nanaya
2 years ago
fd86faca
a3169873
+26
-5
2 changed files
expand all
collapse all
unified
split
app
Http
Controllers
MatchesController.php
Models
LegacyMatch
Game.php
+9
-3
app/Http/Controllers/MatchesController.php
···
64
64
$events = $match->events()
65
65
->with([
66
66
'game.beatmap.beatmapset',
67
67
-
'game.scores' => function ($query) {
68
68
-
$query->with('game')->default();
69
69
-
},
67
67
+
'game.scores' => fn ($q) => $q->default(),
70
68
])->limit($limit);
71
69
72
70
if (isset($after)) {
···
83
81
}
84
82
85
83
$events = $events->get();
84
84
+
foreach ($events as $event) {
85
85
+
$game = $event->game;
86
86
+
if ($game !== null) {
87
87
+
foreach ($game->scores as $score) {
88
88
+
$score->setRelation('game', $game);
89
89
+
}
90
90
+
}
91
91
+
}
86
92
87
93
if ($reverseOrder ?? false) {
88
94
$events = $events->reverse();
+17
-2
app/Models/LegacyMatch/Game.php
···
98
98
'beatmap_id',
99
99
'game_id',
100
100
'match_id',
101
101
-
'match_type',
102
102
-
'play_mode' => $this->getRawAttribute($key),
101
101
+
'match_type' => $this->getRawAttribute($key),
103
102
104
103
'mode' => Beatmap::modeStr($this->play_mode),
105
104
'mods' => app('mods')->bitsetToIds($this->getRawAttribute($key)),
···
111
110
112
111
'end_time_json',
113
112
'start_time_json' => $this->getJsonTimeFast($key),
113
113
+
114
114
+
'play_mode' => $this->getRulesetId(),
114
115
115
116
'beatmap',
116
117
'events',
117
118
'legacyMatch',
118
119
'scores' => $this->getRelationValue($key),
119
120
};
121
121
+
}
122
122
+
123
123
+
private function getRulesetId(): int
124
124
+
{
125
125
+
$gameRulesetId = $this->getRawAttribute('play_mode') ?? Beatmap::MODES['osu'];
126
126
+
$beatmapRulesetId = $this->beatmap?->playmode;
127
127
+
128
128
+
// ruleset set at this model is incorrect when playing ruleset
129
129
+
// specific map with a different selected ruleset.
130
130
+
if ($beatmapRulesetId !== null && $beatmapRulesetId !== $gameRulesetId && $beatmapRulesetId !== Beatmap::MODES['osu']) {
131
131
+
return $beatmapRulesetId;
132
132
+
}
133
133
+
134
134
+
return $gameRulesetId;
120
135
}
121
136
}