Skip to content

Commit

Permalink
Merge pull request #837 from project-primera/develop
Browse files Browse the repository at this point in the history
Release 0.18.0
  • Loading branch information
slime-hatena committed Apr 16, 2024
2 parents f8fd128 + 2f0947e commit a1ecab7
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function getIndex(int $music, string $difficulty){

$battleKeys = ["新入生", "十級", "九級", "八級", "七級", "六級", "五級", "四級", "三級", "二級", "一級", "初段", "二段", "三段", "四段", "五段", "六段", "七段", "八段", "九段", "十段", "奏伝"];

$technicalGrades = ["P", "SSS+", "SSS", "SS", "S", "AAA", "AA", "A", "B"];
$technicalGrades = ["AB+", "SSS+", "SSS", "SS", "S", "AAA", "AA", "A", "B"];

$rateKeys = [];
for ($i = 0; $i <= 17; ++$i) {
Expand Down
93 changes: 34 additions & 59 deletions OngekiScoreLog/app/Http/Controllers/ViewUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getMyUserPage($path = ""){
return redirect("/user/" . $user->id . "/" . $path);
}

public function getUserPage($id, $mode = null){
public function getUserPage(Request $request, $id, $mode = null){
$userStatus = new UserStatus();
$user = User::where('id' ,$id)->first();
$status = $userStatus->getRecentUserData($id);
Expand All @@ -52,7 +52,33 @@ public function getUserPage($id, $mode = null){
$status[0]->badge .= '&nbsp;<span class="tag net-standard">OngekiNet Standard</span>';
}

$score = (new ScoreData)->getRecentUserScore($id)->addMusicData()->addDetailedData()->getValue();
$scoreDataModel = new ScoreData();
$scoreDataModel
->getRecentUserScore($id)
->addMusicData();

// アーカイブモード判定: 表示譜面を変更する
$archive = (int)$request->get('archive');
if ($archive === 0) {
// 現行譜面 / ゼロスコアを除外
$scoreDataModel->exclusionZeroScore();
}elseif ($archive === 1) {
// 現行譜面表示
$scoreDataModel->exclusionDeletedMusic();
}elseif ($archive === 2) {
// 削除譜面のみ / ゼロスコアを除外
$score = $scoreDataModel->exclusionZeroScore()->exclusionNotDeletedMusic();
}elseif ($archive === 3) {
// 削除譜面のみ
$score = $scoreDataModel->exclusionNotDeletedMusic();
}elseif ($archive === 4) {
// すべて表示(従来モード)
// 何もしない
}else{
// 変な設定ならリダイレクトして消す
return redirect("/user/" . $id . "/" . $mode);
}
$score = $scoreDataModel->addDetailedData()->getValue();

array_multisort(array_column($score, 'updated_at'), SORT_DESC, $score);

Expand Down Expand Up @@ -107,6 +133,7 @@ public function getUserPage($id, $mode = null){
];

$stat['level'] = [
"Lv.0" => [],
"Lv.1" => [],
"Lv.2" => [],
"Lv.3" => [],
Expand All @@ -131,11 +158,9 @@ public function getUserPage($id, $mode = null){
"Lv.14+" => [],
"Lv.15" => [],
"Lv.15+" => [],
"Lv.0" => [],
];

$stat['average'] = $stat['level'];
$stat['averageExist'] = $stat['level'];

foreach ($score as $key => $value) {
// レート値を表示していいユーザーなら取得 だめなら隠す
Expand Down Expand Up @@ -311,60 +336,8 @@ public function getUserPage($id, $mode = null){
$stat['average']["All"]["total"]['score'] = 0;
}
$stat['average']["All"]["total"]['score'] += $value->technical_high_score;

// 以下プレイ済み曲のみ
if($value->technical_high_score !== 0){
// レベル平均の曲数を追加
if(!isset($stat['averageExist']["Lv." . $value->level_str][$value->difficulty_str]["count"])){
$stat['averageExist']["Lv." . $value->level_str][$value->difficulty_str]['count'] = 0;
}
$stat['averageExist']["Lv." . $value->level_str][$value->difficulty_str]['count']++;

// レベル平均のスコアを追加 表示時に割る
if(!isset($stat['averageExist']["Lv." . $value->level_str][$value->difficulty_str]["score"])){
$stat['averageExist']["Lv." . $value->level_str][$value->difficulty_str]['score'] = 0;
}
$stat['averageExist']["Lv." . $value->level_str][$value->difficulty_str]['score'] += $value->technical_high_score;

// レベル平均のトータル曲数を追加
if(!isset($stat['averageExist']["Lv." . $value->level_str]["total"]["count"])){
$stat['averageExist']["Lv." . $value->level_str]["total"]['count'] = 0;
}
$stat['averageExist']["Lv." . $value->level_str]["total"]['count']++;

// レベル平均のトータルスコアを追加 表示時に割る
if(!isset($stat['averageExist']["Lv." . $value->level_str]["total"]["score"])){
$stat['averageExist']["Lv." . $value->level_str]["total"]['score'] = 0;
}
$stat['averageExist']["Lv." . $value->level_str]["total"]['score'] += $value->technical_high_score;

// 全曲平均の難易度別曲数を追加
if(!isset($stat['averageExist']["All"][$value->difficulty_str]["count"])){
$stat['averageExist']["All"][$value->difficulty_str]['count'] = 0;
}
$stat['averageExist']["All"][$value->difficulty_str]['count']++;

// 全曲平均の難易度別スコアを追加 表示時に割る
if(!isset($stat['averageExist']["All"][$value->difficulty_str]["score"])){
$stat['averageExist']["All"][$value->difficulty_str]['score'] = 0;
}
$stat['averageExist']["All"][$value->difficulty_str]['score'] += $value->technical_high_score;

// 全曲平均のトータル曲数を追加
if(!isset($stat['averageExist']["All"]["total"]["count"])){
$stat['averageExist']["All"]["total"]['count'] = 0;
}
$stat['averageExist']["All"]["total"]['count']++;

// 全曲平均のトータルスコアを追加 表示時に割る
if(!isset($stat['averageExist']["All"]["total"]["score"])){
$stat['averageExist']["All"]["total"]['score'] = 0;
}
$stat['averageExist']["All"]["total"]['score'] += $value->technical_high_score;
}

}
return view('user', compact('id', 'status', 'score', 'stat', 'mode', 'submenuActive', 'sidemark'));
return view('user', compact('id', 'status', 'score', 'stat', 'mode', 'submenuActive', 'sidemark', 'archive'));
}

public function getOverDamegePage($id){
Expand Down Expand Up @@ -405,7 +378,7 @@ public function getOverDamegePage($id){
}

// 自分のスコアを取得
$score = (new ScoreData)->getRecentUserScore($id)->addMusicData()->getValue();
$score = (new ScoreData)->getRecentUserScore($id)->addMusicData()->exclusionDeletedMusic()->getValue();

// 難易度を通常難易度1つ+LUNATICだけに絞る
// FIXME: こんなのコード側でやっちゃいけない... けどテーブル設計的にどうしようもなく...
Expand All @@ -415,7 +388,9 @@ public function getOverDamegePage($id){
foreach ($score as $value) {
$key = $value->song_id;
if($value->difficulty === 10){
$scoreDatas[] = $value;
if($value->over_damage_high_score !== "0.00"){
$scoreDatas[] = $value;
}
}else{
$temp[$key][] = $value;
}
Expand Down
58 changes: 57 additions & 1 deletion OngekiScoreLog/app/ScoreData.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function addMusicData(){
$this->value[$key]->title = $title[$value->song_id]->title;
$this->value[$key]->genre = $title[$value->song_id]->genre;
$this->value[$key]->artist = $title[$value->song_id]->artist;
$this->value[$key]->deleted_normal = (bool)$title[$value->song_id]->deleted_normal;
$this->value[$key]->deleted_lunatic = (bool)$title[$value->song_id]->deleted_lunatic;

switch (true) {
case ($this->value[$key]->difficulty === 0):
Expand Down Expand Up @@ -136,7 +138,7 @@ function addDetailedData(){
$this->value[$key]->technical_high_score_next = 0;

}else{
$this->value[$key]->technical_high_score_rank = "P";
$this->value[$key]->technical_high_score_rank = "AB+";
$this->value[$key]->technical_high_score_next = 0;

}
Expand All @@ -145,6 +147,60 @@ function addDetailedData(){
return $this;
}

/**
* スコアがゼロの楽曲データを取り除きます。
*
* @return ScoreData
*/
function exclusionZeroScore(){
foreach ($this->value as $key => $value) {
if($value->over_damage_high_score === "0.00" && $value->battle_high_score === 0 && $value->technical_high_score === 0){
unset($this->value[$key]);
}
}
return $this;
}

/**
* 削除済みフラグが立っている楽曲データを取り除きます。
*
* @return ScoreData
*/
function exclusionDeletedMusic(){
foreach ($this->value as $key => $value) {
if ($value->difficulty === 10) {
if($value->deleted_lunatic){
unset($this->value[$key]);
}
}else{
if($value->deleted_normal){
unset($this->value[$key]);
}
}
}
return $this;
}

/**
* 削除済みフラグが立っていない楽曲データを取り除きます。
*
* @return ScoreData
*/
function exclusionNotDeletedMusic(){
foreach ($this->value as $key => $value) {
if ($value->difficulty === 10) {
if(!!!$value->deleted_lunatic){
unset($this->value[$key]);
}
}else{
if(!!!$value->deleted_normal){
unset($this->value[$key]);
}
}
}
return $this;
}

function getRecentGenerationOfScoreData($id, $songID, $difficulty){
$sql = DB::table($this->table)->select('*')
->from($this->table . ' AS t1')->where('user_id', $id)->where('song_id', $songID)->where('difficulty', $difficulty)->whereNotExists(function ($query) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddDeletedFlagInSongs extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('music_datas', function (Blueprint $table){
$table->tinyInteger('deleted_normal')->after('unrated')->unsigned()->default(0);
$table->tinyInteger('deleted_lunatic')->after('deleted_normal')->unsigned()->default(0);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('music_datas', function (Blueprint $table){
$table->dropColumn('deleted_normal');
$table->dropColumn('deleted_lunatic');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<p>
<b>表示モード</b><br>
<div style="margin-bottom: .3em">
<a href="/user/{{$id}}/{{$mode}}" class="button{{($archive === 0) ? " is-info" : ""}}">現行譜面のみ</a>
<a href="/user/{{$id}}/{{$mode}}?archive=1" class="button{{($archive === 1) ? " is-info" : ""}}">現行譜面のみ / スコア0を表示</a><br>
</div>
<div style="margin-bottom: .3em">
<a href="/user/{{$id}}/{{$mode}}?archive=2" class="button{{($archive === 2) ? " is-info" : ""}}">削除譜面のみ</a>
<a href="/user/{{$id}}/{{$mode}}?archive=3" class="button{{($archive === 3) ? " is-info" : ""}}">削除譜面のみ / スコア0を表示</a><br>
</div>
<div>
<a href="/user/{{$id}}/{{$mode}}?archive=4" class="button{{($archive === 4) ? " is-info" : ""}}">すべて表示(従来モード)</a><br>
</div>

</p>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<article class="box">
<p>集計内容は選択する表示モードの内容に準じます。</p>
<div class="accordion">
<input id="tab-aggregate-total" type="checkbox" name="tabs">
<label for="tab-aggregate-total">トータルスコア</label>
Expand Down Expand Up @@ -42,7 +43,7 @@
<thead>
<tr>
<th>&nbsp;</th>
<th>P</th>
<th>AB+</th>
<th>SSS+</th>
<th>SSS</th>
<th>SS</th>
Expand Down Expand Up @@ -71,7 +72,7 @@
{{$key}}
@endslot
@slot('p')
{{isset($value['P']) ? $value['P'] : 0}}
{{isset($value['AB+']) ? $value['AB+'] : 0}}
@endslot
@slot('ssss')
{{isset($value['SSS+']) ? $value['SSS+'] : 0}}
Expand Down Expand Up @@ -130,7 +131,7 @@
@slot('b6')
{{isset($value['不可']) ? $value['不可'] : 0}}
@endslot
@endcomponent
@endcomponent
@endforeach
</tbody>
</table>
Expand All @@ -146,7 +147,7 @@
<thead>
<tr>
<th>&nbsp;</th>
<th>P</th>
<th>AB+</th>
<th>SSS+</th>
<th>SSS</th>
<th>SS</th>
Expand Down Expand Up @@ -175,7 +176,7 @@
{{$key}}
@endslot
@slot('p')
{{isset($value['P']) ? $value['P'] : 0}}
{{isset($value['AB+']) ? $value['AB+'] : 0}}
@endslot
@slot('ssss')
{{isset($value['SSS+']) ? $value['SSS+'] : 0}}
Expand Down Expand Up @@ -234,7 +235,7 @@
@slot('b6')
{{isset($value['不可']) ? $value['不可'] : 0}}
@endslot
@endcomponent
@endcomponent
@endforeach
</tbody>
</table>
Expand Down Expand Up @@ -275,38 +276,4 @@
</div>
</div>
</div>
<div class="accordion">
<input id="tab-aggregate-average-exist" type="checkbox" name="tabs">
<label for="tab-aggregate-average-exist">レベル別平均テクニカルスコア(未プレイを除く)</label>
<div class="accordion-content">
<div class="table_wrap">
<table class="table">
<thead>
<tr>
<th>&nbsp;</th>
<th>Basic</th>
<th>Advanced</th>
<th>Expert</th>
<th>Master</th>
<th>Lunatic</th>
<th>合計</th>
</tr>
</thead>
<tbody>
@foreach ($stat['averageExist'] as $key => $value)
<tr>
<td>{{$key}}</td>
<td>{{array_key_exists("Basic", $value) ? number_format(floor($value['Basic']['score'] / $value['Basic']['count'])) : "-"}}</td>
<td>{{array_key_exists("Advanced", $value) ? number_format(floor($value['Advanced']['score'] / $value['Advanced']['count'])) : "-"}}</td>
<td>{{array_key_exists("Expert", $value) ? number_format(floor($value['Expert']['score'] / $value['Expert']['count'])) : "-"}}</td>
<td>{{array_key_exists("Master", $value) ? number_format(floor($value['Master']['score'] / $value['Master']['count'])) : "-"}}</td>
<td>{{array_key_exists("Lunatic", $value) ? number_format(floor($value['Lunatic']['score'] / $value['Lunatic']['count'])) : "-"}}</td>
<td>{{array_key_exists("total", $value) ? number_format(floor($value['total']['score'] / $value['total']['count'])) : 0}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</article>
</article>
Loading

0 comments on commit a1ecab7

Please sign in to comment.