From b9e35aabf90d9ff4e9b434247e65f95d9e5f0f0e Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 24 Apr 2020 19:20:43 +0000 Subject: [PATCH] Implement gacha mode for emblems instead of just going up the list of possible emblems. --- bemani/backend/jubeat/clan.py | 29 +++++++++++++++++++++++++---- bemani/backend/jubeat/prop.py | 31 ++++++++++++++++++++++++++----- bemani/backend/jubeat/qubell.py | 31 ++++++++++++++++++++++++++----- 3 files changed, 77 insertions(+), 14 deletions(-) diff --git a/bemani/backend/jubeat/clan.py b/bemani/backend/jubeat/clan.py index b2fb2bc..b859d8b 100644 --- a/bemani/backend/jubeat/clan.py +++ b/bemani/backend/jubeat/clan.py @@ -788,8 +788,8 @@ class JubeatClan( emblem.add_child(normal) premium = Node.void('premium') emblem.add_child(premium) - normal.add_child(Node.s16('index', 0)) - premium.add_child(Node.s16('index', 0)) + normal.add_child(Node.s16('index', 2)) + premium.add_child(Node.s16('index', 1)) born = Node.void('born') info.add_child(born) @@ -1342,8 +1342,29 @@ class JubeatClan( emblem.add_child(normal) premium = Node.void('premium') emblem.add_child(premium) - normal.add_child(Node.s16('index', jboxdict.get_int('normal_index') + 1)) - premium.add_child(Node.s16('index', jboxdict.get_int('premium_index') + 1)) + + # 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: + if gameitem.type == 'emblem': + if gameitem.data.get_int('rarity') in {1, 2, 3}: + normalemblems.add(gameitem.id) + if gameitem.data.get_int('rarity') in {3, 4, 5}: + 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] + + normal.add_child(Node.s16('index', normalindex)) + premium.add_child(Node.s16('index', premiumindex)) # New Music stuff new_music = Node.void('new_music') diff --git a/bemani/backend/jubeat/prop.py b/bemani/backend/jubeat/prop.py index 4c8bbe0..cb025cd 100644 --- a/bemani/backend/jubeat/prop.py +++ b/bemani/backend/jubeat/prop.py @@ -2,7 +2,7 @@ import copy import math import random -from typing import Optional, Dict, List, Any, Tuple +from typing import Optional, Dict, List, Any, Set, Tuple from bemani.backend.base import Status from bemani.backend.jubeat.common import ( @@ -486,8 +486,8 @@ class JubeatProp( emblem.add_child(normal) premium = Node.void('premium') emblem.add_child(premium) - normal.add_child(Node.s16('index', 0)) - premium.add_child(Node.s16('index', 0)) + normal.add_child(Node.s16('index', 2)) + premium.add_child(Node.s16('index', 1)) return info @@ -950,8 +950,29 @@ class JubeatProp( emblem.add_child(normal) premium = Node.void('premium') emblem.add_child(premium) - normal.add_child(Node.s16('index', jboxdict.get_int('normal_index') + 1)) - premium.add_child(Node.s16('index', jboxdict.get_int('premium_index') + 1)) + + # 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: + if gameitem.type == 'emblem': + if gameitem.data.get_int('rarity') in {1, 2, 3}: + normalemblems.add(gameitem.id) + if gameitem.data.get_int('rarity') in {3, 4, 5}: + 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] + + normal.add_child(Node.s16('index', normalindex)) + premium.add_child(Node.s16('index', premiumindex)) # Career stuff career = Node.void('career') diff --git a/bemani/backend/jubeat/qubell.py b/bemani/backend/jubeat/qubell.py index 92a822d..c6f5730 100644 --- a/bemani/backend/jubeat/qubell.py +++ b/bemani/backend/jubeat/qubell.py @@ -1,7 +1,7 @@ # vim: set fileencoding=utf-8 import copy import random -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Optional, Set, Tuple from bemani.backend.base import Status from bemani.backend.jubeat.base import JubeatBase @@ -214,8 +214,8 @@ class JubeatQubell( emblem.add_child(normal) premium = Node.void('premium') emblem.add_child(premium) - normal.add_child(Node.s16('index', 0)) - premium.add_child(Node.s16('index', 0)) + normal.add_child(Node.s16('index', 2)) + premium.add_child(Node.s16('index', 1)) born = Node.void('born') info.add_child(born) @@ -659,8 +659,29 @@ class JubeatQubell( emblem.add_child(normal) premium = Node.void('premium') emblem.add_child(premium) - normal.add_child(Node.s16('index', jboxdict.get_int('normal_index') + 1)) - premium.add_child(Node.s16('index', jboxdict.get_int('premium_index') + 1)) + + # 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: + if gameitem.type == 'emblem': + if gameitem.data.get_int('rarity') in {1, 2, 3}: + normalemblems.add(gameitem.id) + if gameitem.data.get_int('rarity') in {3, 4, 5}: + 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] + + normal.add_child(Node.s16('index', normalindex)) + premium.add_child(Node.s16('index', premiumindex)) # Digdig stuff digdig = Node.void('digdig')