Skip to content

Commit

Permalink
WIP heist export for wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
OmegaK2 committed Oct 11, 2020
1 parent f55342b commit 5d6afb1
Show file tree
Hide file tree
Showing 2 changed files with 204 additions and 23 deletions.
120 changes: 120 additions & 0 deletions PyPoE/cli/exporter/wiki/parsers/lua.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ def __init__(self, sub_parser):
func=HarvestParser.main,
)

parser = lua_sub.add_parser(
'heist',
help='Extract heist information (not covered by items)',
)
self.add_default_parsers(
parser=parser,
cls=HeistParser,
func=HeistParser.main,
)

parser = lua_sub.add_parser(
'monster',
help='Extract monster information',
Expand Down Expand Up @@ -830,6 +840,116 @@ def main(self, parsed_args):
return r


class HeistParser(GenericLuaParser):
_files = [
'HeistAreas.dat',
'HeistJobs.dat',
'HeistNPCs.dat',
]

_COPY_KEYS_HEIST_AREAS = (
('Id', {
'key': 'id',
}),
('WorldAreasKeys', {
'key': 'area_ids',
'value': lambda v: ','.join([r['Id'] for r in v]),
}),
('HeistJobsKeys', {
'key': 'job_ids',
'value': lambda v: ','.join([r['Id'] for r in v]),
}),
('Contract_BaseItemTypesKey', {
'key': 'contract_id',
'value': lambda v: v['Id'],
}),
('Blueprint_BaseItemTypesKey', {
'key': 'blueprint_id',
'value': lambda v: v['Id'],
}),
('ClientStringsKey', {
'key': 'reward_text',
'value': lambda v: v['Text'],
}),
)

_COPY_KEYS_HEIST_JOBS = (
('Id', {
'key': 'id',
}),
('Name', {
'key': 'name',
}),
)

_COPY_KEYS_HEIST_NPCS = (
('MonsterVarietiesKey', {
'key': 'id',
'value': lambda v: v['Id'],
}),
('Name', {
'key': 'name',
}),
('HeistJobsKey', {
'key': 'job_id',
'value': lambda v: v['Id'],
}),
)

def main(self, parsed_args):
heist_areas = []
for row in self.rr['HeistAreas.dat']:
self._copy_from_keys(row, self._COPY_KEYS_HEIST_AREAS, heist_areas)

heist_jobs = []
for row in self.rr['HeistJobs.dat']:
self._copy_from_keys(row, self._COPY_KEYS_HEIST_JOBS, heist_jobs)

heist_npcs = []
heist_npc_skills = []
heist_npc_stats = []
for row in self.rr['HeistNPCs.dat']:
mid = row['MonsterVarietiesKey']['Id']
self._copy_from_keys(row, self._COPY_KEYS_HEIST_NPCS, heist_npcs)

skills = [r['Id'] for r in row['SkillLevel_HeistJobsKeys']]
for i, job_id in enumerate(skills):
entry = OrderedDict()
entry['npc_id'] = mid
entry['job_id'] = job_id
entry['level'] = row['SkillLevel_Values'][i]
# StatValues2?
heist_npc_skills.append(entry)

stats = [r['StatsKey']['Id'] for r in row['HeistNPCStatsKeys']]
for i, stat_id in enumerate(stats):
entry = OrderedDict()
entry['npc_id'] = mid
entry['stat_id'] = stat_id
entry['value'] = row['StatValues'][i]
# StatValues2?
heist_npc_stats.append(entry)

heist_npcs[-1]['stat_text'] = self._format_tr(self.tc[
'stat_descriptions.txt'].get_translation(
stats, [int(v) for v in row['StatValues']], full_result=True
))

r = ExporterResult()
for k in ('heist_areas', 'heist_jobs', 'heist_npcs', 'heist_npc_skills',
'heist_npc_stats'):
r.add_result(
text=LuaFormatter.format_module(locals()[k]),
out_file='%s.lua' % k,
wiki_page=[{
'page': 'Module:Heist/%s' % k,
'condition': None,
}]
)

return r


class PantheonParser(GenericLuaParser):
_files = [
'PantheonPanelLayout.dat',
Expand Down
107 changes: 84 additions & 23 deletions PyPoE/poe/file/specification/data/stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -9707,24 +9707,29 @@
type='int',
),
Field(
name='Key0',
name='EnvironmentsKey1',
type='ulong',
key='Environments.dat',
),
Field(
name='Key1',
name='EnvironmentsKey2',
type='ulong',
key='Environments.dat',
),
Field(
name='Keys0',
name='HeistJobsKeys',
type='ref|list|ulong',
key='HeistJobs.dat',
),
Field(
name='Key2',
name='Contract_BaseItemTypesKey',
type='ulong',
key='BaseItemTypes.dat'
),
Field(
name='Key3',
name='Blueprint_BaseItemTypesKey',
type='ulong',
key='BaseItemTypes.dat',
),
Field(
name='DGRFile',
Expand Down Expand Up @@ -9755,16 +9760,19 @@
file_ext='.dds',
),
Field(
name='Keys1',
name='AchievementItemsKeys',
type='ref|list|ulong',
key='AchievementItems.dat',
),
Field(
name='Keys2',
name='AchievementItemsKeys2',
type='ref|list|ulong',
key='AchievementItems.dat',
),
Field(
name='Key4',
name='ClientStringsKey',
type='ulong',
key='ClientStrings.dat',
),
),
),
Expand Down Expand Up @@ -9850,6 +9858,10 @@
name='Unknown24',
type='float',
),
Field(
name='Unknown25',
type='int'
)
),
),
'HeistBlueprintWindowTypes.dat': File(
Expand All @@ -9874,7 +9886,7 @@
type='ref|string',
),
Field(
name='Unknown3',
name='Unknown0',
type='int',
),
Field(
Expand All @@ -9901,6 +9913,10 @@
name='Keys0',
type='ref|list|ulong',
),
Field(
name='Unknown1',
type='int',
),
),
),
'HeistChestTypes.dat': File(
Expand Down Expand Up @@ -9994,12 +10010,14 @@
'HeistContracts.dat': File(
fields=(
Field(
name='Key0',
name='BaseItemTypesKey',
type='ulong',
key='BaseItemTypes.dat',
),
Field(
name='Key1',
name='HeistAreasKey',
type='ulong',
key='HeistAreas.dat'
),
Field(
name='Unknown2',
Expand Down Expand Up @@ -10093,15 +10111,17 @@
'HeistEquipment.dat': File(
fields=(
Field(
name='Key0',
name='BaseItemTypesKey',
type='ulong',
key='BaseItemTypes.dat',
),
Field(
name='Key1',
name='RequiredJob_HeistJobsKey',
type='ulong',
key='HeistJobs.dat',
),
Field(
name='Unknown2',
name='RequiredLevel',
type='int',
),
),
Expand Down Expand Up @@ -10193,6 +10213,10 @@
name='Unknown19',
type='int',
),
Field(
name='Unknown20',
type='int',
),
),
),
'HeistIntroAreas.dat': File(
Expand Down Expand Up @@ -10427,15 +10451,17 @@
'HeistNPCs.dat': File(
fields=(
Field(
name='Key0',
name='NPCsKey',
type='ulong',
key='NPCs.dat',
),
Field(
name='Key1',
name='MonsterVarietiesKey',
type='ulong',
key='MonsterVarieties.dat',
),
Field(
name='HeistJobsKeys',
name='SkillLevel_HeistJobsKeys',
type='ref|list|ulong',
key='HeistJobs.dat',
),
Expand All @@ -10445,19 +10471,20 @@
file_path=True,
),
Field(
name='Keys0',
name='HeistNPCStatsKeys',
type='ref|list|ulong',
key='HeistNPCStats.dat',
),
Field(
name='Unknown5',
name='StatValues',
type='ref|list|float',
),
Field(
name='Unknown6',
type='float',
),
Field(
name='Unknown7',
name='SkillLevel_Values',
type='ref|list|int',
),
Field(
Expand Down Expand Up @@ -10487,12 +10514,13 @@
key='HeistNPCs.dat',
),
Field(
name='Unknown14',
name='StatValues2',
type='ref|list|float',
),
Field(
name='Key2',
name='Ally_NPCsKey',
type='ulong',
key='NPCs.dat',
),
Field(
name='ActiveNPCIcon',
Expand All @@ -10505,8 +10533,9 @@
key='HeistJobs.dat',
),
Field(
name='Keys1',
name='Equip_AchievementItemsKeys',
type='ref|list|ulong',
key='AchievementItems.dat'
),
Field(
name='AOFile',
Expand All @@ -10516,6 +10545,18 @@
),
),
),
'HeistObjectiveValueDescriptions.dat': File(
fields=(
Field(
name='Unknown0',
type='int',
),
Field(
name='Unknown1',
type='int',
),
),
),
'HeistObjectives.dat': File(
fields=(
Field(
Expand Down Expand Up @@ -10671,6 +10712,26 @@
name='Key5',
type='ulong',
),
Field(
name='Unknown21',
type='byte',
),
Field(
name='Key6',
type='ulong',
),
Field(
name='Unknown16',
type='int',
),
Field(
name='Key7',
type='ulong',
),
Field(
name='Unknown18',
type='ref|string',
),
),
),
'HeistRevealingNPCs.dat': File(
Expand Down

0 comments on commit 5d6afb1

Please sign in to comment.