Merge branch 'feature/alphaclones' into development

This commit is contained in:
blitzmann
2017-01-26 19:53:27 -05:00
12 changed files with 181 additions and 7 deletions

View File

@@ -1,2 +1,2 @@
__all__ = ["attribute", "category", "effect", "group", "metaData",
"icon", "item", "marketGroup", "metaGroup", "unit"]
"icon", "item", "marketGroup", "metaGroup", "unit", "alphaClones"]

View File

@@ -0,0 +1,46 @@
# ===============================================================================
# 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 <http://www.gnu.org/licenses/>.
# ===============================================================================
from sqlalchemy import Column, String, Integer, Table, ForeignKey
from sqlalchemy.orm import relation, mapper, synonym
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={
"ID": synonym("alphaCloneID"),
"skills": relation(
AlphaCloneSkill,
cascade="all,delete-orphan",
backref="clone")
})
mapper(AlphaCloneSkill, alphacloneskskills_table)

View File

@@ -24,7 +24,7 @@ import eos.config
from eos.db import gamedata_session
from eos.db.gamedata.metaGroup import metatypes_table, items_table
from eos.db.util import processEager, processWhere
from eos.types import Item, Category, Group, MarketGroup, AttributeInfo, MetaData, MetaGroup
from eos.types import Item, Category, Group, MarketGroup, AttributeInfo, MetaData, MetaGroup, AlphaClone
configVal = getattr(eos.config, "gamedataCache", None)
if configVal is True:
@@ -97,6 +97,24 @@ def getItem(lookfor, eager=None):
return item
@cachedQuery(1, "lookfor")
def getAlphaClone(lookfor, eager=None):
if isinstance(lookfor, int):
if eager is None:
item = gamedata_session.query(AlphaClone).get(lookfor)
else:
item = gamedata_session.query(AlphaClone).options(*processEager(eager)).filter(AlphaClone.ID == lookfor).first()
else:
raise TypeError("Need integer as argument")
return item
def getAlphaCloneList(eager=None):
eager = processEager(eager)
clones = gamedata_session.query(AlphaClone).options(*eager).all()
return clones
groupNameMap = {}

View File

@@ -33,10 +33,12 @@ characters_table = Table("characters", saveddata_meta,
Column("defaultChar", Integer),
Column("chars", String, nullable=True),
Column("defaultLevel", Integer, nullable=True),
Column("alphaCloneID", Integer, nullable=True),
Column("ownerID", ForeignKey("users.ID"), nullable=True))
mapper(Character, characters_table,
properties={
"_Character__alphaCloneID": characters_table.c.alphaCloneID,
"savedName": characters_table.c.name,
"_Character__owner": relation(
User,

View File

@@ -444,6 +444,25 @@ class Category(EqBase):
pass
class AlphaClone(EqBase):
@reconstructor
def init(self):
self.skillCache = {}
for x in self.skills:
self.skillCache[x.typeID] = x
def getSkillLevel(self, skill):
if skill.item.ID in self.skillCache:
return self.skillCache[skill.item.ID].level
else:
return None
class AlphaCloneSkill(EqBase):
pass
class Group(EqBase):
pass

View File

@@ -99,6 +99,7 @@ class Character(object):
self.__skills = []
self.__skillIdMap = {}
self.dirtySkills = set()
self.alphaClone = None
if initSkills:
for item in self.getSkillList():
@@ -109,11 +110,17 @@ class Character(object):
@reconstructor
def init(self):
self.__skillIdMap = {}
for skill in self.__skills:
self.__skillIdMap[skill.itemID] = skill
self.dirtySkills = set()
self.alphaClone = None
if self.alphaCloneID:
self.alphaClone = eos.db.getAlphaClone(self.alphaCloneID)
def apiUpdateCharSheet(self, skills):
del self.__skills[:]
self.__skillIdMap.clear()
@@ -140,6 +147,15 @@ class Character(object):
def name(self, name):
self.savedName = name
@property
def alphaCloneID(self):
return self.__alphaCloneID
@alphaCloneID.setter
def alphaCloneID(self, cloneID):
self.__alphaCloneID = cloneID
self.alphaClone = eos.db.getAlphaClone(cloneID) if cloneID is not None else None
@property
def skills(self):
return self.__skills
@@ -294,6 +310,9 @@ class Skill(HandledItem):
@property
def level(self):
if self.character.alphaClone:
return min(self.activeLevel, self.character.alphaClone.getSkillLevel(self)) or 0
return self.activeLevel or 0
@level.setter

View File

@@ -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

BIN
eve.db

Binary file not shown.

View File

@@ -239,10 +239,25 @@ class SkillTreeView (wx.Panel):
pmainSizer = wx.BoxSizer(wx.VERTICAL)
self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0)
i = self.clonesChoice.Append("Omega Clone", None)
self.clonesChoice.SetSelection(i)
pmainSizer.Add(self.clonesChoice, 0, wx.ALL | wx.EXPAND, 5)
sChar = service.Character.getInstance()
self.alphaClones = sChar.getAlphaCloneList()
char = self.charEditor.entityEditor.getActiveEntity()
for clone in self.alphaClones:
i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID)
if clone.ID == char.alphaCloneID:
self.clonesChoice.SetSelection(i)
self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged)
tree = self.skillTreeListCtrl = wx.gizmos.TreeListCtrl(self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5)
self.imageList = wx.ImageList(16, 16)
tree.SetImageList(self.imageList)
self.skillBookImageId = self.imageList.Add(BitmapLoader.getBitmap("skill_small", "gui"))
@@ -262,7 +277,7 @@ class SkillTreeView (wx.Panel):
tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu)
# bind the Character selection event
self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.populateSkillTree)
self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged)
self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree)
srcContext = "skillItem"
@@ -295,11 +310,30 @@ class SkillTreeView (wx.Panel):
self.Layout()
def cloneChanged(self, event):
sChar = service.Character.getInstance()
sChar.setAlphaClone(self.charEditor.entityEditor.getActiveEntity(), event.ClientData)
self.populateSkillTree()
def charChanged(self, event=None):
char = self.charEditor.entityEditor.getActiveEntity()
for i in range(self.clonesChoice.GetCount()):
cloneID = self.clonesChoice.GetClientData(i)
if char.alphaCloneID == cloneID:
self.clonesChoice.SetSelection(i)
self.populateSkillTree(event)
def populateSkillTree(self, event=None):
sChar = service.Character.getInstance()
char = self.charEditor.entityEditor.getActiveEntity()
dirtyGroups = set([skill.item.group.ID for skill in char.dirtySkills])
if char.name in ("All 0", "All 5"):
self.clonesChoice.Disable()
else:
self.clonesChoice.Enable()
groups = sChar.getSkillGroups()
imageId = self.skillBookImageId
root = self.root

View File

@@ -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()

View File

@@ -80,7 +80,7 @@ if not args.nojson:
list = "dgmexpressions,dgmattribs,dgmeffects,dgmtypeattribs,dgmtypeeffects,"\
"dgmunits,invcategories,invgroups,invmetagroups,invmetatypes,"\
"invtypes,mapbulk_marketGroups,phbmetadata,phbtraits,fsdTypeOverrides,"\
"evegroups,evetypes,evecategories,mapbulk_marketGroups"
"evegroups,evetypes,evecategories,mapbulk_marketGroups,clonegrades"
FlowManager(miners, writers).run(list, "en-us")

View File

@@ -205,6 +205,9 @@ class Character(object):
def all5ID(self):
return self.all5().ID
def getAlphaCloneList(self):
return eos.db.getAlphaCloneList()
def getCharacterList(self):
return eos.db.getCharacterList()
@@ -250,6 +253,10 @@ class Character(object):
skills.append((skill.ID, skill.name))
return skills
def setAlphaClone(self, char, cloneID):
char.alphaCloneID = cloneID
eos.db.commit()
def getSkillDescription(self, itemID):
return eos.db.getItem(itemID).description