Skip to content

Commit

Permalink
Merge pull request #824 from project-primera/feat/overdamage
Browse files Browse the repository at this point in the history
オーバーダメージを詳細表示するユーザーページを追加
  • Loading branch information
slime-hatena committed Apr 15, 2024
2 parents aa13826 + ec1e8d3 commit 289350d
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 11 deletions.
61 changes: 61 additions & 0 deletions OngekiScoreLog/app/Http/Controllers/ViewUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,65 @@ public function getUserPage($id, $mode = null){
}
return view('user', compact('id', 'status', 'score', 'stat', 'mode', 'submenuActive', 'sidemark'));
}

public function getOverDamegePage($id){
$userStatus = new UserStatus();
$user = User::where('id' ,$id)->first();
$status = $userStatus->getRecentUserData($id);
if(count($status) === 0){
if(is_null($user)){
abort(404);
}else{
return view("user_error", ['message' => '<p>このユーザーはOngekiScoreLogに登録していますが、オンゲキNETからスコア取得を行っていません。(UserID: ' . $id . ')</p><p>スコアの取得方法は<a href="/howto">こちら</a>をお読みください。</p>']);
}
}
$status[0]->badge = "";
if($user->role == 7){
$status[0]->badge .= '&nbsp;<span class="tag developer">ProjectPrimera Developer</span>';
}
if(\App\UserInformation::IsPremiumPlan($user->id)){
$status[0]->badge .= '&nbsp;<span class="tag net-premium">OngekiNet Premium</span>';
}else if(\App\UserInformation::IsStandardPlan($user->id)){
$status[0]->badge .= '&nbsp;<span class="tag net-standard">OngekiNet Standard</span>';
}

// トップランカーのスコアを取得してkey: song_id, difficulty, value: over_damage_high_score の配列を作る
$topRankerScore = [];
{
$temp = (new ScoreData)->getTopRankerScore()->getValue();
foreach ($temp as $value) {
$key = $value->song_id . "_" . $value->difficulty;
if(!isset($topRankerScore[$key])){
$topRankerScore[$key] = $value->max_over_damage_high_score;
}
}
}

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

// 難易度を通常難易度1つ+LUNATICだけに絞る
// FIXME: こんなのコード側でやっちゃいけない... けどテーブル設計的にどうしようもなく...
$temp = [];
$scoreDatas = [];
{
foreach ($score as $value) {
$key = $value->song_id;
if($value->difficulty === 10){
$scoreDatas[] = $value;
}else{
$temp[$key][] = $value;
}
}

foreach ($temp as $value) {
array_multisort(array_column($value, 'over_damage_high_score'), SORT_DESC, $value);
if($value[0]->over_damage_high_score !== "0.00"){
$scoreDatas[] = $value[0];
}
}
}

return view('user_overdamage', compact('id', 'status', 'scoreDatas', 'topRankerScore'));
}
}
13 changes: 13 additions & 0 deletions OngekiScoreLog/app/ScoreData.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ function getRecentUserScore($id){
return $this;
}

function getTopRankerScore(){
$sql = DB::table($this->table)
->select('song_id', 'difficulty',
DB::raw('MAX(over_damage_high_score) as max_over_damage_high_score'),
DB::raw('MAX(battle_high_score) as max_battle_high_score'),
DB::raw('MAX(technical_high_score) as max_technical_high_score'),)
->from($this->table)
->groupBy('song_id', 'difficulty')
;
$this->value = $sql->get();
return $this;
}

/**
* 指定した世代のスコアデータを取得します。
*
Expand Down
4 changes: 2 additions & 2 deletions OngekiScoreLog/resources/assets/js/sortTable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var options = {
valueNames: ['sort_title', 'sort_genre', 'sort_difficulty', 'sort_lv', 'sort_lamp', 'sort_fb', 'sort_fc', 'sort_ab', 'sort_rank0', 'sort_rank1', 'sort_bs', 'sort_od', 'sort_ts', 'sort_nod', 'sort_nts', 'sort_rate', 'sort_update', 'sort_raw_battle_rank', 'sort_raw_technical_rank', 'sort_raw_lamp', 'sort_raw_difficulty']
valueNames: ['sort_title', 'sort_genre', 'sort_difficulty', 'sort_lv', 'sort_lamp', 'sort_fb', 'sort_fc', 'sort_ab', 'sort_rank0', 'sort_rank1', 'sort_bs', 'sort_od', 'sort_topod', 'sort_ts', 'sort_nod', 'sort_nts', 'sort_rate', 'sort_update', 'sort_raw_battle_rank', 'sort_raw_technical_rank', 'sort_raw_lamp', 'sort_raw_difficulty', 'sort_key1', 'sort_key2', 'sort_key3']
};
var sortTable = new List('sort_table', options);

Expand Down Expand Up @@ -163,4 +163,4 @@ $('.filter_lamp_button').on('click',function(){
SortTable();
});

SortTable();
SortTable();
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
<ul class="menu-list">
<li><a href="/mypage" class="@yield('sidemark_mypage_default')">簡易表示</a></li>
<li><a href="/mypage/details" class="@yield('sidemark_mypage_details')">詳細表示</a></li>
<li><a href="/mypage/battle" class="@yield('sidemark_mypage_battle')">Battle Score</a></li>
<li><a href="/mypage/technical" class="@yield('sidemark_mypage_technical')">Technical Score</a></li>
<li><a href="/mypage/battle" class="@yield('sidemark_mypage_battle')">Battle Score</a></li>
<li><a href="/mypage/overdamage" class="@yield('sidemark_mypage_overdamage')">Over Damage</a></li>
<li><a href="/mypage/trophy" class="@yield('sidemark_mypage_trophy')">称号</a></li>
<li><a href="/mypage/rating" class="@yield('sidemark_mypage_rating')">レーティング情報</a></li>
<li><a href="/mypage/progress" class="@yield('sidemark_mypage_progress')">更新差分</a></li>
Expand All @@ -45,4 +46,4 @@
{{ $boxBottom }}
</aside>
@endif
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<div class="box">
<p>登録されている全ユーザーのオーバーダメージのうち、一番高いものと比較することが出来ます。<br>
OD埋めなどにご活用ください。</p>
<p>プレイしている楽曲内で、一番ODが高い難易度のみ表示されます。全難易度のODが0の曲は表示されません。なお削除楽曲等も表示されます。ご了承下さい。</p>
</div>

<article class="box">
<p>
<b>表示倍率の変更</b><br>
<button class="button table_scale_change">25%</button>
<button class="button table_scale_change">50%</button>
<button class="button table_scale_change">75%</button>
<button class="button table_scale_change">100%</button>
</p>
<div id="sort_table" class="table_wrap scalable">
<table class="table">
<thead>
<tr>
<th class="sort" data-sort="sort_title">Title</th>
<th class="sort" data-sort="sort_difficulty"><abbr title="Difficulty">Dif</abbr></th>
<th class="sort" data-sort="sort_od"><abbr title="Over Damage">OD</abbr></th>
<th class="sort" data-sort="sort_key1"><abbr title="Top Ranker Score">Top</abbr></th>
<th class="sort" data-sort="sort_key2">diff</th>
<th class="sort" data-sort="sort_key3">達成度</th>
<th class="sort desc" data-sort="sort_update">Update</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="sort" data-sort="sort_title">Title</th>
<th class="sort" data-sort="sort_difficulty"><abbr title="Difficulty">Dif</abbr></th>
<th class="sort" data-sort="sort_od"><abbr title="Over Damage">OD</abbr></th>
<th class="sort" data-sort="sort_key1"><abbr title="Top Ranker Score">Top</abbr></th>
<th class="sort" data-sort="sort_key2">diff</th>
<th class="sort" data-sort="sort_key3">達成度</th>
<th class="sort desc" data-sort="sort_update">Update</th>
</tr>
</tfoot>
<tbody class="list">
@foreach ($score as $s)
<tr>
<td class="sort_title"><span class="sort-key">{{$s->title}}</span><a href="{{url("/user/" . $id . "/music/" . $s->song_id . "/" . strtolower($s->difficulty_str))}}">{{$s->title}}</a></td>
<td class="sort_difficulty"><span class="sort-key">{{$s->difficulty}}</span>{{substr($s->difficulty_str, 0, 3)}}</td>
<td class="sort_od">{{$s->over_damage_high_score . "%"}}</td>
<td class="sort_key1">{{$topRankerScore[$s->song_id . "_" . $s->difficulty] . "%"}}</td>
<td class="sort_key2">{{$s->over_damage_high_score - $topRankerScore[$s->song_id . "_" . $s->difficulty]}}%</td>
<td class="sort_key3">{{($topRankerScore[$s->song_id . "_" . $s->difficulty] != 0) ? ($s->over_damage_high_score / $topRankerScore[$s->song_id . "_" . $s->difficulty]) * 100 : 100}}%</td>
<td class="sort_update">{{date('Y-m-d', strtotime($s->updated_at))}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>

</article>
5 changes: 3 additions & 2 deletions OngekiScoreLog/resources/views/user.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@section('submenu')
<li class="{{$submenuActive[0]}}"><a href="/user/{{$id}}">簡易</a></li>
<li class="{{$submenuActive[1]}}"><a href="/user/{{$id}}/details">詳細</a></li>
<li class="{{$submenuActive[2]}}"><a href="/user/{{$id}}/battle">Battle</a></li>
<li class="{{$submenuActive[3]}}"><a href="/user/{{$id}}/technical">Technical</a></li>
<li class="{{$submenuActive[2]}}"><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/overdamage">OverDamage</a></li>
<li><a href="/user/{{$id}}/trophy">称号</a></li>
<li><a href="/user/{{$id}}/rating">Rating</a></li>
<li><a href="/user/{{$id}}/progress">更新差分</a></li>
Expand Down Expand Up @@ -70,4 +71,4 @@
@component('layouts/components/user/' . $mode, ['score' => $score, 'id' => $id])
@endcomponent

@endsection
@endsection
69 changes: 69 additions & 0 deletions OngekiScoreLog/resources/views/user_overdamage.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@extends('layouts.app')

@section('title', $status[0]->name)
@section('hero_subtitle', $status[0]->trophy)
@section('hero_title', $status[0]->name)
@section('additional_footer')
<script type="text/javascript" src="{{ mix('/js/sortTable.js') }}"></script>
<script type="text/javascript" src="{{ mix('/js/tableScalable.js') }}"></script>
@endsection
@section('sidemark_mypage_overdamage', "is-active")

@section('submenu')
<li><a href="/user/{{$id}}">簡易</a></li>
<li><a href="/user/{{$id}}/details">詳細</a></li>
<li><a href="/user/{{$id}}/technical">Technical</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li class="is-active"><a href="/user/{{$id}}/overdamage">OverDamage</a></li>
<li><a href="/user/{{$id}}/trophy">称号</a></li>
<li><a href="/user/{{$id}}/rating">Rating</a></li>
<li><a href="/user/{{$id}}/progress">更新差分</a></li>
@endsection

@section('content')
@component('layouts/components/user/user_status')
@slot('badge')
{!!$status[0]->badge!!}
@endslot
@slot('name')
{{$status[0]->name}}
@endslot
@slot('trophy')
{{$status[0]->trophy}}
@endslot
@slot('level')
{{$status[0]->level}}
@endslot
@slot('battle_point')
{{$status[0]->battle_point}}
@endslot
@slot('rating')
{{$status[0]->rating}}
@endslot
@slot('rating_max')
{{$status[0]->rating_max}}
@endslot
@slot('money')
{{$status[0]->money}}
@endslot
@slot('money_max')
{{$status[0]->total_money}}
@endslot
@slot('total_play')
{{$status[0]->total_play}}
@endslot
@slot('friend_code')
{{$status[0]->friend_code}}
@endslot
@slot('comment')
{!! nl2br(e($status[0]->comment)) !!}
@endslot
@endcomponent

{{-- @component('layouts/components/user/song_filter')
@endcomponent --}}

@component('layouts/components/user/song_status_overdamage', ['score' => $scoreDatas, 'topRankerScore' => $topRankerScore, 'id' => $id])
@endcomponent

@endsection
3 changes: 2 additions & 1 deletion OngekiScoreLog/resources/views/user_progress.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@section('submenu')
<li><a href="/user/{{$id}}">簡易</a></li>
<li><a href="/user/{{$id}}/details">詳細</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/technical">Technical</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/overdamage">OverDamage</a></li>
<li><a href="/user/{{$id}}/trophy">称号</a></li>
<li><a href="/user/{{$id}}/rating">Rating</a></li>
<li class="is-active"><a href="/user/{{$id}}/progress">更新差分</a></li>
Expand Down
3 changes: 2 additions & 1 deletion OngekiScoreLog/resources/views/user_rating.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@section('submenu')
<li><a href="/user/{{$id}}">簡易</a></li>
<li><a href="/user/{{$id}}/details">詳細</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/technical">Technical</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/overdamage">OverDamage</a></li>
<li><a href="/user/{{$id}}/trophy">称号</a></li>
<li class="is-active"><a href="/user/{{$id}}/rating">Rating</a></li>
<li><a href="/user/{{$id}}/progress">更新差分</a></li>
Expand Down
3 changes: 2 additions & 1 deletion OngekiScoreLog/resources/views/user_rating_error.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@section('submenu')
<li><a href="/user/{{$id}}">簡易</a></li>
<li><a href="/user/{{$id}}/details">詳細</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/technical">Technical</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/overdamage">OverDamage</a></li>
<li><a href="/user/{{$id}}/trophy">称号</a></li>
<li class="is-active"><a href="/user/{{$id}}/rating">Rating</a></li>
<li><a href="/user/{{$id}}/progress">更新差分</a></li>
Expand Down
5 changes: 3 additions & 2 deletions OngekiScoreLog/resources/views/user_trophy.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@section('submenu')
<li><a href="/user/{{$id}}">簡易</a></li>
<li><a href="/user/{{$id}}/details">詳細</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/technical">Technical</a></li>
<li><a href="/user/{{$id}}/battle">Battle</a></li>
<li><a href="/user/{{$id}}/overdamage">OverDamage</a></li>
<li class="is-active"><a href="/user/{{$id}}/trophy">称号</a></li>
<li><a href="/user/{{$id}}/rating">Rating</a></li>
<li><a href="/user/{{$id}}/progress">更新差分</a></li>
Expand Down Expand Up @@ -94,4 +95,4 @@
</table>
</div>
</article>
@endsection
@endsection
1 change: 1 addition & 0 deletions OngekiScoreLog/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Route::get('/user/{id}/trophy', 'ViewUserTrophyController@getIndex')->where(['id' => '\d+']);
Route::get('/user/{id}/music/{music}/{difficulty}', 'ViewUserMusicController@getIndex')->where(['id' => '\d+', 'music' => '\d+', 'difficulty' => '\w+']);
Route::get('/user/{id}/music/{music}', 'ViewUserMusicController@getRedirect')->where(['id' => '\d+', 'music' => '\d+']);
Route::get('/user/{id}/overdamage', 'ViewUserController@getOverDamegePage')->where(['id' => '\d+']);
Route::get('/user/{id}/{mode?}', 'ViewUserController@getUserPage')->where(['id' => '\d+']);

Route::middleware('throttle:3,1')->group(function () {
Expand Down

0 comments on commit 289350d

Please sign in to comment.