only show new rules if they exist in the units, genestealer colors

This commit is contained in:
NilsUeter
2023-05-12 23:27:04 +02:00
parent 46cb96fbce
commit 6834825241
3 changed files with 40 additions and 46 deletions
+1
View File
@@ -305,6 +305,7 @@ const getPrimaryColor = (catalog) => {
case "Thousand Sons":
return "#536766";
case "Tyranids":
case "Tyranids - Genestealer Cults":
return "#44264C";
case "Ynnari":
return "#536766";
+5 -21
View File
@@ -53,6 +53,7 @@ const Force = ({ force, onePerPage }) => {
unit={unit}
catalog={catalog}
onePerPage={onePerPage}
forceRules={rules}
/>
))}
<ForceRules rules={rules} onePerPage={onePerPage} />
@@ -60,7 +61,7 @@ const Force = ({ force, onePerPage }) => {
);
};
const Unit = ({ unit, index, catalog, onePerPage }) => {
const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
const [hide, setHide] = useState(false);
let {
name,
@@ -268,11 +269,13 @@ const Unit = ({ unit, index, catalog, onePerPage }) => {
title="RANGED WEAPONS"
weapons={rangedWeapons}
modelStats={modelStats}
forceRules={forceRules}
/>
<Weapons
title="MELEE WEAPONS"
weapons={meleeWeapons}
modelStats={modelStats}
forceRules={forceRules}
/>
</table>
<div style={{ flex: "1" }}></div>
@@ -805,23 +808,6 @@ const getSpellClassNames = (spells, index) => {
};
const ForceRules = ({ rules, onePerPage }) => {
rules.set(
"Torrent",
"When resolving an attack made with this weapon, do not make a hit roll: it automatically scores a hit."
);
rules.set(
"Indirect Fire",
"This weapon can target units that are not visible to the bearer."
);
rules.set(
"Melta X",
"Each time an attack made with this weapon targets a unit within half range, that attack's Damagae characteristic is increased by the amount denotex by 'X'."
);
rules.set(
"Lethal Hits",
"Each time an attack is made with this weapon profile, an unmodified hit roll of 6 automatically wounds the target."
);
return (
<div
className={"avoid-page-break " + (onePerPage ? "page-break" : "")}
@@ -835,9 +821,7 @@ const ForceRules = ({ rules, onePerPage }) => {
marginBottom: 32,
}}
>
{[...rules.keys()]
.filter((rule) => !rule.startsWith("Explodes"))
.map((rule) => (
{[...rules.keys()].map((rule) => (
<div
key={rule}
style={{
+25 -16
View File
@@ -2,7 +2,7 @@ import meleeIcon from "./assets/meleeIcon.png";
import rangedIcon from "./assets/rangedIcon.png";
import { Arrow } from "./assets/icons";
export const Weapons = ({ title, weapons, modelStats }) => {
export const Weapons = ({ title, weapons, modelStats, forceRules }) => {
const isMelee = title === "MELEE WEAPONS";
return (
<>
@@ -37,6 +37,7 @@ export const Weapons = ({ title, weapons, modelStats }) => {
modelStats={modelStats}
isMelee={isMelee}
className={getWeaponClassNames(weapons, index)}
forceRules={forceRules}
/>
))}
{weapons.length > 0 && (
@@ -50,7 +51,7 @@ export const Weapons = ({ title, weapons, modelStats }) => {
);
};
const Weapon = ({ weapon, modelStats, isMelee, className }) => {
const Weapon = ({ weapon, modelStats, isMelee, className, forceRules }) => {
let { name, selectionName, range, type, str, ap, damage, abilities } = weapon;
var lastWhiteSpace = type.lastIndexOf(" ");
const attacks = type.substring(lastWhiteSpace + 1);
@@ -83,7 +84,11 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
name = name.split(" - ")[1];
}
const replaceAbilityWithType = (occurences, typeName) => {
const replaceAbilityWithType = (
occurences,
typeName,
ruleTextForForceRules
) => {
if (!abilities) return;
if (occurences.some((occurence) => abilities.includes(occurence))) {
for (let i = 0; i < occurences.length; i++) {
@@ -94,7 +99,12 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
} else {
type = typeName;
}
if (ruleTextForForceRules) {
forceRules.set(typeName, ruleTextForForceRules);
}
}
return abilities;
};
@@ -105,20 +115,16 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
"This weapon automatically hits its target.",
"When resolving an attack made with this weapon, do not make a hit roll: it automatically scores a hit.",
],
"Torrent"
"Torrent",
"When resolving an attack made with this weapon, do not make a hit roll: it automatically scores a hit."
);
replaceAbilityWithType(
["This weapon can target units that are not visible to the bearer."],
"Indirect Fire"
);
replaceAbilityWithType(
[
"Plague Weapon.",
"Plague Weapon",
"Each time an attack is made with this weapon, re-roll a wound roll of 1.",
],
"Plague Weapon"
"Indirect Fire",
"This weapon can target units that are not visible to the bearer."
);
replaceAbilityWithType(["Plague Weapon.", "Plague Weapon"], "Plague Weapon");
replaceAbilityWithType(["Sonic Weapon.", "Sonic Weapon"], "Sonic Weapon");
replaceAbilityWithType(
["Turret Weapon.", "Turret weapon.", "Turret Weapon", "Turret weapon"],
"Turret Weapon"
@@ -129,21 +135,24 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+2.",
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+2",
],
"Melta 2"
"Melta 2",
"Each time an attack made with this weapon targets a unit within half range, that attack attack has a Damage characteristic of D6+2."
);
replaceAbilityWithType(
[
"Each time an attack made with this weapon targets an enemy within half range, that attack has a Damage characteristic of D6+4.",
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+4.",
],
"Melta 4"
"Melta 4",
"Each time an attack made with this weapon targets a unit within half range, that attack attack has a Damage characteristic of D6+4."
);
replaceAbilityWithType(
[
"Each time an attack is made with this weapon profile, an unmodified hit roll of 6 automatically wounds the target.",
"Each unmodified hit roll of 6 made for this weapon's attacks automatically hits and results in a wound (do not make a wound roll for that attack).",
],
"Lethal Hits"
"Lethal Hits",
"Each time an attack is made with this weapon profile, an unmodified hit roll of 6 automatically wounds the target."
);
if (