120 lines
2.8 KiB
TypeScript
120 lines
2.8 KiB
TypeScript
import type { ReactElement } from "react";
|
|
|
|
const baseUrl =
|
|
typeof window !== "undefined"
|
|
? window.location.origin
|
|
: process.env.VITE_VERCEL_URL || "http://localhost:5173"; // Fallback for your server env
|
|
|
|
const wandr = await fetch(
|
|
`${baseUrl}/characters/collateral/weaponsandarmor.json`,
|
|
).then((r) => r.json());
|
|
|
|
type DisplayArmor = {
|
|
displayheadarmor: string;
|
|
displayheadarmorsp: number;
|
|
dislpayheadarmorpenalty: number;
|
|
displaybodyarmor: number;
|
|
displaybodyarmorsp: number;
|
|
displaybodyarmorpenalty: number;
|
|
};
|
|
|
|
type DisplayWeapon = {
|
|
name: string;
|
|
features: Array<string>;
|
|
magazine: number;
|
|
damage: string;
|
|
rof: number;
|
|
};
|
|
|
|
function Armor({ armor }: { armor: DisplayArmor }): ReactElement {
|
|
return (
|
|
<table className="cyber-table" style={{ fontSize: "10px" }}>
|
|
<tbody>
|
|
<tr style={{ lineHeight: 1 }}>
|
|
<td>
|
|
<b>Head: {armor.displayheadarmor}</b>
|
|
</td>
|
|
<td>SP: {armor.displayheadarmorsp}</td>
|
|
<td>AP: {armor.dislpayheadarmorpenalty}</td>
|
|
</tr>
|
|
<tr style={{ lineHeight: 1 }}>
|
|
<td>
|
|
<b>Body: {armor.displaybodyarmor}</b>
|
|
</td>
|
|
<td>SP: {armor.displaybodyarmorsp}</td>
|
|
<td>AP: {armor.displaybodyarmorpenalty}</td>
|
|
</tr>
|
|
<tr style={{ lineHeight: 1 }}>
|
|
<td>
|
|
<b>Shield:</b>
|
|
</td>
|
|
<td>HP:</td>
|
|
<td>AP:</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
);
|
|
}
|
|
|
|
function Weapons({ weapons }: { weapons: Array<DisplayWeapon> }): ReactElement {
|
|
const rows: ReactElement[] = weapons.map((weapon, index) => {
|
|
return (
|
|
<tr key={index}>
|
|
<td>
|
|
<b>{weapon.name}</b>
|
|
</td>
|
|
<td>MAG: {weapon.magazine}</td>
|
|
<td>SMG: {weapon.damage}</td>
|
|
<td>ROF: {weapon.rof}</td>
|
|
<td>{weapon.features.join(" | ")}</td>
|
|
</tr>
|
|
);
|
|
});
|
|
|
|
return (
|
|
<table className="cyber-table" style={{ fontSize: "10px" }}>
|
|
<tbody>{rows}</tbody>
|
|
</table>
|
|
);
|
|
}
|
|
|
|
const card = {
|
|
lineHeight: "1",
|
|
paddingTop: "20px",
|
|
paddingLeft: "15px",
|
|
paddingRight: "15px",
|
|
paddingBottom: "10px",
|
|
fontWeight: "10px",
|
|
};
|
|
|
|
const header = {
|
|
marginBottom: "5px",
|
|
paddingBottom: "15px",
|
|
};
|
|
|
|
export function WeaponsAndArmor() {
|
|
return (
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
justifyContent: "space-between",
|
|
height: "230px",
|
|
}}
|
|
>
|
|
<div className="cyber-card" style={card}>
|
|
<div className="cyber-card__header" style={header}>
|
|
<div>Armor</div>
|
|
</div>
|
|
<Armor armor={wandr} />
|
|
</div>
|
|
<div className="cyber-card" style={card}>
|
|
<div className="cyber-card__header" style={header}>
|
|
<div>Weapons</div>
|
|
</div>
|
|
<Weapons weapons={wandr.displayweapons} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|