Returns the text of the tank section
(fit)
| 31 | |
| 32 | |
| 33 | def tankSection(fit): |
| 34 | """ Returns the text of the tank section""" |
| 35 | ehp = [fit.ehp[tank] for tank in tankTypes] if fit.ehp is not None else [0, 0, 0] |
| 36 | ehp.append(sum(ehp)) |
| 37 | ehpStr = [formatAmount(ehpVal, 3, 0, 9) for ehpVal in ehp] |
| 38 | resists = {tankType: [1 - fit.ship.getModifiedItemAttr(s) for s in resonanceNames[tankType]] for tankType in tankTypes} |
| 39 | ehpAgainstDamageType = [sum(pattern.calculateEhp(fit.ship).values()) for pattern in damagePatterns] |
| 40 | ehpAgainstDamageTypeStr = [formatAmount(ehpVal, 3, 0, 9) for ehpVal in ehpAgainstDamageType] |
| 41 | |
| 42 | # not used for now. maybe will be improved later |
| 43 | # def formattedOutput(): |
| 44 | # return \ |
| 45 | # " {:>7} {:>7} {:>7} {:>7} {:>7}\n".format("TOTAL", "EM", "THERM", "KIN", "EXP") + \ |
| 46 | # "EHP {:>7} {:>7} {:>7} {:>7} {:>7}\n".format(ehpStr[3], *ehpAgainstDamageTypeStr) + \ |
| 47 | # "Shield {:>7} {:>7.0%} {:>7.0%} {:>7.0%} {:>7.0%}\n".format(ehpStr[0], *resists["shield"]) + \ |
| 48 | # "Armor {:>7} {:>7.0%} {:>7.0%} {:>7.0%} {:>7.0%}\n".format(ehpStr[1], *resists["armor"]) + \ |
| 49 | # "Hull {:>7} {:>7.0%} {:>7.0%} {:>7.0%} {:>7.0%}\n".format(ehpStr[2], *resists["hull"]) |
| 50 | |
| 51 | def generalOutput(): |
| 52 | rowNames = ["EHP"] |
| 53 | rowNames.extend(RRTypes.names(postProcessor=lambda v: v.capitalize())) |
| 54 | colNames = DmgTypes.names(short=True, postProcessor=lambda v: " " + v.capitalize()) |
| 55 | colNames[0] = colNames[0][1::] |
| 56 | |
| 57 | outputScheme = [] |
| 58 | for index, rowName in enumerate(rowNames): |
| 59 | row = rowName + ": {:>} (" |
| 60 | subsValue = " {:.0%}," if index > 0 else " {:>}," |
| 61 | |
| 62 | row += ''.join([(colName + ":" + subsValue) for colName in colNames]) |
| 63 | row = row[:-1:] + ")\n" |
| 64 | |
| 65 | outputScheme.append(row) |
| 66 | |
| 67 | return \ |
| 68 | outputScheme[0].format(ehpStr[3], *ehpAgainstDamageTypeStr) + \ |
| 69 | outputScheme[1].format(ehpStr[0], *resists["shield"]) + \ |
| 70 | outputScheme[2].format(ehpStr[1], *resists["armor"]) + \ |
| 71 | outputScheme[3].format(ehpStr[2], *resists["hull"]) |
| 72 | |
| 73 | # return \ |
| 74 | # "EHP: {:>} (Em: {:>}, Th: {:>}, Kin: {:>}, Exp: {:>})\n".format(ehpStr[3], *ehpAgainstDamageTypeStr) + \ |
| 75 | # "Shield: {:>} (Em: {:.0%}, Th: {:.0%}, Kin: {:.0%}, Exp: {:.0%})\n".format(ehpStr[0], *resists["shield"]) + \ |
| 76 | # "Armor: {:>} (Em: {:.0%}, Th: {:.0%}, Kin: {:.0%}, Exp: {:.0%})\n".format(ehpStr[1], *resists["armor"]) + \ |
| 77 | # "Hull: {:>} (Em: {:.0%}, Th: {:.0%}, Kin: {:.0%}, Exp: {:.0%})\n".format(ehpStr[2], *resists["hull"]) |
| 78 | |
| 79 | return generalOutput() |
| 80 | |
| 81 | |
| 82 | def _addFormattedColumn(value, name, header, linesList, repStr): |
no test coverage detected