diff --git a/eos/db/__init__.py b/eos/db/__init__.py index 21b790421..b237fcc2e 100644 --- a/eos/db/__init__.py +++ b/eos/db/__init__.py @@ -74,7 +74,7 @@ sd_lock = threading.RLock() # Import all the definitions for all our database stuff # noinspection PyPep8 -from eos.db.gamedata import alphaClones, attribute, category, effect, group, icon, item, marketGroup, metaData, metaGroup, queries, traits, unit +from eos.db.gamedata import alphaClones, attribute, category, effect, group, icon, item, marketGroup, metaData, metaGroup, queries, traits, unit, dynamicAttributes # noinspection PyPep8 from eos.db.saveddata import booster, cargo, character, damagePattern, databaseRepair, drone, fighter, fit, implant, implantSet, loadDefaultDatabaseValues, \ miscData, mutator, module, override, price, queries, skill, targetResists, user diff --git a/eos/db/gamedata/__init__.py b/eos/db/gamedata/__init__.py index eabfd7f1b..ec4ab0c2c 100644 --- a/eos/db/gamedata/__init__.py +++ b/eos/db/gamedata/__init__.py @@ -1,2 +1,2 @@ -__all__ = ["attribute", "category", "effect", "group", "metaData", +__all__ = ["attribute", "category", "effect", "group", "metaData", "dynamicAttributes", "icon", "item", "marketGroup", "metaGroup", "unit", "alphaClones"] diff --git a/eos/db/gamedata/dynamicAttributes.py b/eos/db/gamedata/dynamicAttributes.py new file mode 100644 index 000000000..774f57f78 --- /dev/null +++ b/eos/db/gamedata/dynamicAttributes.py @@ -0,0 +1,43 @@ +# =============================================================================== +# 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, Float, Integer, Table, ForeignKey +from sqlalchemy.orm import mapper + +from eos.db import gamedata_meta +from eos.gamedata import DynamicItem, DynamicItemAttribute, DynamicItemItem + +dynamic_table = Table("mutaplasmids", gamedata_meta, + Column("typeID", ForeignKey("invtypes.typeID"), primary_key=True, index=True), + Column("resultingTypeID", ForeignKey("invtypes.typeID"), primary_key=True)) + +dynamicAttributes_table = Table("mutaplasmidAttributes", gamedata_meta, + Column("typeID", Integer, ForeignKey("mutaplasmids.typeID"), primary_key=True), + Column("attributeID", Integer, primary_key=True), + Column("min", Float), + Column("max", Float)) + +dynamicApplicable_table = Table("mutaplasmidItems", gamedata_meta, + Column("typeID", Integer, ForeignKey("mutaplasmids.typeID"), primary_key=True), + Column("applicableTypeID", ForeignKey("invtypes.typeID"), primary_key=True), + ) + +mapper(DynamicItem, dynamic_table) +mapper(DynamicItemAttribute, dynamicAttributes_table) +mapper(DynamicItemItem, dynamicApplicable_table) diff --git a/eos/gamedata.py b/eos/gamedata.py index af7d413a7..f67a000f6 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -515,6 +515,17 @@ class Icon(EqBase): pass +class DynamicItem(EqBase): + pass + + +class DynamicItemAttribute(EqBase): + pass + + +class DynamicItemItem(EqBase): + pass + class MarketGroup(EqBase): def __repr__(self): return "MarketGroup(ID={}, name={}, parent={}) at {}".format( diff --git a/scripts/jsonToSql.py b/scripts/jsonToSql.py index 67a56d310..33daf977e 100755 --- a/scripts/jsonToSql.py +++ b/scripts/jsonToSql.py @@ -264,6 +264,29 @@ def main(db, json_path): eos.db.gamedata_session.add(instance) + # quick and dirty hack to get this data in + with open(os.path.join(jsonPath, "dynamicAttributes.json"), encoding="utf-8") as f: + bulkdata = json.load(f) + for mutaID, data in bulkdata.items(): + muta = eos.gamedata.DynamicItem() + muta.typeID = mutaID + muta.resultingTypeID = data['inputOutputMapping'][0]['resultingType'] + eos.db.gamedata_session.add(muta) + + for x in data['inputOutputMapping'][0]['applicableTypes']: + item = eos.gamedata.DynamicItemItem() + item.typeID = mutaID + item.applicableTypeID = x + eos.db.gamedata_session.add(item) + + for attrID, attrData in data['attributeIDs'].items(): + attr = eos.gamedata.DynamicItemAttribute() + attr.typeID = mutaID + attr.attributeID = attrID + attr.min = attrData['min'] + attr.max = attrData['max'] + eos.db.gamedata_session.add(attr) + eos.db.gamedata_session.commit() # CCP still has 5 subsystems assigned to T3Cs, even though only 4 are available / usable. They probably have some @@ -280,3 +303,4 @@ if __name__ == "__main__": args = parser.parse_args() main(args.db, args.json) +