Merge branch 'singularity'
This commit is contained in:
@@ -68,14 +68,8 @@ from eos.db.gamedata import *
|
||||
from eos.db.saveddata import *
|
||||
|
||||
#Import queries
|
||||
from eos.db.gamedata.queries import getItem, searchItems, getVariations, getItemsByCategory, directAttributeRequest, \
|
||||
getMarketGroup, getGroup, getCategory, getAttributeInfo, getMetaData, getMetaGroup
|
||||
from eos.db.saveddata.queries import getUser, getCharacter, getFit, getFitsWithShip, countFitsWithShip, searchFits, \
|
||||
getCharacterList, getPrice, getDamagePatternList, getDamagePattern, \
|
||||
getFitList, getFleetList, getFleet, save, remove, commit, add, \
|
||||
getCharactersForUser, getMiscData, getSquadsIDsWithFitID, getWing, \
|
||||
getSquad, getBoosterFits, getProjectedFits, getTargetResistsList, getTargetResists,\
|
||||
clearPrices, countAllFits
|
||||
from eos.db.gamedata.queries import *
|
||||
from eos.db.saveddata.queries import *
|
||||
|
||||
#If using in memory saveddata, you'll want to reflect it so the data structure is good.
|
||||
if config.saveddata_connectionstring == "sqlite:///:memory:":
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
__all__ = ["character", "fit", "module", "user", "skill", "price",
|
||||
"booster", "drone", "implant", "fleet", "damagePattern",
|
||||
"miscData", "targetResists"]
|
||||
__all__ = [
|
||||
"character",
|
||||
"fit",
|
||||
"module",
|
||||
"user",
|
||||
"skill",
|
||||
"price",
|
||||
"booster",
|
||||
"drone",
|
||||
"implant",
|
||||
"fleet",
|
||||
"damagePattern",
|
||||
"miscData",
|
||||
"targetResists",
|
||||
"override",
|
||||
"crest"
|
||||
]
|
||||
|
||||
|
||||
31
eos/db/saveddata/crest.py
Normal file
31
eos/db/saveddata/crest.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#===============================================================================
|
||||
# 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 Table, Column, Integer, String, Boolean
|
||||
from sqlalchemy.orm import mapper
|
||||
|
||||
from eos.db import saveddata_meta
|
||||
from eos.types import CrestChar
|
||||
|
||||
crest_table = Table("crest", saveddata_meta,
|
||||
Column("ID", Integer, primary_key = True),
|
||||
Column("name", String, nullable = False, unique = True),
|
||||
Column("refresh_token", String, nullable = False))
|
||||
|
||||
mapper(CrestChar, crest_table)
|
||||
31
eos/db/saveddata/override.py
Normal file
31
eos/db/saveddata/override.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#===============================================================================
|
||||
# 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 Table, Column, Integer, Float
|
||||
from sqlalchemy.orm import mapper
|
||||
|
||||
from eos.db import saveddata_meta
|
||||
from eos.types import Override
|
||||
|
||||
overrides_table = Table("overrides", saveddata_meta,
|
||||
Column("itemID", Integer, primary_key=True, index = True),
|
||||
Column("attrID", Integer, primary_key=True, index = True),
|
||||
Column("value", Float, nullable = False))
|
||||
|
||||
mapper(Override, overrides_table)
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
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
|
||||
|
||||
from eos.types import User, Character, Fit, Price, DamagePattern, Fleet, MiscData, Wing, Squad, TargetResists, Override, CrestChar
|
||||
from eos.db.saveddata.fleet import squadmembers_table
|
||||
from eos.db.saveddata.fit import projectedFits_table
|
||||
from sqlalchemy.sql import and_
|
||||
@@ -182,7 +183,7 @@ def getFit(lookfor, eager=None):
|
||||
else:
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
fit = saveddata_session.query(Fit).options(*eager).filter(Fit.ID == fitID).first()
|
||||
fit = saveddata_session.query(Fit).options(*eager).filter(Fit.ID == lookfor).first()
|
||||
else:
|
||||
raise TypeError("Need integer as argument")
|
||||
|
||||
@@ -416,6 +417,45 @@ def getProjectedFits(fitID):
|
||||
else:
|
||||
raise TypeError("Need integer as argument")
|
||||
|
||||
def getCrestCharacters(eager=None):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
characters = saveddata_session.query(CrestChar).options(*eager).all()
|
||||
return characters
|
||||
|
||||
@cachedQuery(CrestChar, 1, "lookfor")
|
||||
def getCrestCharacter(lookfor, eager=None):
|
||||
if isinstance(lookfor, int):
|
||||
if eager is None:
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(CrestChar).get(lookfor)
|
||||
else:
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.name == lookfor).first()
|
||||
else:
|
||||
raise TypeError("Need integer or string as argument")
|
||||
return character
|
||||
|
||||
def getOverrides(itemID, eager=None):
|
||||
if isinstance(itemID, int):
|
||||
return saveddata_session.query(Override).filter(Override.itemID == itemID).all()
|
||||
else:
|
||||
raise TypeError("Need integer as argument")
|
||||
|
||||
def clearOverrides():
|
||||
with sd_lock:
|
||||
deleted_rows = saveddata_session.query(Override).delete()
|
||||
commit()
|
||||
return deleted_rows
|
||||
|
||||
def getAllOverrides(eager=None):
|
||||
return saveddata_session.query(Override).all()
|
||||
|
||||
def removeInvalid(fits):
|
||||
invalids = [f for f in fits if f.isInvalid]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# armorTankingGang2
|
||||
# armorWarfareArmorHpReplacer
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Armored Warfare Mindlink
|
||||
@@ -1,7 +1,7 @@
|
||||
# boosterArmorHpPenalty
|
||||
#
|
||||
# Used by:
|
||||
# Implants from group: Booster (12 of 39)
|
||||
# Implants from group: Booster (12 of 37)
|
||||
type = "boosterSideEffect"
|
||||
def handler(fit, booster, context):
|
||||
fit.ship.boostItemAttr("armorHP", booster.getModifiedItemAttr("boosterArmorHPPenalty"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# boosterArmorRepairAmountPenalty
|
||||
#
|
||||
# Used by:
|
||||
# Implants from group: Booster (9 of 39)
|
||||
# Implants from group: Booster (9 of 37)
|
||||
type = "boosterSideEffect"
|
||||
def handler(fit, booster, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Repair Unit",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# boosterMaxVelocityPenalty
|
||||
#
|
||||
# Used by:
|
||||
# Implants from group: Booster (12 of 39)
|
||||
# Implants from group: Booster (12 of 37)
|
||||
type = "boosterSideEffect"
|
||||
def handler(fit, booster, context):
|
||||
fit.ship.boostItemAttr("maxVelocity", booster.getModifiedItemAttr("boosterMaxVelocityPenalty"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# boosterShieldCapacityPenalty
|
||||
#
|
||||
# Used by:
|
||||
# Implants from group: Booster (12 of 39)
|
||||
# Implants from group: Booster (12 of 37)
|
||||
type = "boosterSideEffect"
|
||||
def handler(fit, booster, context):
|
||||
fit.ship.boostItemAttr("shieldCapacity", booster.getModifiedItemAttr("boosterShieldCapacityPenalty"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# boosterTurretOptimalRangePenalty
|
||||
#
|
||||
# Used by:
|
||||
# Implants from group: Booster (9 of 39)
|
||||
# Implants from group: Booster (9 of 37)
|
||||
type = "boosterSideEffect"
|
||||
def handler(fit, booster, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
|
||||
|
||||
11
eos/effects/informationwarfaremaxtargetrangebonus.py
Normal file
11
eos/effects/informationwarfaremaxtargetrangebonus.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# informationWarfareMaxTargetRangeBonus
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Caldari Navy Warfare Mindlink
|
||||
# Implant: Imperial Navy Warfare Mindlink
|
||||
# Implant: Information Warfare Mindlink
|
||||
type = "gang"
|
||||
gangBoost = "maxTargetRange"
|
||||
gangBonus = "maxTargetRangeBonus"
|
||||
def handler(fit, container, context):
|
||||
fit.ship.boostItemAttr(gangBoost, container.getModifiedItemAttr(gangBonus))
|
||||
@@ -2,7 +2,6 @@
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Caldari Navy Warfare Mindlink
|
||||
# Implant: Imperial Navy Warfare Mindlink
|
||||
# Implant: Information Warfare Mindlink
|
||||
type = "passive"
|
||||
def handler(fit, implant, context):
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# miningForemanMindLinkMiningAmountBonusReplacer
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Mining Foreman Mindlink
|
||||
type = "gang"
|
||||
gangBoost = "miningAmount"
|
||||
gangBonus = "miningAmountBonus"
|
||||
def handler(fit, container, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining"),
|
||||
gangBoost, container.getModifiedItemAttr(gangBonus) * level)
|
||||
@@ -1,7 +1,6 @@
|
||||
# miningYieldGangBonusFixed
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Mining Foreman Mindlink
|
||||
# Skill: Mining Foreman
|
||||
type = "gang"
|
||||
gangBoost = "miningAmount"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# missileSkillRapidLauncherRoF
|
||||
#
|
||||
# Used by:
|
||||
# Implants named like: Cerebral Accelerator (5 of 5)
|
||||
# Implants named like: Cerebral Accelerator (3 of 3)
|
||||
# Implants named like: Zainou 'Deadeye' Rapid Launch RL (6 of 6)
|
||||
# Implant: Whelan Machorin's Ballistic Smartlink
|
||||
# Skill: Missile Launcher Operation
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# overloadSelfThermalHardeningBonus
|
||||
#
|
||||
# Used by:
|
||||
# Variations of module: Armor Thermic Hardener I (39 of 39)
|
||||
# Variations of module: Thermic Dissipation Field I (19 of 19)
|
||||
# Module: Civilian Thermic Dissipation Field
|
||||
# Variations of module: Armor Thermal Hardener I (39 of 39)
|
||||
# Variations of module: Thermal Dissipation Field I (19 of 19)
|
||||
# Module: Civilian Thermal Dissipation Field
|
||||
type = "overheat"
|
||||
def handler(fit, module, context):
|
||||
module.boostItemAttr("thermalDamageResistanceBonus", module.getModifiedItemAttr("overloadHardeningBonus"))
|
||||
@@ -1,9 +1,6 @@
|
||||
# reconOperationsMaxTargetRangeBonusPostPercentMaxTargetRangeGangShips
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Caldari Navy Warfare Mindlink
|
||||
# Implant: Imperial Navy Warfare Mindlink
|
||||
# Implant: Information Warfare Mindlink
|
||||
# Skill: Information Warfare
|
||||
type = "gang"
|
||||
gangBoost = "maxTargetRange"
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# shieldDefensiveOperationsShieldCapacityBonusPostPercentShieldCapacityGangShips
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Caldari Navy Warfare Mindlink
|
||||
# Implant: Republic Fleet Warfare Mindlink
|
||||
# Implant: Siege Warfare Mindlink
|
||||
# Skill: Siege Warfare
|
||||
type = "gang"
|
||||
gangBoost = "shieldCapacity"
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#
|
||||
# Used by:
|
||||
# Ship: Devoter
|
||||
# Ship: Gold Magnate
|
||||
# Ship: Impairor
|
||||
# Ship: Phobos
|
||||
# Ship: Silver Magnate
|
||||
type = "passive"
|
||||
def handler(fit, ship, context):
|
||||
fit.ship.boostItemAttr("armorEmDamageResonance", ship.getModifiedItemAttr("rookieArmorResistanceBonus"))
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#
|
||||
# Used by:
|
||||
# Ship: Devoter
|
||||
# Ship: Gold Magnate
|
||||
# Ship: Impairor
|
||||
# Ship: Phobos
|
||||
# Ship: Silver Magnate
|
||||
type = "passive"
|
||||
def handler(fit, ship, context):
|
||||
fit.ship.boostItemAttr("armorExplosiveDamageResonance", ship.getModifiedItemAttr("rookieArmorResistanceBonus"))
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#
|
||||
# Used by:
|
||||
# Ship: Devoter
|
||||
# Ship: Gold Magnate
|
||||
# Ship: Impairor
|
||||
# Ship: Phobos
|
||||
# Ship: Silver Magnate
|
||||
type = "passive"
|
||||
def handler(fit, ship, context):
|
||||
fit.ship.boostItemAttr("armorKineticDamageResonance", ship.getModifiedItemAttr("rookieArmorResistanceBonus"))
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#
|
||||
# Used by:
|
||||
# Ship: Devoter
|
||||
# Ship: Gold Magnate
|
||||
# Ship: Impairor
|
||||
# Ship: Phobos
|
||||
# Ship: Silver Magnate
|
||||
type = "passive"
|
||||
def handler(fit, ship, context):
|
||||
fit.ship.boostItemAttr("armorThermalDamageResonance", ship.getModifiedItemAttr("rookieArmorResistanceBonus"))
|
||||
|
||||
11
eos/effects/siegewarfareshieldcapacitybonusreplacer.py
Normal file
11
eos/effects/siegewarfareshieldcapacitybonusreplacer.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# siegeWarfareShieldCapacityBonusReplacer
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Caldari Navy Warfare Mindlink
|
||||
# Implant: Republic Fleet Warfare Mindlink
|
||||
# Implant: Siege Warfare Mindlink
|
||||
type = "gang"
|
||||
gangBoost = "shieldCapacity"
|
||||
gangBonus = "shieldCapacityBonus"
|
||||
def handler(fit, container, context):
|
||||
fit.ship.boostItemAttr(gangBoost, container.getModifiedItemAttr(gangBonus) * level)
|
||||
@@ -1,9 +1,6 @@
|
||||
# skirmishWarfareAgilityBonus
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Federation Navy Warfare Mindlink
|
||||
# Implant: Republic Fleet Warfare Mindlink
|
||||
# Implant: Skirmish Warfare Mindlink
|
||||
# Skill: Skirmish Warfare
|
||||
type = "gang"
|
||||
gangBoost = "agility"
|
||||
|
||||
11
eos/effects/skirmishwarfareagilitybonusreplacer.py
Normal file
11
eos/effects/skirmishwarfareagilitybonusreplacer.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# skirmishWarfareAgilityBonusReplacer
|
||||
#
|
||||
# Used by:
|
||||
# Implant: Federation Navy Warfare Mindlink
|
||||
# Implant: Republic Fleet Warfare Mindlink
|
||||
# Implant: Skirmish Warfare Mindlink
|
||||
type = "gang"
|
||||
gangBoost = "agility"
|
||||
gangBonus = "agilityBonus"
|
||||
def handler(fit, container, context):
|
||||
fit.ship.boostItemAttr(gangBoost, container.getModifiedItemAttr(gangBonus) * level)
|
||||
@@ -2,6 +2,8 @@
|
||||
#
|
||||
# Used by:
|
||||
# Ship: Coercer
|
||||
# Ship: Gold Magnate
|
||||
# Ship: Silver Magnate
|
||||
type = "passive"
|
||||
def handler(fit, ship, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Small Energy Turret"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# surgicalStrikeDamageMultiplierBonusPostPercentDamageMultiplierLocationShipModulesRequiringGunnery
|
||||
#
|
||||
# Used by:
|
||||
# Implants named like: Cerebral Accelerator (5 of 5)
|
||||
# Implants named like: Cerebral Accelerator (3 of 3)
|
||||
# Implants named like: Eifyr and Co. 'Gunslinger' Surgical Strike SS (6 of 6)
|
||||
type = "passive"
|
||||
def handler(fit, implant, context):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# thermalShieldCompensationHardeningBonusGroupShieldAmp
|
||||
#
|
||||
# Used by:
|
||||
# Skill: Thermic Shield Compensation
|
||||
# Skill: Thermal Shield Compensation
|
||||
type = "passive"
|
||||
def handler(fit, skill, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Shield Amplifier",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# thermicArmorCompensationHardeningBonusGroupArmorCoating
|
||||
#
|
||||
# Used by:
|
||||
# Skill: Thermic Armor Compensation
|
||||
# Skill: Thermal Armor Compensation
|
||||
type = "passive"
|
||||
def handler(fit, skill, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Coating",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# thermicArmorCompensationHardeningBonusGroupEnergized
|
||||
#
|
||||
# Used by:
|
||||
# Skill: Thermic Armor Compensation
|
||||
# Skill: Thermal Armor Compensation
|
||||
type = "passive"
|
||||
def handler(fit, skill, context):
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Plating Energized",
|
||||
|
||||
@@ -24,6 +24,7 @@ from sqlalchemy.orm import reconstructor
|
||||
from eqBase import EqBase
|
||||
|
||||
import traceback
|
||||
import eos.db
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
@@ -168,7 +169,6 @@ class Item(EqBase):
|
||||
info = getattr(cls, "MOVE_ATTR_INFO", None)
|
||||
if info is None:
|
||||
cls.MOVE_ATTR_INFO = info = []
|
||||
import eos.db
|
||||
for id in cls.MOVE_ATTRS:
|
||||
info.append(eos.db.getAttributeInfo(id))
|
||||
|
||||
@@ -191,6 +191,7 @@ class Item(EqBase):
|
||||
self.__moved = False
|
||||
self.__offensive = None
|
||||
self.__assistive = None
|
||||
self.__overrides = None
|
||||
|
||||
@property
|
||||
def attributes(self):
|
||||
@@ -210,6 +211,32 @@ class Item(EqBase):
|
||||
|
||||
return False
|
||||
|
||||
@property
|
||||
def overrides(self):
|
||||
if self.__overrides is None:
|
||||
self.__overrides = {}
|
||||
overrides = eos.db.getOverrides(self.ID)
|
||||
for x in overrides:
|
||||
if x.attr.name in self.__attributes:
|
||||
self.__overrides[x.attr.name] = x
|
||||
|
||||
return self.__overrides
|
||||
|
||||
def setOverride(self, attr, value):
|
||||
from eos.saveddata.override import Override
|
||||
if attr.name in self.__overrides:
|
||||
override = self.__overrides.get(attr.name)
|
||||
override.value = value
|
||||
else:
|
||||
override = Override(self, attr, value)
|
||||
self.__overrides[attr.name] = override
|
||||
eos.db.save(override)
|
||||
|
||||
def deleteOverride(self, attr):
|
||||
override = self.__overrides.pop(attr.name, None)
|
||||
eos.db.saveddata_session.delete(override)
|
||||
eos.db.commit()
|
||||
|
||||
@property
|
||||
def requiredSkills(self):
|
||||
if self.__requiredSkills is None:
|
||||
@@ -345,6 +372,12 @@ class Item(EqBase):
|
||||
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return "Item(ID={}, name={}) at {}".format(
|
||||
self.ID, self.name, hex(id(self))
|
||||
)
|
||||
|
||||
|
||||
class MetaData(EqBase):
|
||||
pass
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@ class ChargeAttrShortcut(object):
|
||||
return None
|
||||
|
||||
class ModifiedAttributeDict(collections.MutableMapping):
|
||||
|
||||
OVERRIDES = False
|
||||
|
||||
class CalculationPlaceholder():
|
||||
pass
|
||||
|
||||
@@ -51,6 +54,8 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
self.__modified = {}
|
||||
# Affected by entities
|
||||
self.__affectedBy = {}
|
||||
# Overrides
|
||||
self.__overrides = {}
|
||||
# Dictionaries for various value modification types
|
||||
self.__forced = {}
|
||||
self.__preAssigns = {}
|
||||
@@ -79,6 +84,14 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
self.__original = val
|
||||
self.__modified.clear()
|
||||
|
||||
@property
|
||||
def overrides(self):
|
||||
return self.__overrides
|
||||
|
||||
@overrides.setter
|
||||
def overrides(self, val):
|
||||
self.__overrides = val
|
||||
|
||||
def __getitem__(self, key):
|
||||
# Check if we have final calculated value
|
||||
if key in self.__modified:
|
||||
@@ -99,6 +112,8 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
del self.__intermediary[key]
|
||||
|
||||
def getOriginal(self, key):
|
||||
if self.OVERRIDES and key in self.__overrides:
|
||||
return self.__overrides.get(key).value
|
||||
val = self.__original.get(key)
|
||||
if val is None:
|
||||
return None
|
||||
|
||||
@@ -58,6 +58,7 @@ class Booster(HandledItem, ItemAttrShortcut):
|
||||
self.__sideEffects = []
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = self.__item.attributes
|
||||
self.__itemModifiedAttributes.overrides = self.__item.overrides
|
||||
self.__slot = self.__calculateSlot(self.__item)
|
||||
|
||||
for effect in self.__item.effects.itervalues():
|
||||
|
||||
@@ -34,6 +34,7 @@ class Cargo(HandledItem, ItemAttrShortcut):
|
||||
self.amount = 0
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = item.attributes
|
||||
self.__itemModifiedAttributes.overrides = item.overrides
|
||||
|
||||
@reconstructor
|
||||
def init(self):
|
||||
@@ -48,6 +49,7 @@ class Cargo(HandledItem, ItemAttrShortcut):
|
||||
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = self.__item.attributes
|
||||
self.__itemModifiedAttributes.overrides = self.__item.overrides
|
||||
|
||||
@property
|
||||
def itemModifiedAttributes(self):
|
||||
|
||||
46
eos/saveddata/crestchar.py
Normal file
46
eos/saveddata/crestchar.py
Normal 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/>.
|
||||
#===============================================================================
|
||||
|
||||
import urllib
|
||||
from cStringIO import StringIO
|
||||
|
||||
from sqlalchemy.orm import reconstructor
|
||||
#from tomorrow import threads
|
||||
|
||||
|
||||
class CrestChar(object):
|
||||
|
||||
def __init__(self, id, name, refresh_token=None):
|
||||
self.ID = id
|
||||
self.name = name
|
||||
self.refresh_token = refresh_token
|
||||
|
||||
@reconstructor
|
||||
def init(self):
|
||||
pass
|
||||
|
||||
'''
|
||||
@threads(1)
|
||||
def fetchImage(self):
|
||||
url = 'https://image.eveonline.com/character/%d_128.jpg'%self.ID
|
||||
fp = urllib.urlopen(url)
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
self.img = StringIO(data)
|
||||
'''
|
||||
@@ -67,6 +67,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
self.__miningyield = None
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = self.__item.attributes
|
||||
self.__itemModifiedAttributes.overrides = self.__item.overrides
|
||||
|
||||
self.__chargeModifiedAttributes = ModifiedAttributeDict()
|
||||
chargeID = self.getModifiedItemAttr("entityMissileTypeID")
|
||||
@@ -74,6 +75,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
charge = eos.db.getItem(int(chargeID))
|
||||
self.__charge = charge
|
||||
self.__chargeModifiedAttributes.original = charge.attributes
|
||||
self.__chargeModifiedAttributes.overrides = charge.overrides
|
||||
|
||||
@property
|
||||
def itemModifiedAttributes(self):
|
||||
|
||||
@@ -56,6 +56,7 @@ class Implant(HandledItem, ItemAttrShortcut):
|
||||
""" Build object. Assumes proper and valid item already set """
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = self.__item.attributes
|
||||
self.__itemModifiedAttributes.overrides = self.__item.overrides
|
||||
self.__slot = self.__calculateSlot(self.__item)
|
||||
|
||||
@property
|
||||
|
||||
@@ -30,6 +30,7 @@ class Mode(ItemAttrShortcut, HandledItem):
|
||||
self.__item = item
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = self.item.attributes
|
||||
self.__itemModifiedAttributes.overrides = self.item.overrides
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
|
||||
@@ -113,10 +113,13 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
if self.__item:
|
||||
self.__itemModifiedAttributes.original = self.__item.attributes
|
||||
self.__itemModifiedAttributes.overrides = self.__item.overrides
|
||||
self.__hardpoint = self.__calculateHardpoint(self.__item)
|
||||
self.__slot = self.__calculateSlot(self.__item)
|
||||
if self.__charge:
|
||||
self.__chargeModifiedAttributes.original = self.__charge.attributes
|
||||
self.__chargeModifiedAttributes.overrides = self.__charge.overrides
|
||||
|
||||
|
||||
@classmethod
|
||||
def buildEmpty(cls, slot):
|
||||
@@ -283,9 +286,11 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
if charge is not None:
|
||||
self.chargeID = charge.ID
|
||||
self.__chargeModifiedAttributes.original = charge.attributes
|
||||
self.__chargeModifiedAttributes.overrides = charge.overrides
|
||||
else:
|
||||
self.chargeID = None
|
||||
self.__chargeModifiedAttributes.original = None
|
||||
self.__chargeModifiedAttributes.overrides = {}
|
||||
|
||||
self.__itemModifiedAttributes.clear()
|
||||
|
||||
|
||||
59
eos/saveddata/override.py
Normal file
59
eos/saveddata/override.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#===============================================================================
|
||||
# Copyright (C) 2015 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 eos.eqBase import EqBase
|
||||
from sqlalchemy.orm import validates, reconstructor
|
||||
import eos.db
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Override(EqBase):
|
||||
|
||||
def __init__(self, item, attr, value):
|
||||
self.itemID = item.ID
|
||||
self.__item = item
|
||||
self.attrID = attr.ID
|
||||
self.__attr = attr
|
||||
self.value = value
|
||||
|
||||
@reconstructor
|
||||
def init(self):
|
||||
self.__attr = None
|
||||
self.__item = None
|
||||
|
||||
if self.attrID:
|
||||
self.__attr = eos.db.getAttributeInfo(self.attrID)
|
||||
if self.__attr is None:
|
||||
logger.error("Attribute (id: %d) does not exist", self.attrID)
|
||||
return
|
||||
|
||||
if self.itemID:
|
||||
self.__item = eos.db.getItem(self.itemID)
|
||||
if self.__item is None:
|
||||
logger.error("Item (id: %d) does not exist", self.itemID)
|
||||
return
|
||||
|
||||
@property
|
||||
def attr(self):
|
||||
return self.__attr
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
return self.__item
|
||||
@@ -51,6 +51,7 @@ class Ship(ItemAttrShortcut, HandledItem):
|
||||
self.__itemModifiedAttributes = ModifiedAttributeDict()
|
||||
self.__itemModifiedAttributes.original = dict(self.item.attributes)
|
||||
self.__itemModifiedAttributes.original.update(self.EXTRA_ATTRIBUTES)
|
||||
self.__itemModifiedAttributes.overrides = self.item.overrides
|
||||
|
||||
self.commandBonus = 0
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ from eos.gamedata import Attribute, Category, Effect, Group, Icon, Item, MarketG
|
||||
MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits
|
||||
from eos.saveddata.price import Price
|
||||
from eos.saveddata.user import User
|
||||
from eos.saveddata.crestchar import CrestChar
|
||||
from eos.saveddata.damagePattern import DamagePattern
|
||||
from eos.saveddata.targetResists import TargetResists
|
||||
from eos.saveddata.character import Character, Skill
|
||||
@@ -35,4 +36,5 @@ from eos.saveddata.fit import Fit
|
||||
from eos.saveddata.mode import Mode
|
||||
from eos.saveddata.fleet import Fleet, Wing, Squad
|
||||
from eos.saveddata.miscData import MiscData
|
||||
from eos.saveddata.override import Override
|
||||
import eos.db
|
||||
|
||||
Reference in New Issue
Block a user