get ammo and gear tables working
This commit is contained in:
1 parent
49dec31761
commit
9298ebcd3e
23 files changed
+928
-391
No files matched your search
@@ -1,14 +1,16 @@
|
||||
import type { ReactElement } from 'react'
|
||||
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 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 => {
|
||||
console.log(r)
|
||||
return r.json()
|
||||
});
|
||||
const wandr = await fetch(
|
||||
`${baseUrl}/characters/collateral/weaponsandarmor.json`,
|
||||
).then((r) => {
|
||||
console.log(r);
|
||||
return r.json();
|
||||
});
|
||||
|
||||
type DisplayArmor = {
|
||||
displayheadarmor: string;
|
||||
@@ -17,7 +19,7 @@ type DisplayArmor = {
|
||||
displaybodyarmor: number;
|
||||
displaybodyarmorsp: number;
|
||||
displaybodyarmorpenalty: number;
|
||||
}
|
||||
};
|
||||
|
||||
type DisplayWeapon = {
|
||||
name: string;
|
||||
@@ -25,52 +27,58 @@ type DisplayWeapon = {
|
||||
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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<td>{weapon.features.join(" | ")}</td>
|
||||
</tr>
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<table className="cyber-table" style={{ fontSize: "10px" }}>
|
||||
<tbody>
|
||||
{rows}
|
||||
</tbody>
|
||||
<tbody>{rows}</tbody>
|
||||
</table>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const card = {
|
||||
@@ -79,17 +87,24 @@ const card = {
|
||||
paddingLeft: "15px",
|
||||
paddingRight: "15px",
|
||||
paddingBottom: "10px",
|
||||
fontWeight: "10px"
|
||||
}
|
||||
fontWeight: "10px",
|
||||
};
|
||||
|
||||
const header = {
|
||||
marginBottom: "5px",
|
||||
paddingBottom: "15px"
|
||||
}
|
||||
paddingBottom: "15px",
|
||||
};
|
||||
|
||||
export function WeaponsAndArmor() {
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "row", justifyContent:"space-between", height: "230px" }}>
|
||||
<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>
|
||||
@@ -103,5 +118,5 @@ export function WeaponsAndArmor() {
|
||||
<Weapons weapons={wandr.displayweapons} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user