initial cyberware page
This commit is contained in:
1 parent
a9e25a0da4
commit
9d17f5f07b
3 files changed
+333
-6
No files matched your search
@@ -7,10 +7,7 @@ const baseUrl =
|
||||
|
||||
const wandr = await fetch(
|
||||
`${baseUrl}/characters/collateral/weaponsandarmor.json`,
|
||||
).then((r) => {
|
||||
console.log(r);
|
||||
return r.json();
|
||||
});
|
||||
).then((r) => r.json());
|
||||
|
||||
type DisplayArmor = {
|
||||
displayheadarmor: string;
|
||||
|
||||
+137
-2
@@ -1,3 +1,4 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import type { Route } from "./+types/home";
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
@@ -7,6 +8,140 @@ export function meta({}: Route.MetaArgs) {
|
||||
];
|
||||
}
|
||||
|
||||
export default function StatsAndSkills() {
|
||||
return <div>POTATO </div>;
|
||||
const baseUrl =
|
||||
typeof window !== "undefined"
|
||||
? window.location.origin
|
||||
: process.env.VITE_VERCEL_URL || "http://localhost:5173"; // Fallback for your server env
|
||||
|
||||
const c = await fetch(`${baseUrl}/characters/collateral/cyberware.json`).then(
|
||||
(r) => r.json(),
|
||||
);
|
||||
|
||||
type CyberBodyData = {
|
||||
neural: FoundationData;
|
||||
audio: FoundationData;
|
||||
lefteye: FoundationData;
|
||||
righteye: FoundationData;
|
||||
leftarm: FoundationData;
|
||||
rightarm: FoundationData;
|
||||
leftleg: FoundationData;
|
||||
rightleg: FoundationData;
|
||||
internal: CyberData[];
|
||||
external: CyberData[];
|
||||
borgware: CyberData[];
|
||||
};
|
||||
|
||||
type FoundationData = {
|
||||
name: string;
|
||||
slots: number;
|
||||
upgraded: boolean;
|
||||
hl: number;
|
||||
contents: CyberData[];
|
||||
};
|
||||
|
||||
type CyberData = {
|
||||
name: string;
|
||||
description: string;
|
||||
hl: number;
|
||||
};
|
||||
|
||||
function FoundationHeader(): ReactElement {
|
||||
return (
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
);
|
||||
}
|
||||
|
||||
function FoundationRow({
|
||||
cyber,
|
||||
}: {
|
||||
cyber: CyberData | undefined;
|
||||
}): ReactElement {
|
||||
if (!cyber) {
|
||||
return (
|
||||
<tr>
|
||||
<td>--</td>
|
||||
<td>--</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
const upgrade = !cyber.upgraded ? (
|
||||
<></>
|
||||
) : (
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{cyber.upgraded.name}: {cyber.upgraded.description}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<tr>
|
||||
<td>{cyber.name}</td>
|
||||
<td>{cyber.description}</td>
|
||||
</tr>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Foundation({
|
||||
foundation,
|
||||
}: {
|
||||
foundation: FoundationData;
|
||||
}): ReactElement {
|
||||
const rows: ReactElement[] = Array(foundation.slots);
|
||||
|
||||
for (let i = 0; i < foundation.slots; i++) {
|
||||
rows[i] = <FoundationRow key={i} cyber={foundation.contents[i]} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>{foundation.name}</div>
|
||||
<table className="cyber-table">
|
||||
<FoundationHeader />
|
||||
<tbody>{rows}</tbody>
|
||||
</table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const rowStyle = {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
width: "25%",
|
||||
};
|
||||
|
||||
export default function Cyberware() {
|
||||
const [cyber, setCyber] = useState(c);
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "row" }}>
|
||||
<div style={rowStyle}>
|
||||
<Foundation foundation={cyber.lefteye} />
|
||||
<Foundation foundation={cyber.leftarm} />
|
||||
<Foundation foundation={cyber.leftleg} />
|
||||
</div>
|
||||
<div style={rowStyle}>
|
||||
<Foundation foundation={cyber.neural} />
|
||||
<Foundation foundation={cyber.audio} />
|
||||
</div>
|
||||
<div style={rowStyle}>
|
||||
<Foundation foundation={cyber.righteye} />
|
||||
<Foundation foundation={cyber.rightarm} />
|
||||
<Foundation foundation={cyber.rightleg} />
|
||||
</div>
|
||||
<div style={rowStyle}>
|
||||
<Foundation foundation={cyber.internal} />
|
||||
<Foundation foundation={cyber.external} />
|
||||
<Foundation foundation={cyber.borgware} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user