Merge pull request #807 from IndictionEve/ImportExportFighters
Fighters for export and import functions
This commit is contained in:
@@ -120,6 +120,10 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
|||||||
def amountActive(self, i):
|
def amountActive(self, i):
|
||||||
self.amount = int(max(min(i, self.getModifiedItemAttr("fighterSquadronMaxSize")), 0))
|
self.amount = int(max(min(i, self.getModifiedItemAttr("fighterSquadronMaxSize")), 0))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fighterSquadronMaxSize(self):
|
||||||
|
return int(self.getModifiedItemAttr("fighterSquadronMaxSize"))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def abilities(self):
|
def abilities(self):
|
||||||
return self.__abilities or []
|
return self.__abilities or []
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import re
|
|||||||
import os
|
import os
|
||||||
import xml.dom
|
import xml.dom
|
||||||
|
|
||||||
from eos.types import State, Slot, Module, Cargo, Fit, Ship, Drone, Implant, Booster, Citadel
|
from eos.types import State, Slot, Module, Cargo, Fit, Ship, Drone, Implant, Booster, Citadel, Fighter
|
||||||
import service
|
import service
|
||||||
import wx
|
import wx
|
||||||
import logging
|
import logging
|
||||||
@@ -46,6 +46,7 @@ INV_FLAGS = {
|
|||||||
|
|
||||||
INV_FLAG_CARGOBAY = 5
|
INV_FLAG_CARGOBAY = 5
|
||||||
INV_FLAG_DRONEBAY = 87
|
INV_FLAG_DRONEBAY = 87
|
||||||
|
INV_FLAG_FIGHTER = 158
|
||||||
|
|
||||||
class Port(object):
|
class Port(object):
|
||||||
"""Service which houses all import/export format functions"""
|
"""Service which houses all import/export format functions"""
|
||||||
@@ -131,6 +132,15 @@ class Port(object):
|
|||||||
item['type']['name'] = ''
|
item['type']['name'] = ''
|
||||||
fit['items'].append(item)
|
fit['items'].append(item)
|
||||||
|
|
||||||
|
for fighter in ofit.fighters:
|
||||||
|
item = nested_dict()
|
||||||
|
item['flag'] = INV_FLAG_FIGHTER
|
||||||
|
item['quantity'] = fighter.amountActive
|
||||||
|
item['type']['href'] = "%sinventory/types/%d/"%(eve._authed_endpoint, fighter.item.ID)
|
||||||
|
item['type']['id'] = fighter.item.ID
|
||||||
|
item['type']['name'] = fighter.item.name
|
||||||
|
fit['items'].append(item)
|
||||||
|
|
||||||
return json.dumps(fit)
|
return json.dumps(fit)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -196,6 +206,9 @@ class Port(object):
|
|||||||
c = Cargo(item)
|
c = Cargo(item)
|
||||||
c.amount = module['quantity']
|
c.amount = module['quantity']
|
||||||
f.cargo.append(c)
|
f.cargo.append(c)
|
||||||
|
elif module['flag'] == INV_FLAG_FIGHTER:
|
||||||
|
fighter = Fighter(item)
|
||||||
|
f.fighters.append(fighter)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
m = Module(item)
|
m = Module(item)
|
||||||
@@ -270,6 +283,11 @@ class Port(object):
|
|||||||
d = Drone(item)
|
d = Drone(item)
|
||||||
d.amount = int(amount)
|
d.amount = int(amount)
|
||||||
f.drones.append(d)
|
f.drones.append(d)
|
||||||
|
elif item.category.name == "Fighter":
|
||||||
|
ft = Fighter(item)
|
||||||
|
ft.amount = int(amount) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize
|
||||||
|
if ft.fits(f):
|
||||||
|
f.fighters.append(ft)
|
||||||
elif item.category.name == "Charge":
|
elif item.category.name == "Charge":
|
||||||
c = Cargo(item)
|
c = Cargo(item)
|
||||||
c.amount = int(amount)
|
c.amount = int(amount)
|
||||||
@@ -374,7 +392,15 @@ class Port(object):
|
|||||||
if not modName in droneMap:
|
if not modName in droneMap:
|
||||||
droneMap[modName] = 0
|
droneMap[modName] = 0
|
||||||
droneMap[modName] += extraAmount
|
droneMap[modName] += extraAmount
|
||||||
if len(modExtra) == 2 and item.category.name != "Drone":
|
elif item.category.name == "Fighter":
|
||||||
|
extraAmount = int(extraAmount) if extraAmount is not None else 1
|
||||||
|
fighterItem = Fighter(item)
|
||||||
|
if (extraAmount > fighterItem.fighterSquadronMaxSize): #Amount bigger then max fightergroup size
|
||||||
|
extraAmount = fighterItem.fighterSquadronMaxSize
|
||||||
|
if fighterItem.fits(fit):
|
||||||
|
fit.fighters.append(fighterItem)
|
||||||
|
|
||||||
|
if len(modExtra) == 2 and item.category.name != "Drone" and item.category.name != "Fighter":
|
||||||
extraAmount = int(extraAmount) if extraAmount is not None else 1
|
extraAmount = int(extraAmount) if extraAmount is not None else 1
|
||||||
if not modName in cargoMap:
|
if not modName in cargoMap:
|
||||||
cargoMap[modName] = 0
|
cargoMap[modName] = 0
|
||||||
@@ -507,16 +533,21 @@ class Port(object):
|
|||||||
droneItem = sMkt.getItem(droneName, eager="group.category")
|
droneItem = sMkt.getItem(droneName, eager="group.category")
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if droneItem.category.name != "Drone":
|
if droneItem.category.name == "Drone":
|
||||||
|
# Add drone to the fitting
|
||||||
|
d = Drone(droneItem)
|
||||||
|
d.amount = droneAmount
|
||||||
|
if entityState == "Active":
|
||||||
|
d.amountActive = droneAmount
|
||||||
|
elif entityState == "Inactive":
|
||||||
|
d.amountActive = 0
|
||||||
|
f.drones.append(d)
|
||||||
|
elif droneItem.category.name == "Fighter": # EFT saves fighter as drones
|
||||||
|
ft = Fighter(droneItem)
|
||||||
|
ft.amount = int(droneAmount) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize
|
||||||
|
f.fighters.append(ft)
|
||||||
|
else:
|
||||||
continue
|
continue
|
||||||
# Add drone to the fitting
|
|
||||||
d = Drone(droneItem)
|
|
||||||
d.amount = droneAmount
|
|
||||||
if entityState == "Active":
|
|
||||||
d.amountActive = droneAmount
|
|
||||||
elif entityState == "Inactive":
|
|
||||||
d.amountActive = 0
|
|
||||||
f.drones.append(d)
|
|
||||||
elif entityType == "Implant":
|
elif entityType == "Implant":
|
||||||
# Bail if we can't get item or it's not from implant category
|
# Bail if we can't get item or it's not from implant category
|
||||||
try:
|
try:
|
||||||
@@ -648,6 +679,10 @@ class Port(object):
|
|||||||
d = Drone(item)
|
d = Drone(item)
|
||||||
d.amount = int(hardware.getAttribute("qty"))
|
d.amount = int(hardware.getAttribute("qty"))
|
||||||
f.drones.append(d)
|
f.drones.append(d)
|
||||||
|
elif item.category.name == "Fighter":
|
||||||
|
ft = Fighter(item)
|
||||||
|
ft.amount = int(hardware.getAttribute("qty")) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize
|
||||||
|
f.fighters.append(ft)
|
||||||
elif hardware.getAttribute("slot").lower() == "cargo":
|
elif hardware.getAttribute("slot").lower() == "cargo":
|
||||||
# although the eve client only support charges in cargo, third-party programs
|
# although the eve client only support charges in cargo, third-party programs
|
||||||
# may support items or "refits" in cargo. Support these by blindly adding all
|
# may support items or "refits" in cargo. Support these by blindly adding all
|
||||||
@@ -800,6 +835,9 @@ class Port(object):
|
|||||||
for droneItemID in groupedDrones:
|
for droneItemID in groupedDrones:
|
||||||
dna += ":{0};{1}".format(droneItemID, groupedDrones[droneItemID])
|
dna += ":{0};{1}".format(droneItemID, groupedDrones[droneItemID])
|
||||||
|
|
||||||
|
for fighter in fit.fighters:
|
||||||
|
dna += ":{0};{1}".format(fighter.itemID, fighter.amountActive)
|
||||||
|
|
||||||
for cargo in fit.cargo:
|
for cargo in fit.cargo:
|
||||||
# DNA format is a simple/dumb format. As CCP uses the slot information of the item itself
|
# DNA format is a simple/dumb format. As CCP uses the slot information of the item itself
|
||||||
# without designating slots in the DNA standard, we need to make sure we only include
|
# without designating slots in the DNA standard, we need to make sure we only include
|
||||||
@@ -873,6 +911,13 @@ class Port(object):
|
|||||||
hardware.setAttribute("type", drone.item.name)
|
hardware.setAttribute("type", drone.item.name)
|
||||||
fitting.appendChild(hardware)
|
fitting.appendChild(hardware)
|
||||||
|
|
||||||
|
for fighter in fit.fighters:
|
||||||
|
hardware = doc.createElement("hardware")
|
||||||
|
hardware.setAttribute("qty", "%d" % fighter.amountActive)
|
||||||
|
hardware.setAttribute("slot", "fighter bay")
|
||||||
|
hardware.setAttribute("type", fighter.item.name)
|
||||||
|
fitting.appendChild(hardware)
|
||||||
|
|
||||||
for cargo in fit.cargo:
|
for cargo in fit.cargo:
|
||||||
if not cargo.item.name in charges:
|
if not cargo.item.name in charges:
|
||||||
charges[cargo.item.name] = 0
|
charges[cargo.item.name] = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user