diff --git a/bemani/frontend/jubeat/endpoints.py b/bemani/frontend/jubeat/endpoints.py index d152d96..5dbf261 100644 --- a/bemani/frontend/jubeat/endpoints.py +++ b/bemani/frontend/jubeat/endpoints.py @@ -3,7 +3,7 @@ import re from typing import Any, Dict from flask import Blueprint, request, Response, url_for, abort -from bemani.common import ID, GameConstants +from bemani.common import ID, GameConstants, VersionConstants from bemani.data import UserID from bemani.frontend.app import loginrequired, jsonify, render_react from bemani.frontend.jubeat.jubeat import JubeatFrontend @@ -183,16 +183,22 @@ def viewtopscores(musicid: int) -> Response: name = None artist = None genre = None - difficulties = [0, 0, 0] + category = 0 + difficulties = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] for version in versions: - for chart in [0, 1, 2]: + for chart in [0, 1, 2, 3, 4, 5]: details = g.data.local.music.get_song(GameConstants.JUBEAT, version, musicid, chart) if details is not None: name = details.name artist = details.artist genre = details.genre - difficulties[chart] = details.data.get_int('difficulty', 13) + if category < version: + category = version; + if difficulties[chart] == 0.0: + difficulties[chart] = details.data.get_float('difficulty', 13) + if difficulties[chart] >= 13.0: + difficulties[chart] = float(details.data.get_int('difficulty', 13)) if name is None: # Not a real song! @@ -208,6 +214,7 @@ def viewtopscores(musicid: int) -> Response: 'artist': artist, 'genre': genre, 'difficulties': difficulties, + 'new_rating': category >= VersionConstants.JUBEAT_FESTO, 'players': top_scores['players'], 'topscores': top_scores['topscores'], }, diff --git a/bemani/frontend/jubeat/jubeat.py b/bemani/frontend/jubeat/jubeat.py index 601962e..a1d8907 100644 --- a/bemani/frontend/jubeat/jubeat.py +++ b/bemani/frontend/jubeat/jubeat.py @@ -15,6 +15,9 @@ class JubeatFrontend(FrontendBase): JubeatBase.CHART_TYPE_BASIC, JubeatBase.CHART_TYPE_ADVANCED, JubeatBase.CHART_TYPE_EXTREME, + JubeatBase.CHART_TYPE_HARD_BASIC, + JubeatBase.CHART_TYPE_HARD_ADVANCED, + JubeatBase.CHART_TYPE_HARD_EXTREME, ] valid_rival_types: List[str] = ['rival'] @@ -42,6 +45,9 @@ class JubeatFrontend(FrontendBase): def format_score(self, userid: UserID, score: Score) -> Dict[str, Any]: formatted_score = super().format_score(userid, score) formatted_score['combo'] = score.data.get_int('combo', -1) + formatted_score['music_rate'] = score.data.get_int('music_rate', -1) + if formatted_score['music_rate'] >= 0: + formatted_score['music_rate'] /= 10 formatted_score['medal'] = score.data.get_int('medal') formatted_score['status'] = { JubeatBase.PLAY_MEDAL_FAILED: "FAILED", @@ -57,6 +63,9 @@ class JubeatFrontend(FrontendBase): formatted_attempt = super().format_attempt(userid, attempt) formatted_attempt['combo'] = attempt.data.get_int('combo', -1) formatted_attempt['medal'] = attempt.data.get_int('medal') + formatted_attempt['music_rate'] = attempt.data.get_int('music_rate', -1) + if formatted_attempt['music_rate'] >= 0: + formatted_attempt['music_rate'] /= 10 formatted_attempt['status'] = { JubeatBase.PLAY_MEDAL_FAILED: "FAILED", JubeatBase.PLAY_MEDAL_CLEARED: "CLEARED", @@ -73,8 +82,10 @@ class JubeatFrontend(FrontendBase): return formatted_profile def format_song(self, song: Song) -> Dict[str, Any]: - difficulties = [0, 0, 0] - difficulties[song.chart] = song.data.get_int('difficulty', 13) + difficulties = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + difficulties[song.chart] = song.data.get_float('difficulty', 13) + if difficulties[song.chart] == 13.0: + difficulties[song.chart] = float(song.data.get_int('difficulty', 13)) formatted_song = super().format_song(song) formatted_song['bpm_min'] = song.data.get_int('bpm_min', 120) @@ -99,6 +110,8 @@ class JubeatFrontend(FrontendBase): def merge_song(self, existing: Dict[str, Any], new: Song) -> Dict[str, Any]: new_song = super().merge_song(existing, new) - if existing['difficulties'][new.chart] == 0: - new_song['difficulties'][new.chart] = new.data.get_int('difficulty', 13) + if existing['difficulties'][new.chart] == 0.0: + new_song['difficulties'][new.chart] = new.data.get_float('difficulty', 13) + if new_song['difficulties'][new.chart] == 13.0: + new_song['difficulties'][new.chart] = float(new.data.get_int('difficulty', 13)) return new_song diff --git a/bemani/frontend/static/controllers/jubeat/records.react.js b/bemani/frontend/static/controllers/jubeat/records.react.js index 29d2cdb..e3c3f16 100644 --- a/bemani/frontend/static/controllers/jubeat/records.react.js +++ b/bemani/frontend/static/controllers/jubeat/records.react.js @@ -1,7 +1,7 @@ /*** @jsx React.DOM */ var valid_sorts = ['series', 'name', 'popularity']; -var valid_charts = ['Basic', 'Advanced', 'Extreme']; +var valid_charts = ['Basic', 'Advanced', 'Extreme', 'Hard Mode Basic', 'Hard Mode Advanced', 'Hard Mode Extreme']; var valid_mixes = Object.keys(window.versions).map(function(mix) { return (parseInt(mix) - 1).toString(); }); @@ -120,10 +120,16 @@ var network_records = React.createClass({ }, renderDifficulty: function(songid, chart) { - if (this.state.songs[songid].difficulties[chart] == 0) { + var diff = this.state.songs[songid].difficulties[chart]; + var new_rating = ( + this.state.songs[songid].difficulties[3] > 0 || + this.state.songs[songid].difficulties[4] > 0 || + this.state.songs[songid].difficulties[5] > 0 + ); + if (this.state.songs[songid].difficulties[chart] < 1) { return --; } else { - return {this.state.songs[songid].difficulties[chart]}★; + return {diff >= 9 && new_rating ? diff.toFixed(1) : diff.toFixed(0)}★; } }, @@ -208,6 +214,9 @@ var network_records = React.createClass({