Пример #1
0
    def __init__(self, raw: Dict[str, Any], server: Server):
        self.name = str(raw['name'])
        self.clean_name = pad_util.strip_colors(self.name)

        # Start time as gungho time string
        self.start_time_str = str(raw.get('start', raw.get('start_time_str')))
        self.start_timestamp = pad_util.gh_to_timestamp_2(self.start_time_str, server)

        # End time as gungho time string
        self.end_time_str = str(raw.get('end', raw.get('end_time_str')))
        self.end_timestamp = pad_util.gh_to_timestamp_2(self.end_time_str, server)

        # TODO: extra egg machine parser needs to pull out comment
        self.comment = str(raw.get('comment', ''))
        self.clean_comment = pad_util.strip_colors(self.comment)

        # The egg machine ID used in the API call param grow
        self.egg_machine_row = int(raw.get('row', raw.get('egg_machine_row')))

        # The egg machine ID used in the API call param gtype
        # Corresponds to the ordering of the item in egatya3
        self.egg_machine_type = int(raw['egg_machine_type'])

        # Stone or pal point cost
        self.cost = int(raw.get('pri', raw.get('cost')))

        # Monster ID to %
        contents = raw.get('contents', {})
        self.contents = {int(k): v for k, v in contents.items()}
Пример #2
0
    def __init__(self, raw: List[str], server: Server):
        self.server = server
        self.unknown_000 = str(raw[0])  # Seems to always be 'A'

        # Seems to be the unique ID for the trade?
        self.trade_id = int(raw[1])

        # Seems to be an order field, with lower values towards the top?
        self.display_order = int(raw[2])

        # 1-indexed menu this appears in
        self.menu_idx = int(raw[3])

        # Trade monster ID
        self.monster_id = int(raw[4])

        # Usually 1 and 0
        # Except for the PAD Appreciation/Spring Fest Medal trades which are 99 and 3
        self.unknown_005 = int(raw[5])
        self.unknown_006 = int(raw[6])

        # Trade availability start time string
        self.start_time_str = str(raw[7])
        self.start_timestamp = pad_util.gh_to_timestamp_2(
            self.start_time_str, server)

        # Trade availability end time string
        self.end_time_str = str(raw[8])
        self.end_timestamp = pad_util.gh_to_timestamp_2(
            self.end_time_str, server)

        # Start time string for the announcement text, probably?
        self.announcement_start_time_str = str(raw[9])
        self.announcement_start_timestamp = pad_util.gh_to_timestamp_2(
            self.announcement_start_time_str,
            server) if self.announcement_start_time_str else ''

        # End time string for the announcement text, probably?
        self.announcement_end_time_str = str(raw[10])
        self.announcement_end_timestamp = pad_util.gh_to_timestamp_2(
            self.announcement_end_time_str,
            server) if self.announcement_end_time_str else ''

        # Optional text that appears above monster name, for limited time events
        self.announcement_text = str(raw[11])

        # Clean version of the announcement text without formatting
        self.announcement_text_clean = pad_util.strip_colors(
            self.announcement_text)

        # Number of required monsters for the trade
        self.required_count = int(raw[12])

        # Seems to be the 'flag' type, e.g. 'restricted'?
        # If so, 0=No Flag, 2='Restricted'.
        self.flag_type = int(raw[13])
        self.restricted = (self.flag_type == 2)

        # Options for trading the monster
        self.required_monsters = list(map(int, raw[14:]))
Пример #3
0
    def __init__(self, raw: List[str], server: Server):
        self.server = server
        self.unknown_000 = str(raw[0])  # Seems to always be 'A'

        # Seems to be the unique ID for the trade?
        self.trade_id = int(raw[1])

        # Seems to be an order field, with lower values towards the top?
        self.display_order = int(raw[2])

        # 1-indexed menu this appears in
        self.menu_idx = int(raw[3])

        # Trade monster ID
        self.monster_id = int(raw[4])

        # Trade monster info
        self.monster_level = int(raw[5])
        monster_flags = int(raw[6])

        self.monster_max_skill = bool(monster_flags & 1)
        self.monster_max_awoken = bool(monster_flags & 2)

        # Trade availability start time string
        self.start_time_str = str(raw[7])
        self.start_timestamp = pad_util.gh_to_timestamp_2(self.start_time_str, server)

        # Trade availability end time string
        self.end_time_str = str(raw[8])
        self.end_timestamp = pad_util.gh_to_timestamp_2(self.end_time_str, server)

        # Start time string for the announcement text, probably?
        self.announcement_start_time_str = str(raw[9])
        self.announcement_start_timestamp = pad_util.gh_to_timestamp_2(
            self.announcement_start_time_str, server) if self.announcement_start_time_str else ''

        # End time string for the announcement text, probably?
        self.announcement_end_time_str = str(raw[10])
        self.announcement_end_timestamp = pad_util.gh_to_timestamp_2(
            self.announcement_end_time_str, server) if self.announcement_end_time_str else ''

        # Optional text that appears above monster name, for limited time events
        self.announcement_text = str(raw[11])

        # Clean version of the announcement text without formatting
        self.announcement_text_clean = pad_util.strip_colors(self.announcement_text)

        # Number of required monsters for the trade
        self.required_count = int(raw[12])

        # Flags, e.g. restricted
        self.flag_type = int(raw[13])
        self.no_dupes = bool(self.flag_type & 1)
        self.restricted = bool(self.flag_type & 2)
        self.multi_exchange = bool(self.flag_type & 4)

        # Options for trading the monster
        self.required_monsters = list(map(int, raw[14:]))
Пример #4
0
 def __init__(self, server: Server, bonus: Bonus, dungeon: Dungeon,
              group: StarterGroup):
     self.server = server
     self.bonus = bonus
     self.dungeon = dungeon
     self.group = group
     self.start_timestamp = pad_util.gh_to_timestamp_2(
         bonus.start_time_str, server)
     self.end_timestamp = pad_util.gh_to_timestamp_2(
         bonus.end_time_str, server)
Пример #5
0
    def __init__(self, raw: Dict[str, str], server: Server):
        if not set(raw) <= set(Bonus.keys):
            raise ValueError('Unexpected keys: ' +
                             str(set(raw) - set(Bonus.keys)))

        # Start time as gungho time string
        self.start_time_str = str(raw['s'])
        self.start_timestamp = pad_util.gh_to_timestamp_2(
            self.start_time_str, server)

        # End time as gungho time string
        self.end_time_str = str(raw['e'])
        self.end_timestamp = pad_util.gh_to_timestamp_2(
            self.end_time_str, server)

        # Optional DungeonId
        self.dungeon_id = None  # type: Optional[DungeonId]
        if 'd' in raw:
            self.dungeon_id = DungeonId(int(raw['d']))

        # Optional DungeonFloorId
        # Stuff like rewards text in monthly quests
        self.sub_dungeon_id = None  # type: Optional[SubDungeonId]
        if 'f' in raw:
            self.sub_dungeon_id = SubDungeonId(int(raw['f']))

        # If REM/PEM, the ID of the machine
        self.egg_machine_id = None  # type: Optional[int]
        if 'i' in raw:
            self.egg_machine_id = int(raw['i'])

        # Optional human-readable message (with formatting)
        self.message = None  # type: Optional[str]
        # Optional human-readable message (no formatting)
        self.clean_message = None  # type: Optional[str]
        if 'm' in raw:
            self.message = str(raw['m'])
            self.clean_message = pad_util.strip_colors(self.message)

        bonus_id = int(raw['b'])
        self.bonus_info = TYPES_MAP.get(bonus_id, UNKNOWN_TYPE)

        # Bonus value, if provided, optionally processed
        self.bonus_value = None  # type: Optional[Union[float, int]]
        if 'a' in raw:
            self.bonus_value = raw['a']
            if self.bonus_info.mod_fn:
                self.bonus_value = self.bonus_info.mod_fn(self.bonus_value)

        # Human readable name for the bonus
        self.bonus_name = self.bonus_info.bonus_type.name
        if self.bonus_info.bonus_type == BonusType.unknown:
            self.bonus_name += '({})'.format(bonus_id)
        self.bonus_id = bonus_id
Пример #6
0
    def __init__(self, raw: Dict[str, Any], server: Server):
        if not set(raw) <= set(Bonus.keys):
            raise ValueError('Unexpected keys: ' +
                             str(set(raw) - set(Bonus.keys)))

        self.raw = raw

        # Start time as gungho time string
        self.start_time_str = str(raw['s'])
        self.start_timestamp = pad_util.gh_to_timestamp_2(
            self.start_time_str, server)

        # End time as gungho time string
        self.end_time_str = str(raw['e'])
        self.end_timestamp = pad_util.gh_to_timestamp_2(
            self.end_time_str, server)

        # Optional DungeonId
        self.dungeon_id = None  # type: Optional[DungeonId]
        if 'd' in raw:
            self.dungeon_id = DungeonId(int(raw['d']))

        # Optional DungeonFloorId
        # Stuff like rewards text in monthly quests
        self.sub_dungeon_id = None  # type: Optional[SubDungeonId]
        if 'f' in raw:
            self.sub_dungeon_id = SubDungeonId(int(raw['f']))

        # If REM/PEM, the ID of the machine
        self.egg_machine_id = None  # type: Optional[int]
        if 'i' in raw:
            self.egg_machine_id = int(raw['i'])

        # Optional human-readable message (with formatting)
        self.message = None  # type: Optional[str]
        # Optional human-readable message (no formatting)
        self.clean_message = None  # type: Optional[str]
        # Optional URL in message
        self.url = None  # type: Optional[str]
        if 'm' in raw:
            self.message = str(raw['m'])
            self.clean_message = pad_util.strip_colors(self.message)
            if (match := re.search(r'https?:.+?(?=\|)', self.message)):
                self.url = match.group()
Пример #7
0
    def __init__(self, raw: List[str], server: Server, tbegin: str, tend: str):
        self.server = server
        self.start_time_str = tbegin
        self.start_timestamp = pad_util.gh_to_timestamp_2(
            self.start_time_str, server)
        self.end_time_str = tend
        self.end_timestamp = pad_util.gh_to_timestamp_2(
            self.end_time_str, server)
        self.type = str(raw[0])  # Should be P

        # Trade monster ID
        self.monster_id = int(raw[1])

        # Cost of the monster in MP
        self.cost = int(raw[2])

        # Probably amount.  Always 1
        self.amount = int(raw[3])

        # A None and two 0s
        self.unknown = raw[4:]