Skip to content

Commit

Permalink
Fighters for export and import functions
Browse files Browse the repository at this point in the history
  • Loading branch information
IndictionEve committed Nov 10, 2016
1 parent 6849478 commit 04c30e7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
4 changes: 4 additions & 0 deletions eos/saveddata/fighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def amountActive(self):
def amountActive(self, i):
self.amount = int(max(min(i, self.getModifiedItemAttr("fighterSquadronMaxSize")), 0))

@property
def fighterSquadronMaxSize(self):
return int(self.getModifiedItemAttr("fighterSquadronMaxSize"))

@property
def abilities(self):
return self.__abilities or []
Expand Down
54 changes: 43 additions & 11 deletions service/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os
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 wx
import logging
Expand Down Expand Up @@ -270,6 +270,11 @@ def logtransform(s):
d = Drone(item)
d.amount = int(amount)
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":
c = Cargo(item)
c.amount = int(amount)
Expand Down Expand Up @@ -374,7 +379,15 @@ def importEft(eftString):
if not modName in droneMap:
droneMap[modName] = 0
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
if not modName in cargoMap:
cargoMap[modName] = 0
Expand Down Expand Up @@ -507,16 +520,21 @@ def importEftCfg(shipname, contents, callback=None):
droneItem = sMkt.getItem(droneName, eager="group.category")
except:
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
# 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":
# Bail if we can't get item or it's not from implant category
try:
Expand Down Expand Up @@ -648,6 +666,10 @@ def importXml(text, callback=None, encoding="utf-8"):
d = Drone(item)
d.amount = int(hardware.getAttribute("qty"))
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":
# 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
Expand Down Expand Up @@ -795,6 +817,9 @@ def exportDna(fit):
for drone in fit.drones:
dna += ":{0};{1}".format(drone.itemID, drone.amount)

for fighter in fit.fighters:
dna += ":{0};{1}".format(fighter.itemID, fighter.amountActive)

for cargo in fit.cargo:
# 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
Expand Down Expand Up @@ -868,6 +893,13 @@ def exportXml(cls, callback=None, *fits):
hardware.setAttribute("type", drone.item.name)
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:
if not cargo.item.name in charges:
charges[cargo.item.name] = 0
Expand Down

0 comments on commit 04c30e7

Please sign in to comment.