Merge pull request #1869 from IndictionEve/Code_Cleanup_Enums
Code cleanup enums #1862
This commit is contained in:
@@ -37,7 +37,8 @@ from service.esi import Esi
|
||||
|
||||
from eos.saveddata.implant import Implant as es_Implant
|
||||
from eos.saveddata.character import Character as es_Character, Skill
|
||||
from eos.saveddata.module import Slot as es_Slot, Module as es_Module
|
||||
from eos.saveddata.module import Module as es_Module
|
||||
from eos.const import FittingSlot as es_Slot
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
102
service/const.py
Normal file
102
service/const.py
Normal file
@@ -0,0 +1,102 @@
|
||||
# =============================================================================
|
||||
# Copyright (C) 2019 Ryan Holmes
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
#
|
||||
# pyfa is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# pyfa 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
from enum import Enum, IntEnum, unique, auto
|
||||
|
||||
|
||||
@unique
|
||||
class EsiLoginMethod(IntEnum):
|
||||
"""
|
||||
Contains the method of ESI login
|
||||
"""
|
||||
SERVER = 0
|
||||
MANUAL = 1
|
||||
|
||||
|
||||
@unique
|
||||
class EsiSsoMode(IntEnum):
|
||||
"""
|
||||
Contains the mode of ESI sso mode
|
||||
"""
|
||||
AUTO = 0
|
||||
CUSTOM = 1
|
||||
|
||||
|
||||
class EsiEndpoints(Enum):
|
||||
"""
|
||||
Contains the endpoint paths for the ESI access
|
||||
"""
|
||||
CHAR = "/v4/characters/{character_id}/"
|
||||
CHAR_SKILLS = "/v4/characters/{character_id}/skills/"
|
||||
CHAR_FITTINGS = "/v1/characters/{character_id}/fittings/"
|
||||
CHAR_DEL_FIT = "/v1/characters/{character_id}/fittings/{fitting_id}/"
|
||||
|
||||
|
||||
@unique
|
||||
class PortMultiBuyOptions(IntEnum):
|
||||
"""
|
||||
Contains different types of items for multibuy export
|
||||
"""
|
||||
IMPLANTS = 1
|
||||
CARGO = 2
|
||||
LOADED_CHARGES = 3
|
||||
|
||||
|
||||
@unique
|
||||
class PortEftOptions(IntEnum):
|
||||
"""
|
||||
Contains different options for eft-export
|
||||
"""
|
||||
IMPLANTS = 1
|
||||
MUTATIONS = 2
|
||||
LOADED_CHARGES = 3
|
||||
|
||||
|
||||
@unique
|
||||
class PortEftRigSize(IntEnum):
|
||||
"""
|
||||
Contains different sizes of ship rigs
|
||||
This enum is not actively used, but maybe useful someday.
|
||||
"""
|
||||
SMALL = 1
|
||||
MEDIUM = 2
|
||||
LARGE = 3
|
||||
CAPITAL = 4
|
||||
|
||||
|
||||
@unique
|
||||
class GuiAttrGroup(IntEnum):
|
||||
"""
|
||||
Define the various groups of attributes.
|
||||
This enum is used for GUI functions and getting redefined in
|
||||
/gui/builtinItemStatsViews/attributeGrouping.py
|
||||
"""
|
||||
FITTING = auto()
|
||||
STRUCTURE = auto()
|
||||
SHIELD = auto()
|
||||
ARMOR = auto()
|
||||
TARGETING = auto()
|
||||
EWAR_RESISTS = auto()
|
||||
CAPACITOR = auto()
|
||||
SHARED_FACILITIES = auto()
|
||||
FIGHTER_FACILITIES = auto()
|
||||
ON_DEATH = auto()
|
||||
JUMP_SYSTEMS = auto()
|
||||
PROPULSIONS = auto()
|
||||
FIGHTERS = auto()
|
||||
@@ -9,9 +9,9 @@ import config
|
||||
import webbrowser
|
||||
|
||||
import eos.db
|
||||
from eos.enum import Enum
|
||||
from service.const import EsiLoginMethod, EsiSsoMode
|
||||
from eos.saveddata.ssocharacter import SsoCharacter
|
||||
from service.esiAccess import APIException, SsoMode
|
||||
from service.esiAccess import APIException
|
||||
import gui.globalEvents as GE
|
||||
from gui.ssoLogin import SsoLogin, SsoLoginServer
|
||||
from service.server import StoppableHTTPServer, AuthHandler
|
||||
@@ -24,11 +24,6 @@ from requests import Session
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class LoginMethod(Enum):
|
||||
SERVER = 0
|
||||
MANUAL = 1
|
||||
|
||||
|
||||
class Esi(EsiAccess):
|
||||
_instance = None
|
||||
|
||||
@@ -107,8 +102,8 @@ class Esi(EsiAccess):
|
||||
|
||||
def login(self):
|
||||
# always start the local server if user is using client details. Otherwise, start only if they choose to do so.
|
||||
if self.settings.get('ssoMode') == SsoMode.CUSTOM or self.settings.get('loginMode') == LoginMethod.SERVER:
|
||||
dlg = gui.ssoLogin.SsoLoginServer(6461 if self.settings.get('ssoMode') == SsoMode.CUSTOM else 0)
|
||||
if self.settings.get('ssoMode') == EsiSsoMode.CUSTOM or self.settings.get('loginMode') == EsiLoginMethod.SERVER:
|
||||
dlg = gui.ssoLogin.SsoLoginServer(6461 if self.settings.get('ssoMode') == EsiSsoMode.CUSTOM else 0)
|
||||
dlg.ShowModal()
|
||||
else:
|
||||
dlg = gui.ssoLogin.SsoLogin()
|
||||
@@ -142,7 +137,7 @@ class Esi(EsiAccess):
|
||||
def handleLogin(self, message):
|
||||
|
||||
# we already have authenticated stuff for the auto mode
|
||||
if self.settings.get('ssoMode') == SsoMode.AUTO:
|
||||
if self.settings.get('ssoMode') == EsiSsoMode.AUTO:
|
||||
ssoInfo = message['SSOInfo'][0]
|
||||
auth_response = json.loads(base64.b64decode(ssoInfo))
|
||||
else:
|
||||
|
||||
@@ -17,7 +17,7 @@ import config
|
||||
import base64
|
||||
|
||||
import datetime
|
||||
from eos.enum import Enum
|
||||
from service.const import EsiSsoMode, EsiEndpoints
|
||||
from service.settings import EsiSettings, NetworkSettings
|
||||
|
||||
from requests import Session
|
||||
@@ -42,11 +42,6 @@ scopes = [
|
||||
]
|
||||
|
||||
|
||||
class SsoMode(Enum):
|
||||
AUTO = 0
|
||||
CUSTOM = 1
|
||||
|
||||
|
||||
class APIException(Exception):
|
||||
""" Exception for SSO related errors """
|
||||
|
||||
@@ -66,13 +61,6 @@ class APIException(Exception):
|
||||
return 'HTTP Error %s' % self.status_code
|
||||
|
||||
|
||||
class ESIEndpoints(Enum):
|
||||
CHAR = "/v4/characters/{character_id}/"
|
||||
CHAR_SKILLS = "/v4/characters/{character_id}/skills/"
|
||||
CHAR_FITTINGS = "/v1/characters/{character_id}/fittings/"
|
||||
CHAR_DEL_FIT = "/v1/characters/{character_id}/fittings/{fitting_id}/"
|
||||
|
||||
|
||||
class EsiAccess(object):
|
||||
def __init__(self):
|
||||
self.settings = EsiSettings.getInstance()
|
||||
@@ -89,7 +77,7 @@ class EsiAccess(object):
|
||||
|
||||
@property
|
||||
def sso_url(self):
|
||||
if self.settings.get("ssoMode") == SsoMode.CUSTOM:
|
||||
if self.settings.get("ssoMode") == EsiSsoMode.CUSTOM:
|
||||
return "https://login.eveonline.com"
|
||||
return "https://www.pyfa.io"
|
||||
|
||||
@@ -110,20 +98,20 @@ class EsiAccess(object):
|
||||
return '%s/oauth/token' % self.sso_url
|
||||
|
||||
def getSkills(self, char):
|
||||
return self.get(char, ESIEndpoints.CHAR_SKILLS, character_id=char.characterID)
|
||||
return self.get(char, EsiEndpoints.CHAR_SKILLS, character_id=char.characterID)
|
||||
|
||||
def getSecStatus(self, char):
|
||||
return self.get(char, ESIEndpoints.CHAR, character_id=char.characterID)
|
||||
return self.get(char, EsiEndpoints.CHAR, character_id=char.characterID)
|
||||
|
||||
def getFittings(self, char):
|
||||
return self.get(char, ESIEndpoints.CHAR_FITTINGS, character_id=char.characterID)
|
||||
return self.get(char, EsiEndpoints.CHAR_FITTINGS, character_id=char.characterID)
|
||||
|
||||
def postFitting(self, char, json_str):
|
||||
# @todo: new fitting ID can be recovered from resp.data,
|
||||
return self.post(char, ESIEndpoints.CHAR_FITTINGS, json_str, character_id=char.characterID)
|
||||
return self.post(char, EsiEndpoints.CHAR_FITTINGS, json_str, character_id=char.characterID)
|
||||
|
||||
def delFitting(self, char, fittingID):
|
||||
return self.delete(char, ESIEndpoints.CHAR_DEL_FIT, character_id=char.characterID, fitting_id=fittingID)
|
||||
return self.delete(char, EsiEndpoints.CHAR_DEL_FIT, character_id=char.characterID, fitting_id=fittingID)
|
||||
|
||||
@staticmethod
|
||||
def update_token(char, tokenResponse):
|
||||
@@ -136,7 +124,7 @@ class EsiAccess(object):
|
||||
def getLoginURI(self, redirect=None):
|
||||
self.state = str(uuid.uuid4())
|
||||
|
||||
if self.settings.get("ssoMode") == SsoMode.AUTO:
|
||||
if self.settings.get("ssoMode") == EsiSsoMode.AUTO:
|
||||
args = {
|
||||
'state': self.state,
|
||||
'pyfa_version': config.version,
|
||||
@@ -183,7 +171,7 @@ class EsiAccess(object):
|
||||
'refresh_token': refreshToken,
|
||||
}
|
||||
|
||||
if self.settings.get('ssoMode') == SsoMode.AUTO:
|
||||
if self.settings.get('ssoMode') == EsiSsoMode.AUTO:
|
||||
# data is all we really need, the rest is handled automatically by pyfa.io
|
||||
return {
|
||||
'data': data,
|
||||
|
||||
@@ -30,8 +30,9 @@ from eos.saveddata.citadel import Citadel as es_Citadel
|
||||
from eos.saveddata.damagePattern import DamagePattern as es_DamagePattern
|
||||
from eos.saveddata.drone import Drone as es_Drone
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
from eos.saveddata.fit import Fit as FitType, ImplantLocation
|
||||
from eos.saveddata.module import Module as es_Module, State
|
||||
from eos.const import ImplantLocation, FittingModuleState
|
||||
from eos.saveddata.fit import Fit as FitType
|
||||
from eos.saveddata.module import Module as es_Module
|
||||
from eos.saveddata.ship import Ship as es_Ship
|
||||
from service.character import Character
|
||||
from service.damagePattern import DamagePattern
|
||||
@@ -352,7 +353,7 @@ class Fit(FitDeprecated):
|
||||
elif isinstance(thing, es_Module):
|
||||
thing.state = es_Module.getProposedState(thing, click)
|
||||
if not thing.canHaveState(thing.state, fit):
|
||||
thing.state = State.OFFLINE
|
||||
thing.state = FittingModuleState.OFFLINE
|
||||
elif isinstance(thing, FitType):
|
||||
projectionInfo = thing.getProjectionInfo(fitID)
|
||||
if projectionInfo:
|
||||
@@ -384,8 +385,8 @@ class Fit(FitDeprecated):
|
||||
if m.fits(fit):
|
||||
m.owner = fit
|
||||
fit.modules.toModule(position, m)
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
|
||||
# As some items may affect state-limiting attributes of the ship, calculate new attributes first
|
||||
self.recalc(fit)
|
||||
@@ -539,13 +540,13 @@ class Fit(FitDeprecated):
|
||||
if mod != base:
|
||||
# fix for #529, where a module may be in incorrect state after CCP changes mechanics of module
|
||||
if not mod.canHaveState(mod.state) or not mod.isValidState(mod.state):
|
||||
mod.state = State.ONLINE
|
||||
mod.state = FittingModuleState.ONLINE
|
||||
changed = True
|
||||
|
||||
for mod in fit.projectedModules:
|
||||
# fix for #529, where a module may be in incorrect state after CCP changes mechanics of module
|
||||
if not mod.canHaveState(mod.state, fit) or not mod.isValidState(mod.state):
|
||||
mod.state = State.OFFLINE
|
||||
mod.state = FittingModuleState.OFFLINE
|
||||
changed = True
|
||||
|
||||
for drone in fit.projectedDrones:
|
||||
|
||||
@@ -27,7 +27,8 @@ from eos.saveddata.cargo import Cargo as es_Cargo
|
||||
from eos.saveddata.drone import Drone as es_Drone
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
from eos.saveddata.implant import Implant as es_Implant
|
||||
from eos.saveddata.module import Module as es_Module, State
|
||||
from eos.saveddata.module import Module as es_Module
|
||||
from eos.const import FittingModuleState
|
||||
from eos.saveddata.fit import Fit as FitType
|
||||
from utils.deprecated import deprecated
|
||||
|
||||
@@ -304,16 +305,16 @@ class FitDeprecated(object):
|
||||
fit.projectedFighters.append(fighter)
|
||||
elif thing.group.name in es_Module.SYSTEM_GROUPS:
|
||||
module = es_Module(thing)
|
||||
module.state = State.ONLINE
|
||||
module.state = FittingModuleState.ONLINE
|
||||
fit.projectedModules.append(module)
|
||||
else:
|
||||
try:
|
||||
module = es_Module(thing)
|
||||
except ValueError:
|
||||
return False
|
||||
module.state = State.ACTIVE
|
||||
module.state = FittingModuleState.ACTIVE
|
||||
if not module.canHaveState(module.state, fit):
|
||||
module.state = State.OFFLINE
|
||||
module.state = FittingModuleState.OFFLINE
|
||||
fit.projectedModules.append(module)
|
||||
|
||||
eos.db.commit()
|
||||
@@ -396,8 +397,8 @@ class FitDeprecated(object):
|
||||
m.owner = fit
|
||||
numSlots = len(fit.modules)
|
||||
fit.modules.append(m)
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
|
||||
# As some items may affect state-limiting attributes of the ship, calculate new attributes first
|
||||
self.recalc(fit)
|
||||
@@ -465,8 +466,8 @@ class FitDeprecated(object):
|
||||
if m.fits(fit):
|
||||
m.owner = fit
|
||||
fit.modules.toModule(position, m)
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
|
||||
if recalc:
|
||||
# As some items may affect state-limiting attributes of the ship, calculate new attributes first
|
||||
@@ -508,8 +509,8 @@ class FitDeprecated(object):
|
||||
try:
|
||||
cargoP = es_Module(cargo.item)
|
||||
cargoP.owner = fit
|
||||
if cargoP.isValidState(State.ACTIVE):
|
||||
cargoP.state = State.ACTIVE
|
||||
if cargoP.isValidState(FittingModuleState.ACTIVE):
|
||||
cargoP.state = FittingModuleState.ACTIVE
|
||||
except:
|
||||
pyfalog.warning("Invalid item: {0}", cargo.item)
|
||||
return
|
||||
|
||||
@@ -28,8 +28,9 @@ from eos.saveddata.citadel import Citadel
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from eos.saveddata.fit import Fit
|
||||
from eos.saveddata.module import Module, State, Slot
|
||||
from eos.saveddata.module import Module
|
||||
from eos.saveddata.ship import Ship
|
||||
from eos.const import FittingSlot, FittingModuleState
|
||||
from service.fit import Fit as svcFit
|
||||
from service.market import Market
|
||||
|
||||
@@ -106,8 +107,8 @@ def importDna(string):
|
||||
f.modules.append(m)
|
||||
else:
|
||||
m.owner = f
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
moduleList.append(m)
|
||||
|
||||
# Recalc to get slot numbers correct for T3 cruisers
|
||||
@@ -116,8 +117,8 @@ def importDna(string):
|
||||
for module in moduleList:
|
||||
if module.fits(f):
|
||||
module.owner = f
|
||||
if module.isValidState(State.ACTIVE):
|
||||
module.state = State.ACTIVE
|
||||
if module.isValidState(FittingModuleState.ACTIVE):
|
||||
module.state = FittingModuleState.ACTIVE
|
||||
f.modules.append(module)
|
||||
|
||||
return f
|
||||
@@ -131,7 +132,7 @@ def exportDna(fit):
|
||||
sFit = svcFit.getInstance()
|
||||
for mod in fit.modules:
|
||||
if not mod.isEmpty:
|
||||
if mod.slot == Slot.SUBSYSTEM:
|
||||
if mod.slot == FittingSlot.SUBSYSTEM:
|
||||
subsystems.append(mod)
|
||||
continue
|
||||
if mod.itemID not in mods:
|
||||
|
||||
@@ -6,8 +6,9 @@ from numbers import Number
|
||||
from config import version as pyfaVersion
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
from eos.enum import Enum
|
||||
from eos.saveddata.module import Hardpoint, Slot, Module, State
|
||||
from eos.const import FittingModuleState, FittingHardpoint, FittingSlot
|
||||
from service.const import PortEftRigSize
|
||||
from eos.saveddata.module import Module
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.effectHandlerHelpers import HandledList
|
||||
from eos.db import gamedata_session, getCategory, getAttributeInfo, getGroup
|
||||
@@ -19,14 +20,6 @@ from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class RigSize(Enum):
|
||||
# Matches to item attribute "rigSize" on ship and rig items
|
||||
SMALL = 1
|
||||
MEDIUM = 2
|
||||
LARGE = 3
|
||||
CAPITAL = 4
|
||||
|
||||
|
||||
class EfsPort:
|
||||
wepTestSet = {}
|
||||
version = 0.03
|
||||
@@ -58,13 +51,13 @@ class EfsPort:
|
||||
mwd50mn = mapPropData("50MN Microwarpdrive II")
|
||||
mwd500mn = mapPropData("500MN Microwarpdrive II")
|
||||
mwd50000mn = mapPropData("50000MN Microwarpdrive II")
|
||||
if rigSize == RigSize.SMALL or rigSize is None:
|
||||
if rigSize == PortEftRigSize.SMALL or rigSize is None:
|
||||
propID = mwd5mn["id"] if shipPower > mwd5mn["powerReq"] else None
|
||||
elif rigSize == RigSize.MEDIUM:
|
||||
elif rigSize == PortEftRigSize.MEDIUM:
|
||||
propID = mwd50mn["id"] if shipPower > mwd50mn["powerReq"] else mwd5mn["id"]
|
||||
elif rigSize == RigSize.LARGE:
|
||||
elif rigSize == PortEftRigSize.LARGE:
|
||||
propID = mwd500mn["id"] if shipPower > mwd500mn["powerReq"] else mwd50mn["id"]
|
||||
elif rigSize == RigSize.CAPITAL:
|
||||
elif rigSize == PortEftRigSize.CAPITAL:
|
||||
propID = mwd50000mn["id"] if shipPower > mwd50000mn["powerReq"] else mwd500mn["id"]
|
||||
|
||||
if propID is None:
|
||||
@@ -86,7 +79,7 @@ class EfsPort:
|
||||
propWithBloom = next(filter(activePropWBloomFilter, propMods), None)
|
||||
if propWithBloom is not None:
|
||||
oldPropState = propWithBloom.state
|
||||
propWithBloom.state = State.ONLINE
|
||||
propWithBloom.state = FittingModuleState.ONLINE
|
||||
sFit.recalc(fit)
|
||||
sp = fit.maxSpeed
|
||||
sig = fit.ship.getModifiedItemAttr("signatureRadius")
|
||||
@@ -198,8 +191,8 @@ class EfsPort:
|
||||
def getModuleInfo(fit, padTypeIDs=False):
|
||||
moduleNames = []
|
||||
modTypeIDs = []
|
||||
moduleNameSets = {Slot.LOW: [], Slot.MED: [], Slot.HIGH: [], Slot.RIG: [], Slot.SUBSYSTEM: []}
|
||||
modTypeIDSets = {Slot.LOW: [], Slot.MED: [], Slot.HIGH: [], Slot.RIG: [], Slot.SUBSYSTEM: []}
|
||||
moduleNameSets = {FittingSlot.LOW: [], FittingSlot.MED: [], FittingSlot.HIGH: [], FittingSlot.RIG: [], FittingSlot.SUBSYSTEM: []}
|
||||
modTypeIDSets = {FittingSlot.LOW: [], FittingSlot.MED: [], FittingSlot.HIGH: [], FittingSlot.RIG: [], FittingSlot.SUBSYSTEM: []}
|
||||
for mod in fit.modules:
|
||||
try:
|
||||
if mod.item is not None:
|
||||
@@ -216,17 +209,17 @@ class EfsPort:
|
||||
pyfalog.error("Could not find name for module {0}".format(vars(mod)))
|
||||
|
||||
for modInfo in [
|
||||
["High Slots:"], moduleNameSets[Slot.HIGH], ["", "Med Slots:"], moduleNameSets[Slot.MED],
|
||||
["", "Low Slots:"], moduleNameSets[Slot.LOW], ["", "Rig Slots:"], moduleNameSets[Slot.RIG]
|
||||
["High Slots:"], moduleNameSets[FittingSlot.HIGH], ["", "Med Slots:"], moduleNameSets[FittingSlot.MED],
|
||||
["", "Low Slots:"], moduleNameSets[FittingSlot.LOW], ["", "Rig Slots:"], moduleNameSets[FittingSlot.RIG]
|
||||
]:
|
||||
moduleNames.extend(modInfo)
|
||||
if len(moduleNameSets[Slot.SUBSYSTEM]) > 0:
|
||||
if len(moduleNameSets[FittingSlot.SUBSYSTEM]) > 0:
|
||||
moduleNames.extend(["", "Subsystems:"])
|
||||
moduleNames.extend(moduleNameSets[Slot.SUBSYSTEM])
|
||||
moduleNames.extend(moduleNameSets[FittingSlot.SUBSYSTEM])
|
||||
|
||||
for slotType in [Slot.HIGH, Slot.MED, Slot.LOW, Slot.RIG, Slot.SUBSYSTEM]:
|
||||
if slotType is not Slot.SUBSYSTEM or len(modTypeIDSets[slotType]) > 0:
|
||||
modTypeIDs.extend([0, 0] if slotType is not Slot.HIGH else [0])
|
||||
for slotType in [FittingSlot.HIGH, FittingSlot.MED, FittingSlot.LOW, FittingSlot.RIG, FittingSlot.SUBSYSTEM]:
|
||||
if slotType is not FittingSlot.SUBSYSTEM or len(modTypeIDSets[slotType]) > 0:
|
||||
modTypeIDs.extend([0, 0] if slotType is not FittingSlot.HIGH else [0])
|
||||
modTypeIDs.extend(modTypeIDSets[slotType])
|
||||
|
||||
droneNames = []
|
||||
@@ -331,18 +324,18 @@ class EfsPort:
|
||||
name = stats.item.name + ", " + stats.charge.name
|
||||
else:
|
||||
name = stats.item.name
|
||||
if stats.hardpoint == Hardpoint.TURRET:
|
||||
if stats.hardpoint == FittingHardpoint.TURRET:
|
||||
tracking = stats.getModifiedItemAttr("trackingSpeed")
|
||||
typeing = "Turret"
|
||||
# Bombs share most attributes with missiles despite not needing the hardpoint
|
||||
elif stats.hardpoint == Hardpoint.MISSILE or "Bomb Launcher" in stats.item.name:
|
||||
elif stats.hardpoint == FittingHardpoint.MISSILE or "Bomb Launcher" in stats.item.name:
|
||||
maxVelocity = stats.getModifiedChargeAttr("maxVelocity")
|
||||
explosionDelay = stats.getModifiedChargeAttr("explosionDelay")
|
||||
damageReductionFactor = stats.getModifiedChargeAttr("aoeDamageReductionFactor")
|
||||
explosionRadius = stats.getModifiedChargeAttr("aoeCloudSize")
|
||||
explosionVelocity = stats.getModifiedChargeAttr("aoeVelocity")
|
||||
typeing = "Missile"
|
||||
elif stats.hardpoint == Hardpoint.NONE:
|
||||
elif stats.hardpoint == FittingHardpoint.NONE:
|
||||
aoeFieldRange = stats.getModifiedItemAttr("empFieldRange")
|
||||
# This also covers non-bomb weapons with dps values and no hardpoints, most notably targeted doomsdays.
|
||||
typeing = "SmartBomb"
|
||||
@@ -496,11 +489,11 @@ class EfsPort:
|
||||
getDroneMulti = lambda d: sumDamage(d.getModifiedItemAttr) * d.getModifiedItemAttr("damageMultiplier")
|
||||
fitMultipliers["drones"] = list(map(getDroneMulti, tf.drones))
|
||||
|
||||
getFitTurrets = lambda f: filter(lambda mod: mod.hardpoint == Hardpoint.TURRET, f.modules)
|
||||
getFitTurrets = lambda f: filter(lambda mod: mod.hardpoint == FittingHardpoint.TURRET, f.modules)
|
||||
getTurretMulti = lambda mod: mod.getModifiedItemAttr("damageMultiplier") / mod.cycleTime
|
||||
fitMultipliers["turrets"] = list(map(getTurretMulti, getFitTurrets(tf)))
|
||||
|
||||
getFitLaunchers = lambda f: filter(lambda mod: mod.hardpoint == Hardpoint.MISSILE, f.modules)
|
||||
getFitLaunchers = lambda f: filter(lambda mod: mod.hardpoint == FittingHardpoint.MISSILE, f.modules)
|
||||
getLauncherMulti = lambda mod: sumDamage(mod.getModifiedChargeAttr) / mod.cycleTime
|
||||
fitMultipliers["launchers"] = list(map(getLauncherMulti, getFitLaunchers(tf)))
|
||||
return fitMultipliers
|
||||
@@ -538,7 +531,7 @@ class EfsPort:
|
||||
if effect._Effect__effectModule is not None:
|
||||
effect.handler(tf, fit.mode, [])
|
||||
if fit.ship.item.groupID == getGroup("Strategic Cruiser").ID:
|
||||
subSystems = list(filter(lambda mod: mod.slot == Slot.SUBSYSTEM and mod.item, fit.modules))
|
||||
subSystems = list(filter(lambda mod: mod.slot == FittingSlot.SUBSYSTEM and mod.item, fit.modules))
|
||||
for sub in subSystems:
|
||||
for effect in sub.item.effects.values():
|
||||
if effect._Effect__effectModule is not None:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
import re
|
||||
from enum import Enum
|
||||
from service.const import PortEftOptions, PortEftRigSize
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
@@ -30,9 +30,10 @@ from eos.saveddata.booster import Booster
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.module import Module, State, Slot
|
||||
from eos.saveddata.module import Module
|
||||
from eos.saveddata.ship import Ship
|
||||
from eos.saveddata.fit import Fit
|
||||
from eos.const import FittingSlot, FittingModuleState
|
||||
from service.fit import Fit as svcFit
|
||||
from service.market import Market
|
||||
from service.port.muta import parseMutant, renderMutant
|
||||
@@ -41,22 +42,15 @@ from service.port.shared import IPortUser, fetchItem, processing_notify
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class Options(Enum):
|
||||
IMPLANTS = 1
|
||||
MUTATIONS = 2
|
||||
LOADED_CHARGES = 3
|
||||
|
||||
|
||||
EFT_OPTIONS = (
|
||||
(Options.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True),
|
||||
(Options.MUTATIONS.value, 'Mutated Attributes', 'Export mutated modules\' stats', True),
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', True),
|
||||
(PortEftOptions.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True),
|
||||
(PortEftOptions.MUTATIONS.value, 'Mutated Attributes', 'Export mutated modules\' stats', True),
|
||||
(PortEftOptions.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', True),
|
||||
)
|
||||
|
||||
|
||||
MODULE_CATS = ('Module', 'Subsystem', 'Structure Module')
|
||||
SLOT_ORDER = (Slot.LOW, Slot.MED, Slot.HIGH, Slot.RIG, Slot.SUBSYSTEM, Slot.SERVICE)
|
||||
SLOT_ORDER = (FittingSlot.LOW, FittingSlot.MED, FittingSlot.HIGH, FittingSlot.RIG, FittingSlot.SUBSYSTEM, FittingSlot.SERVICE)
|
||||
OFFLINE_SUFFIX = '/OFFLINE'
|
||||
|
||||
|
||||
@@ -86,21 +80,21 @@ def exportEft(fit, options):
|
||||
modName = module.baseItem.name
|
||||
else:
|
||||
modName = module.item.name
|
||||
if module.isMutated and options[Options.MUTATIONS.value]:
|
||||
if module.isMutated and options[PortEftOptions.MUTATIONS.value]:
|
||||
mutants[mutantReference] = module
|
||||
mutationSuffix = ' [{}]'.format(mutantReference)
|
||||
mutantReference += 1
|
||||
else:
|
||||
mutationSuffix = ''
|
||||
modOfflineSuffix = ' {}'.format(OFFLINE_SUFFIX) if module.state == State.OFFLINE else ''
|
||||
if module.charge and options[Options.LOADED_CHARGES.value]:
|
||||
modOfflineSuffix = ' {}'.format(OFFLINE_SUFFIX) if module.state == FittingModuleState.OFFLINE else ''
|
||||
if module.charge and options[PortEftOptions.LOADED_CHARGES.value]:
|
||||
rackLines.append('{}, {}{}{}'.format(
|
||||
modName, module.charge.name, modOfflineSuffix, mutationSuffix))
|
||||
else:
|
||||
rackLines.append('{}{}{}'.format(modName, modOfflineSuffix, mutationSuffix))
|
||||
else:
|
||||
rackLines.append('[Empty {} slot]'.format(
|
||||
Slot.getName(slotType).capitalize() if slotType is not None else ''))
|
||||
FittingSlot(slotType).name.capitalize() if slotType is not None else ''))
|
||||
if rackLines:
|
||||
modSection.append('\n'.join(rackLines))
|
||||
if modSection:
|
||||
@@ -122,7 +116,7 @@ def exportEft(fit, options):
|
||||
sections.append('\n\n'.join(minionSection))
|
||||
|
||||
# Section 3: implants, boosters
|
||||
if options[Options.IMPLANTS.value]:
|
||||
if options[PortEftOptions.IMPLANTS.value]:
|
||||
charSection = []
|
||||
implantLines = []
|
||||
for implant in fit.implants:
|
||||
@@ -149,7 +143,7 @@ def exportEft(fit, options):
|
||||
|
||||
# Section 5: mutated modules' details
|
||||
mutationLines = []
|
||||
if mutants and options[Options.MUTATIONS.value]:
|
||||
if mutants and options[PortEftOptions.MUTATIONS.value]:
|
||||
for mutantReference in sorted(mutants):
|
||||
mutant = mutants[mutantReference]
|
||||
mutationLines.append(renderMutant(mutant, firstPrefix='[{}] '.format(mutantReference), prefix=' '))
|
||||
@@ -441,8 +435,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
else:
|
||||
m.owner = fitobj
|
||||
# Activate mod if it is activable
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
# Add charge to mod if applicable, on any errors just don't add anything
|
||||
if chargeName:
|
||||
try:
|
||||
@@ -722,12 +716,12 @@ class AbstractFit:
|
||||
@property
|
||||
def __slotContainerMap(self):
|
||||
return {
|
||||
Slot.HIGH: self.modulesHigh,
|
||||
Slot.MED: self.modulesMed,
|
||||
Slot.LOW: self.modulesLow,
|
||||
Slot.RIG: self.rigs,
|
||||
Slot.SUBSYSTEM: self.subsystems,
|
||||
Slot.SERVICE: self.services}
|
||||
FittingSlot.HIGH: self.modulesHigh,
|
||||
FittingSlot.MED: self.modulesMed,
|
||||
FittingSlot.LOW: self.modulesLow,
|
||||
FittingSlot.RIG: self.rigs,
|
||||
FittingSlot.SUBSYSTEM: self.subsystems,
|
||||
FittingSlot.SERVICE: self.services}
|
||||
|
||||
def getContainerBySlot(self, slotType):
|
||||
return self.__slotContainerMap.get(slotType)
|
||||
@@ -798,10 +792,10 @@ class AbstractFit:
|
||||
|
||||
if itemSpec.charge is not None and m.isValidCharge(itemSpec.charge):
|
||||
m.charge = itemSpec.charge
|
||||
if itemSpec.offline and m.isValidState(State.OFFLINE):
|
||||
m.state = State.OFFLINE
|
||||
elif m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if itemSpec.offline and m.isValidState(FittingModuleState.OFFLINE):
|
||||
m.state = FittingModuleState.OFFLINE
|
||||
elif m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
return m
|
||||
|
||||
def addImplant(self, itemSpec):
|
||||
|
||||
@@ -28,7 +28,8 @@ from eos.saveddata.citadel import Citadel
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from eos.saveddata.fit import Fit
|
||||
from eos.saveddata.module import Module, State, Slot
|
||||
from eos.saveddata.module import Module
|
||||
from eos.const import FittingSlot, FittingModuleState
|
||||
from eos.saveddata.ship import Ship
|
||||
from service.fit import Fit as svcFit
|
||||
from service.market import Market
|
||||
@@ -41,12 +42,12 @@ class ESIExportException(Exception):
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
INV_FLAGS = {
|
||||
Slot.LOW: 11,
|
||||
Slot.MED: 19,
|
||||
Slot.HIGH: 27,
|
||||
Slot.RIG: 92,
|
||||
Slot.SUBSYSTEM: 125,
|
||||
Slot.SERVICE: 164
|
||||
FittingSlot.LOW: 11,
|
||||
FittingSlot.MED: 19,
|
||||
FittingSlot.HIGH: 27,
|
||||
FittingSlot.RIG: 92,
|
||||
FittingSlot.SUBSYSTEM: 125,
|
||||
FittingSlot.SERVICE: 164
|
||||
}
|
||||
|
||||
INV_FLAG_CARGOBAY = 5
|
||||
@@ -82,7 +83,7 @@ def exportESI(ofit):
|
||||
item = nested_dict()
|
||||
slot = module.slot
|
||||
|
||||
if slot == Slot.SUBSYSTEM:
|
||||
if slot == FittingSlot.SUBSYSTEM:
|
||||
# Order of subsystem matters based on this attr. See GH issue #130
|
||||
slot = int(module.getModifiedItemAttr("subSystemSlot"))
|
||||
item['flag'] = slot
|
||||
@@ -189,8 +190,8 @@ def importESI(string):
|
||||
if m.fits(fitobj):
|
||||
fitobj.modules.append(m)
|
||||
else:
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
|
||||
moduleList.append(m)
|
||||
|
||||
|
||||
@@ -18,19 +18,12 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Options(Enum):
|
||||
IMPLANTS = 1
|
||||
CARGO = 2
|
||||
LOADED_CHARGES = 3
|
||||
|
||||
from service.const import PortMultiBuyOptions
|
||||
|
||||
MULTIBUY_OPTIONS = (
|
||||
(Options.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True),
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', False),
|
||||
(Options.CARGO.value, 'Cargo', 'Export cargo contents', True),
|
||||
(PortMultiBuyOptions.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True),
|
||||
(PortMultiBuyOptions.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', False),
|
||||
(PortMultiBuyOptions.CARGO.value, 'Cargo', 'Export cargo contents', True),
|
||||
)
|
||||
|
||||
|
||||
@@ -48,7 +41,7 @@ def exportMultiBuy(fit, options):
|
||||
if module.isMutated:
|
||||
continue
|
||||
addItem(module.item)
|
||||
if module.charge and options[Options.LOADED_CHARGES.value]:
|
||||
if module.charge and options[PortMultiBuyOptions.LOADED_CHARGES.value]:
|
||||
addItem(module.charge, module.numCharges)
|
||||
|
||||
for drone in fit.drones:
|
||||
@@ -57,11 +50,11 @@ def exportMultiBuy(fit, options):
|
||||
for fighter in fit.fighters:
|
||||
addItem(fighter.item, fighter.amountActive)
|
||||
|
||||
if options[Options.CARGO.value]:
|
||||
if options[PortMultiBuyOptions.CARGO.value]:
|
||||
for cargo in fit.cargo:
|
||||
addItem(cargo.item, cargo.amount)
|
||||
|
||||
if options[Options.IMPLANTS.value]:
|
||||
if options[PortMultiBuyOptions.IMPLANTS.value]:
|
||||
for implant in fit.implants:
|
||||
addItem(implant.item)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ from bs4 import UnicodeDammit
|
||||
from logbook import Logger
|
||||
|
||||
from eos import db
|
||||
from eos.saveddata.fit import ImplantLocation
|
||||
from eos.const import ImplantLocation
|
||||
from service.fit import Fit as svcFit
|
||||
from service.port.dna import exportDna, importDna
|
||||
from service.port.eft import exportEft, importEft, importEftCfg
|
||||
|
||||
@@ -28,8 +28,9 @@ from eos.saveddata.citadel import Citadel
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from eos.saveddata.fit import Fit
|
||||
from eos.saveddata.module import Module, State, Slot
|
||||
from eos.saveddata.module import Module
|
||||
from eos.saveddata.ship import Ship
|
||||
from eos.const import FittingSlot, FittingModuleState
|
||||
from service.fit import Fit as svcFit
|
||||
from service.market import Market
|
||||
from utils.strfunctions import sequential_rep, replace_ltgt
|
||||
@@ -198,8 +199,8 @@ def importXml(text, iportuser):
|
||||
m.owner = fitobj
|
||||
fitobj.modules.append(m)
|
||||
else:
|
||||
if m.isValidState(State.ACTIVE):
|
||||
m.state = State.ACTIVE
|
||||
if m.isValidState(FittingModuleState.ACTIVE):
|
||||
m.state = FittingModuleState.ACTIVE
|
||||
|
||||
moduleList.append(m)
|
||||
|
||||
@@ -266,7 +267,7 @@ def exportXml(iportuser, *fits):
|
||||
|
||||
slot = module.slot
|
||||
|
||||
if slot == Slot.SUBSYSTEM:
|
||||
if slot == FittingSlot.SUBSYSTEM:
|
||||
# Order of subsystem matters based on this attr. See GH issue #130
|
||||
slotId = module.getModifiedItemAttr("subSystemSlot") - 125
|
||||
else:
|
||||
@@ -278,7 +279,7 @@ def exportXml(iportuser, *fits):
|
||||
|
||||
hardware = doc.createElement("hardware")
|
||||
hardware.setAttribute("type", module.item.name)
|
||||
slotName = Slot.getName(slot).lower()
|
||||
slotName = FittingSlot(slot).name.lower()
|
||||
slotName = slotName if slotName != "high" else "hi"
|
||||
hardware.setAttribute("slot", "%s slot %d" % (slotName, slotId))
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
Reference in New Issue
Block a user