add wound tracks

This commit is contained in:
NilsUeter
2023-05-09 20:22:45 +02:00
parent f2b89b606b
commit b966a31606
3 changed files with 52 additions and 4 deletions
+3 -3
View File
@@ -234,11 +234,11 @@ function App() {
const getPrimaryColor = (catalog) => { const getPrimaryColor = (catalog) => {
switch (catalog) { switch (catalog) {
case "Adeptus Astartes": case "Imperium - Adeptus Astartes":
return "#536766"; return "#536766";
case "Adeptus Custodes": case "Imperium - Adeptus Custodes":
return "#536766"; return "#536766";
case "Adeptus Mechanicus": case "Imperium - Adeptus Mechanicus":
return "#536766"; return "#536766";
case "Imperium - Astra Militarum": case "Imperium - Astra Militarum":
return "#375441"; return "#375441";
+47
View File
@@ -73,6 +73,7 @@ const Unit = ({ unit, index, catalog, onePerPage }) => {
psykers, psykers,
spells, spells,
cost, cost,
woundTracker,
} = unit; } = unit;
const meleeWeapons = weapons const meleeWeapons = weapons
@@ -232,6 +233,7 @@ const Unit = ({ unit, index, catalog, onePerPage }) => {
} }
/> />
))} ))}
<WoundTracker woundTracker={woundTracker} />
</div> </div>
</div> </div>
</div> </div>
@@ -676,6 +678,51 @@ const Psyker = ({ psyker, index }) => {
); );
}; };
const WoundTracker = ({ woundTracker }) => {
if (!woundTracker || woundTracker.length === 0) return null;
return (
<div style={{ display: "flex" }}>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
>
<table
className="weapons-table"
style={{ width: "100%", margin: "4px 2px", marginBottom: -16 }}
>
<thead>
<tr
style={{
backgroundColor: "var(--primary-color)",
color: "#fff",
}}
>
{[...woundTracker[0].table.keys()].map((key) => (
<th key={key}>{key}</th>
))}
</tr>
</thead>
<tbody>
{woundTracker.map((woundTrack, index) => (
<tr key={index}>
{[...woundTrack.table.values()].map((entry) => (
<td key={entry} style={{ borderTop: "none" }}>
{entry}
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
</div>
);
};
const Spells = ({ title, spells }) => { const Spells = ({ title, spells }) => {
return ( return (
<table <table
+2 -1
View File
@@ -65,6 +65,7 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
name = "Krak grenade"; name = "Krak grenade";
} }
const differentProfiles = const differentProfiles =
selectionName &&
selectionName !== name && selectionName !== name &&
!name.includes("(Shooting)") && !name.includes("(Shooting)") &&
!name.includes("(Melee)"); !name.includes("(Melee)");
@@ -78,7 +79,6 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
if (name.startsWith("Missile launcher, ")) { if (name.startsWith("Missile launcher, ")) {
name = name.replace("Missile launcher, ", ""); name = name.replace("Missile launcher, ", "");
} }
if (differentProfiles && name.includes(" - ")) { if (differentProfiles && name.includes(" - ")) {
name = name.split(" - ")[1]; name = name.split(" - ")[1];
} }
@@ -99,6 +99,7 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
} }
if (abilities?.toLowerCase().includes("turret weapon")) { if (abilities?.toLowerCase().includes("turret weapon")) {
abilities = abilities abilities = abilities
.replaceAll("Turret Weapon.", "")
.replaceAll("Turret weapon.", "") .replaceAll("Turret weapon.", "")
.replaceAll("Turret Weapon", "") .replaceAll("Turret Weapon", "")
.replaceAll("Turret weapon", ""); .replaceAll("Turret weapon", "");