import React from "react"; import ArmorTypeNames from "../types/ArmorTypeValues"; import { styled, Table, TableBody, TableCell, tableCellClasses, TableContainer, TableHead, TableRow } from "@mui/material"; import ArmorType from "./ArmorType"; import {IMod} from "../types/Imod"; import {IPiercing} from "../types/IPiercing"; import {IArmorType} from "../types/IArmorType"; export default function DpsTable(props: { mod: IMod, minDamageValue?: number, minDamage?: number, maxDamage?: number, piercings: IPiercing[], targetFilter: IArmorType[], moraleDamage?: number }) { const StyledTableCell = styled(TableCell)(({theme}) => ({ [`&.${tableCellClasses.head}`]: { backgroundColor: "rgb(244,244,244)", marginRight: 'auto', marginLeft: 'auto', paddingLeft: 10 }, [`&.${tableCellClasses.body}`]: { fontSize: 12, textAlign: 'center', paddingRight: 18, paddingLeft: 10 }, })); function getPiercingK(armorType: string): number|null { if(props.targetFilter.length > 0 && props.targetFilter.find(tf => tf.name == armorType) === undefined) return null const piercing = props.piercings.find((p) => p.armorType.name === armorType) return (typeof piercing !== "undefined" ? piercing.piercingValue : 10) / 100 } const infLowPiercing = getPiercingK(ArmorTypeNames.InfantryLow) const infMedPiercing = getPiercingK(ArmorTypeNames.InfantryMedium) const infHighPiercing = getPiercingK(ArmorTypeNames.InfantryHigh) const infHeavyMedPiercing = getPiercingK(ArmorTypeNames.InfantryHeavyMedium) const infHeavyHighPiercing = getPiercingK(ArmorTypeNames.InfantryHeavyHigh) const demonPiercing = getPiercingK(ArmorTypeNames.DemonMedium) const demonHighPiercing = getPiercingK(ArmorTypeNames.DemonHigh) const commanderPiercing = getPiercingK(ArmorTypeNames.Commander) const airPiercing = getPiercingK(ArmorTypeNames.Air) const vehLowPiercing = getPiercingK(ArmorTypeNames.VehicleLow) const vehMedPiercing = getPiercingK(ArmorTypeNames.VehicleMedium) const vehHighPiercing = getPiercingK(ArmorTypeNames.VehicleHigh) const buildingLowPiercing = getPiercingK(ArmorTypeNames.BuildingLow) const buildingMedPiercing = getPiercingK(ArmorTypeNames.BuildingMedium) const buildingHighPiercing = getPiercingK(ArmorTypeNames.BuildingHigh) // UA mod const demonLowPiercing = getPiercingK(ArmorTypeNames.DemonLow) const buildingSuperPiercing = getPiercingK(ArmorTypeNames.BuildingSuper) const livingMetalPiercing = getPiercingK(ArmorTypeNames.LivingMetal) const titanPiercing = getPiercingK(ArmorTypeNames.Titan) const getTotalDamage = (damagePiercing: number|null) => { if(damagePiercing === null) return "" if(props.minDamageValue !== undefined && props.minDamage !== undefined && props.maxDamage !== undefined){ var minDamage = damagePiercing * props.minDamage var maxDamage = damagePiercing * props.maxDamage if(props.minDamageValue !== undefined){ if (minDamage < props.minDamageValue) { minDamage = props.minDamageValue } if (maxDamage < props.minDamageValue) { maxDamage = props.minDamageValue } } const averageDmg = (minDamage + maxDamage) / 2 return averageDmg.toFixed(2) } } const getMoraleDamage = () => { if(props.moraleDamage !== undefined) return (props.moraleDamage / 2).toFixed(2) } return ( { props.mod !== undefined && props.mod.name.includes("Ultimate Apocalypse") ? {getTotalDamage(infLowPiercing)} {getTotalDamage(infMedPiercing)} {getTotalDamage(infHighPiercing)} {getTotalDamage(infHeavyMedPiercing)} {getTotalDamage(infHeavyHighPiercing)} {getTotalDamage(commanderPiercing)} {getTotalDamage(demonLowPiercing)} {getTotalDamage(demonPiercing)} {getTotalDamage(demonHighPiercing)} {getTotalDamage(airPiercing)}
Morale
{getTotalDamage(vehLowPiercing)} {getTotalDamage(vehMedPiercing)} {getTotalDamage(vehHighPiercing)} {getTotalDamage(livingMetalPiercing)} {getTotalDamage(titanPiercing)} {getTotalDamage(buildingLowPiercing)} {getTotalDamage(buildingMedPiercing)} {getTotalDamage(buildingHighPiercing)} {getTotalDamage(buildingSuperPiercing)} {getMoraleDamage()}
:
Morale
{getTotalDamage(infLowPiercing)} {getTotalDamage(infMedPiercing)} {getTotalDamage(infHighPiercing)} {getTotalDamage(infHeavyMedPiercing)} {getTotalDamage(infHeavyHighPiercing)} {getTotalDamage(commanderPiercing)} {getTotalDamage(demonPiercing)} {getTotalDamage(demonHighPiercing)} {getTotalDamage(airPiercing)} {getTotalDamage(vehLowPiercing)} {getTotalDamage(vehMedPiercing)} {getTotalDamage(vehHighPiercing)} {getTotalDamage(buildingLowPiercing)} {getTotalDamage(buildingMedPiercing)} {getTotalDamage(buildingHighPiercing)} {getMoraleDamage()}
}
) }