Merge branch 'master' into price_optimize

This commit is contained in:
DarkPhoenix
2019-03-07 13:13:17 +03:00
24 changed files with 612 additions and 161 deletions

26
eos/const.py Normal file
View File

@@ -0,0 +1,26 @@
from eos.enum import Enum
class Slot(Enum):
# These are self-explanatory
LOW = 1
MED = 2
HIGH = 3
RIG = 4
SUBSYSTEM = 5
# not a real slot, need for pyfa display rack separation
MODE = 6
# system effects. They are projected "modules" and pyfa assumes all modules
# have a slot. In this case, make one up.
SYSTEM = 7
# used for citadel services
SERVICE = 8
# fighter 'slots'. Just easier to put them here...
F_LIGHT = 10
F_SUPPORT = 11
F_HEAVY = 12
# fighter 'slots' (for structures)
FS_LIGHT = 13
FS_SUPPORT = 14
FS_HEAVY = 15

View File

@@ -39,6 +39,8 @@ attributes_table = Table("dgmattribs", gamedata_meta,
Column("displayName", String),
Column("highIsGood", Boolean),
Column("iconID", Integer),
Column("attributeCategory", Integer),
Column("tooltipDescription", Integer),
Column("unitID", Integer, ForeignKey("dgmunits.unitID")))
mapper(Attribute, typeattributes_table,

View File

@@ -561,6 +561,15 @@ class Unit(EqBase):
self.name = None
self.displayName = None
@property
def rigSizes(self):
return {
1: "Small",
2: "Medium",
3: "Large",
4: "X-Large"
}
@property
def translations(self):
""" This is a mapping of various tweaks that we have to do between the internal representation of an attribute
@@ -593,10 +602,10 @@ class Unit(EqBase):
lambda u: "",
lambda d: d),
"Sizeclass": (
lambda v: v,
lambda v: v,
lambda u: "",
lambda d: d),
lambda v: self.rigSizes[v],
lambda v: self.rigSizes[v],
lambda d: next(i for i in self.rigSizes.keys() if self.rigSizes[i] == 'Medium'),
lambda u: ""),
"Absolute Percent": (
lambda v: v * 100,
lambda v: v * 100,

View File

@@ -23,6 +23,7 @@ from logbook import Logger
from sqlalchemy.orm import reconstructor, validates
import eos.db
from eos.const import Slot
from eos.effectHandlerHelpers import HandledCharge, HandledItem
from eos.enum import Enum
from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict
@@ -42,30 +43,6 @@ class State(Enum):
OVERHEATED = 2
class Slot(Enum):
# These are self-explanatory
LOW = 1
MED = 2
HIGH = 3
RIG = 4
SUBSYSTEM = 5
# not a real slot, need for pyfa display rack separation
MODE = 6
# system effects. They are projected "modules" and pyfa assumes all modules
# have a slot. In this case, make one up.
SYSTEM = 7
# used for citadel services
SERVICE = 8
# fighter 'slots'. Just easier to put them here...
F_LIGHT = 10
F_SUPPORT = 11
F_HEAVY = 12
# fighter 'slots' (for structures)
FS_LIGHT = 13
FS_SUPPORT = 14
FS_HEAVY = 15
ProjectedMap = {
State.OVERHEATED: State.ACTIVE,
State.ACTIVE: State.OFFLINE,
@@ -185,7 +162,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
self.__itemModifiedAttributes.original = self.__item.attributes
self.__itemModifiedAttributes.overrides = self.__item.overrides
self.__hardpoint = self.__calculateHardpoint(self.__item)
self.__slot = self.__calculateSlot(self.__item)
self.__slot = self.calculateSlot(self.__item)
# Instantiate / remove mutators if this is a mutated module
if self.__baseItem:
@@ -755,7 +732,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
return Hardpoint.NONE
@staticmethod
def __calculateSlot(item):
def calculateSlot(item):
effectSlotMap = {
"rigSlot" : Slot.RIG,
"loPower" : Slot.LOW,
@@ -772,7 +749,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if item.group.name in Module.SYSTEM_GROUPS:
return Slot.SYSTEM
raise ValueError("Passed item does not fit in any known slot")
return None
@validates("ID", "itemID", "ammoID")
def validator(self, key, val):