예제 #1
0
    def from_eem(eem: ExtraEggMachine, server: Server) -> 'EggMachine':
        if eem.egg_machine_type == 1:  # REM
            egg_machine_type_id = 2
        elif eem.egg_machine_type == 2:  # PEM
            egg_machine_type_id = 1
        else:  # Special (collab or other)
            egg_machine_type_id = 0

        id_mapper = server_monster_id_fn(server)
        content_map = {
            '({})'.format(id_mapper(k)): v
            for k, v in eem.contents.items()
        }
        contents = json.dumps(content_map, sort_keys=True)

        return EggMachine(
            egg_machine_id=None,  # Key that is looked up or inserted
            server_id=server.value,
            egg_machine_type_id=egg_machine_type_id,
            start_timestamp=eem.start_timestamp,
            end_timestamp=eem.end_timestamp,
            machine_row=eem.egg_machine_row,
            machine_type=eem.egg_machine_type,
            name=eem.clean_name,
            cost=eem.cost,
            contents=contents)
예제 #2
0
 def from_raw_purchase(o: "Purchase"):
     id_mapper = server_monster_id_fn(o.server)
     target_monster_id = id_mapper(o.monster_id)
     permanent = int(
         timedelta(seconds=(o.end_timestamp -
                            o.start_timestamp)) > timedelta(days=60))
     return Purchase(server_id=o.server.value,
                     target_monster_id=target_monster_id,
                     mp_cost=o.cost,
                     amount=o.amount,
                     start_timestamp=o.start_timestamp,
                     end_timestamp=o.end_timestamp,
                     permanent=permanent)
예제 #3
0
    def __init__(
            self,
            id: int = None,
            pull_id: int = None,
            entry_id: int = None,
            server: str = None,
            dungeon_id: int = None,
            floor_id: int = None,
            stage: int = None,
            slot: int = None,
            spawn_type: int = None,
            monster_id: int = None,
            monster_level: int = None,
            drop_monster_id: int = None,
            drop_monster_level: int = None,
            plus_amount: int = None,
            monster: wave_data.WaveMonster = None,
            pull_time=None,  # Ignored
            leader_id: int = None,
            friend_id: int = None):
        self.id = id
        self.server = server
        self.dungeon_id = dungeon_id
        self.floor_id = floor_id  # ID starts at 1 for lowest
        self.stage = stage  # 0-indexed
        self.slot = slot  # 0-indexed

        self.spawn_type = spawn_type
        self.monster_id = monster_id
        self.monster_level = monster_level

        # If drop_monster_id == 9900, then drop_monster_level is the bonus gold amount
        self.drop_monster_id = drop_monster_id
        self.drop_monster_level = drop_monster_level
        self.plus_amount = plus_amount

        if monster:
            self.spawn_type = monster.spawn_type
            # Need to correct the drop/spawn IDs for NA vs JP
            mapping_fn = server_monster_id_fn(Server.from_str(self.server))
            self.monster_id = mapping_fn(monster.monster_id)
            self.monster_level = monster.monster_level
            self.drop_monster_id = mapping_fn(monster.drop_monster_id)
            self.drop_monster_level = monster.drop_monster_level
            self.plus_amount = monster.plus_amount

        self.pull_id = pull_id
        self.entry_id = entry_id

        self.leader_id = leader_id
        self.friend_id = friend_id
예제 #4
0
    def process(self, db: DbWrapper):
        for server, egg_machine_list in self.egg_machines.items():
            logger.debug('Process {} egg machines'.format(server.name.upper()))
            for egg_machine in egg_machine_list:
                item = EggMachine.from_eem(egg_machine, server)
                egg_machine_id = db.insert_or_update(item)

                # process contents of the eggmachines
                id_mapper = server_monster_id_fn(server)
                monsters = [
                    EggMachinesMonster(egg_machine_monster_id=None,
                                       monster_id=id_mapper(k),
                                       roll_chance=v,
                                       egg_machine_id=egg_machine_id)
                    for k, v in egg_machine.contents.items()
                ]
                for emm in monsters:
                    db.insert_or_update(emm)
예제 #5
0
    def __init__(self, server: Server, card: Card, active_skill: ActiveSkill,
                 leader_skill: LeaderSkill, enemy_skills: List[ESInstance]):
        self.server = server
        self.id_mapper = server_monster_id_fn(self.server)
        self.monster_no = card.monster_no
        self.monster_id = self.no_to_id(card.monster_no)
        self.card = card

        self.linked_monster_id = None  # type: Optional[int]
        if self.card.linked_monster_no:
            self.linked_monster_id = self.no_to_id(card.linked_monster_no)

        self.active_skill_id = active_skill.skill_id if active_skill else None
        self.active_skill = active_skill

        self.leader_skill_id = leader_skill.skill_id if leader_skill else None
        self.leader_skill = leader_skill

        self.enemy_skills = enemy_skills
예제 #6
0
 def from_raw_exchange(o):
     id_mapper = server_monster_id_fn(o.server)
     target_monster_id = id_mapper(o.monster_id)
     req_monster_csv_str = ','.join(
         ['({})'.format(id_mapper(idx)) for idx in o.required_monsters])
     permanent = int(
         timedelta(seconds=(o.end_timestamp -
                            o.start_timestamp)) > timedelta(days=60))
     return Exchange(trade_id=o.trade_id,
                     server_id=o.server.value,
                     target_monster_id=target_monster_id,
                     required_monster_ids=req_monster_csv_str,
                     required_count=o.required_count,
                     start_timestamp=o.start_timestamp,
                     end_timestamp=o.end_timestamp,
                     permanent=permanent,
                     menu_idx=o.menu_idx,
                     order_idx=o.display_order,
                     flags=o.flag_type)
    def load_database(self, skip_skills=False, skip_bonus=False, skip_extra=False):
        base_dir = self.base_dir
        raw_cards = card.load_card_data(data_dir=base_dir)
        self.dungeons = dungeon.load_dungeon_data(data_dir=base_dir)

        if not skip_bonus:
            self.bonus_sets = {
                g.value: bonus.load_bonus_data(data_dir=base_dir, server=self.server, data_group=g.value) for g in
                StarterGroup
            }

        if not skip_skills:
            self.skills = skill.load_skill_data(data_dir=base_dir)
            parser = SkillParser()
            parser.parse(self.skills)
            self.leader_skills = parser.leader_skills
            self.active_skills = parser.active_skills
            self.skill_id_to_leader_skill = {s.skill_id: s for s in self.leader_skills}
            self.skill_id_to_active_skill = {s.skill_id: s for s in self.active_skills}

        self.raw_enemy_skills = enemy_skill.load_enemy_skill_data(data_dir=base_dir)
        es_parser = BehaviorParser()
        es_parser.parse(self.raw_enemy_skills)
        self.enemy_skills = es_parser.enemy_behaviors
        self.es_id_to_enemy_skill = {es.enemy_skill_id: es for es in self.enemy_skills}

        if not skip_extra:
            self.exchange = exchange.load_data(data_dir=base_dir, server=self.server)
            self.purchase = purchase.load_data(data_dir=base_dir, server=self.server)
            self.egg_machines = extra_egg_machine.load_data(data_dir=base_dir, server=self.server)

        self.bonuses = _clean_bonuses(self.server, self.bonus_sets, self.dungeons)
        self.enemies = _clean_enemy(raw_cards, self.enemy_skills)
        self.cards = _clean_cards(self.server, raw_cards, self.enemies, self)

        self.dungeon_id_to_dungeon = {d.dungeon_id: d for d in self.dungeons}
        self.monster_no_to_card = {c.monster_no: c for c in self.cards}

        id_mapper = server_monster_id_fn(self.server)
        self.monster_id_to_card = {id_mapper(c.monster_no): c for c in self.cards}

        self.enemy_id_to_enemy = {e.enemy_id: e for e in self.enemies}
예제 #8
0
 def from_fc(o: Optional[FixedCardObject], idx: int,
             cssd: CrossServerSubDungeon) -> 'FixedTeamMonster':
     if o is None:
         return FixedTeamMonster(fixed_team_id=cssd.sub_dungeon_id,
                                 fixed_slot_type_id=0,
                                 order_idx=idx)
     if not o.monster_id:
         return FixedTeamMonster(fixed_team_id=cssd.sub_dungeon_id,
                                 fixed_slot_type_id=1,
                                 order_idx=idx)
     return FixedTeamMonster(fixed_team_id=cssd.sub_dungeon_id,
                             fixed_slot_type_id=2,
                             alt_monster_id=server_monster_id_fn(
                                 cssd.server)(o.monster_id),
                             monster_level=o.level,
                             plus_hp=o.plus_hp,
                             plus_atk=o.plus_atk,
                             plus_rcv=o.plus_rcv,
                             awakening_count=o.awakening_count,
                             skill_level=o.skill_level,
                             assist_alt_monster_id=o.assist,
                             super_awakening_id=o.super_awakening_id,
                             order_idx=idx)
예제 #9
0
 def no_to_id(self, monster_no: MonsterNo) -> MonsterId:
     return server_monster_id_fn(self.server)(monster_no)