2019-12-08 22:43:49 +01:00
|
|
|
# vim: set fileencoding=utf-8
|
|
|
|
import math
|
|
|
|
import random
|
2020-04-24 21:20:43 +02:00
|
|
|
from typing import Optional, Dict, List, Any, Set, Tuple
|
2021-09-07 19:56:15 +02:00
|
|
|
from typing_extensions import Final
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
from bemani.backend.base import Status
|
|
|
|
from bemani.backend.jubeat.common import (
|
|
|
|
JubeatDemodataGetHitchartHandler,
|
|
|
|
JubeatDemodataGetNewsHandler,
|
|
|
|
JubeatGamendRegisterHandler,
|
|
|
|
JubeatGametopGetMeetingHandler,
|
|
|
|
JubeatLobbyCheckHandler,
|
|
|
|
JubeatLoggerReportHandler,
|
|
|
|
)
|
|
|
|
from bemani.backend.jubeat.course import JubeatCourse
|
|
|
|
from bemani.backend.jubeat.base import JubeatBase
|
|
|
|
from bemani.backend.jubeat.saucerfulfill import JubeatSaucerFulfill
|
2021-08-20 06:43:13 +02:00
|
|
|
from bemani.common import Profile, ValidatedDict, VersionConstants, Time
|
2019-12-08 22:43:49 +01:00
|
|
|
from bemani.data import Data, Score, UserID
|
|
|
|
from bemani.protocol import Node
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatProp(
|
|
|
|
JubeatDemodataGetHitchartHandler,
|
|
|
|
JubeatDemodataGetNewsHandler,
|
|
|
|
JubeatGamendRegisterHandler,
|
|
|
|
JubeatGametopGetMeetingHandler,
|
|
|
|
JubeatLobbyCheckHandler,
|
|
|
|
JubeatLoggerReportHandler,
|
|
|
|
JubeatCourse,
|
|
|
|
JubeatBase,
|
|
|
|
):
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
name: str = "Jubeat Prop"
|
2021-09-07 19:56:15 +02:00
|
|
|
version: int = VersionConstants.JUBEAT_PROP
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2021-09-07 19:56:15 +02:00
|
|
|
GAME_COURSE_REQUIREMENT_SCORE: Final[int] = 1
|
|
|
|
GAME_COURSE_REQUIREMENT_FULL_COMBO: Final[int] = 2
|
|
|
|
GAME_COURSE_REQUIREMENT_PERFECT_PERCENT: Final[int] = 3
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2021-09-07 19:56:15 +02:00
|
|
|
GAME_COURSE_RATING_FAILED: Final[int] = 1
|
|
|
|
GAME_COURSE_RATING_BRONZE: Final[int] = 2
|
|
|
|
GAME_COURSE_RATING_SILVER: Final[int] = 3
|
|
|
|
GAME_COURSE_RATING_GOLD: Final[int] = 4
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2021-09-07 19:56:15 +02:00
|
|
|
JBOX_EMBLEM_NORMAL: Final[int] = 1
|
|
|
|
JBOX_EMBLEM_PREMIUM: Final[int] = 2
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2021-09-07 19:56:15 +02:00
|
|
|
EVENTS: Dict[int, Dict[str, bool]] = {
|
2019-12-08 22:43:49 +01:00
|
|
|
5: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
6: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
9: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
14: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
15: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
16: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
17: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
18: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
19: {
|
2022-10-15 20:56:30 +02:00
|
|
|
"enabled": False,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
def previous_version(self) -> Optional[JubeatBase]:
|
|
|
|
return JubeatSaucerFulfill(self.data, self.config, self.model)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __class_to_rank(cls, cur_class: int, cur_subclass: int) -> int:
|
|
|
|
"""
|
|
|
|
Given a class and subclass, return an integer rank for that class.
|
|
|
|
|
|
|
|
Class mapping is as follows:
|
|
|
|
1 - Amateur
|
|
|
|
2 - Regular
|
|
|
|
3 - Master
|
|
|
|
4 - Legend
|
|
|
|
|
|
|
|
Subclass ranges from 1 to 5, except on Legend where it is 1 only.
|
|
|
|
"""
|
|
|
|
if cur_subclass > 5:
|
|
|
|
cur_subclass = 5
|
|
|
|
if cur_subclass < 1:
|
|
|
|
cur_subclass = 1
|
|
|
|
if cur_class > 4:
|
|
|
|
cur_class = 4
|
|
|
|
if cur_class < 1:
|
|
|
|
cur_class = 1
|
|
|
|
|
|
|
|
lut = {
|
|
|
|
1: {
|
|
|
|
5: 0,
|
|
|
|
4: 1,
|
|
|
|
3: 2,
|
|
|
|
2: 3,
|
|
|
|
1: 4,
|
|
|
|
},
|
|
|
|
2: {
|
|
|
|
5: 5,
|
|
|
|
4: 6,
|
|
|
|
3: 7,
|
|
|
|
2: 8,
|
|
|
|
1: 9,
|
|
|
|
},
|
|
|
|
3: {
|
|
|
|
5: 10,
|
|
|
|
4: 11,
|
|
|
|
3: 12,
|
|
|
|
2: 13,
|
|
|
|
1: 14,
|
|
|
|
},
|
|
|
|
# Legend only has one sub-class value (1), so to make range checks
|
|
|
|
# easier, just map all 5 possible values to the same integer.
|
|
|
|
4: {
|
|
|
|
5: 15,
|
|
|
|
4: 15,
|
|
|
|
3: 15,
|
|
|
|
2: 15,
|
|
|
|
1: 15,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return lut[cur_class][cur_subclass]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __rank_to_class(cls, rank: int) -> Tuple[int, int]:
|
|
|
|
"""
|
|
|
|
Given a rank, return a tuple representing class, subclass. This function
|
|
|
|
is the inverse of __class_to_rank.
|
|
|
|
"""
|
|
|
|
if rank < 0:
|
|
|
|
rank = 0
|
|
|
|
if rank > 15:
|
|
|
|
rank = 15
|
|
|
|
|
|
|
|
lut = {
|
|
|
|
0: (1, 5),
|
|
|
|
1: (1, 4),
|
|
|
|
2: (1, 3),
|
|
|
|
3: (1, 2),
|
|
|
|
4: (1, 1),
|
|
|
|
5: (2, 5),
|
|
|
|
6: (2, 4),
|
|
|
|
7: (2, 3),
|
|
|
|
8: (2, 2),
|
|
|
|
9: (2, 1),
|
|
|
|
10: (3, 5),
|
|
|
|
11: (3, 4),
|
|
|
|
12: (3, 3),
|
|
|
|
13: (3, 2),
|
|
|
|
14: (3, 1),
|
|
|
|
15: (4, 1),
|
|
|
|
}
|
|
|
|
return lut[rank]
|
|
|
|
|
|
|
|
@classmethod
|
2021-05-31 20:14:04 +02:00
|
|
|
def _increment_class(cls, cur_class: int, cur_subclass: int) -> Tuple[int, int]:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Given a class and subclass, return a tuple representing the next
|
|
|
|
class/subclass if we were to be promoted.
|
|
|
|
"""
|
|
|
|
return cls.__rank_to_class(cls.__class_to_rank(cur_class, cur_subclass) + 1)
|
|
|
|
|
|
|
|
@classmethod
|
2021-05-31 20:14:04 +02:00
|
|
|
def _decrement_class(cls, cur_class: int, cur_subclass: int) -> Tuple[int, int]:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Given a class and subclass, return a tuple representing the previous
|
|
|
|
class/subclass if we were to be demoted.
|
|
|
|
"""
|
|
|
|
return cls.__rank_to_class(cls.__class_to_rank(cur_class, cur_subclass) - 1)
|
|
|
|
|
|
|
|
@classmethod
|
2022-10-15 20:56:30 +02:00
|
|
|
def _get_league_buckets(
|
|
|
|
cls, scores: List[Tuple[UserID, int]]
|
|
|
|
) -> Tuple[List[UserID], List[UserID], List[UserID]]:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Given a list of userid, score tuples, return a tuple containing three lists.
|
|
|
|
The first list is the top 30% scorer IDs, the next list is the middle 40%
|
|
|
|
scorer IDs, and the final list is the bottom 30% scorer IDs.
|
|
|
|
"""
|
|
|
|
sorted_scores = sorted(scores, key=lambda x: x[1], reverse=True)
|
|
|
|
|
|
|
|
# Top 30% get promoted
|
|
|
|
promoted_amount = math.ceil(len(sorted_scores) * 0.3)
|
|
|
|
promotions = [x[0] for x in sorted_scores[:promoted_amount]]
|
|
|
|
rest = sorted_scores[promoted_amount:]
|
|
|
|
|
|
|
|
# Bottom 30% get demoted (this is bottom 3/7 of the rest)
|
|
|
|
demoted_amount = math.ceil(len(rest) * 0.42)
|
|
|
|
demotions = [x[0] for x in rest[-demoted_amount:]]
|
|
|
|
neutrals = [x[0] for x in rest[:-demoted_amount]]
|
|
|
|
|
|
|
|
return (promotions, neutrals, demotions)
|
|
|
|
|
|
|
|
@classmethod
|
2022-10-15 20:56:30 +02:00
|
|
|
def _get_league_scores(
|
|
|
|
cls, data: Data, current_id: int, profiles: List[Tuple[UserID, Profile]]
|
|
|
|
) -> Tuple[List[Tuple[UserID, int]], List[UserID]]:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Given the current League ID (calculated based on the date range) and a list of
|
|
|
|
all user profiles for this game/version, return a uple containing two lists.
|
|
|
|
The first list should contain tuples where the first integer is a user ID and
|
|
|
|
the second integer is the user's total score for last week's course. The second
|
|
|
|
list is a list of user IDs that did not participate last week but have played
|
|
|
|
this game at some point.
|
|
|
|
"""
|
|
|
|
last_id = current_id - 1
|
|
|
|
|
|
|
|
scores = []
|
|
|
|
absentees = []
|
2021-07-07 00:29:41 +02:00
|
|
|
for [userid, _player] in profiles:
|
2019-12-08 22:43:49 +01:00
|
|
|
# Look up scores for last week if they played
|
|
|
|
league_score = data.local.user.get_achievement(
|
|
|
|
cls.game,
|
|
|
|
cls.version,
|
|
|
|
userid,
|
|
|
|
last_id,
|
2022-10-15 20:56:30 +02:00
|
|
|
"league",
|
2019-12-08 22:43:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# If they played, grab their total score so we can figure out if we should
|
|
|
|
# promote, demote or leave alone
|
|
|
|
if league_score is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
scores.append(
|
|
|
|
(
|
|
|
|
userid,
|
|
|
|
league_score["score"][0]
|
|
|
|
+ league_score["score"][1]
|
|
|
|
+ league_score["score"][2],
|
|
|
|
)
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
absentees.append(userid)
|
|
|
|
|
|
|
|
return scores, absentees
|
|
|
|
|
|
|
|
@classmethod
|
2022-10-15 20:56:30 +02:00
|
|
|
def _get_league_absentees(
|
|
|
|
cls, data: Data, current_id: int, absentees: List[UserID]
|
|
|
|
) -> List[UserID]:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Given a list of user IDs that didn't play for some number of weeks, return
|
|
|
|
a subset of those IDs that have been absent enough weeks to get a demotion.
|
|
|
|
Demotions happen for every two weeks without play.
|
|
|
|
"""
|
|
|
|
delinquents = []
|
|
|
|
for userid in absentees:
|
|
|
|
# Figure out the last time they played, if its an even boundary
|
|
|
|
# and at least 2 weeks back, demote them (one demotion for every
|
|
|
|
# two weeks not played).
|
|
|
|
last_league_id = 0
|
|
|
|
for achievement in data.local.user.get_achievements(
|
|
|
|
cls.game,
|
|
|
|
cls.version,
|
|
|
|
userid,
|
|
|
|
):
|
2022-10-15 20:56:30 +02:00
|
|
|
if achievement.type == "league":
|
2019-12-08 22:43:49 +01:00
|
|
|
last_league_id = max(achievement.id, last_league_id)
|
|
|
|
|
|
|
|
if last_league_id != 0:
|
|
|
|
# If they played mid-week two IDs ago, that's not quite
|
|
|
|
# two weeks back, so adjust by one.
|
|
|
|
weeks_different = (current_id - last_league_id) - 1
|
|
|
|
|
|
|
|
if weeks_different >= 2 and weeks_different % 2 == 0:
|
|
|
|
# It's been at least two weeks (or four, or six), which means
|
|
|
|
# there have been two weeks since the last time we did this,
|
|
|
|
# demote this person.
|
|
|
|
delinquents.append(userid)
|
|
|
|
|
|
|
|
return delinquents
|
|
|
|
|
|
|
|
@classmethod
|
2021-05-31 20:14:04 +02:00
|
|
|
def _modify_profile(cls, data: Data, userid: UserID, direction: str) -> None:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Given a user ID and a direction (promote or demote), load the user's profile,
|
|
|
|
make the necessary promotion/demotion, and set the profile to notify the user
|
|
|
|
on next play that they have lost/gained rank. If the user still hasn't checked
|
|
|
|
their rank since last time we changed it, make sure they know about multiple
|
|
|
|
promotions/demotions.
|
|
|
|
"""
|
|
|
|
profile = data.local.user.get_profile(cls.game, cls.version, userid)
|
2022-10-15 20:56:30 +02:00
|
|
|
cur_class = profile.get_int("league_class", 1)
|
|
|
|
cur_subclass = profile.get_int("league_subclass", 5)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
if direction == "promote":
|
2021-05-31 20:14:04 +02:00
|
|
|
new_class, new_subclass = cls._increment_class(cur_class, cur_subclass)
|
2022-10-15 20:56:30 +02:00
|
|
|
elif direction == "demote":
|
2021-05-31 20:14:04 +02:00
|
|
|
new_class, new_subclass = cls._decrement_class(cur_class, cur_subclass)
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
2022-10-15 20:56:30 +02:00
|
|
|
raise Exception(f"Logic error, unknown direction {direction}!")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
if new_class != cur_class or new_subclass != cur_subclass:
|
|
|
|
# If they've checked last time, set up the new old class.
|
2022-10-15 20:56:30 +02:00
|
|
|
if profile.get_bool("league_is_checked"):
|
|
|
|
last = profile.get_dict("last")
|
|
|
|
last.replace_int("league_class", cur_class)
|
|
|
|
last.replace_int("league_subclass", cur_subclass)
|
|
|
|
profile.replace_dict("last", last)
|
2019-12-08 22:43:49 +01:00
|
|
|
# We actually changed a level, let the user know!
|
2022-10-15 20:56:30 +02:00
|
|
|
profile.replace_int("league_class", new_class)
|
|
|
|
profile.replace_int("league_subclass", new_subclass)
|
|
|
|
profile.replace_bool("league_is_checked", False)
|
2019-12-08 22:43:49 +01:00
|
|
|
data.local.user.put_profile(cls.game, cls.version, userid, profile)
|
|
|
|
|
|
|
|
@classmethod
|
2022-10-15 20:56:30 +02:00
|
|
|
def run_scheduled_work(
|
|
|
|
cls, data: Data, config: Dict[str, Any]
|
|
|
|
) -> List[Tuple[str, Dict[str, Any]]]:
|
2019-12-08 22:43:49 +01:00
|
|
|
"""
|
|
|
|
Once a week, insert a new league course. Every day, insert new FC challenge courses.
|
|
|
|
"""
|
|
|
|
events = []
|
2022-10-15 20:56:30 +02:00
|
|
|
if data.local.network.should_schedule(
|
|
|
|
cls.game, cls.version, "league_course", "weekly"
|
|
|
|
):
|
2019-12-08 22:43:49 +01:00
|
|
|
# Generate a new league course list, save it to the DB.
|
2022-10-15 20:56:30 +02:00
|
|
|
start_time, end_time = data.local.network.get_schedule_duration("weekly")
|
|
|
|
all_songs = set(
|
|
|
|
song.id
|
|
|
|
for song in data.local.music.get_all_songs(cls.game, cls.version)
|
|
|
|
)
|
2021-09-06 21:06:34 +02:00
|
|
|
if len(all_songs) >= 3:
|
|
|
|
league_songs = random.sample(all_songs, 3)
|
|
|
|
data.local.game.put_time_sensitive_settings(
|
|
|
|
cls.game,
|
|
|
|
cls.version,
|
2022-10-15 20:56:30 +02:00
|
|
|
"league",
|
2021-09-06 21:06:34 +02:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"start_time": start_time,
|
|
|
|
"end_time": end_time,
|
|
|
|
"music": league_songs,
|
2021-09-06 21:06:34 +02:00
|
|
|
},
|
|
|
|
)
|
2022-10-15 20:56:30 +02:00
|
|
|
events.append(
|
|
|
|
(
|
|
|
|
"jubeat_league_course",
|
|
|
|
{
|
|
|
|
"version": cls.version,
|
|
|
|
"songs": league_songs,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
2021-09-06 21:06:34 +02:00
|
|
|
|
|
|
|
# League ID for the current league we just added.
|
|
|
|
leagueid = int(start_time / 604800)
|
|
|
|
|
|
|
|
# Evaluate player scores on previous courses and find players
|
|
|
|
# that didn't play last week.
|
|
|
|
all_profiles = data.local.user.get_all_profiles(cls.game, cls.version)
|
|
|
|
scores, absentees = cls._get_league_scores(data, leagueid, all_profiles)
|
|
|
|
|
|
|
|
# Get user IDs to promote, demote and ignore based on scores.
|
|
|
|
promote, ignore, demote = cls._get_league_buckets(scores)
|
|
|
|
demote.extend(cls._get_league_absentees(data, leagueid, absentees))
|
|
|
|
|
|
|
|
# Actually modify the profiles so the game knows to tell the user.
|
|
|
|
for userid in promote:
|
2022-10-15 20:56:30 +02:00
|
|
|
cls._modify_profile(data, userid, "promote")
|
2021-09-06 21:06:34 +02:00
|
|
|
for userid in demote:
|
2022-10-15 20:56:30 +02:00
|
|
|
cls._modify_profile(data, userid, "demote")
|
2021-09-06 21:06:34 +02:00
|
|
|
|
|
|
|
# Mark that we did some actual work here.
|
2022-10-15 20:56:30 +02:00
|
|
|
data.local.network.mark_scheduled(
|
|
|
|
cls.game, cls.version, "league_course", "weekly"
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
if data.local.network.should_schedule(
|
|
|
|
cls.game, cls.version, "fc_challenge", "daily"
|
|
|
|
):
|
2019-12-08 22:43:49 +01:00
|
|
|
# Generate a new list of two FC challenge songs.
|
2022-10-15 20:56:30 +02:00
|
|
|
start_time, end_time = data.local.network.get_schedule_duration("daily")
|
|
|
|
all_songs = set(
|
|
|
|
song.id
|
|
|
|
for song in data.local.music.get_all_songs(cls.game, cls.version)
|
|
|
|
)
|
2021-09-06 21:06:34 +02:00
|
|
|
if len(all_songs) >= 2:
|
|
|
|
daily_songs = random.sample(all_songs, 2)
|
|
|
|
data.local.game.put_time_sensitive_settings(
|
|
|
|
cls.game,
|
|
|
|
cls.version,
|
2022-10-15 20:56:30 +02:00
|
|
|
"fc_challenge",
|
2021-09-06 21:06:34 +02:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"start_time": start_time,
|
|
|
|
"end_time": end_time,
|
|
|
|
"today": daily_songs[0],
|
|
|
|
"whim": daily_songs[1],
|
2021-09-06 21:06:34 +02:00
|
|
|
},
|
|
|
|
)
|
2022-10-15 20:56:30 +02:00
|
|
|
events.append(
|
|
|
|
(
|
|
|
|
"jubeat_fc_challenge_charts",
|
|
|
|
{
|
|
|
|
"version": cls.version,
|
|
|
|
"today": daily_songs[0],
|
|
|
|
"whim": daily_songs[1],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
2021-09-06 21:06:34 +02:00
|
|
|
|
|
|
|
# Mark that we did some actual work here.
|
2022-10-15 20:56:30 +02:00
|
|
|
data.local.network.mark_scheduled(
|
|
|
|
cls.game, cls.version, "fc_challenge", "daily"
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
return events
|
|
|
|
|
|
|
|
def __get_global_info(self) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
info = Node.void("info")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Event info. Valid event IDs are 5, 6, 9, 14, 15, 16, 17, 18, 19
|
2022-10-15 20:56:30 +02:00
|
|
|
event_info = Node.void("event_info")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(event_info)
|
|
|
|
for event in self.EVENTS:
|
2022-10-15 20:56:30 +02:00
|
|
|
evt = Node.void("event")
|
2019-12-08 22:43:49 +01:00
|
|
|
event_info.add_child(evt)
|
2022-10-15 20:56:30 +02:00
|
|
|
evt.set_attribute("type", str(event))
|
|
|
|
evt.add_child(Node.u8("state", 1 if self.EVENTS[event]["enabled"] else 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Each of the following three sections should have zero or more child nodes (no
|
|
|
|
# particular name) which look like the following:
|
|
|
|
# <node>
|
|
|
|
# <id __type="s32">songid</id>
|
|
|
|
# <stime __type="str">start time?</stime>
|
|
|
|
# <etime __type="str">end time?</etime>
|
|
|
|
# </node>
|
|
|
|
# Share music?
|
2022-10-15 20:56:30 +02:00
|
|
|
share_music = Node.void("share_music")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(share_music)
|
|
|
|
|
|
|
|
# Bonus music?
|
2022-10-15 20:56:30 +02:00
|
|
|
bonus_music = Node.void("bonus_music")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(bonus_music)
|
|
|
|
|
|
|
|
# Only now music?
|
2022-10-15 20:56:30 +02:00
|
|
|
only_now_music = Node.void("only_now_music")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(only_now_music)
|
|
|
|
|
|
|
|
# Full combo challenge?
|
2022-10-15 20:56:30 +02:00
|
|
|
entry = self.data.local.game.get_time_sensitive_settings(
|
|
|
|
self.game, self.version, "fc_challenge"
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
if entry is None:
|
|
|
|
entry = ValidatedDict()
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
fc_challenge = Node.void("fc_challenge")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(fc_challenge)
|
2022-10-15 20:56:30 +02:00
|
|
|
today = Node.void("today")
|
2019-12-08 22:43:49 +01:00
|
|
|
fc_challenge.add_child(today)
|
2022-10-15 20:56:30 +02:00
|
|
|
today.add_child(Node.s32("music_id", entry.get_int("today", -1)))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Some sort of music DB whitelist
|
2022-10-15 20:56:30 +02:00
|
|
|
info.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"white_music_list",
|
|
|
|
[
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
info.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"open_music_list",
|
|
|
|
[
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
cabinet_survey = Node.void("cabinet_survey")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(cabinet_survey)
|
2022-10-15 20:56:30 +02:00
|
|
|
cabinet_survey.add_child(Node.s32("id", -1))
|
|
|
|
cabinet_survey.add_child(Node.s32("status", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
kaitou_bisco = Node.void("kaitou_bisco")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(kaitou_bisco)
|
2022-10-15 20:56:30 +02:00
|
|
|
kaitou_bisco.add_child(Node.s32("remaining_days", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
league = Node.void("league")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(league)
|
2022-10-15 20:56:30 +02:00
|
|
|
league.add_child(Node.u8("status", 1))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
bistro = Node.void("bistro")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(bistro)
|
2022-10-15 20:56:30 +02:00
|
|
|
bistro.add_child(Node.u16("bistro_id", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
jbox = Node.void("jbox")
|
2019-12-08 22:43:49 +01:00
|
|
|
info.add_child(jbox)
|
2022-10-15 20:56:30 +02:00
|
|
|
jbox.add_child(Node.s32("point", 0))
|
|
|
|
emblem = Node.void("emblem")
|
2019-12-08 22:43:49 +01:00
|
|
|
jbox.add_child(emblem)
|
2022-10-15 20:56:30 +02:00
|
|
|
normal = Node.void("normal")
|
2019-12-08 22:43:49 +01:00
|
|
|
emblem.add_child(normal)
|
2022-10-15 20:56:30 +02:00
|
|
|
premium = Node.void("premium")
|
2019-12-08 22:43:49 +01:00
|
|
|
emblem.add_child(premium)
|
2022-10-15 20:56:30 +02:00
|
|
|
normal.add_child(Node.s16("index", 2))
|
|
|
|
premium.add_child(Node.s16("index", 1))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
return info
|
|
|
|
|
|
|
|
def handle_shopinfo_regist_request(self, request: Node) -> Node:
|
|
|
|
# Update the name of this cab for admin purposes
|
2022-10-15 20:56:30 +02:00
|
|
|
self.update_machine_name(request.child_value("shop/name"))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
shopinfo = Node.void("shopinfo")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
shopinfo.add_child(data)
|
2022-10-15 20:56:30 +02:00
|
|
|
data.add_child(Node.u32("cabid", 1))
|
|
|
|
data.add_child(Node.string("locationid", "nowhere"))
|
|
|
|
data.add_child(Node.u8("tax_phase", 1))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
facility = Node.void("facility")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(facility)
|
2022-10-15 20:56:30 +02:00
|
|
|
facility.add_child(Node.u32("exist", 1))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
data.add_child(self.__get_global_info())
|
|
|
|
|
|
|
|
return shopinfo
|
|
|
|
|
|
|
|
def handle_gametop_regist_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = request.child("data")
|
|
|
|
player = data.child("player")
|
|
|
|
refid = player.child_value("refid")
|
|
|
|
name = player.child_value("name")
|
2019-12-08 22:43:49 +01:00
|
|
|
root = self.new_profile_by_refid(refid, name)
|
|
|
|
return root
|
|
|
|
|
|
|
|
def handle_gametop_get_pdata_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = request.child("data")
|
|
|
|
player = data.child("player")
|
|
|
|
refid = player.child_value("refid")
|
2019-12-08 22:43:49 +01:00
|
|
|
root = self.get_profile_by_refid(refid)
|
|
|
|
if root is None:
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("gametop")
|
|
|
|
root.set_attribute("status", str(Status.NO_PROFILE))
|
2019-12-08 22:43:49 +01:00
|
|
|
return root
|
|
|
|
|
|
|
|
def handle_gametop_get_mdata_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = request.child("data")
|
|
|
|
player = data.child("player")
|
|
|
|
extid = player.child_value("jid")
|
|
|
|
mdata_ver = player.child_value(
|
|
|
|
"mdata_ver"
|
|
|
|
) # Game requests mdata 3 times per profile for some reason
|
2021-08-11 01:19:30 +02:00
|
|
|
if mdata_ver != 1:
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("gametop")
|
|
|
|
datanode = Node.void("data")
|
2021-08-11 01:19:30 +02:00
|
|
|
root.add_child(datanode)
|
2022-10-15 20:56:30 +02:00
|
|
|
player = Node.void("player")
|
2021-08-11 01:19:30 +02:00
|
|
|
datanode.add_child(player)
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.s32("jid", extid))
|
|
|
|
playdata = Node.void("mdata_list")
|
2021-08-11 01:19:30 +02:00
|
|
|
player.add_child(playdata)
|
|
|
|
return root
|
2019-12-08 22:43:49 +01:00
|
|
|
root = self.get_scores_by_extid(extid)
|
|
|
|
if root is None:
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("gametop")
|
|
|
|
root.set_attribute("status", str(Status.NO_PROFILE))
|
2019-12-08 22:43:49 +01:00
|
|
|
return root
|
|
|
|
|
|
|
|
def handle_gametop_get_info_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("gametop")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
root.add_child(data)
|
|
|
|
data.add_child(self.__get_global_info())
|
|
|
|
|
|
|
|
return root
|
|
|
|
|
|
|
|
def handle_gametop_get_course_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = request.child("data")
|
|
|
|
player = data.child("player")
|
|
|
|
extid = player.child_value("jid")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
gametop = Node.void("gametop")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
gametop.add_child(data)
|
|
|
|
|
|
|
|
# Course list available
|
2022-10-15 20:56:30 +02:00
|
|
|
course_list = Node.void("course_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(course_list)
|
|
|
|
|
|
|
|
validcourses: List[int] = []
|
|
|
|
courses = self.get_all_courses()
|
2022-10-15 20:56:30 +02:00
|
|
|
courses.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": 31,
|
|
|
|
"name": "Enjoy! The 5th KAC ~ tracks of prop ~",
|
|
|
|
"level": 5,
|
|
|
|
"music": [
|
|
|
|
(60000065, 1),
|
|
|
|
(60000008, 1),
|
|
|
|
(60000001, 1),
|
|
|
|
(60001009, 1),
|
|
|
|
(60000010, 1),
|
|
|
|
],
|
|
|
|
"requirements": {
|
|
|
|
self.COURSE_REQUIREMENT_SCORE: [900000, 950000, 980000],
|
|
|
|
self.COURSE_REQUIREMENT_FULL_COMBO: [1, 2, 4],
|
|
|
|
},
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
{
|
|
|
|
"id": 32,
|
|
|
|
"name": "Challenge! The 5th KAC ~ tracks of prop ~",
|
|
|
|
"level": 7,
|
|
|
|
"music": [
|
|
|
|
(60000065, 2),
|
|
|
|
(60000008, 2),
|
|
|
|
(60000001, 2),
|
|
|
|
(60001009, 2),
|
|
|
|
(60000010, 2),
|
|
|
|
],
|
|
|
|
"requirements": {
|
|
|
|
self.COURSE_REQUIREMENT_SCORE: [900000, 950000, 980000],
|
|
|
|
},
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
{
|
|
|
|
"id": 33,
|
|
|
|
"name": "The 5th KAC ~ tracks of prop ~",
|
|
|
|
"level": 10,
|
|
|
|
"music": [
|
|
|
|
(60000065, 2),
|
|
|
|
(60000008, 2),
|
|
|
|
(60000001, 2),
|
|
|
|
(60001009, 2),
|
|
|
|
(60000010, 2),
|
|
|
|
],
|
|
|
|
"requirements": {
|
|
|
|
self.COURSE_REQUIREMENT_SCORE: [920000, 950000, 980000],
|
|
|
|
},
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
for course in courses:
|
2022-10-15 20:56:30 +02:00
|
|
|
coursenode = Node.void("course")
|
2019-12-08 22:43:49 +01:00
|
|
|
course_list.add_child(coursenode)
|
|
|
|
|
|
|
|
# Basic course info
|
2022-10-15 20:56:30 +02:00
|
|
|
if course["id"] in validcourses:
|
|
|
|
raise Exception("Cannot have same course ID specified twice!")
|
|
|
|
validcourses.append(course["id"])
|
|
|
|
coursenode.add_child(Node.s32("id", course["id"]))
|
|
|
|
coursenode.add_child(Node.string("name", course["name"]))
|
|
|
|
coursenode.add_child(Node.u8("level", course["level"]))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Translate internal to game
|
|
|
|
def translate_req(internal_req: int) -> int:
|
|
|
|
return {
|
|
|
|
self.COURSE_REQUIREMENT_SCORE: self.GAME_COURSE_REQUIREMENT_SCORE,
|
|
|
|
self.COURSE_REQUIREMENT_FULL_COMBO: self.GAME_COURSE_REQUIREMENT_FULL_COMBO,
|
|
|
|
self.COURSE_REQUIREMENT_PERFECT_PERCENT: self.GAME_COURSE_REQUIREMENT_PERFECT_PERCENT,
|
|
|
|
}.get(internal_req, 0)
|
|
|
|
|
|
|
|
# Course bronze/silver/gold rules
|
|
|
|
ids = [0] * 3
|
|
|
|
bronze_values = [0] * 3
|
|
|
|
silver_values = [0] * 3
|
|
|
|
gold_values = [0] * 3
|
|
|
|
slot = 0
|
2022-10-15 20:56:30 +02:00
|
|
|
for req in course["requirements"]:
|
|
|
|
req_values = course["requirements"][req]
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
ids[slot] = translate_req(req)
|
|
|
|
bronze_values[slot] = req_values[0]
|
|
|
|
silver_values[slot] = req_values[1]
|
|
|
|
gold_values[slot] = req_values[2]
|
|
|
|
slot = slot + 1
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
norma = Node.void("norma")
|
2019-12-08 22:43:49 +01:00
|
|
|
coursenode.add_child(norma)
|
2022-10-15 20:56:30 +02:00
|
|
|
norma.add_child(Node.s32_array("norma_id", ids))
|
|
|
|
norma.add_child(Node.s32_array("bronze_value", bronze_values))
|
|
|
|
norma.add_child(Node.s32_array("silver_value", silver_values))
|
|
|
|
norma.add_child(Node.s32_array("gold_value", gold_values))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Music list for course
|
|
|
|
music_index = 0
|
2022-10-15 20:56:30 +02:00
|
|
|
music_list = Node.void("music_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
coursenode.add_child(music_list)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
for entry in course["music"]:
|
|
|
|
music = Node.void("music")
|
|
|
|
music.set_attribute("index", str(music_index))
|
2019-12-08 22:43:49 +01:00
|
|
|
music_list.add_child(music)
|
2022-10-15 20:56:30 +02:00
|
|
|
music.add_child(Node.s32("music_id", entry[0]))
|
|
|
|
music.add_child(Node.u8("seq", entry[1]))
|
2019-12-08 22:43:49 +01:00
|
|
|
music_index = music_index + 1
|
|
|
|
|
|
|
|
# Look up profile so we can load the last course played
|
|
|
|
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
|
|
|
|
profile = self.get_profile(userid)
|
|
|
|
if profile is None:
|
2021-08-20 06:43:13 +02:00
|
|
|
profile = Profile(self.game, self.version, "", extid)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Player scores for courses
|
2022-10-15 20:56:30 +02:00
|
|
|
player_list = Node.void("player_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(player_list)
|
2022-10-15 20:56:30 +02:00
|
|
|
player = Node.void("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
player_list.add_child(player)
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.s32("jid", extid))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
result_list = Node.void("result_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(result_list)
|
|
|
|
playercourses = self.get_courses(userid)
|
|
|
|
for courseid in playercourses:
|
|
|
|
if courseid not in validcourses:
|
|
|
|
continue
|
|
|
|
|
|
|
|
rating = {
|
|
|
|
self.COURSE_RATING_FAILED: self.GAME_COURSE_RATING_FAILED,
|
|
|
|
self.COURSE_RATING_BRONZE: self.GAME_COURSE_RATING_BRONZE,
|
|
|
|
self.COURSE_RATING_SILVER: self.GAME_COURSE_RATING_SILVER,
|
|
|
|
self.COURSE_RATING_GOLD: self.GAME_COURSE_RATING_GOLD,
|
2022-10-15 20:56:30 +02:00
|
|
|
}[playercourses[courseid]["rating"]]
|
|
|
|
scores = playercourses[courseid]["scores"]
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
result = Node.void("result")
|
2019-12-08 22:43:49 +01:00
|
|
|
result_list.add_child(result)
|
2022-10-15 20:56:30 +02:00
|
|
|
result.add_child(Node.s32("id", courseid))
|
|
|
|
result.add_child(Node.u8("rating", rating))
|
|
|
|
result.add_child(Node.s32_array("score", scores))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Last course ID
|
2022-10-15 20:56:30 +02:00
|
|
|
data.add_child(
|
|
|
|
Node.s32(
|
|
|
|
"last_course_id", profile.get_dict("last").get_int("last_course_id", -1)
|
|
|
|
)
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
return gametop
|
|
|
|
|
|
|
|
def handle_gametop_get_league_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = request.child("data")
|
|
|
|
player = data.child("player")
|
|
|
|
extid = player.child_value("jid")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Look up profile so we can load the last course played
|
|
|
|
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
|
|
|
|
profile = self.get_profile(userid)
|
|
|
|
if profile is None:
|
2021-08-20 06:43:13 +02:00
|
|
|
profile = Profile(self.game, self.version, "", extid)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
gametop = Node.void("gametop")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
gametop.add_child(data)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
league_list = Node.void("league_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(league_list)
|
|
|
|
|
|
|
|
# Look up the current league charts in the DB
|
2022-10-15 20:56:30 +02:00
|
|
|
entry = self.data.local.game.get_time_sensitive_settings(
|
|
|
|
self.game, self.version, "league"
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
if entry is not None:
|
|
|
|
# Just get the week number, use that as the ID
|
2022-10-15 20:56:30 +02:00
|
|
|
leagueid = int(entry["start_time"] / 604800)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
league = Node.void("league")
|
2019-12-08 22:43:49 +01:00
|
|
|
league_list.add_child(league)
|
2022-10-15 20:56:30 +02:00
|
|
|
league.set_attribute("index", "0")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
league.add_child(Node.s32("id", leagueid))
|
|
|
|
league.add_child(Node.u64("stime", entry["start_time"] * 1000))
|
|
|
|
league.add_child(Node.u64("etime", entry["end_time"] * 1000))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
music_list = Node.void("music_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
league.add_child(music_list)
|
|
|
|
|
|
|
|
# We need to know the player class so we can determine what chart to present.
|
2022-10-15 20:56:30 +02:00
|
|
|
current_class = profile.get_int("league_class", 1)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
song_index = 0
|
2022-10-15 20:56:30 +02:00
|
|
|
for song in entry["music"]:
|
|
|
|
music = Node.void("music")
|
2019-12-08 22:43:49 +01:00
|
|
|
music_list.add_child(music)
|
2022-10-15 20:56:30 +02:00
|
|
|
music.set_attribute("index", str(song_index))
|
2019-12-08 22:43:49 +01:00
|
|
|
song_index = song_index + 1
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
music.add_child(Node.s32("music_id", song))
|
|
|
|
music.add_child(Node.u8("seq", 1 if current_class == 1 else 2))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
player_list = Node.void("player_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
league.add_child(player_list)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
player = Node.void("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
player_list.add_child(player)
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.s32("jid", extid))
|
|
|
|
result = Node.void("result")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(result)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
league_score = self.data.local.user.get_achievement(
|
|
|
|
self.game, self.version, userid, leagueid, "league"
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
if league_score is None:
|
|
|
|
league_score = ValidatedDict()
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
result.add_child(
|
|
|
|
Node.s32_array("score", league_score.get_int_array("score", 3, [0] * 3))
|
|
|
|
)
|
|
|
|
result.add_child(
|
|
|
|
Node.s8_array("clear", league_score.get_int_array("clear", 3, [0] * 3))
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
data.add_child(
|
|
|
|
Node.s32("last_class", profile.get_dict("last").get_int("league_class", 1))
|
|
|
|
)
|
|
|
|
data.add_child(
|
|
|
|
Node.s32(
|
|
|
|
"last_subclass", profile.get_dict("last").get_int("league_subclass", 5)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
data.add_child(Node.bool("is_checked", profile.get_bool("league_is_checked")))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
return gametop
|
|
|
|
|
2021-08-20 06:43:13 +02:00
|
|
|
def format_profile(self, userid: UserID, profile: Profile) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("gametop")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
root.add_child(data)
|
|
|
|
# Jubeat Prop appears to allow full event overrides per-player
|
|
|
|
data.add_child(self.__get_global_info())
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
player = Node.void("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(player)
|
|
|
|
|
|
|
|
# Basic profile info
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.string("name", profile.get_str("name", "なし")))
|
|
|
|
player.add_child(Node.s32("jid", profile.extid))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Miscelaneous crap
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.s32("session_id", 1))
|
|
|
|
player.add_child(Node.u64("event_flag", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Player info and statistics
|
2022-10-15 20:56:30 +02:00
|
|
|
info = Node.void("info")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(info)
|
2022-10-15 20:56:30 +02:00
|
|
|
info.add_child(Node.s16("jubility", profile.get_int("jubility")))
|
|
|
|
info.add_child(Node.s16("jubility_yday", profile.get_int("jubility_yday")))
|
|
|
|
info.add_child(Node.s32("tune_cnt", profile.get_int("tune_cnt")))
|
|
|
|
info.add_child(Node.s32("save_cnt", profile.get_int("save_cnt")))
|
|
|
|
info.add_child(Node.s32("saved_cnt", profile.get_int("saved_cnt")))
|
|
|
|
info.add_child(Node.s32("fc_cnt", profile.get_int("fc_cnt")))
|
|
|
|
info.add_child(Node.s32("ex_cnt", profile.get_int("ex_cnt")))
|
|
|
|
info.add_child(Node.s32("clear_cnt", profile.get_int("clear_cnt")))
|
|
|
|
info.add_child(Node.s32("pf_cnt", profile.get_int("pf_cnt")))
|
|
|
|
info.add_child(Node.s32("match_cnt", profile.get_int("match_cnt")))
|
|
|
|
info.add_child(Node.s32("beat_cnt", profile.get_int("beat_cnt")))
|
|
|
|
info.add_child(Node.s32("mynews_cnt", profile.get_int("mynews_cnt")))
|
|
|
|
info.add_child(
|
|
|
|
Node.s32("bonus_tune_points", profile.get_int("bonus_tune_points"))
|
|
|
|
)
|
|
|
|
info.add_child(
|
|
|
|
Node.bool("is_bonus_tune_played", profile.get_bool("is_bonus_tune_played"))
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Looks to be set to true when there's an old profile, stops tutorial from
|
|
|
|
# happening on first load.
|
2022-10-15 20:56:30 +02:00
|
|
|
info.add_child(
|
|
|
|
Node.bool(
|
|
|
|
"inherit",
|
|
|
|
profile.get_bool("has_old_version") and not profile.get_bool("saved"),
|
|
|
|
)
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Not saved, but loaded
|
2022-10-15 20:56:30 +02:00
|
|
|
info.add_child(Node.s32("mtg_entry_cnt", 123))
|
|
|
|
info.add_child(Node.s32("mtg_hold_cnt", 456))
|
|
|
|
info.add_child(Node.u8("mtg_result", 10))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Last played data, for showing cursor and such
|
2022-10-15 20:56:30 +02:00
|
|
|
lastdict = profile.get_dict("last")
|
|
|
|
last = Node.void("last")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(last)
|
2022-10-15 20:56:30 +02:00
|
|
|
last.add_child(Node.s64("play_time", lastdict.get_int("play_time")))
|
|
|
|
last.add_child(Node.string("shopname", lastdict.get_str("shopname")))
|
|
|
|
last.add_child(Node.string("areaname", lastdict.get_str("areaname")))
|
|
|
|
last.add_child(Node.s8("expert_option", lastdict.get_int("expert_option")))
|
|
|
|
last.add_child(Node.s8("category", lastdict.get_int("category")))
|
|
|
|
last.add_child(Node.s8("sort", lastdict.get_int("sort")))
|
|
|
|
last.add_child(Node.s32("music_id", lastdict.get_int("music_id")))
|
|
|
|
last.add_child(Node.s8("seq_id", lastdict.get_int("seq_id")))
|
|
|
|
|
|
|
|
settings = Node.void("settings")
|
2019-12-08 22:43:49 +01:00
|
|
|
last.add_child(settings)
|
2022-10-15 20:56:30 +02:00
|
|
|
settings.add_child(Node.s8("marker", lastdict.get_int("marker")))
|
|
|
|
settings.add_child(Node.s8("theme", lastdict.get_int("theme")))
|
|
|
|
settings.add_child(Node.s16("title", lastdict.get_int("title")))
|
|
|
|
settings.add_child(Node.s16("parts", lastdict.get_int("parts")))
|
|
|
|
settings.add_child(Node.s8("rank_sort", lastdict.get_int("rank_sort")))
|
|
|
|
settings.add_child(Node.s8("combo_disp", lastdict.get_int("combo_disp")))
|
|
|
|
settings.add_child(
|
|
|
|
Node.s16_array("emblem", lastdict.get_int_array("emblem", 5))
|
|
|
|
)
|
|
|
|
settings.add_child(Node.s8("matching", lastdict.get_int("matching")))
|
|
|
|
settings.add_child(Node.s8("hazard", lastdict.get_int("hazard")))
|
|
|
|
settings.add_child(Node.s8("hard", lastdict.get_int("hard")))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Secret unlocks
|
2022-10-15 20:56:30 +02:00
|
|
|
item = Node.void("item")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(item)
|
2022-10-15 20:56:30 +02:00
|
|
|
item.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"music_list", profile.get_int_array("music_list", 32, [-1] * 32)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
item.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"secret_list", profile.get_int_array("secret_list", 32, [-1] * 32)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
item.add_child(Node.s16("theme_list", profile.get_int("theme_list", -1)))
|
|
|
|
item.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"marker_list", profile.get_int_array("marker_list", 2, [-1] * 2)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
item.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"title_list", profile.get_int_array("title_list", 160, [-1] * 160)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
item.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"parts_list", profile.get_int_array("parts_list", 160, [-1] * 160)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
item.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"emblem_list", profile.get_int_array("emblem_list", 96, [-1] * 96)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
new = Node.void("new")
|
2019-12-08 22:43:49 +01:00
|
|
|
item.add_child(new)
|
2022-10-15 20:56:30 +02:00
|
|
|
new.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"secret_list", profile.get_int_array("secret_list_new", 32, [-1] * 32)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
new.add_child(Node.s16("theme_list", profile.get_int("theme_list_new", -1)))
|
|
|
|
new.add_child(
|
|
|
|
Node.s32_array(
|
|
|
|
"marker_list", profile.get_int_array("marker_list_new", 2, [-1] * 2)
|
|
|
|
)
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Sane defaults for unknown/who cares nodes
|
2022-10-15 20:56:30 +02:00
|
|
|
history = Node.void("history")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(history)
|
2022-10-15 20:56:30 +02:00
|
|
|
history.set_attribute("count", "0")
|
|
|
|
lab_edit_seq = Node.void("lab_edit_seq")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(lab_edit_seq)
|
2022-10-15 20:56:30 +02:00
|
|
|
lab_edit_seq.set_attribute("count", "0")
|
|
|
|
cabinet_survey = Node.void("cabinet_survey")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(cabinet_survey)
|
2022-10-15 20:56:30 +02:00
|
|
|
cabinet_survey.add_child(Node.u32("read_flag", 0))
|
|
|
|
kaitou_bisco = Node.void("kaitou_bisco")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(kaitou_bisco)
|
2022-10-15 20:56:30 +02:00
|
|
|
kaitou_bisco.add_child(
|
|
|
|
Node.u32("read_flag", profile.get_int("kaitou_bisco_read_flag"))
|
|
|
|
)
|
|
|
|
navi = Node.void("navi")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(navi)
|
2022-10-15 20:56:30 +02:00
|
|
|
navi.add_child(Node.u32("flag", profile.get_int("navi_flag")))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Player status for events
|
2022-10-15 20:56:30 +02:00
|
|
|
event_info = Node.void("event_info")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(event_info)
|
2022-10-15 20:56:30 +02:00
|
|
|
achievements = self.data.local.user.get_achievements(
|
|
|
|
self.game, self.version, userid
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
for achievement in achievements:
|
2022-10-15 20:56:30 +02:00
|
|
|
if achievement.type == "event":
|
2019-12-08 22:43:49 +01:00
|
|
|
# There are two significant bits here, 0x1 and 0x2, I think the first
|
|
|
|
# one is whether the event is started, second is if its finished?
|
2022-10-15 20:56:30 +02:00
|
|
|
event = Node.void("event")
|
2019-12-08 22:43:49 +01:00
|
|
|
event_info.add_child(event)
|
2022-10-15 20:56:30 +02:00
|
|
|
event.set_attribute("type", str(achievement.id))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
state = 0x0
|
2022-10-15 20:56:30 +02:00
|
|
|
state = (
|
|
|
|
state + 0x2 if achievement.data.get_bool("is_completed") else 0x0
|
|
|
|
)
|
|
|
|
event.add_child(Node.u8("state", state))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Full combo challenge
|
2022-10-15 20:56:30 +02:00
|
|
|
entry = self.data.local.game.get_time_sensitive_settings(
|
|
|
|
self.game, self.version, "fc_challenge"
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
if entry is None:
|
|
|
|
entry = ValidatedDict()
|
|
|
|
|
|
|
|
# Figure out if we've played these songs
|
2022-10-15 20:56:30 +02:00
|
|
|
start_time, end_time = self.data.local.network.get_schedule_duration("daily")
|
|
|
|
today_attempts = self.data.local.music.get_all_attempts(
|
|
|
|
self.game,
|
|
|
|
self.music_version,
|
|
|
|
userid,
|
|
|
|
entry.get_int("today", -1),
|
|
|
|
timelimit=start_time,
|
|
|
|
)
|
|
|
|
whim_attempts = self.data.local.music.get_all_attempts(
|
|
|
|
self.game,
|
|
|
|
self.music_version,
|
|
|
|
userid,
|
|
|
|
entry.get_int("whim", -1),
|
|
|
|
timelimit=start_time,
|
|
|
|
)
|
|
|
|
|
|
|
|
fc_challenge = Node.void("fc_challenge")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(fc_challenge)
|
2022-10-15 20:56:30 +02:00
|
|
|
today = Node.void("today")
|
2019-12-08 22:43:49 +01:00
|
|
|
fc_challenge.add_child(today)
|
2022-10-15 20:56:30 +02:00
|
|
|
today.add_child(Node.s32("music_id", entry.get_int("today", -1)))
|
|
|
|
today.add_child(Node.u8("state", 0x40 if len(today_attempts) > 0 else 0x0))
|
|
|
|
whim = Node.void("whim")
|
2019-12-08 22:43:49 +01:00
|
|
|
fc_challenge.add_child(whim)
|
2022-10-15 20:56:30 +02:00
|
|
|
whim.add_child(Node.s32("music_id", entry.get_int("whim", -1)))
|
|
|
|
whim.add_child(Node.u8("state", 0x40 if len(whim_attempts) > 0 else 0x0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# No news, ever.
|
2022-10-15 20:56:30 +02:00
|
|
|
news = Node.void("news")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(news)
|
2022-10-15 20:56:30 +02:00
|
|
|
news.add_child(Node.s16("checked", 0))
|
|
|
|
news.add_child(Node.u32("checked_flag", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2020-05-09 00:41:51 +02:00
|
|
|
# Add rivals to profile.
|
2022-10-15 20:56:30 +02:00
|
|
|
rivallist = Node.void("rivallist")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(rivallist)
|
2020-05-09 00:41:51 +02:00
|
|
|
|
|
|
|
links = self.data.local.user.get_links(self.game, self.version, userid)
|
|
|
|
rivalcount = 0
|
|
|
|
for link in links:
|
2022-10-15 20:56:30 +02:00
|
|
|
if link.type != "rival":
|
2020-05-09 00:41:51 +02:00
|
|
|
continue
|
|
|
|
|
|
|
|
rprofile = self.get_profile(link.other_userid)
|
|
|
|
if rprofile is None:
|
|
|
|
continue
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
rival = Node.void("rival")
|
2020-05-09 00:41:51 +02:00
|
|
|
rivallist.add_child(rival)
|
2022-10-15 20:56:30 +02:00
|
|
|
rival.add_child(Node.s32("jid", rprofile.extid))
|
|
|
|
rival.add_child(Node.string("name", rprofile.get_str("name")))
|
2020-05-09 00:41:51 +02:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
rcareerdict = rprofile.get_dict("career")
|
|
|
|
career = Node.void("career")
|
2020-05-09 00:41:51 +02:00
|
|
|
rival.add_child(career)
|
2022-10-15 20:56:30 +02:00
|
|
|
career.add_child(Node.s16("level", rcareerdict.get_int("level", 1)))
|
2020-05-09 00:41:51 +02:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
league = Node.void("league")
|
2020-05-09 00:41:51 +02:00
|
|
|
rival.add_child(league)
|
2022-10-15 20:56:30 +02:00
|
|
|
league.add_child(
|
|
|
|
Node.bool(
|
|
|
|
"is_first_play", rprofile.get_bool("league_is_first_play", True)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
league.add_child(Node.s32("class", rprofile.get_int("league_class", 1)))
|
|
|
|
league.add_child(
|
|
|
|
Node.s32("subclass", rprofile.get_int("league_subclass", 5))
|
|
|
|
)
|
2020-05-09 00:41:51 +02:00
|
|
|
|
|
|
|
# Lazy way of keeping track of rivals, since we can only have 3
|
|
|
|
# or the game with throw up.
|
|
|
|
rivalcount += 1
|
|
|
|
if rivalcount >= 3:
|
|
|
|
break
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
rivallist.set_attribute("count", str(rivalcount))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Nothing in life is free, WTF?
|
2022-10-15 20:56:30 +02:00
|
|
|
free_first_play = Node.void("free_first_play")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(free_first_play)
|
2022-10-15 20:56:30 +02:00
|
|
|
free_first_play.add_child(Node.bool("is_available", False))
|
|
|
|
free_first_play.add_child(Node.s32("point", 0))
|
|
|
|
free_first_play.add_child(Node.s32("point_used", 0))
|
|
|
|
come_come_jbox = Node.void("come_come_jbox")
|
2019-12-08 22:43:49 +01:00
|
|
|
free_first_play.add_child(come_come_jbox)
|
2022-10-15 20:56:30 +02:00
|
|
|
come_come_jbox.add_child(Node.bool("is_valid", False))
|
|
|
|
come_come_jbox.add_child(Node.s64("end_time_if_paired", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# JBox stuff
|
2022-10-15 20:56:30 +02:00
|
|
|
jbox = Node.void("jbox")
|
|
|
|
jboxdict = profile.get_dict("jbox")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(jbox)
|
2022-10-15 20:56:30 +02:00
|
|
|
jbox.add_child(Node.s32("point", jboxdict.get_int("point")))
|
|
|
|
emblem = Node.void("emblem")
|
2019-12-08 22:43:49 +01:00
|
|
|
jbox.add_child(emblem)
|
2022-10-15 20:56:30 +02:00
|
|
|
normal = Node.void("normal")
|
2019-12-08 22:43:49 +01:00
|
|
|
emblem.add_child(normal)
|
2022-10-15 20:56:30 +02:00
|
|
|
premium = Node.void("premium")
|
2019-12-08 22:43:49 +01:00
|
|
|
emblem.add_child(premium)
|
2020-04-24 21:20:43 +02:00
|
|
|
|
|
|
|
# Calculate a random index for normal and premium to give to player
|
|
|
|
# as a gatcha.
|
|
|
|
gameitems = self.data.local.game.get_items(self.game, self.version)
|
|
|
|
normalemblems: Set[int] = set()
|
|
|
|
premiumemblems: Set[int] = set()
|
|
|
|
for gameitem in gameitems:
|
2022-10-15 20:56:30 +02:00
|
|
|
if gameitem.type == "emblem":
|
|
|
|
if gameitem.data.get_int("rarity") in {1, 2, 3}:
|
2020-04-24 21:20:43 +02:00
|
|
|
normalemblems.add(gameitem.id)
|
2022-10-15 20:56:30 +02:00
|
|
|
if gameitem.data.get_int("rarity") in {3, 4, 5}:
|
2020-04-24 21:20:43 +02:00
|
|
|
premiumemblems.add(gameitem.id)
|
|
|
|
|
|
|
|
# Default to some emblems in case the catalog is not available.
|
|
|
|
normalindex = 2
|
|
|
|
premiumindex = 1
|
|
|
|
if normalemblems:
|
|
|
|
normalindex = random.sample(normalemblems, 1)[0]
|
|
|
|
if premiumemblems:
|
|
|
|
premiumindex = random.sample(premiumemblems, 1)[0]
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
normal.add_child(Node.s16("index", normalindex))
|
|
|
|
premium.add_child(Node.s16("index", premiumindex))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Career stuff
|
2022-10-15 20:56:30 +02:00
|
|
|
career = Node.void("career")
|
|
|
|
careerdict = profile.get_dict("career")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(career)
|
2022-10-15 20:56:30 +02:00
|
|
|
career.add_child(Node.s16("level", careerdict.get_int("level", 1)))
|
|
|
|
career.add_child(Node.s32("point", careerdict.get_int("point")))
|
|
|
|
career.add_child(
|
|
|
|
Node.s32_array("param", careerdict.get_int_array("param", 10, [-1] * 10))
|
|
|
|
)
|
|
|
|
career.add_child(Node.bool("is_unlocked", careerdict.get_bool("is_unlocked")))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# League stuff
|
2022-10-15 20:56:30 +02:00
|
|
|
league = Node.void("league")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(league)
|
2022-10-15 20:56:30 +02:00
|
|
|
league.add_child(
|
|
|
|
Node.bool("is_first_play", profile.get_bool("league_is_first_play", True))
|
|
|
|
)
|
|
|
|
league.add_child(Node.s32("class", profile.get_int("league_class", 1)))
|
|
|
|
league.add_child(Node.s32("subclass", profile.get_int("league_subclass", 5)))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# New Music stuff
|
2022-10-15 20:56:30 +02:00
|
|
|
new_music = Node.void("new_music")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(new_music)
|
|
|
|
|
|
|
|
# Emblem list stuff?
|
2022-10-15 20:56:30 +02:00
|
|
|
eapass_privilege = Node.void("eapass_privilege")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(eapass_privilege)
|
2022-10-15 20:56:30 +02:00
|
|
|
emblem_list = Node.void("emblem_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
eapass_privilege.add_child(emblem_list)
|
|
|
|
|
|
|
|
# Bonus music stuff?
|
2022-10-15 20:56:30 +02:00
|
|
|
bonus_music = Node.void("bonus_music")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(bonus_music)
|
2022-10-15 20:56:30 +02:00
|
|
|
bonus_music.add_child(Node.void("music"))
|
|
|
|
bonus_music.add_child(Node.s32("event_id", -1))
|
|
|
|
bonus_music.add_child(Node.string("till_time", ""))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Bistro stuff is back?
|
2022-10-15 20:56:30 +02:00
|
|
|
bistro = Node.void("bistro")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(bistro)
|
2022-10-15 20:56:30 +02:00
|
|
|
chef = Node.void("chef")
|
2019-12-08 22:43:49 +01:00
|
|
|
bistro.add_child(chef)
|
2022-10-15 20:56:30 +02:00
|
|
|
chef.add_child(Node.s32("id", 1))
|
|
|
|
bistro.add_child(Node.s32("carry_over", 0))
|
|
|
|
route_list = Node.void("route_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
bistro.add_child(route_list)
|
2022-10-15 20:56:30 +02:00
|
|
|
route_list.add_child(Node.u8("route_count", 0))
|
2019-12-08 22:43:49 +01:00
|
|
|
# If we have routes, they look like this:
|
|
|
|
# <route>
|
|
|
|
# <no __type="u8">#</no>
|
|
|
|
# <content kind="?">
|
|
|
|
# <value __type="s32">??</value>
|
|
|
|
# </content>
|
|
|
|
# <gourmates>
|
|
|
|
# <id __type="s32">??</id>
|
|
|
|
# </gourmates>
|
2022-10-15 20:56:30 +02:00
|
|
|
bistro.add_child(Node.bool("extension", False))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Gift list, maybe from other players?
|
2022-10-15 20:56:30 +02:00
|
|
|
gift_list = Node.void("gift_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(gift_list)
|
|
|
|
# If we had gifts, they look like this:
|
|
|
|
# <gift reason="??" kind="??">
|
|
|
|
# <id __type="s32">??</id>
|
|
|
|
# </gift>
|
|
|
|
|
|
|
|
return root
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
def unformat_profile(
|
|
|
|
self, userid: UserID, request: Node, oldprofile: Profile
|
|
|
|
) -> Profile:
|
2021-09-07 19:56:15 +02:00
|
|
|
newprofile = oldprofile.clone()
|
2022-10-15 20:56:30 +02:00
|
|
|
newprofile.replace_bool("saved", True)
|
|
|
|
data = request.child("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab system information
|
2022-10-15 20:56:30 +02:00
|
|
|
sysinfo = data.child("info")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab player information
|
2022-10-15 20:56:30 +02:00
|
|
|
player = data.child("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab result information
|
2022-10-15 20:56:30 +02:00
|
|
|
result = data.child("result")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab last information. Lots of this will be filled in while grabbing scores
|
2022-10-15 20:56:30 +02:00
|
|
|
last = newprofile.get_dict("last")
|
2019-12-08 22:43:49 +01:00
|
|
|
if sysinfo is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
last.replace_int("play_time", sysinfo.child_value("time_gameend"))
|
|
|
|
last.replace_str("shopname", sysinfo.child_value("shopname"))
|
|
|
|
last.replace_str("areaname", sysinfo.child_value("areaname"))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab player info for echoing back
|
2022-10-15 20:56:30 +02:00
|
|
|
info = player.child("info")
|
2019-12-08 22:43:49 +01:00
|
|
|
if info is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
newprofile.replace_int("jubility", info.child_value("jubility"))
|
|
|
|
newprofile.replace_int("jubility_yday", info.child_value("jubility_yday"))
|
|
|
|
newprofile.replace_int("tune_cnt", info.child_value("tune_cnt"))
|
|
|
|
newprofile.replace_int("save_cnt", info.child_value("save_cnt"))
|
|
|
|
newprofile.replace_int("saved_cnt", info.child_value("saved_cnt"))
|
|
|
|
newprofile.replace_int("fc_cnt", info.child_value("fc_cnt"))
|
|
|
|
newprofile.replace_int("ex_cnt", info.child_value("ex_cnt"))
|
|
|
|
newprofile.replace_int("pf_cnt", info.child_value("pf_cnt"))
|
|
|
|
newprofile.replace_int("clear_cnt", info.child_value("clear_cnt"))
|
|
|
|
newprofile.replace_int("match_cnt", info.child_value("match_cnt"))
|
|
|
|
newprofile.replace_int("beat_cnt", info.child_value("beat_cnt"))
|
|
|
|
newprofile.replace_int(
|
|
|
|
"total_best_score", info.child_value("total_best_score")
|
|
|
|
)
|
|
|
|
newprofile.replace_int("mynews_cnt", info.child_value("mynews_cnt"))
|
|
|
|
|
|
|
|
newprofile.replace_int(
|
|
|
|
"bonus_tune_points", info.child_value("bonus_tune_points")
|
|
|
|
)
|
|
|
|
newprofile.replace_bool(
|
|
|
|
"is_bonus_tune_played", info.child_value("is_bonus_tune_played")
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab last settings (finally mostly in its own node!)
|
2022-10-15 20:56:30 +02:00
|
|
|
lastnode = player.child("last")
|
2019-12-08 22:43:49 +01:00
|
|
|
if lastnode is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
last.replace_int("expert_option", lastnode.child_value("expert_option"))
|
|
|
|
last.replace_int("sort", lastnode.child_value("sort"))
|
|
|
|
last.replace_int("category", lastnode.child_value("category"))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
settings = lastnode.child("settings")
|
2019-12-08 22:43:49 +01:00
|
|
|
if settings is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
last.replace_int("matching", settings.child_value("matching"))
|
|
|
|
last.replace_int("hazard", settings.child_value("hazard"))
|
|
|
|
last.replace_int("hard", settings.child_value("hard"))
|
|
|
|
last.replace_int("marker", settings.child_value("marker"))
|
|
|
|
last.replace_int("theme", settings.child_value("theme"))
|
|
|
|
last.replace_int("title", settings.child_value("title"))
|
|
|
|
last.replace_int("parts", settings.child_value("parts"))
|
|
|
|
last.replace_int("rank_sort", settings.child_value("rank_sort"))
|
|
|
|
last.replace_int("combo_disp", settings.child_value("combo_disp"))
|
|
|
|
last.replace_int_array("emblem", 5, settings.child_value("emblem"))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Grab unlock progress
|
2022-10-15 20:56:30 +02:00
|
|
|
item = player.child("item")
|
2019-12-08 22:43:49 +01:00
|
|
|
if item is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
newprofile.replace_int_array(
|
|
|
|
"secret_list", 32, item.child_value("secret_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int_array(
|
|
|
|
"title_list", 160, item.child_value("title_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int("theme_list", item.child_value("theme_list"))
|
|
|
|
newprofile.replace_int_array(
|
|
|
|
"marker_list", 2, item.child_value("marker_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int_array(
|
|
|
|
"parts_list", 160, item.child_value("parts_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int_array(
|
|
|
|
"music_list", 32, item.child_value("music_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int_array(
|
|
|
|
"emblem_list", 96, item.child_value("emblem_list")
|
|
|
|
)
|
|
|
|
|
|
|
|
newitem = item.child("new")
|
2019-12-08 22:43:49 +01:00
|
|
|
if newitem is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
newprofile.replace_int_array(
|
|
|
|
"secret_list_new", 32, newitem.child_value("secret_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int(
|
|
|
|
"theme_list_new", newitem.child_value("theme_list")
|
|
|
|
)
|
|
|
|
newprofile.replace_int_array(
|
|
|
|
"marker_list_new", 2, newitem.child_value("marker_list")
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Career progression
|
2022-10-15 20:56:30 +02:00
|
|
|
career = player.child("career")
|
|
|
|
careerdict = newprofile.get_dict("career")
|
2019-12-08 22:43:49 +01:00
|
|
|
if career is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
careerdict.replace_int("level", career.child_value("level"))
|
|
|
|
careerdict.replace_int("point", career.child_value("point"))
|
|
|
|
careerdict.replace_int_array("param", 10, career.child_value("param"))
|
|
|
|
careerdict.replace_bool("is_unlocked", career.child_value("is_unlocked"))
|
|
|
|
newprofile.replace_dict("career", careerdict)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# jbox stuff
|
2022-10-15 20:56:30 +02:00
|
|
|
jbox = player.child("jbox")
|
|
|
|
jboxdict = newprofile.get_dict("jbox")
|
2019-12-08 22:43:49 +01:00
|
|
|
if jbox is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
jboxdict.replace_int("point", jbox.child_value("point"))
|
|
|
|
emblemtype = jbox.child_value("emblem/type")
|
|
|
|
index = jbox.child_value("emblem/index")
|
2019-12-08 22:43:49 +01:00
|
|
|
if emblemtype == self.JBOX_EMBLEM_NORMAL:
|
2022-10-15 20:56:30 +02:00
|
|
|
jboxdict.replace_int("normal_index", index)
|
2019-12-08 22:43:49 +01:00
|
|
|
elif emblemtype == self.JBOX_EMBLEM_PREMIUM:
|
2022-10-15 20:56:30 +02:00
|
|
|
jboxdict.replace_int("premium_index", index)
|
|
|
|
newprofile.replace_dict("jbox", jboxdict)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# event stuff
|
2022-10-15 20:56:30 +02:00
|
|
|
event_info = player.child("event_info")
|
2019-12-08 22:43:49 +01:00
|
|
|
if event_info is not None:
|
|
|
|
for child in event_info.children:
|
|
|
|
try:
|
2022-10-15 20:56:30 +02:00
|
|
|
eventid = int(child.attribute("type"))
|
2019-12-08 22:43:49 +01:00
|
|
|
except TypeError:
|
|
|
|
# Event is empty
|
|
|
|
continue
|
2022-10-15 20:56:30 +02:00
|
|
|
is_completed = child.child_value("is_completed")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Figure out if we should update the rating/scores or not
|
|
|
|
oldevent = self.data.local.user.get_achievement(
|
|
|
|
self.game,
|
|
|
|
self.version,
|
|
|
|
userid,
|
|
|
|
eventid,
|
2022-10-15 20:56:30 +02:00
|
|
|
"event",
|
2019-12-08 22:43:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if oldevent is None:
|
|
|
|
# Create a new event structure for this
|
|
|
|
oldevent = ValidatedDict()
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
oldevent.replace_bool("is_completed", is_completed)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Save it as an achievement
|
|
|
|
self.data.local.user.put_achievement(
|
|
|
|
self.game,
|
|
|
|
self.version,
|
|
|
|
userid,
|
|
|
|
eventid,
|
2022-10-15 20:56:30 +02:00
|
|
|
"event",
|
2019-12-08 22:43:49 +01:00
|
|
|
oldevent,
|
|
|
|
)
|
|
|
|
|
|
|
|
# A whole bunch of miscelaneous shit
|
2022-10-15 20:56:30 +02:00
|
|
|
newprofile.replace_int("navi_flag", player.child_value("navi/flag"))
|
|
|
|
newprofile.replace_int(
|
|
|
|
"kaitou_bisco_read_flag", player.child_value("kaitou_bisco/read_flag")
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Get timestamps for played songs
|
|
|
|
timestamps: Dict[int, int] = {}
|
2022-10-15 20:56:30 +02:00
|
|
|
history = player.child("history")
|
2019-12-08 22:43:49 +01:00
|
|
|
if history is not None:
|
|
|
|
for tune in history.children:
|
2022-10-15 20:56:30 +02:00
|
|
|
if tune.name != "tune":
|
2019-12-08 22:43:49 +01:00
|
|
|
continue
|
2022-10-15 20:56:30 +02:00
|
|
|
entry = int(tune.attribute("log_id"))
|
|
|
|
ts = int(tune.child_value("timestamp") / 1000)
|
2019-12-08 22:43:49 +01:00
|
|
|
timestamps[entry] = ts
|
|
|
|
|
|
|
|
# Grab scores and save those
|
|
|
|
if result is not None:
|
|
|
|
for tune in result.children:
|
2022-10-15 20:56:30 +02:00
|
|
|
if tune.name != "tune":
|
2019-12-08 22:43:49 +01:00
|
|
|
continue
|
2022-10-15 20:56:30 +02:00
|
|
|
result = tune.child("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
entry = int(tune.attribute("id"))
|
|
|
|
songid = tune.child_value("music")
|
2019-12-08 22:43:49 +01:00
|
|
|
timestamp = timestamps.get(entry, Time.now())
|
2022-10-15 20:56:30 +02:00
|
|
|
chart = int(result.child("score").attribute("seq"))
|
|
|
|
points = result.child_value("score")
|
|
|
|
flags = int(result.child("score").attribute("clear"))
|
|
|
|
combo = int(result.child("score").attribute("combo"))
|
|
|
|
ghost = result.child_value("mbar")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Miscelaneous last data for echoing to profile get
|
2022-10-15 20:56:30 +02:00
|
|
|
last.replace_int("music_id", songid)
|
|
|
|
last.replace_int("seq_id", chart)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
mapping = {
|
|
|
|
self.GAME_FLAG_BIT_CLEARED: self.PLAY_MEDAL_CLEARED,
|
|
|
|
self.GAME_FLAG_BIT_FULL_COMBO: self.PLAY_MEDAL_FULL_COMBO,
|
|
|
|
self.GAME_FLAG_BIT_EXCELLENT: self.PLAY_MEDAL_EXCELLENT,
|
|
|
|
self.GAME_FLAG_BIT_NEARLY_FULL_COMBO: self.PLAY_MEDAL_NEARLY_FULL_COMBO,
|
|
|
|
self.GAME_FLAG_BIT_NEARLY_EXCELLENT: self.PLAY_MEDAL_NEARLY_EXCELLENT,
|
|
|
|
}
|
|
|
|
|
|
|
|
# Figure out the highest medal based on bits passed in
|
|
|
|
medal = self.PLAY_MEDAL_FAILED
|
|
|
|
for bit in mapping:
|
|
|
|
if flags & bit > 0:
|
|
|
|
medal = max(medal, mapping[bit])
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
self.update_score(
|
|
|
|
userid, timestamp, songid, chart, points, medal, combo, ghost
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# If this was a course save, grab and save that info too
|
2022-10-15 20:56:30 +02:00
|
|
|
course = player.child("course")
|
2019-12-08 22:43:49 +01:00
|
|
|
if course is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
courseid = course.child_value("course_id")
|
2019-12-08 22:43:49 +01:00
|
|
|
rating = {
|
|
|
|
self.GAME_COURSE_RATING_FAILED: self.COURSE_RATING_FAILED,
|
|
|
|
self.GAME_COURSE_RATING_BRONZE: self.COURSE_RATING_BRONZE,
|
|
|
|
self.GAME_COURSE_RATING_SILVER: self.COURSE_RATING_SILVER,
|
|
|
|
self.GAME_COURSE_RATING_GOLD: self.COURSE_RATING_GOLD,
|
2022-10-15 20:56:30 +02:00
|
|
|
}[course.child_value("rating")]
|
2019-12-08 22:43:49 +01:00
|
|
|
scores = [0] * 5
|
|
|
|
for music in course.children:
|
2022-10-15 20:56:30 +02:00
|
|
|
if music.name != "music":
|
2019-12-08 22:43:49 +01:00
|
|
|
continue
|
2022-10-15 20:56:30 +02:00
|
|
|
index = int(music.attribute("index"))
|
|
|
|
scores[index] = music.child_value("score")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Save course itself
|
|
|
|
self.save_course(userid, courseid, rating, scores)
|
|
|
|
|
|
|
|
# Save the last course ID
|
2022-10-15 20:56:30 +02:00
|
|
|
last.replace_int("last_course_id", courseid)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# If this was a league save, grab and save that info too
|
2022-10-15 20:56:30 +02:00
|
|
|
league = player.child("league")
|
2019-12-08 22:43:49 +01:00
|
|
|
if league is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
leagueid = league.child_value("league_id")
|
|
|
|
newprofile.replace_bool(
|
|
|
|
"league_is_checked", league.child_value("is_checked")
|
|
|
|
)
|
|
|
|
newprofile.replace_bool(
|
|
|
|
"league_is_first_play", league.child_value("is_first_play")
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Extract scores
|
|
|
|
score = [0] * 3
|
|
|
|
clear = [0] * 3
|
|
|
|
for music in league.children:
|
2022-10-15 20:56:30 +02:00
|
|
|
if music.name != "music":
|
2019-12-08 22:43:49 +01:00
|
|
|
continue
|
2022-10-15 20:56:30 +02:00
|
|
|
index = int(music.attribute("index"))
|
|
|
|
scorenode = music.child("score")
|
|
|
|
clear[index] = int(scorenode.attribute("clear"))
|
2019-12-08 22:43:49 +01:00
|
|
|
score[index] = scorenode.value
|
|
|
|
|
|
|
|
# Update score if it is higher
|
|
|
|
oldleague = self.data.local.user.get_achievement(
|
|
|
|
self.game,
|
|
|
|
self.version,
|
|
|
|
userid,
|
|
|
|
leagueid,
|
2022-10-15 20:56:30 +02:00
|
|
|
"league",
|
2019-12-08 22:43:49 +01:00
|
|
|
)
|
|
|
|
if oldleague is None:
|
|
|
|
oldleague = ValidatedDict()
|
2022-10-15 20:56:30 +02:00
|
|
|
oldscore = oldleague.get_int_array("score", 3)
|
2019-12-08 22:43:49 +01:00
|
|
|
if sum(oldscore) < sum(score):
|
|
|
|
self.data.local.user.put_achievement(
|
|
|
|
self.game,
|
|
|
|
self.version,
|
|
|
|
userid,
|
|
|
|
leagueid,
|
2022-10-15 20:56:30 +02:00
|
|
|
"league",
|
|
|
|
{"score": score, "clear": clear},
|
2019-12-08 22:43:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Save back last information gleaned from results
|
2022-10-15 20:56:30 +02:00
|
|
|
newprofile.replace_dict("last", last)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Keep track of play statistics
|
|
|
|
self.update_play_statistics(userid)
|
|
|
|
|
|
|
|
return newprofile
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
def format_scores(
|
|
|
|
self, userid: UserID, profile: Profile, scores: List[Score]
|
|
|
|
) -> Node:
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("gametop")
|
|
|
|
datanode = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
root.add_child(datanode)
|
2022-10-15 20:56:30 +02:00
|
|
|
player = Node.void("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
datanode.add_child(player)
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.s32("jid", profile.extid))
|
|
|
|
playdata = Node.void("mdata_list")
|
2019-12-08 22:43:49 +01:00
|
|
|
player.add_child(playdata)
|
|
|
|
|
|
|
|
music = ValidatedDict()
|
|
|
|
for score in scores:
|
2022-09-23 02:52:34 +02:00
|
|
|
# Ignore festo-and-above chart types.
|
2022-10-15 20:56:30 +02:00
|
|
|
if score.chart not in {
|
|
|
|
self.CHART_TYPE_BASIC,
|
|
|
|
self.CHART_TYPE_ADVANCED,
|
|
|
|
self.CHART_TYPE_EXTREME,
|
|
|
|
}:
|
2022-09-23 02:52:34 +02:00
|
|
|
continue
|
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
data = music.get_dict(str(score.id))
|
2022-10-15 20:56:30 +02:00
|
|
|
play_cnt = data.get_int_array("play_cnt", 3)
|
|
|
|
clear_cnt = data.get_int_array("clear_cnt", 3)
|
|
|
|
clear_flags = data.get_int_array("clear_flags", 3)
|
|
|
|
fc_cnt = data.get_int_array("fc_cnt", 3)
|
|
|
|
ex_cnt = data.get_int_array("ex_cnt", 3)
|
|
|
|
points = data.get_int_array("points", 3)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Replace data for this chart type
|
|
|
|
play_cnt[score.chart] = score.plays
|
2022-10-15 20:56:30 +02:00
|
|
|
clear_cnt[score.chart] = score.data.get_int("clear_count")
|
|
|
|
fc_cnt[score.chart] = score.data.get_int("full_combo_count")
|
|
|
|
ex_cnt[score.chart] = score.data.get_int("excellent_count")
|
2019-12-08 22:43:49 +01:00
|
|
|
points[score.chart] = score.points
|
|
|
|
|
|
|
|
# Format the clear flags
|
|
|
|
clear_flags[score.chart] = self.GAME_FLAG_BIT_PLAYED
|
2022-10-15 20:56:30 +02:00
|
|
|
if score.data.get_int("clear_count") > 0:
|
2019-12-08 22:43:49 +01:00
|
|
|
clear_flags[score.chart] |= self.GAME_FLAG_BIT_CLEARED
|
2022-10-15 20:56:30 +02:00
|
|
|
if score.data.get_int("full_combo_count") > 0:
|
2019-12-08 22:43:49 +01:00
|
|
|
clear_flags[score.chart] |= self.GAME_FLAG_BIT_FULL_COMBO
|
2022-10-15 20:56:30 +02:00
|
|
|
if score.data.get_int("excellent_count") > 0:
|
2019-12-08 22:43:49 +01:00
|
|
|
clear_flags[score.chart] |= self.GAME_FLAG_BIT_EXCELLENT
|
|
|
|
|
|
|
|
# Save chart data back
|
2022-10-15 20:56:30 +02:00
|
|
|
data.replace_int_array("play_cnt", 3, play_cnt)
|
|
|
|
data.replace_int_array("clear_cnt", 3, clear_cnt)
|
|
|
|
data.replace_int_array("clear_flags", 3, clear_flags)
|
|
|
|
data.replace_int_array("fc_cnt", 3, fc_cnt)
|
|
|
|
data.replace_int_array("ex_cnt", 3, ex_cnt)
|
|
|
|
data.replace_int_array("points", 3, points)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Update the ghost (untyped)
|
2022-10-15 20:56:30 +02:00
|
|
|
ghost = data.get("ghost", [None, None, None])
|
|
|
|
ghost[score.chart] = score.data.get("ghost")
|
|
|
|
data["ghost"] = ghost
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Save it back
|
|
|
|
music.replace_dict(str(score.id), data)
|
|
|
|
|
|
|
|
for scoreid in music:
|
|
|
|
scoredata = music[scoreid]
|
2022-10-15 20:56:30 +02:00
|
|
|
musicdata = Node.void("musicdata")
|
2019-12-08 22:43:49 +01:00
|
|
|
playdata.add_child(musicdata)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
musicdata.set_attribute("music_id", scoreid)
|
|
|
|
musicdata.add_child(
|
|
|
|
Node.s32_array("play_cnt", scoredata.get_int_array("play_cnt", 3))
|
|
|
|
)
|
|
|
|
musicdata.add_child(
|
|
|
|
Node.s32_array("clear_cnt", scoredata.get_int_array("clear_cnt", 3))
|
|
|
|
)
|
|
|
|
musicdata.add_child(
|
|
|
|
Node.s32_array("fc_cnt", scoredata.get_int_array("fc_cnt", 3))
|
|
|
|
)
|
|
|
|
musicdata.add_child(
|
|
|
|
Node.s32_array("ex_cnt", scoredata.get_int_array("ex_cnt", 3))
|
|
|
|
)
|
|
|
|
musicdata.add_child(
|
|
|
|
Node.s32_array("score", scoredata.get_int_array("points", 3))
|
|
|
|
)
|
|
|
|
musicdata.add_child(
|
|
|
|
Node.s8_array("clear", scoredata.get_int_array("clear_flags", 3))
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
ghosts = scoredata.get("ghost", [None, None, None])
|
2019-12-08 22:43:49 +01:00
|
|
|
for i in range(len(ghosts)):
|
|
|
|
ghost = ghosts[i]
|
|
|
|
if ghost is None:
|
|
|
|
continue
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
bar = Node.u8_array("bar", ghost)
|
2019-12-08 22:43:49 +01:00
|
|
|
musicdata.add_child(bar)
|
2022-10-15 20:56:30 +02:00
|
|
|
bar.set_attribute("seq", str(i))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
return root
|