import React, { useState, useEffect } from "react"; import { ActiveFragment } from "../ActiveFragment"; import { IStaneksGift } from "../IStaneksGift"; import { FragmentType, Effect } from "../FragmentType"; import { numeralWrapper } from "../../ui/numeralFormat"; import Paper from "@mui/material/Paper"; import Typography from "@mui/material/Typography"; type IProps = { gift: IStaneksGift; fragment: ActiveFragment | null; x: number; y: number; }; export function FragmentInspector(props: IProps): React.ReactElement { const [, setC] = useState(new Date()); useEffect(() => { const id = setInterval(() => setC(new Date()), 250); return () => clearInterval(id); }, []); if (props.fragment === null) { return ( ID: N/A
Effect: N/A
Magnitude: N/A
Charge: N/A
Heat: N/A
Effect: N/A
[X, Y] N/A
[X, Y] {props.x}, {props.y}
); } const f = props.fragment.fragment(); let charge = numeralWrapper.formatStaneksGiftCharge(props.fragment.charge); let effect = "N/A"; // Boosters and cooling don't deal with heat. if ([FragmentType.Booster, FragmentType.None, FragmentType.Delete].includes(f.type)) { charge = "N/A"; effect = `${f.power}x adjacent fragment power`; } else { effect = Effect(f.type).replace("x%", numeralWrapper.formatPercentage(props.gift.effect(props.fragment) - 1)); } return ( ID: {props.fragment.id}
Effect: {effect}
Power: {numeralWrapper.formatStaneksGiftPower(f.power)}
Charge: {charge}

root [X, Y] {props.fragment.x}, {props.fragment.y}
[X, Y] {props.x}, {props.y}
); }