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