Show EHP restored by AAR/ASB before reload

This commit is contained in:
DarkPhoenix
2013-06-12 13:27:36 +04:00
parent 003eaa45ed
commit db64713756
4 changed files with 46 additions and 5 deletions

View File

@@ -165,6 +165,20 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
else:
return self.__chargeCycles
@property
def hpBeforeReload(self):
"""
If item is some kind of repairer with charges, calculate
HP it reps before going into reload.
"""
cycles = self.numShots
armorRep = self.getModifiedItemAttr("armorDamageAmount") or 0
shieldRep = self.getModifiedItemAttr("shieldBonus") or 0
if not cycles or (not armorRep and not shieldRep):
return None
hp = round((armorRep + shieldRep) * cycles)
return hp
def __calculateAmmoShots(self):
if self.charge is not None:
# Set number of cycles before reload is needed
@@ -335,7 +349,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
# Check ship type restrictions
fitsOnType = set()
fitsOnGroup = set()
shipType = self.getModifiedItemAttr("fitsToShipType")
if shipType is not None:
fitsOnType.add(shipType)
@@ -355,7 +369,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if (len(fitsOnGroup) > 0 or len(fitsOnType) > 0) and fit.ship.item.group.ID not in fitsOnGroup and fit.ship.item.ID not in fitsOnType:
return False
# If the mod is a subsystem, don't let two subs in the same slot fit
if self.slot == Slot.SUBSYSTEM:
subSlot = self.getModifiedItemAttr("subSystemSlot")

View File

@@ -26,6 +26,7 @@ from gui.utils.numberFormatter import formatAmount
import service
import gui.mainFrame
import gui.builtinViews.fittingView as fv
import gui.globalEvents as GE
EffectiveHpToggled, EFFECTIVE_HP_TOGGLED = wx.lib.newevent.NewEvent()
@@ -160,9 +161,7 @@ class ResistancesViewFull(StatsView):
def ehpSwitch(self, event):
self.showEffective = event.effective
sFit = service.Fit.getInstance()
self.refreshPanel(sFit.getFit(self.mainFrame.getActiveFit()))
event.Skip()
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here

View File

@@ -17,11 +17,14 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
import gui.mainFrame
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.utils.numberFormatter import formatAmount
from gui.utils.listFormatter import formatList
from service.fit import Fit
import wx
@@ -42,6 +45,7 @@ class Miscellanea(ViewColumn):
if params["displayName"] or self.imageId == -1:
self.columnText = "Misc data"
self.mask |= wx.LIST_MASK_TEXT
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def getText(self, stuff):
text = self.__getData(stuff)[0]
@@ -407,6 +411,28 @@ class Miscellanea(ViewColumn):
text = "{0}s".format(cycleTime)
tooltip = "Spoolup time"
return text, tooltip
elif itemGroup in ("Fueled Armor Repairer", "Fueled Shield Booster"):
hp = stuff.hpBeforeReload
cycles = stuff.numShots
cycleTime = stuff.cycleTime
if not hp or not cycleTime or not cycles:
return "", None
fit = Fit.getInstance().getFit(self.mainFrame.getActiveFit())
ehpTotal = fit.ehp
hpTotal = fit.hp
useEhp = self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective
if useEhp:
if itemGroup == "Fueled Armor Repairer":
hpRatio = ehpTotal["armor"] / hpTotal["armor"]
else:
hpRatio = ehpTotal["shield"] / hpTotal["shield"]
else:
hpRatio = 1
ehp = hp * hpRatio
duration = cycles * cycleTime / 1000
text = "{0} / {1}s".format(formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3))
tooltip = "Hitpoints restored over duration using charges"
return text, tooltip
elif stuff.charge is not None:
chargeGroup = stuff.charge.group.name
if chargeGroup in ("Rocket", "Advanced Rocket", "Light Missile", "Advanced Light Missile", "FoF Light Missile",

View File

@@ -54,6 +54,7 @@ class StatsPane(wx.Panel):
self.SetSizer(mainSizer)
self.views = []
self.nameViewMap = {}
maxviews = len(self.DEFAULT_VIEWS)
i=0
for viewName in self.DEFAULT_VIEWS:
@@ -62,6 +63,7 @@ class StatsPane(wx.Panel):
contentPanel.viewName = viewName
view = StatsView.getView(viewName)(self)
self.nameViewMap[viewName] = view
self.views.append(view)
headerPanel = tp.GetHeaderPanel()