Preliminary backend support for tactical destroyer modes.

* Modifies fits table to add "mode" column, which contains typeID of mode for fit
* Introduces Mode type, similar to Ship and Module type
* Includes effects for Amarr Tactical Destroyer Propulsion Mode

Still a lot to do: GUI switching, constraints on which ships get modes, etc
This commit is contained in:
blitzmann
2014-11-27 23:23:24 -05:00
parent d4af877e47
commit f53384c4c2
8 changed files with 104 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ evemonMinVersion = "4081"
# Database version (int ONLY)
# Increment every time we need to flag for user database upgrade/modification
dbversion = 2
dbversion = 3
pyfaPath = None
savePath = None

View File

@@ -0,0 +1,13 @@
"""
Migration 3
- Adds mode column for fits (t3 dessy)
"""
import sqlalchemy
def upgrade(saveddata_engine):
try:
saveddata_engine.execute("SELECT mode FROM fits LIMIT 1")
except sqlalchemy.exc.DatabaseError:
saveddata_engine.execute("ALTER TABLE fits ADD COLUMN mode INTEGER")

View File

@@ -40,7 +40,9 @@ fits_table = Table("fits", saveddata_meta,
Column("characterID", ForeignKey("characters.ID"), nullable = True),
Column("damagePatternID", ForeignKey("damagePatterns.ID"), nullable=True),
Column("booster", Boolean, nullable = False, index = True, default = 0),
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True))
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True),
Column("mode", Integer, nullable=True),
)
projectedFits_table = Table("projectedFits", saveddata_meta,
Column("sourceID", ForeignKey("fits.ID"), primary_key = True),

View File

@@ -0,0 +1,5 @@
type = "passive"
def handler(fit, module, context):
# @todo: most likely have to fix this on release
fit.ship.boostItemAttr("agility", module.getModifiedItemAttr("modeAgilityPostDiv"),
stackingPenalties = True, penaltyGroup="postDiv")

View File

@@ -0,0 +1,5 @@
type = "passive"
def handler(fit, module, context):
# @todo: most likely have to fix this on release
fit.ship.boostItemAttr("maxVelocity", module.getModifiedItemAttr("modeVelocityPostDiv"),
stackingPenalties = True, penaltyGroup="postDiv")

View File

@@ -27,6 +27,7 @@ from copy import deepcopy
from math import sqrt, log, asinh
from eos.types import Drone, Cargo, Ship, Character, State, Slot, Module, Implant, Booster, Skill
from eos.saveddata.module import State
from eos.saveddata.mode import Mode
import time
try:
@@ -66,6 +67,7 @@ class Fit(object):
self.gangBoosts = None
self.timestamp = time.time()
self.ecmProjectedStr = 1
self.mode = None
self.build()
@reconstructor
@@ -98,6 +100,7 @@ class Fit(object):
self.extraAttributes = ModifiedAttributeDict(self)
self.extraAttributes.original = self.EXTRA_ATTRIBUTES
self.ship = Ship(db.getItem(self.shipID)) if self.shipID is not None else None
self.mode = Mode(db.getItem(self.mode)) if self.mode is not None else None
@property
def targetResists(self):
@@ -355,9 +358,9 @@ class Fit(object):
# Avoid adding projected drones and modules when fit is projected onto self
# TODO: remove this workaround when proper self-projection using virtual duplicate fits is implemented
if forceProjected is True:
c = chain((self.character, self.ship), self.drones, self.boosters, self.appliedImplants, self.modules)
c = chain((self.character, self.ship, self.mode), self.drones, self.boosters, self.appliedImplants, self.modules)
else:
c = chain((self.character, self.ship), self.drones, self.boosters, self.appliedImplants, self.modules,
c = chain((self.character, self.ship, self.mode), self.drones, self.boosters, self.appliedImplants, self.modules,
self.projectedDrones, self.projectedModules)
if self.gangBoosts is not None:

71
eos/saveddata/mode.py Normal file
View File

@@ -0,0 +1,71 @@
#===============================================================================
# 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 eos.modifiedAttributeDict import ModifiedAttributeDict, ItemAttrShortcut
from eos.effectHandlerHelpers import HandledItem
class Mode(ItemAttrShortcut, HandledItem):
def __init__(self, item):
self.__item = item
self.itemID = item.ID if item is not None else None
self.__itemModifiedAttributes = ModifiedAttributeDict()
if not isinstance(item, int):
self.__buildOriginal()
def __fetchItemInfo(self):
import eos.db
self.__item = eos.db.getItem(self.__item)
self.__buildOriginal()
def __buildOriginal(self):
self.__itemModifiedAttributes.original = self.item.attributes
@property
def item(self):
if isinstance(self.__item, int):
self.__fetchItemInfo()
return self.__item
@property
def itemModifiedAttributes(self):
if isinstance(self.__item, int):
self.__fetchItemInfo()
return self.__itemModifiedAttributes
# @todo: rework to fit only on t3 dessy
def fits(self, fit):
raise NotImplementedError()
# @ todo: rework to get valid modes (probably put in fit object, not mode)
def getValidModes(self):
raise NotImplementedError()
def clear(self):
self.itemModifiedAttributes.clear()
def calculateModifiedAttributes(self, fit, runTime, forceProjected = False):
if self.item:
for effect in self.item.effects.itervalues():
if effect.runTime == runTime:
effect.handler(fit, self, context = ("module",))

View File

@@ -32,6 +32,7 @@ from eos.saveddata.booster import SideEffect
from eos.saveddata.booster import Booster
from eos.saveddata.ship import Ship
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
import eos.db