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
$events = $match->events()
65
->with([
66
'game.beatmap.beatmapset',
67
-
'game.scores' => function ($query) {
68
-
$query->with('game')->default();
69
-
},
70
])->limit($limit);
71
72
if (isset($after)) {
···
83
}
84
85
$events = $events->get();
0
0
0
0
0
0
0
0
86
87
if ($reverseOrder ?? false) {
88
$events = $events->reverse();
···
64
$events = $match->events()
65
->with([
66
'game.beatmap.beatmapset',
67
+
'game.scores' => fn ($q) => $q->default(),
0
0
68
])->limit($limit);
69
70
if (isset($after)) {
···
81
}
82
83
$events = $events->get();
84
+
foreach ($events as $event) {
85
+
$game = $event->game;
86
+
if ($game !== null) {
87
+
foreach ($game->scores as $score) {
88
+
$score->setRelation('game', $game);
89
+
}
90
+
}
91
+
}
92
93
if ($reverseOrder ?? false) {
94
$events = $events->reverse();
+17
-2
app/Models/LegacyMatch/Game.php
···
98
'beatmap_id',
99
'game_id',
100
'match_id',
101
-
'match_type',
102
-
'play_mode' => $this->getRawAttribute($key),
103
104
'mode' => Beatmap::modeStr($this->play_mode),
105
'mods' => app('mods')->bitsetToIds($this->getRawAttribute($key)),
···
111
112
'end_time_json',
113
'start_time_json' => $this->getJsonTimeFast($key),
0
0
114
115
'beatmap',
116
'events',
117
'legacyMatch',
118
'scores' => $this->getRelationValue($key),
119
};
0
0
0
0
0
0
0
0
0
0
0
0
0
0
120
}
121
}
···
98
'beatmap_id',
99
'game_id',
100
'match_id',
101
+
'match_type' => $this->getRawAttribute($key),
0
102
103
'mode' => Beatmap::modeStr($this->play_mode),
104
'mods' => app('mods')->bitsetToIds($this->getRawAttribute($key)),
···
110
111
'end_time_json',
112
'start_time_json' => $this->getJsonTimeFast($key),
113
+
114
+
'play_mode' => $this->getRulesetId(),
115
116
'beatmap',
117
'events',
118
'legacyMatch',
119
'scores' => $this->getRelationValue($key),
120
};
121
+
}
122
+
123
+
private function getRulesetId(): int
124
+
{
125
+
$gameRulesetId = $this->getRawAttribute('play_mode') ?? Beatmap::MODES['osu'];
126
+
$beatmapRulesetId = $this->beatmap?->playmode;
127
+
128
+
// ruleset set at this model is incorrect when playing ruleset
129
+
// specific map with a different selected ruleset.
130
+
if ($beatmapRulesetId !== null && $beatmapRulesetId !== $gameRulesetId && $beatmapRulesetId !== Beatmap::MODES['osu']) {
131
+
return $beatmapRulesetId;
132
+
}
133
+
134
+
return $gameRulesetId;
135
}
136
}