Skip to content

Commit e0663b1

Browse files
committed
feat: LampForRatingを取得する関数をOngekiUtilityに追加、それに伴って既存使用箇所がOngekiUtilityのgetLampForRatingを参照するように変更
1 parent b624bbc commit e0663b1

File tree

3 files changed

+30
-53
lines changed

3 files changed

+30
-53
lines changed

OngekiScoreLog/app/Http/Controllers/ViewUserProgressController.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ function shapingKeys($array){
216216
if($value->battle_high_score !== 0){
217217
// not implemented → played
218218
// echo "[new] " . $value->title . " / " . $value->difficulty_str . "<br>";
219-
$newNormalRating = OngekiUtility::RateValueFromTitle($value->title, $value->difficulty, $value->technical_high_score, $value->lampForRating, $value->genre, $value->artist);
220219
$progress[$music][$difficulty]["new"] = $value;
221220
$progress[$music][$difficulty]["difference"]['battle_high_score'] = "+" . number_format($value->battle_high_score);
222221
$progress[$music][$difficulty]["difference"]['technical_high_score'] = "+" . number_format($value->technical_high_score);
@@ -304,34 +303,8 @@ function shapingKeys($array){
304303
}
305304

306305
// Rating計算はできるだけ少なくしたいので先に計算しておく。
307-
// ViewUserRatingController.php から引用。
308-
// WARNING: レーティング処理を変えたら変更元も変更する!
309306
if ($isPremium) {
310-
$oldLampForRating = "";
311-
if ($old[$music][$difficulty]->technical_high_score == 1010000){
312-
if ($old[$music][$difficulty]->full_bell == 1) {
313-
$oldLampForRating = "FB/AB+";
314-
} else {
315-
$oldLampForRating = "AB+";
316-
}
317-
} elseif ($old[$music][$difficulty]->all_break == 1) {
318-
if ($old[$music][$difficulty]->full_bell == 1) {
319-
$oldLampForRating = "FB/AB";
320-
} else {
321-
$oldLampForRating = "AB";
322-
}
323-
} elseif ($old[$music][$difficulty]->full_combo == 1) {
324-
if ($old[$music][$difficulty]->full_bell == 1) {
325-
$oldLampForRating = "FB/FC";
326-
} else {
327-
$oldLampForRating = "FC";
328-
}
329-
} else {
330-
if ($old[$music][$difficulty]->full_bell == 1) {
331-
$oldLampForRating = "FB";
332-
}
333-
}
334-
307+
$oldLampForRating = OngekiUtility::getLampForRating($old[$music][$difficulty]->technical_high_score, $old[$music][$difficulty]->full_bell == 1, $old[$music][$difficulty]->full_combo == 1, $old[$music][$difficulty]->all_break == 1);
335308
$newNormalRating = OngekiUtility::RateValueFromTitle($value->title, $value->difficulty, $value->technical_high_score, $value->lampForRating, $value->genre, $value->artist);
336309
$oldNormalRating = OngekiUtility::RateValueFromTitle($value->title, $old[$music][$difficulty]->difficulty, $old[$music][$difficulty]->technical_high_score, $oldLampForRating, $value->genre, $value->artist);
337310
$progress[$music][$difficulty]["difference"]['normal_rating'] = ($newNormalRating - $oldNormalRating) != 0 ? "+" . sprintf("%.3f",($newNormalRating - $oldNormalRating)) : "";

OngekiScoreLog/app/Http/Controllers/ViewUserRatingController.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,7 @@ private function editMusic($scores, int $totalMusicCount){
2525
for ($index = 0; $index < count($scores); $index++) {
2626
if (isset($scores[$index])) {
2727
// ランプ情報追加
28-
// WARNING: OngekiScoreLog\app\Http\Controllers\ViewUserProgressController.php にてコピペで使用している! 変更したらそっちも変更すること!
29-
$scores[$index]->lampForRating = "";
30-
if ($scores[$index]->technical_high_score == 1010000){
31-
if ($scores[$index]->full_bell == 1) {
32-
$scores[$index]->lampForRating = "FB/AB+";
33-
} else {
34-
$scores[$index]->lampForRating = "AB+";
35-
}
36-
} elseif ($scores[$index]->all_break == 1) {
37-
if ($scores[$index]->full_bell == 1) {
38-
$scores[$index]->lampForRating = "FB/AB";
39-
} else {
40-
$scores[$index]->lampForRating = "AB";
41-
}
42-
} elseif ($scores[$index]->full_combo == 1) {
43-
if ($scores[$index]->full_bell == 1) {
44-
$scores[$index]->lampForRating = "FB/FC";
45-
} else {
46-
$scores[$index]->lampForRating = "FC";
47-
}
48-
} else {
49-
if ($scores[$index]->full_bell == 1) {
50-
$scores[$index]->lampForRating = "FB";
51-
}
52-
}
28+
$scores[$index]->lampForRating = OngekiUtility::getLampForRating($scores[$index]->technical_high_score, $scores[$index]->full_bell == 1, $scores[$index]->full_combo == 1, $scores[$index]->all_break == 1);
5329

5430
// 単極レート値の取得
5531
$scores[$index]->ratingValue = sprintf("%.3f", OngekiUtility::RateValueFromTitle($scores[$index]->title, $scores[$index]->difficulty, $scores[$index]->technical_high_score, $scores[$index]->lampForRating, $scores[$index]->genre, $scores[$index]->artist));

OngekiScoreLog/app/Services/OngekiUtility.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,34 @@ public function RateValueFromTitleForPlatinum(string $title, $difficulty, int $p
235235
return $this->calcPlatinumRatingValue($this::$MusicList[$title][$difficulty], $platinuScore, $starCount);
236236
}
237237

238+
public function getLampForRating(int $technicalScore, bool $fullBell, bool $fullCombo, bool $allBreak): string
239+
{
240+
if ($technicalScore == 1010000) {
241+
if ($fullBell == 1) {
242+
return "FB/AB+";
243+
} else {
244+
return "AB+";
245+
}
246+
} elseif ($allBreak) {
247+
if ($fullBell) {
248+
return "FB/AB";
249+
} else {
250+
return "AB";
251+
}
252+
} elseif ($fullCombo) {
253+
if ($fullBell) {
254+
return "FB/FC";
255+
} else {
256+
return "FC";
257+
}
258+
} else {
259+
if ($fullBell) {
260+
return "FB";
261+
}
262+
}
263+
return "";
264+
}
265+
238266
private function calcPlatinumRatingValue(float $extraLevel, int $platinumScore, int $starCount)
239267
{
240268
if($starCount > 5){

0 commit comments

Comments
 (0)