From 2cb73c76808aa86e90fe91e563b6111f1ca0593e Mon Sep 17 00:00:00 2001 From: NilsUeter Date: Sat, 1 Mar 2025 12:44:46 +0100 Subject: [PATCH] when showing invul in characteristics, remove it from abilities section --- src/10th/Roster.jsx | 75 +++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/src/10th/Roster.jsx b/src/10th/Roster.jsx index dc3618b..6f5e65b 100644 --- a/src/10th/Roster.jsx +++ b/src/10th/Roster.jsx @@ -470,7 +470,7 @@ const Unit = ({ -
+
{ case "this model has 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.": @@ -806,9 +784,54 @@ const Rules = ({ rules }) => { ); }; +const removeInvulnsWithoutSpecialRules = (abilities) => { + const filteredAbilities = new Map(); + for (let [key, value] of abilities) { + switch (value?.trim()?.toLowerCase()) { + case "2+": + if (!key?.toLowerCase().includes("invulnerable save")) + filteredAbilities.set(key, value); + break; + case "3+": + if (!key?.toLowerCase().includes("invulnerable save")) + filteredAbilities.set(key, value); + break; + case "4+": + if (!key?.toLowerCase().includes("invulnerable save")) + filteredAbilities.set(key, value); + break; + case "5+": + if (!key?.toLowerCase().includes("invulnerable save")) + filteredAbilities.set(key, value); + break; + case "6+": + if (!key?.toLowerCase().includes("invulnerable save")) + filteredAbilities.set(key, value); + break; + + case "models in this unit have a 2+ invulnerable save.": + case "models in this unit have a 3+ invulnerable save.": + case "models in this unit have a 4+ invulnerable save.": + case "models in this unit have a 5+ invulnerable save.": + case "models in this unit have a 6+ invulnerable save.": + case "this model has a 2+ invulnerable save.": + case "this model has a 3+ invulnerable save.": + case "this model has a 4+ invulnerable save.": + case "this model has a 5+ invulnerable save.": + case "this model has a 6+ invulnerable save.": + break; + default: + filteredAbilities.set(key, value); + } + } + return filteredAbilities; +}; + const Abilities = ({ abilities }) => { if (!abilities) return null; - let keys = [...abilities.keys()]; + const filteredAbilities = removeInvulnsWithoutSpecialRules(abilities); + + let keys = [...filteredAbilities.keys()]; return (
{ borderBottom: "1px dotted rgb(158, 159, 161)", }} > - {abilities && + {filteredAbilities && keys.map((ability) => (
{ }} > {ability}:{" "} - {abilities.get(ability)} + {filteredAbilities.get(ability)}
))}