import React, {useState, useEffect} from "react"; import { ActiveFragment } from "../ActiveFragment"; import { FragmentType } from "../FragmentType"; import { numeralWrapper } from "../../ui/numeralFormat"; import { MuiPaper } from "../../ui/React/MuiPaper"; import { CalculateEffect } from "../formulas/effect"; type IProps = { fragment: ActiveFragment | null; } export function FragmentInspector(props: IProps) { const [, setC] = useState(new Date()) useEffect(() => { const id = setInterval(() => setC(new Date()), 250); return () => clearInterval(id); }, []); if(props.fragment === null) { return (
                ID:        N/A
Type: N/A
Magnitude: N/A
Charge: N/A
Heat: N/A
Effect: N/A
[X, Y] N/A
) } const f = props.fragment.fragment(); let charge = numeralWrapper.formatStaneksGiftCharge(props.fragment.charge); let heat = numeralWrapper.formatStaneksGiftHeat(props.fragment.heat); // Boosters and cooling don't deal with heat. if(f.type === FragmentType.Booster || f.type === FragmentType.Cooling) { charge = "N/A"; heat = "N/A"; } const effect = numeralWrapper.format((CalculateEffect(props.fragment.charge, f.power)-1), "+0.00%"); return (
            ID:     {props.fragment.id}
Type: {FragmentType[f.type]}
Power: {numeralWrapper.formatStaneksGiftPower(f.power)}
Charge: {charge}
Heat: {heat}
Effect: {effect}
[X, Y] {props.fragment.x}, {props.fragment.y}
) }