Beispiel #1
0
    def generalOutput():
        rowNames = ["EHP"]
        rowNames.extend(RRTypes.names(postProcessor=lambda v: v.capitalize()))
        colNames = DmgTypes.names(short=True,
                                  postProcessor=lambda v: " " + v.capitalize())
        colNames[0] = colNames[0][1::]

        outputScheme = []
        for index, rowName in enumerate(rowNames):
            row = rowName + ": {:>} ("
            subsValue = " {:.0%}," if index > 0 else " {:>},"

            row += ''.join([(colName + ":" + subsValue)
                            for colName in colNames])
            row = row[:-1:] + ")\n"

            outputScheme.append(row)

        return \
            outputScheme[0].format(ehpStr[3], *ehpAgainstDamageTypeStr) + \
            outputScheme[1].format(ehpStr[0], *resists["shield"]) + \
            outputScheme[2].format(ehpStr[1], *resists["armor"]) + \
            outputScheme[3].format(ehpStr[2], *resists["hull"])
Beispiel #2
0
def repsSection(fit):
    """ Returns the text of the repairs section"""
    selfRep = [
        fit.effectiveTank[tankType + "Repair"] for tankType in tankTypes
    ]
    sustainRep = [
        fit.effectiveSustainableTank[tankType + "Repair"]
        for tankType in tankTypes
    ]
    remoteRepObj = fit.getRemoteReps()
    remoteRep = [remoteRepObj.shield, remoteRepObj.armor, remoteRepObj.hull]
    shieldRegen = [fit.effectiveSustainableTank["passiveShield"], 0, 0]
    shieldRechargeModuleMultipliers = [
        module.item.attributes["shieldRechargeRateMultiplier"].value
        for module in fit.modules if module.item
        and "shieldRechargeRateMultiplier" in module.item.attributes
    ]
    shieldRechargeMultiplierByModules = reduce(
        lambda x, y: x * y, shieldRechargeModuleMultipliers, 1)
    if shieldRechargeMultiplierByModules >= 0.9:  # If the total affect of modules on the shield recharge is negative or insignificant, we don't care about it
        shieldRegen[0] = 0
    totalRep = list(zip(selfRep, remoteRep, shieldRegen))
    totalRep = list(map(sum, totalRep))

    selfRep.append(sum(selfRep))
    sustainRep.append(sum(sustainRep))
    remoteRep.append(sum(remoteRep))
    shieldRegen.append(sum(shieldRegen))
    totalRep.append(sum(totalRep))

    totalSelfRep = selfRep[-1]
    totalRemoteRep = remoteRep[-1]
    totalShieldRegen = shieldRegen[-1]

    text = ""

    if sum(
            totalRep
    ) > 0:  # Most commonly, there are no reps at all; then we skip this section
        singleTypeRep = None
        singleTypeRepName = None
        if totalRemoteRep == 0 and totalShieldRegen == 0:  # Only self rep
            singleTypeRep = selfRep[:-1]
            singleTypeRepName = "Self"
        if totalSelfRep == 0 and totalShieldRegen == 0:  # Only remote rep
            singleTypeRep = remoteRep[:-1]
            singleTypeRepName = "Remote"
        if totalSelfRep == 0 and totalRemoteRep == 0:  # Only shield regen
            singleTypeRep = shieldRegen[:-1]
            singleTypeRepName = "Regen"
        if singleTypeRep and sum(
                x > 0 for x in singleTypeRep
        ) == 1:  # Only one type of reps and only one tank type is repaired
            index = next(i for i, v in enumerate(singleTypeRep) if v > 0)
            if singleTypeRepName == "Regen":
                text += "Shield regeneration: {} EHP/s".format(
                    formatAmount(singleTypeRep[index], 3, 0, 9))
            else:
                text += "{} {} repair: {} EHP/s".format(
                    singleTypeRepName, tankTypes[index],
                    formatAmount(singleTypeRep[index], 3, 0, 9))
            if (singleTypeRepName
                    == "Self") and (sustainRep[index] != singleTypeRep[index]):
                text += " (Sustained: {} EHP/s)".format(
                    formatAmount(sustainRep[index], 3, 0, 9))
            text += "\n"
        else:  # Otherwise show a table
            selfRepStr = [formatAmount(rep, 3, 0, 9) for rep in selfRep]
            sustainRepStr = [formatAmount(rep, 3, 0, 9) for rep in sustainRep]
            remoteRepStr = [formatAmount(rep, 3, 0, 9) for rep in remoteRep]
            shieldRegenStr = [
                formatAmount(rep, 3, 0, 9) if rep != 0 else ""
                for rep in shieldRegen
            ]
            totalRepStr = [formatAmount(rep, 3, 0, 9) for rep in totalRep]

            lines = RRTypes.names(postProcessor=lambda v: v.capitalize())
            lines.append("Total")
            lines = ["{:<8}".format(line) for line in lines]

            showSelfRepColumn = totalSelfRep > 0
            showSustainRepColumn = sustainRep != selfRep
            showRemoteRepColumn = totalRemoteRep > 0
            showShieldRegenColumn = totalShieldRegen > 0

            header = "REPS    "
            header, lines = _addFormattedColumn(
                (showSelfRepColumn + showSustainRepColumn +
                 showRemoteRepColumn + showShieldRegenColumn > 1), "TOTAL",
                header, lines, totalRepStr)
            header, lines = _addFormattedColumn(showSelfRepColumn, "SELF",
                                                header, lines, selfRepStr)
            header, lines = _addFormattedColumn(showSustainRepColumn, "SUST",
                                                header, lines, sustainRepStr)
            header, lines = _addFormattedColumn(showRemoteRepColumn, "REMOTE",
                                                header, lines, remoteRepStr)
            header, lines = _addFormattedColumn(showShieldRegenColumn, "REGEN",
                                                header, lines, shieldRegenStr)

            text += header + "\n"
            repsByTank = zip(totalRep, selfRep, sustainRep, remoteRep,
                             shieldRegen)
            for line in lines:
                reps = next(repsByTank)
                if sum(reps) > 0:
                    text += line + "\n"
    return text
Beispiel #3
0
def test_rrtypes_names_lambda():
    assert RRTypes.names(
        True, lambda v: v.capitalize()) == ['Shield', 'Armor', 'Hull']
    assert RRTypes.names(postProcessor=lambda v: v.upper(), ehpOnly=False) == [
        'SHIELD', 'ARMOR', 'HULL', 'CAPACITOR'
    ]
Beispiel #4
0
from functools import reduce
from eos.saveddata.damagePattern import DamagePattern
from eos.utils.stats import RRTypes, DmgTypes
from gui.utils.numberFormatter import formatAmount

tankTypes = RRTypes.names()
damageTypes = DmgTypes.names()
damagePatterns = [
    DamagePattern.oneType(damageType) for damageType in damageTypes
]
damageTypeResonanceNames = [
    damageType.capitalize() + "DamageResonance" for damageType in damageTypes
]
resonanceNames = {
    tankTypes[0]: [tankTypes[0] + s for s in damageTypeResonanceNames],
    tankTypes[1]: [tankTypes[1] + s for s in damageTypeResonanceNames],
    tankTypes[2]: [s[0].lower() + s[1:] for s in damageTypeResonanceNames]
}


def firepowerSection(fit):
    """ Returns the text of the firepower section"""
    totalDps = fit.getTotalDps().total
    weaponDps = fit.getWeaponDps().total
    droneDps = fit.getDroneDps().total
    totalVolley = fit.getTotalVolley().total
    firepower = [totalDps, weaponDps, droneDps, totalVolley]

    firepowerStr = [formatAmount(dps, 3, 0, 0) for dps in firepower]
    # showWeaponAndDroneDps = (weaponDps > 0) and (droneDps > 0)
    if sum(firepower) == 0:
Beispiel #5
0
def test_rrtypes_names():
    assert RRTypes.names() == ['shield', 'armor', 'hull']
    assert RRTypes.names(True) == ['shield', 'armor', 'hull']
    assert RRTypes.names(ehpOnly=True) == ['shield', 'armor', 'hull']
    assert RRTypes.names(False) == ['shield', 'armor', 'hull', 'capacitor']