diff --git a/eos/db/gamedata/__init__.py b/eos/db/gamedata/__init__.py index 83fe03c97..eabfd7f1b 100644 --- a/eos/db/gamedata/__init__.py +++ b/eos/db/gamedata/__init__.py @@ -1,2 +1,2 @@ __all__ = ["attribute", "category", "effect", "group", "metaData", - "icon", "item", "marketGroup", "metaGroup", "unit"] + "icon", "item", "marketGroup", "metaGroup", "unit", "alphaClones"] diff --git a/eos/db/gamedata/alphaClones.py b/eos/db/gamedata/alphaClones.py new file mode 100644 index 000000000..e21b61d5c --- /dev/null +++ b/eos/db/gamedata/alphaClones.py @@ -0,0 +1,45 @@ +# =============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of eos. +# +# eos is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# eos is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with eos. If not, see . +# =============================================================================== + +from sqlalchemy import Column, String, Integer, Table, ForeignKey +from sqlalchemy.orm import relation, mapper + +from eos.db import gamedata_meta +from eos.types import AlphaClone, AlphaCloneSkill + +alphaclones_table = Table("alphaClones", gamedata_meta, + Column("alphaCloneID", Integer, primary_key=True), + Column("alphaCloneName", String), + ) + +alphacloneskskills_table = Table("alphaCloneSkills", gamedata_meta, + Column("alphaCloneID", Integer, ForeignKey("alphaClones.alphaCloneID"), primary_key=True), + Column("typeID", Integer, primary_key=True), + Column("level", Integer), + ) + +mapper(AlphaClone, alphaclones_table, + properties={ + "_AlphaClone__skills": relation( + AlphaCloneSkill, + cascade="all,delete-orphan", + backref="clone") + }) + +mapper(AlphaCloneSkill, alphacloneskskills_table) diff --git a/eos/db/saveddata/character.py b/eos/db/saveddata/character.py index fad8c579d..7d0c5f14c 100644 --- a/eos/db/saveddata/character.py +++ b/eos/db/saveddata/character.py @@ -33,6 +33,7 @@ characters_table = Table("characters", saveddata_meta, Column("defaultChar", Integer), Column("chars", String, nullable=True), Column("defaultLevel", Integer, nullable=True), + Column("alphaClone", Integer, nullable=True), Column("ownerID", ForeignKey("users.ID"), nullable=True)) mapper(Character, characters_table, diff --git a/eos/gamedata.py b/eos/gamedata.py index c4b58b235..1084cb317 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -444,6 +444,14 @@ class Category(EqBase): pass +class AlphaClone(EqBase): + pass + + +class AlphaCloneSkill(EqBase): + pass + + class Group(EqBase): pass diff --git a/eos/types.py b/eos/types.py index d42cd0fe8..80f36a826 100644 --- a/eos/types.py +++ b/eos/types.py @@ -18,7 +18,8 @@ # =============================================================================== from eos.gamedata import Attribute, Category, Effect, Group, Icon, Item, MarketGroup, \ - MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits + MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits, AlphaClone, \ + AlphaCloneSkill from eos.saveddata.price import Price from eos.saveddata.user import User from eos.saveddata.crestchar import CrestChar diff --git a/scripts/jsonToSql.py b/scripts/jsonToSql.py index 1f431f3d8..173fc59f3 100755 --- a/scripts/jsonToSql.py +++ b/scripts/jsonToSql.py @@ -47,6 +47,7 @@ def main(db, json_path): # Config dict tables = { + "clonegrades": eos.gamedata.AlphaCloneSkill, "dgmattribs": eos.gamedata.AttributeInfo, "dgmeffects": eos.gamedata.EffectInfo, "dgmtypeattribs": eos.gamedata.Attribute, @@ -60,7 +61,8 @@ def main(db, json_path): "evetypes": eos.gamedata.Item, "phbtraits": eos.gamedata.Traits, "phbmetadata": eos.gamedata.MetaData, - "mapbulk_marketGroups": eos.gamedata.MarketGroup + "mapbulk_marketGroups": eos.gamedata.MarketGroup, + } fieldMapping = { @@ -109,6 +111,19 @@ def main(db, json_path): new.append(v) return new + def convertClones(data): + newData = [] + + for ID in data: + for skill in data[ID]["skills"]: + newData.append({ + "alphaCloneID": int(ID), + "alphaCloneName": data[ID]["internalDescription"], + "typeID": skill["typeID"], + "level": skill["level"]}) + + return newData + def convertTraits(data): def convertSection(sectionData): @@ -167,6 +182,8 @@ def main(db, json_path): tableData = convertTraits(tableData) if jsonName == "evetypes": tableData = convertTypes(tableData) + if jsonName == "clonegrades": + tableData = convertClones(tableData) data[jsonName] = tableData # Set with typeIDs which we will have in our database @@ -191,7 +208,10 @@ def main(db, json_path): # Loop through each json file and write it away, checking ignored rows for jsonName, table in data.iteritems(): fieldMap = fieldMapping.get(jsonName, {}) + tmp = [] + 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): @@ -207,6 +227,14 @@ def main(db, json_path): if jsonName is "icons" and "modules/" in str(row["iconFile"]).lower(): row["iconFile"] = row["iconFile"].lower().replace("modules/", "").replace(".png", "") + if jsonName is "clonegrades": + if (row["alphaCloneID"] not in tmp): + cloneParent = eos.gamedata.AlphaClone() + setattr(cloneParent, "alphaCloneID", row["alphaCloneID"]) + setattr(cloneParent, "alphaCloneName", row["alphaCloneName"]) + eos.db.gamedata_session.add(cloneParent) + tmp.append(row['alphaCloneID']) + for k, v in row.iteritems(): if (isinstance(v, basestring)): v = v.strip()