Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.16 Export Fixes for Items and Passives #38

Merged
merged 16 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions PyPoE/cli/exporter/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ def get_content_path():


def fix_path(path: str) -> str:
#First, replace any double quotes with HTML-encoded quotes
path = path.replace('\"','"')
if re.search('[a-zA-Z]:.*', path) is not None:
return path[:2] + re.sub(r':', '_', path[2:])
else:
Expand Down
6 changes: 4 additions & 2 deletions PyPoE/cli/exporter/wiki/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ def wrapper(pargs, *args, **kwargs):

if pargs.write:
out_path = os.path.join(out_dir, fix_path(
item['out_file']))
# 3.15
# Added to escape quotes in "The Kiss Good Night"
item['out_file'].replace('"', "'", 2)))
console('Writing data to "%s"...' % out_path)
with open(out_path, 'w', encoding='utf-8') as f:
f.write(text)
Expand Down Expand Up @@ -522,4 +524,4 @@ def add_parser_arguments(parser):
action='store',
type=str,
default='',
)
)
44 changes: 23 additions & 21 deletions PyPoE/cli/exporter/wiki/parsers/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class AreaParser(parser.BaseParser):
'template': 'loading_screen',
'format': lambda value: value.replace('Art/Textures/Interface/Loadi'
'ngImages/', '').replace('.dds', ''),
'default': [],
}),
('Connections_WorldAreasKeys', {
'template': 'connection_ids',
Expand Down Expand Up @@ -276,21 +277,21 @@ class AreaParser(parser.BaseParser):
]),
}),

('Strongbox_SpawnChance', {
'template': 'strongbox_spawn_chance',
'condition': lambda area: area['Strongbox_SpawnChance'] > 0,
}),
('Strongbox_MaxCount', {
'template': 'strongbox_max',
'condition': lambda area: area['Strongbox_SpawnChance'] > 0,
'default': 0,
}),
('Strongbox_RarityWeight', {
'template': 'strongbox_rarity_weight',
'condition': lambda area: area['Strongbox_SpawnChance'] > 0,
'default': '',
'format': lambda value: ', '.join([str(v) for v in value]),
}),
# ('Strongbox_SpawnChance', {
# 'template': 'strongbox_spawn_chance',
# 'condition': lambda area: area['Strongbox_SpawnChance'] > 0,
# }),
# ('Strongbox_MaxCount', {
# 'template': 'strongbox_max',
# 'condition': lambda area: area['Strongbox_SpawnChance'] > 0,
# 'default': 0,
# }),
# ('Strongbox_RarityWeight', {
# 'template': 'strongbox_rarity_weight',
# 'condition': lambda area: area['Strongbox_SpawnChance'] > 0,
# 'default': '',
# 'format': lambda value: ', '.join([str(v) for v in value]),
# }),
# bools
('IsMapArea', {
'template': 'is_map_area',
Expand Down Expand Up @@ -449,12 +450,12 @@ def export(self, parsed_args, areas):
area)
if map:
map = map[0]
if map['MapSeriesKey']['Id'] == 'MapWorlds':
if str(map['MapSeriesKey'])[0] == 'MapWorlds':
data['main_page'] = map['BaseItemTypesKey']['Name']
else:
data['main_page'] = '%s (%s)' % (
map['BaseItemTypesKey']['Name'],
map['MapSeriesKey']['Name']
str(map['MapSeriesKey'])[0]
)
elif data.get('tags') and 'map' in data['tags']:
map_version = None
Expand All @@ -480,10 +481,11 @@ def export(self, parsed_args, areas):
tier = re.sub('^.*Harbinger', '', area['Id'])
if tier:
if map_version is None:
data['main_page'] = '%s (%s)' % (
area['Name'],
lang[tier],
)
# data['main_page'] = '%s (%s)' % (
# area['Name'],
# lang[tier],
# )
continue
else:
data['main_page'] = '%s (%s) (%s)' % (
area['Name'],
Expand Down
139 changes: 98 additions & 41 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 @@ -565,7 +566,8 @@ class ItemsParser(SkillParserShared):
'Heist': '3.12.0',
'Ritual': '3.13.0',
'Ultimatum': '3.14.0',
'Expedition': '3.15.0'
'Expedition': '3.15.0',
'Scourge': '3.16.0'
}

_IGNORE_DROP_LEVEL_CLASSES = (
Expand Down Expand Up @@ -764,12 +766,26 @@ class ItemsParser(SkillParserShared):
'Metadata/Items/Gems/SupportGemConcentratedEffect': '',
'Metadata/Items/Gems/SupportGemIncreasedCriticalStrikes': '',
'Metadata/Items/Gems/SupportGemMeleeSplash': '',
'Metadata/Items/Gems/SkillGemEnergyBlade': '',
# =================================================================
# One Hand Axes
# =================================================================

'Metadata/Items/Weapons/OneHandWeapons/OneHandAxes/OneHandAxe22':
'',

# =================================================================
# One Hand Swords
# =================================================================
'Metadata/Items/Weapons/OneHandWeapons/OneHandSwords/StormBladeOneHand':
' (One Handed Sword)',

# =================================================================
# Two Hand Swords
# =================================================================
'Metadata/Items/Weapons/TwoHandWeapons/TwoHandSwords/StormBladeTwoHand':
' (Two Handed Sword)',

# =================================================================
# Boots
# =================================================================
Expand Down Expand Up @@ -2199,24 +2215,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 @@ -2361,17 +2393,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',
# }),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a case of YAGNI?

Will we ever have any need for this? @Journeytojah @angelic-knight
If not needed, just remove outright instead of comment. But please check with one another first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be safe to delete. @Journeytojah, what's your take on it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine to remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this and surrounding related code.

)

def _apply_master_map(self, infobox, base_item_type, hideout):
Expand All @@ -2386,19 +2418,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 @@ -2442,7 +2474,8 @@ def MapSeriesHelper(d):
'Heist',
'Ritual',
'Ultimatum',
'Expedition'
'Expedition',
'Scourge'
]
# print('yep', map_series[d])
return map_series[d]
Expand Down Expand Up @@ -2779,10 +2812,14 @@ def _harvest_plant_booster_extra(self, infobox, base_item_type,
row_index=True,
)

'''
This defines the expected data elements for an item class.
'''
Comment on lines +3303 to +3305
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me like we're inside of a method here, which would mean that we should use line comments here instead of docstrings. Can we please change this to be # This defines the expected data elements for an item class. insead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's within a class, not a method.
I'm tweaking it so intellisense will pick up on the docstring.

_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 @@ -2990,7 +3027,8 @@ def _conflict_atlas_region_upgrade(
_conflict_resolver_map = {
'Active Skill Gem': _conflict_active_skill_gems,
'QuestItem': _conflict_quest_items,
'HideoutDoodad': _conflict_hideout_doodad,
#TODO: Make a new doodad resolver that doesn't rely on 'HideoutNPCsKey'
#'HideoutDoodad': _conflict_hideout_doodad,
'Map': _conflict_maps,
'MapFragment': _conflict_map_fragments,
'DivinationCard': _conflict_divination_card,
Expand All @@ -3017,12 +3055,12 @@ def _process_purchase_costs(self, source, infobox):
for rarity in RARITY:
if rarity.id >= 5:
break
for i, (item, cost) in enumerate(
source[rarity.name_upper + 'Purchase'],
start=1):
prefix = 'purchase_cost_%s%s' % (rarity.name_lower, i)
infobox[prefix + '_name'] = item['Name']
infobox[prefix + '_amount'] = cost
# for i, (item, cost) in enumerate(
# source[rarity.name_upper + 'Purchase'],
# start=1):
# prefix = 'purchase_cost_%s%s' % (rarity.name_lower, i)
# infobox[prefix + '_name'] = item['Name']
# infobox[prefix + '_amount'] = cost

def by_rowid(self, parsed_args):
return self._export(
Expand Down Expand Up @@ -3194,6 +3232,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 @@ -3281,6 +3321,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 (not 'start' in vars(parsed_args).keys()) or (not 'end' in vars(parsed_args).keys()):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as #37 (comment)

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
8 changes: 3 additions & 5 deletions PyPoE/cli/exporter/wiki/parsers/lua.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,8 @@ def main(self, parsed_args):
self._copy_from_keys(
row, self._COPY_KEYS_BESTIARY_COMPONENTS, components
)
if row['RarityKey'] != RARITY.ANY:
components[-1]['rarity'] = self.rr['ClientStrings.dat'].index[
'Id']['ItemDisplayString' + row['RarityKey'].name_upper][
'Text']
if row['BeastRarity'] != RARITY.ANY:
components[-1]['rarity'] = self.rr['ClientStrings.dat'].index['Id']['ItemDisplayString' + row['BeastRarity'].name_upper]['Text']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's a doozy to follow by-eye. Can we try:

if row['BeastRarity'] != RARITY.ANY:
    display_string = 'ItemDisplayString' + row['BeastRarity'].name_upper
    components[-1]['rarity'] = self.rr['ClientStrings.dat'].index['Id'][display_string]['Text']

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 👍


recipe_components = []
for recipe_id, data in recipe_components_temp.items():
Expand Down Expand Up @@ -1438,7 +1436,7 @@ def SortCategoryHelper(d):
# 'default': '',
# }),
('CraftingItemClassCategoriesKeys', {
'key': 'crafting_item_class_categories',
'key': 'item_class_categories',
'value': lambda v: [k['Text'] for k in v],
}),
# ('CraftingBenchUnlockCategoriesKeys', {
Expand Down
5 changes: 5 additions & 0 deletions PyPoE/cli/exporter/wiki/parsers/passives.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# Python
import re
import os.path
import warnings
from functools import partialmethod
from collections import OrderedDict

Expand Down Expand Up @@ -289,6 +290,10 @@ def export(self, parsed_args, passives):
data['icon'] = '%s (%s)' % (icon[-1], icon[-2])
else:
data['icon'] = icon[-1]
#atlas_start_node doesn't have an icon path
else:
data['icon'] = ''
warnings.warn('Icon path file not found for {}: {}'.format(passive['Id'], passive['Name']))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as #37 (comment)


data['icon'] = data['icon'].replace('.dds', '')

Expand Down
Loading