Merge in some of Subject38's Jubeat frontend, fix a few broken cases, properly hide charts we don't support.
This commit is contained in:
parent
5a94ea4ec7
commit
b520cd9a2b
@ -3,7 +3,7 @@ import re
|
|||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
from flask import Blueprint, request, Response, url_for, abort
|
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.data import UserID
|
||||||
from bemani.frontend.app import loginrequired, jsonify, render_react
|
from bemani.frontend.app import loginrequired, jsonify, render_react
|
||||||
from bemani.frontend.jubeat.jubeat import JubeatFrontend
|
from bemani.frontend.jubeat.jubeat import JubeatFrontend
|
||||||
@ -183,16 +183,22 @@ def viewtopscores(musicid: int) -> Response:
|
|||||||
name = None
|
name = None
|
||||||
artist = None
|
artist = None
|
||||||
genre = 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 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)
|
details = g.data.local.music.get_song(GameConstants.JUBEAT, version, musicid, chart)
|
||||||
if details is not None:
|
if details is not None:
|
||||||
name = details.name
|
name = details.name
|
||||||
artist = details.artist
|
artist = details.artist
|
||||||
genre = details.genre
|
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:
|
if name is None:
|
||||||
# Not a real song!
|
# Not a real song!
|
||||||
@ -208,6 +214,7 @@ def viewtopscores(musicid: int) -> Response:
|
|||||||
'artist': artist,
|
'artist': artist,
|
||||||
'genre': genre,
|
'genre': genre,
|
||||||
'difficulties': difficulties,
|
'difficulties': difficulties,
|
||||||
|
'new_rating': category >= VersionConstants.JUBEAT_FESTO,
|
||||||
'players': top_scores['players'],
|
'players': top_scores['players'],
|
||||||
'topscores': top_scores['topscores'],
|
'topscores': top_scores['topscores'],
|
||||||
},
|
},
|
||||||
|
@ -15,6 +15,9 @@ class JubeatFrontend(FrontendBase):
|
|||||||
JubeatBase.CHART_TYPE_BASIC,
|
JubeatBase.CHART_TYPE_BASIC,
|
||||||
JubeatBase.CHART_TYPE_ADVANCED,
|
JubeatBase.CHART_TYPE_ADVANCED,
|
||||||
JubeatBase.CHART_TYPE_EXTREME,
|
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']
|
valid_rival_types: List[str] = ['rival']
|
||||||
@ -42,6 +45,9 @@ class JubeatFrontend(FrontendBase):
|
|||||||
def format_score(self, userid: UserID, score: Score) -> Dict[str, Any]:
|
def format_score(self, userid: UserID, score: Score) -> Dict[str, Any]:
|
||||||
formatted_score = super().format_score(userid, score)
|
formatted_score = super().format_score(userid, score)
|
||||||
formatted_score['combo'] = score.data.get_int('combo', -1)
|
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['medal'] = score.data.get_int('medal')
|
||||||
formatted_score['status'] = {
|
formatted_score['status'] = {
|
||||||
JubeatBase.PLAY_MEDAL_FAILED: "FAILED",
|
JubeatBase.PLAY_MEDAL_FAILED: "FAILED",
|
||||||
@ -57,6 +63,9 @@ class JubeatFrontend(FrontendBase):
|
|||||||
formatted_attempt = super().format_attempt(userid, attempt)
|
formatted_attempt = super().format_attempt(userid, attempt)
|
||||||
formatted_attempt['combo'] = attempt.data.get_int('combo', -1)
|
formatted_attempt['combo'] = attempt.data.get_int('combo', -1)
|
||||||
formatted_attempt['medal'] = attempt.data.get_int('medal')
|
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'] = {
|
formatted_attempt['status'] = {
|
||||||
JubeatBase.PLAY_MEDAL_FAILED: "FAILED",
|
JubeatBase.PLAY_MEDAL_FAILED: "FAILED",
|
||||||
JubeatBase.PLAY_MEDAL_CLEARED: "CLEARED",
|
JubeatBase.PLAY_MEDAL_CLEARED: "CLEARED",
|
||||||
@ -73,8 +82,10 @@ class JubeatFrontend(FrontendBase):
|
|||||||
return formatted_profile
|
return formatted_profile
|
||||||
|
|
||||||
def format_song(self, song: Song) -> Dict[str, Any]:
|
def format_song(self, song: Song) -> Dict[str, Any]:
|
||||||
difficulties = [0, 0, 0]
|
difficulties = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||||
difficulties[song.chart] = song.data.get_int('difficulty', 13)
|
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 = super().format_song(song)
|
||||||
formatted_song['bpm_min'] = song.data.get_int('bpm_min', 120)
|
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]:
|
def merge_song(self, existing: Dict[str, Any], new: Song) -> Dict[str, Any]:
|
||||||
new_song = super().merge_song(existing, new)
|
new_song = super().merge_song(existing, new)
|
||||||
if existing['difficulties'][new.chart] == 0:
|
if existing['difficulties'][new.chart] == 0.0:
|
||||||
new_song['difficulties'][new.chart] = new.data.get_int('difficulty', 13)
|
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
|
return new_song
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*** @jsx React.DOM */
|
/*** @jsx React.DOM */
|
||||||
|
|
||||||
var valid_sorts = ['series', 'name', 'popularity'];
|
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) {
|
var valid_mixes = Object.keys(window.versions).map(function(mix) {
|
||||||
return (parseInt(mix) - 1).toString();
|
return (parseInt(mix) - 1).toString();
|
||||||
});
|
});
|
||||||
@ -120,10 +120,16 @@ var network_records = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderDifficulty: function(songid, chart) {
|
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 <span className="difficulty">--</span>;
|
return <span className="difficulty">--</span>;
|
||||||
} else {
|
} else {
|
||||||
return <span className="difficulty">{this.state.songs[songid].difficulties[chart]}★</span>;
|
return <span className="difficulty">{diff >= 9 && new_rating ? diff.toFixed(1) : diff.toFixed(0)}★</span>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -208,6 +214,9 @@ var network_records = React.createClass({
|
|||||||
<td className="subheader">Basic</td>
|
<td className="subheader">Basic</td>
|
||||||
<td className="subheader">Advanced</td>
|
<td className="subheader">Advanced</td>
|
||||||
<td className="subheader">Extreme</td>
|
<td className="subheader">Extreme</td>
|
||||||
|
<td className="subheader">Hard Mode Basic</td>
|
||||||
|
<td className="subheader">Hard Mode Advanced</td>
|
||||||
|
<td className="subheader">Hard Mode Extreme</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -234,7 +243,7 @@ var network_records = React.createClass({
|
|||||||
{this.renderDifficulty(songid, 2)}
|
{this.renderDifficulty(songid, 2)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className={difficulties[0] > 0 ? "" : "nochart"}>
|
||||||
<HighScore
|
<HighScore
|
||||||
players={this.state.players}
|
players={this.state.players}
|
||||||
songid={songid}
|
songid={songid}
|
||||||
@ -242,7 +251,7 @@ var network_records = React.createClass({
|
|||||||
score={records[0]}
|
score={records[0]}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className={difficulties[1] > 0 ? "" : "nochart"}>
|
||||||
<HighScore
|
<HighScore
|
||||||
players={this.state.players}
|
players={this.state.players}
|
||||||
songid={songid}
|
songid={songid}
|
||||||
@ -250,7 +259,7 @@ var network_records = React.createClass({
|
|||||||
score={records[1]}
|
score={records[1]}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className={difficulties[2] > 0 ? "" : "nochart"}>
|
||||||
<HighScore
|
<HighScore
|
||||||
players={this.state.players}
|
players={this.state.players}
|
||||||
songid={songid}
|
songid={songid}
|
||||||
@ -258,6 +267,30 @@ var network_records = React.createClass({
|
|||||||
score={records[2]}
|
score={records[2]}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
<td className={difficulties[3] > 0 ? "" : "nochart"}>
|
||||||
|
<HighScore
|
||||||
|
players={this.state.players}
|
||||||
|
songid={songid}
|
||||||
|
chart={3}
|
||||||
|
score={records[3]}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td className={difficulties[4] > 0 ? "" : "nochart"}>
|
||||||
|
<HighScore
|
||||||
|
players={this.state.players}
|
||||||
|
songid={songid}
|
||||||
|
chart={4}
|
||||||
|
score={records[4]}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td className={difficulties[5] > 0 ? "" : "nochart"}>
|
||||||
|
<HighScore
|
||||||
|
players={this.state.players}
|
||||||
|
songid={songid}
|
||||||
|
chart={5}
|
||||||
|
score={records[5]}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -418,6 +451,9 @@ var network_records = React.createClass({
|
|||||||
<th className="subheader">Basic</th>
|
<th className="subheader">Basic</th>
|
||||||
<th className="subheader">Advanced</th>
|
<th className="subheader">Advanced</th>
|
||||||
<th className="subheader">Extreme</th>
|
<th className="subheader">Extreme</th>
|
||||||
|
<th className="subheader">Hard Mode Basic</th>
|
||||||
|
<th className="subheader">Hard Mode Advanced</th>
|
||||||
|
<th className="subheader">Hard Mode Extreme</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -451,7 +487,7 @@ var network_records = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
{ showplays ? <div className="songplays">#{index + 1} - {plays}{plays == 1 ? ' play' : ' plays'}</div> : null }
|
{ showplays ? <div className="songplays">#{index + 1} - {plays}{plays == 1 ? ' play' : ' plays'}</div> : null }
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className={difficulties[0] > 0 ? "" : "nochart"}>
|
||||||
<HighScore
|
<HighScore
|
||||||
players={this.state.players}
|
players={this.state.players}
|
||||||
songid={songid}
|
songid={songid}
|
||||||
@ -459,7 +495,7 @@ var network_records = React.createClass({
|
|||||||
score={records[0]}
|
score={records[0]}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className={difficulties[1] > 0 ? "" : "nochart"}>
|
||||||
<HighScore
|
<HighScore
|
||||||
players={this.state.players}
|
players={this.state.players}
|
||||||
songid={songid}
|
songid={songid}
|
||||||
@ -467,7 +503,7 @@ var network_records = React.createClass({
|
|||||||
score={records[1]}
|
score={records[1]}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className={difficulties[2] > 0 ? "" : "nochart"}>
|
||||||
<HighScore
|
<HighScore
|
||||||
players={this.state.players}
|
players={this.state.players}
|
||||||
songid={songid}
|
songid={songid}
|
||||||
@ -475,13 +511,37 @@ var network_records = React.createClass({
|
|||||||
score={records[2]}
|
score={records[2]}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
<td className={difficulties[3] > 0 ? "" : "nochart"}>
|
||||||
|
<HighScore
|
||||||
|
players={this.state.players}
|
||||||
|
songid={songid}
|
||||||
|
chart={3}
|
||||||
|
score={records[3]}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td className={difficulties[4] > 0 ? "" : "nochart"}>
|
||||||
|
<HighScore
|
||||||
|
players={this.state.players}
|
||||||
|
songid={songid}
|
||||||
|
chart={4}
|
||||||
|
score={records[4]}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td className={difficulties[5] > 0 ? "" : "nochart"}>
|
||||||
|
<HighScore
|
||||||
|
players={this.state.players}
|
||||||
|
songid={songid}
|
||||||
|
chart={5}
|
||||||
|
score={records[5]}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}.bind(this))}
|
}.bind(this))}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={4}>
|
<td colSpan={7}>
|
||||||
{ this.state.offset > 0 ?
|
{ this.state.offset > 0 ?
|
||||||
<Prev onClick={function(event) {
|
<Prev onClick={function(event) {
|
||||||
var page = this.state.offset - this.state.limit;
|
var page = this.state.offset - this.state.limit;
|
||||||
|
@ -40,6 +40,12 @@ var network_scores = React.createClass({
|
|||||||
return 'Advanced';
|
return 'Advanced';
|
||||||
case 2:
|
case 2:
|
||||||
return 'Extreme';
|
return 'Extreme';
|
||||||
|
case 0:
|
||||||
|
return 'Hard Mode Basic';
|
||||||
|
case 1:
|
||||||
|
return 'Hard Mode Advanced';
|
||||||
|
case 2:
|
||||||
|
return 'Hard Mode Extreme';
|
||||||
default:
|
default:
|
||||||
return 'u broke it';
|
return 'u broke it';
|
||||||
}
|
}
|
||||||
@ -53,6 +59,8 @@ var network_scores = React.createClass({
|
|||||||
<span className="score">{score.points}</span>
|
<span className="score">{score.points}</span>
|
||||||
<span className="label">Combo</span>
|
<span className="label">Combo</span>
|
||||||
<span className="score">{score.combo < 0 ? '-' : score.combo}</span>
|
<span className="score">{score.combo < 0 ? '-' : score.combo}</span>
|
||||||
|
<span className="label">Music Rate</span>
|
||||||
|
<span className="score">{score.music_rate < 0 ? '-' : score.music_rate}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span className="status">{score.status}</span>
|
<span className="status">{score.status}</span>
|
||||||
@ -80,6 +88,12 @@ var network_scores = React.createClass({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var diff = window.songs[attempt.songid].difficulties[attempt.chart];
|
||||||
|
var new_rating = (
|
||||||
|
window.songs[attempt.songid].difficulties[3] > 0 ||
|
||||||
|
window.songs[attempt.songid].difficulties[4] > 0 ||
|
||||||
|
window.songs[attempt.songid].difficulties[5] > 0
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
{ window.shownames ? <td><a href={Link.get('player', attempt.userid)}>{
|
{ window.shownames ? <td><a href={Link.get('player', attempt.userid)}>{
|
||||||
@ -107,7 +121,7 @@ var network_scores = React.createClass({
|
|||||||
}</a>
|
}</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>{window.songs[attempt.songid].difficulties[attempt.chart]}★</span>
|
<span>{diff >= 9 && new_rating ? diff.toFixed(1) : diff.toFixed(0)}★</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{ this.renderScore(attempt) }</td>
|
<td>{ this.renderScore(attempt) }</td>
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
/*** @jsx React.DOM */
|
/*** @jsx React.DOM */
|
||||||
|
|
||||||
var valid_charts = ['Basic', 'Advanced', 'Extreme'];
|
var valid_charts = window.new_rating ?
|
||||||
|
['Basic', 'Advanced', 'Extreme', 'Hard Mode Basic', 'Hard Mode Advanced', 'Hard Mode Extreme'] :
|
||||||
|
['Basic', 'Advanced', 'Extreme'];
|
||||||
var pagenav = new History(valid_charts);
|
var pagenav = new History(valid_charts);
|
||||||
|
|
||||||
var top_scores = React.createClass({
|
var top_scores = React.createClass({
|
||||||
|
|
||||||
sortTopScores: function(topscores) {
|
sortTopScores: function(topscores) {
|
||||||
var newscores = [[], [], [], []];
|
var newscores = [[], [], [], [], [], []];
|
||||||
topscores.map(function(score) {
|
topscores.map(function(score) {
|
||||||
newscores[score.chart].push(score);
|
newscores[score.chart].push(score);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -50,6 +52,12 @@ var top_scores = React.createClass({
|
|||||||
return 1;
|
return 1;
|
||||||
case 'Extreme':
|
case 'Extreme':
|
||||||
return 2;
|
return 2;
|
||||||
|
case 'Hard Mode Basic':
|
||||||
|
return 3;
|
||||||
|
case 'Hard Mode Advanced':
|
||||||
|
return 4;
|
||||||
|
case 'Hard Mode Extreme':
|
||||||
|
return 5;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -57,13 +65,14 @@ var top_scores = React.createClass({
|
|||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var chart = this.convertChart(this.state.chart);
|
var chart = this.convertChart(this.state.chart);
|
||||||
|
var diff = window.difficulties[chart];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="section">
|
<div className="section">
|
||||||
<div className="songname">{window.name}</div>
|
<div className="songname">{window.name}</div>
|
||||||
<div className="songartist">{window.artist}</div>
|
<div className="songartist">{window.artist}</div>
|
||||||
<div className="songdifficulty">{window.difficulties[chart]}★</div>
|
<div className="songdifficulty">{diff >= 9 && window.new_rating ? diff.toFixed(1) : diff.toFixed(0)}★</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="section">
|
<div className="section">
|
||||||
{valid_charts.map(function(chart) {
|
{valid_charts.map(function(chart) {
|
||||||
|
Loading…
Reference in New Issue
Block a user