1
0
mirror of synced 2025-02-17 11:18:33 +01:00

Make frontend smart enough to only show emblem items that you have earned.

This commit is contained in:
Jennifer Taylor 2022-11-13 00:21:26 +00:00
parent 6de1cd7e6d
commit d85ccea865
2 changed files with 24 additions and 13 deletions

View File

@ -143,11 +143,26 @@ class JubeatFrontend(FrontendBase):
def format_profile(
self, profile: Profile, playstats: ValidatedDict
) -> Dict[str, Any]:
# Grab achievements for both jubility in festo, as well as emblem parts in
# prop onward.
userid = self.data.local.user.from_refid(
profile.game, profile.version, profile.refid
)
if userid is not None:
achievements = self.data.local.user.get_achievements(
profile.game, profile.version, userid
)
else:
achievements = []
formatted_profile = super().format_profile(profile, playstats)
formatted_profile["plays"] = playstats.get_int("total_plays")
formatted_profile["emblem"] = self.format_emblem(
profile.get_dict("last").get_int_array("emblem", 5)
)
formatted_profile["owned_emblems"] = [
ach.id for ach in achievements if ach.type == "emblem"
]
formatted_profile["jubility"] = (
profile.get_int("jubility")
if profile.version
@ -181,16 +196,6 @@ class JubeatFrontend(FrontendBase):
# Look up achievements which is where jubility was stored. This is a bit of a hack
# due to the fact that this could be formatting remote profiles, but then they should
# have no achievements.
userid = self.data.local.user.from_refid(
profile.game, profile.version, profile.refid
)
if userid is not None:
achievements = self.data.local.user.get_achievements(
profile.game, profile.version, userid
)
else:
achievements = []
jubeat_entries: List[ValidatedDict] = []
for achievement in achievements:
if achievement.type != "jubility":

View File

@ -163,8 +163,14 @@ var settings_view = createReactClass({
var player = this.state.player[this.state.version]
var layer = valid_emblem_options.indexOf(emblem_option) + 1
var items = window.emblems[this.state.version].filter(function (emblem) {
return emblem.layer == layer
});
return (
emblem.layer == layer &&
(
this.state.player[this.state.version].owned_emblems.indexOf(emblem.index) >= 0 ||
emblem.rarity == 1 && emblem.layer == 2
)
);
}.bind(this));
var results = {};
items
.map(function(item) { return { 'index': item.index, 'name': `${item.name} (★${item.rarity})` } })
@ -244,7 +250,7 @@ var settings_view = createReactClass({
{this.renderName(player)}
</div>
{
this.state.version > 9 ? this.renderEmblem(player) : null
(this.state.version > 9 && window.emblems[this.state.version].length > 0) ? this.renderEmblem(player) : null
}
</div>
);