Skip to content

Commit

Permalink
Merge branch 'charImplants' into singularity
Browse files Browse the repository at this point in the history
# Conflicts:
#	eos/db/saveddata/fit.py
#	gui/builtinContextMenus/itemStats.py
  • Loading branch information
blitzmann committed Apr 13, 2016
2 parents e11e368 + 0d41cb9 commit e7118f6
Show file tree
Hide file tree
Showing 66 changed files with 1,576 additions and 849 deletions.
6 changes: 4 additions & 2 deletions eos/db/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import re
import os
import migrations
import logging

logger = logging.getLogger(__name__)

def getVersion(db):
cursor = db.execute('PRAGMA user_version')
Expand All @@ -30,10 +33,9 @@ def update(saveddata_engine):
shutil.copyfile(config.saveDB, toFile)

for version in xrange(dbVersion, appVersion):

func = migrations.updates[version+1]
if func:
print "applying update",version+1
logger.info("Applying database update: %d", version+1)
func(saveddata_engine)

# when all is said and done, set version to current
Expand Down
15 changes: 15 additions & 0 deletions eos/db/migrations/upgrade13.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Migration 13
- Alters fits table to introduce implant location attribute
"""

import sqlalchemy

def upgrade(saveddata_engine):
# Update fits schema to include implant location attribute
try:
saveddata_engine.execute("SELECT implantLocation FROM fits LIMIT 1")
except sqlalchemy.exc.DatabaseError:
saveddata_engine.execute("ALTER TABLE fits ADD COLUMN implantLocation INTEGER;")
saveddata_engine.execute("UPDATE fits SET implantLocation = 0")
3 changes: 2 additions & 1 deletion eos/db/saveddata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"miscData",
"targetResists",
"override",
"crest"
"crest",
"implantSet"
]

26 changes: 20 additions & 6 deletions eos/db/saveddata/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,23 @@
Column("ownerID", ForeignKey("users.ID"), nullable = True))

mapper(Character, characters_table,
properties = {"_Character__owner" : relation(User, backref = "characters"),
"_Character__skills" : relation(Skill, backref="character", cascade = "all,delete-orphan"),
"_Character__implants" : relation(Implant, collection_class = HandledImplantBoosterList, cascade='all,delete-orphan', single_parent=True,
primaryjoin = charImplants_table.c.charID == characters_table.c.ID,
secondaryjoin = charImplants_table.c.implantID == Implant.ID,
secondary = charImplants_table),})
properties = {
"savedName": characters_table.c.name,
"_Character__owner": relation(
User,
backref = "characters"),
"_Character__skills": relation(
Skill,
backref="character",
cascade = "all,delete-orphan"),
"_Character__implants": relation(
Implant,
collection_class = HandledImplantBoosterList,
cascade='all,delete-orphan',
backref='character',
single_parent=True,
primaryjoin = charImplants_table.c.charID == characters_table.c.ID,
secondaryjoin = charImplants_table.c.implantID == Implant.ID,
secondary = charImplants_table),
}
)
3 changes: 2 additions & 1 deletion eos/db/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from eos.db.saveddata.fighter import fighters_table
from eos.db.saveddata.cargo import cargo_table
from eos.db.saveddata.implant import fitImplants_table
from eos.types import Fit, Module, User, Booster, Drone, Fighter, Cargo, Implant, Character, DamagePattern, TargetResists
from eos.types import Fit, Module, User, Booster, Drone, Fighter, Cargo, Implant, Character, DamagePattern, TargetResists, ImplantLocation
from eos.effectHandlerHelpers import *

fits_table = Table("fits", saveddata_meta,
Expand All @@ -43,6 +43,7 @@
Column("booster", Boolean, nullable = False, index = True, default = 0),
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True),
Column("modeID", Integer, nullable=True),
Column("implantLocation", Integer, nullable=False, default=ImplantLocation.FIT),
)

projectedFits_table = Table("projectedFits", saveddata_meta,
Expand Down
4 changes: 4 additions & 0 deletions eos/db/saveddata/implant.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@
Column("charID", ForeignKey("characters.ID"), index = True),
Column("implantID", ForeignKey("implants.ID"), primary_key = True))

implantsSetMap_table = Table("implantSetMap", saveddata_meta,
Column("setID", ForeignKey("implantSets.ID"), index = True),
Column("implantID", ForeignKey("implants.ID"), primary_key = True))

mapper(Implant, implants_table)
45 changes: 45 additions & 0 deletions eos/db/saveddata/implantSet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#===============================================================================
# Copyright (C) 2016 Ryan Holmes
#
# 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 Table, Column, Integer, ForeignKey, String
from sqlalchemy.orm import relation, mapper

from eos.db import saveddata_meta
from eos.db.saveddata.implant import implantsSetMap_table
from eos.types import Implant, ImplantSet
from eos.effectHandlerHelpers import HandledImplantBoosterList

implant_set_table = Table("implantSets", saveddata_meta,
Column("ID", Integer, primary_key = True),
Column("name", String, nullable = False),
)

mapper(ImplantSet, implant_set_table,
properties = {
"_ImplantSet__implants": relation(
Implant,
collection_class = HandledImplantBoosterList,
cascade='all, delete, delete-orphan',
backref='set',
single_parent=True,
primaryjoin = implantsSetMap_table.c.setID == implant_set_table.c.ID,
secondaryjoin = implantsSetMap_table.c.implantID == Implant.ID,
secondary = implantsSetMap_table),
}
)
28 changes: 26 additions & 2 deletions eos/db/saveddata/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from eos.db.util import processEager, processWhere
from eos.db import saveddata_session, sd_lock

from eos.types import User, Character, Fit, Price, DamagePattern, Fleet, MiscData, Wing, Squad, TargetResists, Override, CrestChar
from eos.types import *
from eos.db.saveddata.fleet import squadmembers_table
from eos.db.saveddata.fit import projectedFits_table
from sqlalchemy.sql import and_
Expand Down Expand Up @@ -154,7 +154,7 @@ def getCharacter(lookfor, eager=None):
elif isinstance(lookfor, basestring):
eager = processEager(eager)
with sd_lock:
character = saveddata_session.query(Character).options(*eager).filter(Character.name == lookfor).first()
character = saveddata_session.query(Character).options(*eager).filter(Character.savedName == lookfor).first()
else:
raise TypeError("Need integer or string as argument")
return character
Expand Down Expand Up @@ -349,6 +349,12 @@ def getTargetResistsList(eager=None):
patterns = saveddata_session.query(TargetResists).options(*eager).all()
return patterns

def getImplantSetList(eager=None):
eager = processEager(eager)
with sd_lock:
sets = saveddata_session.query(ImplantSet).options(*eager).all()
return sets

@cachedQuery(DamagePattern, 1, "lookfor")
def getDamagePattern(lookfor, eager=None):
if isinstance(lookfor, int):
Expand Down Expand Up @@ -385,6 +391,24 @@ def getTargetResists(lookfor, eager=None):
raise TypeError("Need integer or string as argument")
return pattern

@cachedQuery(ImplantSet, 1, "lookfor")
def getImplantSet(lookfor, eager=None):
if isinstance(lookfor, int):
if eager is None:
with sd_lock:
pattern = saveddata_session.query(ImplantSet).get(lookfor)
else:
eager = processEager(eager)
with sd_lock:
pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.ID == lookfor).first()
elif isinstance(lookfor, basestring):
eager = processEager(eager)
with sd_lock:
pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.name == lookfor).first()
else:
raise TypeError("Improper argument")
return pattern

def searchFits(nameLike, where=None, eager=None):
if not isinstance(nameLike, basestring):
raise TypeError("Need string as argument")
Expand Down
2 changes: 1 addition & 1 deletion eos/effects/angelsetbonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(
fit.appliedImplants.filteredItemMultiply(
lambda implant: "signatureRadiusBonus" in implant.itemModifiedAttributes and "implantSetAngel" in implant.itemModifiedAttributes,
"signatureRadiusBonus",
implant.getModifiedItemAttr("implantSetAngel"))
2 changes: 1 addition & 1 deletion eos/effects/caldarisetbonus3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanGravimetricStrengthPercent", implant.getModifiedItemAttr("implantSetCaldariNavy"))
2 changes: 1 addition & 1 deletion eos/effects/caldarisetlgbonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanGravimetricStrengthModifier", implant.getModifiedItemAttr("implantSetLGCaldariNavy"))
2 changes: 1 addition & 1 deletion eos/effects/federationsetbonus3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
type = "passive"
runTime = "early"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanMagnetometricStrengthPercent", implant.getModifiedItemAttr("implantSetFederationNavy"))
2 changes: 1 addition & 1 deletion eos/effects/federationsetlgbonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
type = "passive"
runTime = "early"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanMagnetometricStrengthModifier", implant.getModifiedItemAttr("implantSetLGFederationNavy"))
2 changes: 1 addition & 1 deletion eos/effects/imperialsetbonus3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
type = "passive"
runTime = "early"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanRadarStrengthPercent", implant.getModifiedItemAttr("implantSetImperialNavy"))
2 changes: 1 addition & 1 deletion eos/effects/imperialsetlgbonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
type = "passive"
runTime = "early"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanRadarStrengthModifier", implant.getModifiedItemAttr("implantSetLGImperialNavy"))
2 changes: 1 addition & 1 deletion eos/effects/implantsetwarpspeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"WarpSBonus", implant.getModifiedItemAttr("implantSetWarpSpeed"))
2 changes: 1 addition & 1 deletion eos/effects/republicsetbonus3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanLadarStrengthPercent", implant.getModifiedItemAttr("implantSetRepublicFleet"))
2 changes: 1 addition & 1 deletion eos/effects/republicsetlgbonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"scanLadarStrengthModifier", implant.getModifiedItemAttr("implantSetLGRepublicFleet"))
2 changes: 1 addition & 1 deletion eos/effects/setbonusbloodraider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"durationBonus", implant.getModifiedItemAttr("implantSetBloodraider"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmasagilitybonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"agilityBonus", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmasarmorhpbonus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"armorHpBonus2", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmasbonusvelocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"implantBonusVelocity", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmascapacitorcapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"capacitorCapacityBonus", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmascapacitorrecharge2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"capRechargeBonus", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmascpuoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"cpuOutputBonus2", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmaspowergrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"powerEngineeringOutputBonus", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonuschristmasshieldcapacitybonus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"shieldCapacityBonus", implant.getModifiedItemAttr("implantSetChristmas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonusguristas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"shieldBoostMultiplier", implant.getModifiedItemAttr("implantSetGuristas"))
2 changes: 1 addition & 1 deletion eos/effects/setbonusmordus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"rangeSkillBonus", implant.getModifiedItemAttr("implantSetMordus"))
2 changes: 1 addition & 1 deletion eos/effects/setbonusore.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"maxRangeBonus", implant.getModifiedItemAttr("implantSetORE"))
2 changes: 1 addition & 1 deletion eos/effects/setbonussansha.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
fit.appliedImplants.filteredItemMultiply(lambda target: target.item.requiresSkill("Cybernetics"),
"armorHpBonus", implant.getModifiedItemAttr("implantSetSansha") or 1)
2 changes: 1 addition & 1 deletion eos/effects/setbonusserpentis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"velocityBonus", implant.getModifiedItemAttr("implantSetSerpentis"))
2 changes: 1 addition & 1 deletion eos/effects/setbonussisters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"scanStrengthBonus", implant.getModifiedItemAttr("implantSetSisters"))
2 changes: 1 addition & 1 deletion eos/effects/setbonussyndicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"boosterAttributeModifier", implant.getModifiedItemAttr("implantSetSyndicate"))
2 changes: 1 addition & 1 deletion eos/effects/setbonusthukker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
runTime = "early"
type = "passive"
def handler(fit, implant, context):
fit.implants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
fit.appliedImplants.filteredItemMultiply(lambda mod: mod.item.group.name == "Cyberimplant",
"agilityBonus", implant.getModifiedItemAttr("implantSetThukker"))
Loading

0 comments on commit e7118f6

Please sign in to comment.