Adapt pyfa scripts to latest Phobos changes
This commit is contained in:
@@ -53,9 +53,8 @@ mapper(Item, items_table,
|
||||
"name" : synonym("typeName"),
|
||||
"description" : deferred(items_table.c.description),
|
||||
"traits" : relation(Traits,
|
||||
primaryjoin = traits_table.c.typeID == items_table.c.typeID,
|
||||
order_by = traits_table.c.typeID,
|
||||
uselist = True)
|
||||
primaryjoin = traits_table.c.typeID == items_table.c.typeID,
|
||||
uselist = False)
|
||||
})
|
||||
|
||||
Item.category = association_proxy("group", "category")
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
|
||||
from sqlalchemy import Column, Table, Integer, String, ForeignKey, and_, select
|
||||
from sqlalchemy.orm import mapper, column_property
|
||||
from eos.types import Item, Traits
|
||||
from sqlalchemy import Column, Table, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import mapper
|
||||
from eos.types import Traits
|
||||
from eos.db import gamedata_meta
|
||||
|
||||
traits_table = Table("invtraits", gamedata_meta,
|
||||
Column("typeID", Integer, ForeignKey("invtypes.typeID"), primary_key=True),
|
||||
Column("skillID", Integer, ForeignKey("invtypes.typeID"), primary_key=True),
|
||||
Column("bonusText", String, primary_key=True))
|
||||
Column("traitText", String))
|
||||
|
||||
|
||||
from .item import items_table
|
||||
|
||||
mapper(Traits, traits_table,
|
||||
properties = {"skillName" : column_property(
|
||||
select([items_table.c.typeName],
|
||||
and_(
|
||||
items_table.c.typeID == traits_table.c.skillID,
|
||||
traits_table.c.skillID != -1
|
||||
)))
|
||||
});
|
||||
mapper(Traits, traits_table);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
#======================================================================
|
||||
# Copyright (C) 2012 Diego Duclos
|
||||
#
|
||||
@@ -25,7 +25,6 @@ import sys
|
||||
path = os.path.dirname(unicode(__file__, sys.getfilesystemencoding()))
|
||||
sys.path.append(os.path.realpath(os.path.join(path, "..", "..", "..")))
|
||||
|
||||
import sqlite3
|
||||
import json
|
||||
import argparse
|
||||
|
||||
@@ -50,27 +49,102 @@ if __name__ == "__main__":
|
||||
eos.db.gamedata_meta.create_all()
|
||||
|
||||
# Config dict
|
||||
tables = {"dgmattribs": eos.gamedata.AttributeInfo,
|
||||
"dgmeffects": eos.gamedata.EffectInfo,
|
||||
"dgmtypeattribs": eos.gamedata.Attribute,
|
||||
"dgmtypeeffects": eos.gamedata.Effect,
|
||||
"dgmunits": eos.gamedata.Unit,
|
||||
"icons": eos.gamedata.Icon,
|
||||
"invcategories": eos.gamedata.Category,
|
||||
"invgroups": eos.gamedata.Group,
|
||||
"invmetagroups": eos.gamedata.MetaGroup,
|
||||
"invmetatypes": eos.gamedata.MetaType,
|
||||
"invtypes": eos.gamedata.Item,
|
||||
"phobostraits": eos.gamedata.Traits,
|
||||
"marketProxy()_GetMarketGroups()": eos.gamedata.MarketGroup}
|
||||
|
||||
fieldMapping = {"icons": {"id": "iconID"}}
|
||||
tables = {
|
||||
"dgmattribs": eos.gamedata.AttributeInfo,
|
||||
"dgmeffects": eos.gamedata.EffectInfo,
|
||||
"dgmtypeattribs": eos.gamedata.Attribute,
|
||||
"dgmtypeeffects": eos.gamedata.Effect,
|
||||
"dgmunits": eos.gamedata.Unit,
|
||||
"icons": eos.gamedata.Icon,
|
||||
"invcategories": eos.gamedata.Category,
|
||||
"invgroups": eos.gamedata.Group,
|
||||
"invmetagroups": eos.gamedata.MetaGroup,
|
||||
"invmetatypes": eos.gamedata.MetaType,
|
||||
"invtypes": eos.gamedata.Item,
|
||||
"phbtraits": eos.gamedata.Traits,
|
||||
"mapbulk_marketGroups": eos.gamedata.MarketGroup
|
||||
}
|
||||
|
||||
fieldMapping = {
|
||||
"dgmattribs": {
|
||||
"displayName_en-us": "displayName"
|
||||
},
|
||||
"dgmeffects": {
|
||||
"displayName_en-us": "displayName",
|
||||
"description_en-us": "description"
|
||||
},
|
||||
"dgmunits": {
|
||||
"displayName_en-us": "displayName"
|
||||
},
|
||||
#icons???
|
||||
"invcategories": {
|
||||
"categoryName_en-us": "categoryName"
|
||||
},
|
||||
"invgroups": {
|
||||
"groupName_en-us": "groupName"
|
||||
},
|
||||
"invmetagroups": {
|
||||
"metaGroupName_en-us": "metaGroupName"
|
||||
},
|
||||
"invtypes": {
|
||||
"typeName_en-us": "typeName",
|
||||
"description_en-us": "description"
|
||||
},
|
||||
#phbtraits???
|
||||
"mapbulk_marketGroups": {
|
||||
"marketGroupName_en-us": "marketGroupName",
|
||||
"description_en-us": "description"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def convertIcons(data):
|
||||
new = []
|
||||
for k, v in data.items():
|
||||
v["iconID"] = k
|
||||
new.append(v)
|
||||
return new
|
||||
|
||||
def convertTraits(data):
|
||||
|
||||
def convertSection(sectionData):
|
||||
sectionLines = []
|
||||
headerText = u"<b>{}</b>".format(sectionData["header"])
|
||||
sectionLines.append(headerText)
|
||||
for bonusData in sectionData["bonuses"]:
|
||||
prefix = u"{} ".format(bonusData["number"]) if "number" in bonusData else ""
|
||||
bonusText = u"{}{}".format(prefix, bonusData["text"])
|
||||
sectionLines.append(bonusText)
|
||||
sectionLine = u"<br />\n".join(sectionLines)
|
||||
return sectionLine
|
||||
|
||||
newData = []
|
||||
for row in data:
|
||||
typeLines = []
|
||||
typeId = row["typeID"]
|
||||
traitData = row["traits_en-us"]
|
||||
for skillData in sorted(traitData.get("skills", ()), key=lambda i: i["header"]):
|
||||
typeLines.append(convertSection(skillData))
|
||||
if "role" in traitData:
|
||||
typeLines.append(convertSection(traitData["role"]))
|
||||
if "misc" in traitData:
|
||||
typeLines.append(convertSection(traitData["misc"]))
|
||||
traitLine = u"<br />\n<br />\n".join(typeLines)
|
||||
newRow = {"typeID": typeId, "traitText": traitLine}
|
||||
newData.append(newRow)
|
||||
return newData
|
||||
|
||||
data = {}
|
||||
|
||||
# Dump all data to memory so we can easely cross check ignored rows
|
||||
for jsonName, cls in tables.iteritems():
|
||||
f = open(os.path.join(jsonPath, "{}.json".format(jsonName)))
|
||||
data[jsonName] = json.load(f, encoding='cp1252')
|
||||
with open(os.path.join(jsonPath, "{}.json".format(jsonName))) as f:
|
||||
tableData = json.load(f)
|
||||
if jsonName == "icons":
|
||||
tableData = convertIcons(tableData)
|
||||
if jsonName == "phbtraits":
|
||||
tableData = convertTraits(tableData)
|
||||
data[jsonName] = tableData
|
||||
|
||||
# Do some preprocessing to make our job easier
|
||||
invTypes = set()
|
||||
@@ -92,21 +166,21 @@ if __name__ == "__main__":
|
||||
return False
|
||||
|
||||
# Loop through each json file and write it away, checking ignored rows
|
||||
for jsonName, table in data.iteritems():
|
||||
fieldMap = fieldMapping.get(jsonName, {})
|
||||
for jsonName, table in data.iteritems():
|
||||
fieldMap = fieldMapping.get(jsonName, {})
|
||||
print "processing {}".format(jsonName)
|
||||
for row in table:
|
||||
# We don't care about some kind of rows, filter it out if so
|
||||
if not isIgnored(jsonName, row):
|
||||
instance = tables[jsonName]()
|
||||
# fix for issue 80
|
||||
if jsonName is "icons" and "res:/UI/Texture/Icons/" in str(row['iconFile']):
|
||||
row['iconFile'] = row['iconFile'].replace('res:/UI/Texture/Icons/','').replace('.png','')
|
||||
for k, v in row.iteritems():
|
||||
setattr(instance, fieldMap.get(k, k), v)
|
||||
if jsonName is "icons" and "res:/UI/Texture/Icons/" in str(row["iconFile"]):
|
||||
row["iconFile"] = row["iconFile"].replace("res:/UI/Texture/Icons/","").replace(".png", "")
|
||||
for k, v in row.iteritems():
|
||||
setattr(instance, fieldMap.get(k, k), v)
|
||||
|
||||
eos.db.gamedata_session.add(instance)
|
||||
|
||||
eos.db.gamedata_session.commit()
|
||||
|
||||
|
||||
print("done")
|
||||
|
||||
@@ -154,7 +154,7 @@ class ItemStatsContainer ( wx.Panel ):
|
||||
self.nbContainer = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
mainSizer.Add( self.nbContainer, 1, wx.EXPAND |wx.ALL, 2 )
|
||||
|
||||
if len(item.traits) != 0:
|
||||
if len(item.traits.traitText) != 0:
|
||||
self.traits = ItemTraits(self.nbContainer, stuff, item)
|
||||
self.nbContainer.AddPage(self.traits, "Traits")
|
||||
|
||||
@@ -221,32 +221,8 @@ class ItemTraits ( wx.Panel ):
|
||||
self.SetSizer(mainSizer)
|
||||
|
||||
self.traits = wx.html.HtmlWindow(self)
|
||||
|
||||
# Format: {skill name: [bonus text]}
|
||||
traitData = {}
|
||||
for trait in item.traits:
|
||||
skillData = traitData.setdefault(trait.skillName, [])
|
||||
skillData.append(trait.bonusText)
|
||||
|
||||
def getSection(header, rows):
|
||||
sectionRows = [header]
|
||||
for row in sorted(rows):
|
||||
sectionRows.append(row)
|
||||
return u'<br />'.join(sectionRows)
|
||||
|
||||
textRows = []
|
||||
for skillName in sorted(traitData):
|
||||
# Skills always go 1st
|
||||
if skillName is None:
|
||||
continue
|
||||
header = u"<b>{} bonuses (per skill level):</b>".format(skillName)
|
||||
textRows.append(getSection(header, traitData[skillName]))
|
||||
|
||||
if None in traitData:
|
||||
textRows.append(getSection("<b>Role Bonus:</b>", traitData[None]))
|
||||
|
||||
fullText = u"<br /><br />".join(textRows)
|
||||
self.traits.SetPage(fullText)
|
||||
print(item.traits)
|
||||
self.traits.SetPage(item.traits.traitText)
|
||||
|
||||
mainSizer.Add(self.traits, 1, wx.ALL|wx.EXPAND, 0)
|
||||
self.Layout()
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user