diff --git a/src/10th/Roster.jsx b/src/10th/Roster.jsx index 908be67..31a43ba 100644 --- a/src/10th/Roster.jsx +++ b/src/10th/Roster.jsx @@ -76,6 +76,7 @@ const Unit = ({ colorUserChoice, }) => { const [hide, setHide] = useState(false); + const [hideModelCount, setHideModelCount] = useState(false); const uploadRef = useRef(); let { name, @@ -179,23 +180,42 @@ const Unit = ({ : "", }} > - +
+ + +
1} + abilities={abilities.Abilities} /> ))}
- {modelStats?.[0] && ( + {!hideModelCount && modelStats?.[0] && (
1 ? "" : "self-center" @@ -449,7 +470,7 @@ const Unit = ({
-
+
{ +const checkAbilitiesForInvul = (abilitiesMap, name) => { + const abilities = [...abilitiesMap.keys()]; + for (let ability of abilities) { + if (ability.includes(":")) { + // if : then only match if the name is the same + if ( + !name + .trim() + .toLowerCase() + .includes(ability.split(":")[1].trim().toLowerCase()) + ) { + continue; + } + } + switch (abilitiesMap.get(ability)?.trim()?.toLowerCase()) { + case "2+": + if (ability?.toLowerCase().includes("invulnerable save")) return "2+"; + break; + case "3+": + if (ability?.toLowerCase().includes("invulnerable save")) return "3+"; + break; + case "4+": + if (ability?.toLowerCase().includes("invulnerable save")) return "4+"; + break; + case "5+": + if (ability?.toLowerCase().includes("invulnerable save")) return "5+"; + break; + case "6+": + if (ability?.toLowerCase().includes("invulnerable save")) return "6+"; + break; + + case "this model has a 2+ invulnerable save.": + return "2+"; + case "this model has a 3+ invulnerable save.": + return "3+"; + case "this model has a 4+ invulnerable save.": + return "4+"; + case "this model has a 5+ invulnerable save.": + return "5+"; + case "this model has a 6+ invulnerable save.": + return "6+"; + + case "models in this unit have a 2+ invulnerable save.": + return "2+"; + case "models in this unit have a 3+ invulnerable save.": + return "3+"; + case "models in this unit have a 4+ invulnerable save.": + return "4+"; + case "models in this unit have a 5+ invulnerable save.": + return "5+"; + case "models in this unit have a 6+ invulnerable save.": + return "6+"; + + case "models in this unit have a 2+ invulnerable save against ranged weapons.": + return "2+*"; + case "models in this unit have a 3+ invulnerable save against ranged weapons.": + return "3+*"; + case "models in this unit have a 4+ invulnerable save against ranged weapons.": + return "4+*"; + case "models in this unit have a 5+ invulnerable save against ranged weapons.": + return "5+*"; + case "models in this unit have a 6+ invulnerable save against ranged weapons.": + return "6+*"; + + case "while this model is leading a unit, models in that unit have a 2+ invulnerable save.": + return "2+*"; + case "while this model is leading a unit, models in that unit have a 3+ invulnerable save.": + return "3+*"; + case "while this model is leading a unit, models in that unit have a 4+ invulnerable save.": + return "4+*"; + case "while this model is leading a unit, models in that unit have a 5+ invulnerable save.": + return "5+*"; + case "while this model is leading a unit, models in that unit have a 6+ invulnerable save.": + return "6+*"; + + case "while this model is leading a unit, models in that unit have a 2+ invulnerable save against ranged attacks.": + return "2+*"; + case "while this model is leading a unit, models in that unit have a 3+ invulnerable save against ranged attacks.": + return "3+*"; + case "while this model is leading a unit, models in that unit have a 4+ invulnerable save against ranged attacks.": + return "4+*"; + case "while this model is leading a unit, models in that unit have a 5+ invulnerable save against ranged attacks.": + return "5+*"; + case "while this model is leading a unit, models in that unit have a 6+ invulnerable save against ranged attacks.": + return "6+*"; + + case "this model has a 2+ invulnerable save. you cannot re-roll invulnerable saving throws made for this model.": + return "2+*"; + case "this model has a 3+ invulnerable save. you cannot re-roll invulnerable saving throws made for this model.": + return "3+*"; + case "this model has a 4+ invulnerable save. you cannot re-roll invulnerable saving throws made for this model.": + return "4+*"; + case "this model has a 5+ invulnerable save. you cannot re-roll invulnerable saving throws made for this model.": + return "5+*"; + case "this model has a 6+ invulnerable save. you cannot re-roll invulnerable saving throws made for this model.": + return "6+*"; + } + } + return false; +}; + +const ModelStats = ({ modelStat, index, showName, abilities }) => { let { move, toughness, save, wounds, leadership, name, oc, bs, ws, attacks } = modelStat; if (!wounds) { wounds = "/"; } + const hasInvul = checkAbilitiesForInvul(abilities, name); return ( -
- - - - - - - {showName && ( -
-
{name}
-
- )} +
+
+ + + + + + + {showName && ( +
+
{name}
+
+ )} +
+ +
+ ); +}; + +const InvulRow = ({ hasInvul }) => { + if (!hasInvul) return null; + + const isSpecialInvul = hasInvul.includes("*"); + const invulWithoutSpecial = hasInvul.replace("*", ""); + return ( +
+
+ + + {invulWithoutSpecial} +
+ + INVULNERABLE SAVE{isSpecialInvul ? "*" : ""} +
); }; @@ -672,15 +834,17 @@ const Characteristic = ({ title, characteristic, index }) => { ); }; -const FancyBox = ({ children }) => { +const FancyBox = ({ children, className, style }) => { return (
{ background: "#E8EDE7", clipPath: "polygon(10% 0, 100% 0, 100% 20%, 100% 90%, 90% 100%, 20% 100%, 0 100%, 0 10%)", - padding: 3, + padding: "3px 1px", fontSize: "1.6em", fontWeight: 800, }} @@ -704,6 +868,42 @@ const FancyBox = ({ children }) => { ); }; +const FancyShield = ({ children, className, style }) => { + return ( +
+
+
{children}
+
+
+ ); +}; + const OtherAbilities = ({ abilities }) => { let keys = [...Object.keys(abilities)?.filter((key) => key !== "Abilities")]; return keys.map((key) => { diff --git a/src/App.jsx b/src/App.jsx index 99d75d7..443ff45 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -314,7 +314,14 @@ function App() { className="print-display-none max-w-[95vw]" style={{ display: roster ? "flex" : "none", width: "100%", gap: 16 }} > -