the browser-facing portion of osu!

Consider beatmap ruleset for legacy match game

nanaya fd86faca a3169873

+26 -5
+9 -3
app/Http/Controllers/MatchesController.php
··· 64 64 $events = $match->events() 65 65 ->with([ 66 66 'game.beatmap.beatmapset', 67 - 'game.scores' => function ($query) { 68 - $query->with('game')->default(); 69 - }, 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 + 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 + } 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 - 'match_type', 102 - 'play_mode' => $this->getRawAttribute($key), 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 + 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 + } 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; 120 135 } 121 136 }