Skip to content

Commit

Permalink
Supporting armour base types with ranges for their defence values
Browse files Browse the repository at this point in the history
Adding printing to indicate current rows being processed (up to 200 row IDs and names will print) during exporting.
Re-evaluated and updated the MAP_FRAGMENTS_FAMILIES enum
Fixed some specs that were erroring out during item exporting.
  • Loading branch information
angelic-knight committed Nov 2, 2021
1 parent f702e9a commit 78214dc
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 53 deletions.
104 changes: 72 additions & 32 deletions PyPoE/cli/exporter/wiki/parsers/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@


def _apply_column_map(infobox, column_map, list_object):

for k, data in column_map:
value = list_object[k]
if data.get('condition') and not data['condition'](value):
Expand Down Expand Up @@ -2200,24 +2201,40 @@ def _type_amulet(self, infobox, base_item_type):
_type_armour = _type_factory(
data_file='ArmourTypes.dat',
data_mapping=(
('Armour', {
'template': 'armour',
('ArmourMin', {
'template': 'armour_min',
'condition': lambda v: v > 0,
}),
('Evasion', {
'template': 'evasion',
('ArmourMax', {
'template': 'armour_max',
'condition': lambda v: v > 0,
}),
('EnergyShield', {
'template': 'energy_shield',
('EvasionMin', {
'template': 'evasion_min',
'condition': lambda v: v > 0,
}),
('EvasionMin', {
'template': 'evasion_max',
'condition': lambda v: v > 0,
}),
('EnergyShieldMin', {
'template': 'energy_shield_min',
'condition': lambda v: v > 0,
}),
('EnergyShieldMax', {
'template': 'energy_shield_max',
'condition': lambda v: v > 0,
}),
('IncreasedMovementSpeed', {
'template': 'movement_speed',
'condition': lambda v: v != 0,
}),
('Ward', {
'template': 'ward',
('WardMin', {
'template': 'ward_min',
'condition': lambda v: v != 0,
}),
('WardMax', {
'template': 'ward_max',
'condition': lambda v: v != 0,
}),
),
Expand Down Expand Up @@ -2362,17 +2379,17 @@ def _currency_extra(self, infobox, base_item_type, currency):
)

_master_hideout_doodad_map = (
('HideoutNPCsKey', {
'template': 'master',
'format': lambda v: v['Hideout_NPCsKey']['Name'],
'condition': lambda v: v is not None,
}),
('MasterLevel', {
'template': 'master_level_requirement',
}),
('FavourCost', {
'template': 'master_favour_cost',
}),
# ('HideoutNPCsKey', {
# 'template': 'master',
# 'format': lambda v: v['Hideout_NPCsKey']['Name'],
# 'condition': lambda v: v is not None,
# }),
# ('MasterLevel', {
# 'template': 'master_level_requirement',
# }),
# ('FavourCost', {
# 'template': 'master_favour_cost',
# }),
)

def _apply_master_map(self, infobox, base_item_type, hideout):
Expand All @@ -2387,19 +2404,19 @@ def _apply_master_map(self, infobox, base_item_type, hideout):
'template': 'is_master_doodad',
'format': lambda v: not v,
}),
('HideoutNPCsKey', {
'template': 'master',
'format': lambda v: v['Hideout_NPCsKey']['Name'],
'condition': lambda v: v,
}),
('FavourCost', {
'template': 'master_favour_cost',
#'condition': lambda v: v,
}),
('MasterLevel', {
'template': 'master_level_requirement',
#'condition': lambda v: v,
}),
# ('HideoutNPCsKey', {
# 'template': 'master',
# 'format': lambda v: v['Hideout_NPCsKey']['Name'],
# 'condition': lambda v: v,
# }),
# ('FavourCost', {
# 'template': 'master_favour_cost',
# #'condition': lambda v: v,
# }),
# ('MasterLevel', {
# 'template': 'master_level_requirement',
# #'condition': lambda v: v,
# }),
('Variation_AOFiles', {
'template': 'variation_count',
'format': lambda v: len(v),
Expand Down Expand Up @@ -2781,10 +2798,14 @@ def _harvest_plant_booster_extra(self, infobox, base_item_type,
row_index=True,
)

'''
This defines the expected data elements for an item class.
'''
_cls_map = {
# Jewellery
'Amulet': (_type_amulet, ),
# Armour types
'Armour': (_type_level, _type_attribute, _type_armour, ),
'Gloves': (_type_level, _type_attribute, _type_armour, ),
'Boots': (_type_level, _type_attribute, _type_armour, ),
'Body Armour': (_type_level, _type_attribute, _type_armour, ),
Expand Down Expand Up @@ -3196,6 +3217,8 @@ def _export(self, parsed_args, items):
cls_id = base_item_type['ItemClassesKey']['Id']
m_id = base_item_type['Id']

self._print_item_rowid(parsed_args, base_item_type)

infobox = OrderedDict()
self._process_base_item_type(base_item_type, infobox)
self._process_purchase_costs(base_item_type, infobox)
Expand Down Expand Up @@ -3283,6 +3306,23 @@ def _export(self, parsed_args, items):

return r

def _print_item_rowid(self, parsed_args, base_item_type):
#Don't print anything if not running in the rowid mode.
if (parsed_args.start is None) or (parsed_args.end is None):
return

export_row_count = parsed_args.end - parsed_args.start
#If we're printing less than 100 rows, print every rowid
if export_row_count <= 100:
print_granularity = 1
else:
print_granularity = export_row_count//100

item_offset = base_item_type.rowid - parsed_args.start
if (item_offset == 0) or item_offset % print_granularity == 0:
console('Processing item with rowid {}: {}'.format(base_item_type.rowid, base_item_type['Name']))
return

def _format_map_name(self, base_item_type, map_series, language=None):
if language is None:
language = self._language
Expand Down
36 changes: 20 additions & 16 deletions PyPoE/poe/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,23 +605,27 @@ class MAP_FRAGMENT_FAMILIES(IntEnumOverride):
"""
Representation of map fragment families (MapFragmentFamilies.dat)
"""
BESTIARY = 0
BESTIARY_AND_SULPHITE = 0 #Maybe just master-related?
BREACH = 1
CARTOGRAPHY = 2
RELIQUARY = 3
SHAPER = 4
ELDER = 5
DIVINATION = 6
TORMENT = 7
AMBUSH = 8
HARBINGER = 9
PERANDUS = 10
LEGION = 11
METAMORPH = 12
REGULAR = 13
RITUAL = 14
EXPEDITION = 15
SCOURGE = 16
CARTOGRAPHY_SCARAB = 2
RELIQUARY_SCARAB = 3
SHAPER_SCARAB = 4
ELDER_SCARAB = 5
DIVINATION_SCARAB = 6
TORMENT_SCARAB = 7
AMBUSH_SCARAB = 8
HARBINGER_SCARAB = 9
EXPEDITION_SCARAB = 10
LEGION_SCARAB = 11
METAMORPH_SCARAB = 12
BLIGHT_SCARAB = 13
ABYSS_SCARAB = 14
KARUI = 15
MARAKETH = 16
ETERNAL = 17
TEMPLAR = 18
VAAL = 19
REGULAR = 20

DEFAULT = REGULAR
STANDARD = REGULAR
Expand Down
42 changes: 37 additions & 5 deletions PyPoE/poe/file/specification/data/stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@
name='Message',
type='ref|string',
),
Field(
name='Unknown0',
type='byte',
),
Field(
name='Unknown1',
type='byte',
),
Field(
name='Unknown2',
type='byte',
),
Field(
name='Unknown3',
type='byte',
),
),
),
'AchievementItems.dat': File(
Expand Down Expand Up @@ -230,6 +246,22 @@
name='HideoutName',
type='ref|string',
),
Field(
name='Unknown0',
type='byte',
),
Field(
name='Unknown2',
type='byte',
),
Field(
name='Unknown3',
type='byte',
),
Field(
name='Unknown4',
type='byte',
),
),
),
'AchievementSetsDisplay.dat': File(
Expand Down Expand Up @@ -19266,7 +19298,7 @@
),
Field(
name='Stuck_AOFile',
type='ref|string',
type='ref|list|ref|string',
file_path=True,
file_ext='.ao',
),
Expand Down Expand Up @@ -19324,10 +19356,6 @@
name='Keys0',
type='ref|list|ulong',
),
Field(
name='Key3',
type='ulong',
),
Field(
name='Flag5',
type='bool',
Expand All @@ -19336,6 +19364,10 @@
name='Unknown12',
type='int',
),
Field(
name='Unknown13',
type='int',
),
),
),
'Prophecies.dat': File(
Expand Down

0 comments on commit 78214dc

Please sign in to comment.