more types

This commit is contained in:
NilsUeter
2023-05-10 23:07:53 +02:00
parent ef08b72e4f
commit 2a6ea1ecb4
3 changed files with 94 additions and 53 deletions
+2
View File
@@ -259,6 +259,8 @@ const getPrimaryColor = (catalog) => {
return "#536766"; return "#536766";
case "Imperium - Adeptus Mechanicus": case "Imperium - Adeptus Mechanicus":
return "#536766"; return "#536766";
case "Imperium - Adepta Sororitas":
return "#5e0a00";
case "Imperium - Astra Militarum": case "Imperium - Astra Militarum":
return "#375441"; return "#375441";
case "Chaos - Daemons": case "Chaos - Daemons":
+18 -1
View File
@@ -78,7 +78,11 @@ const Unit = ({ unit, index, catalog, onePerPage }) => {
} = unit; } = unit;
const meleeWeapons = weapons const meleeWeapons = weapons
.filter((weapon) => weapon.range === "Melee" || weapon.type === "Melee") .filter(
(weapon) =>
(weapon.range === "Melee" || weapon.type === "Melee") &&
weapon.range !== ""
)
.sort((a, b) => a.selectionName.localeCompare(b.selectionName)); .sort((a, b) => a.selectionName.localeCompare(b.selectionName));
if (meleeWeapons.length === 0) { if (meleeWeapons.length === 0) {
meleeWeapons.push({ meleeWeapons.push({
@@ -829,6 +833,19 @@ const getSpellClassNames = (spells, index) => {
}; };
const ForceRules = ({ rules, onePerPage }) => { 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'."
);
return ( return (
<div <div
className={"avoid-page-break " + (onePerPage ? "page-break" : "")} className={"avoid-page-break " + (onePerPage ? "page-break" : "")}
+69 -47
View File
@@ -59,7 +59,7 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
const bs = modelStats[0].bs; const bs = modelStats[0].bs;
let ws = modelStats[0].ws; let ws = modelStats[0].ws;
const strModel = modelStats[0].str; const strModel = modelStats[0].str;
let meleeAttacks = modelStats[0].attacks; let meleeAttacks = modelStats.map((modelStat) => modelStat.attacks);
if (name === "Krak grenades") { if (name === "Krak grenades") {
name = "Krak grenade"; name = "Krak grenade";
@@ -83,55 +83,61 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
name = name.split(" - ")[1]; name = name.split(" - ")[1];
} }
if (abilities?.includes("Blast")) { const replaceAbilityWithType = (occurences, typeName) => {
abilities = abilities.replaceAll("Blast.", "").replaceAll("Blast", ""); if (!abilities) return;
type += ", Blast"; if (occurences.some((occurence) => abilities.includes(occurence))) {
for (let i = 0; i < occurences.length; i++) {
abilities = abilities.replaceAll(occurences[i], "");
} }
if (abilities?.includes("Plague Weapon")) {
abilities = abilities
.replaceAll("Plague Weapon.", "")
.replaceAll("Plague Weapon", "");
if (type) { if (type) {
type += ", Plague Weapon"; type += `, ${typeName}`;
} else { } else {
type = "Plague Weapon"; type = typeName;
} }
} }
if (abilities?.toLowerCase().includes("turret weapon")) { return abilities;
abilities = abilities };
.replaceAll("Turret Weapon.", "")
.replaceAll("Turret weapon.", "") replaceAbilityWithType(["Blast.", "Blast"], "Blast");
.replaceAll("Turret Weapon", "") replaceAbilityWithType(
.replaceAll("Turret weapon", ""); [
if (type) { "Each time an attack is made with this weapon, that attack automatically hits the target.",
type += ", Turret weapon"; "This weapon automatically hits its target.",
} else { "When resolving an attack made with this weapon, do not make a hit roll: it automatically scores a hit.",
type = "Turret weapon"; ],
} "Torrent"
} );
/* if ( replaceAbilityWithType(
abilities?.includes( ["This weapon can target units that are not visible to the bearer."],
"Each time an attack made with this weapon targets an enemy within half range, that attack has a Damage characteristic of D6+2." "Indirect Fire"
) || );
abilities?.includes( replaceAbilityWithType(
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+2." [
) "Plague Weapon.",
) { "Plague Weapon",
abilities = abilities "Each time an attack is made with this weapon, re-roll a wound roll of 1.",
.replaceAll( ],
"Each time an attack made with this weapon targets an enemy within half range, that attack has a Damage characteristic of D6+2.", "Plague Weapon"
"" );
) replaceAbilityWithType(
.replaceAll( ["Turret Weapon.", "Turret weapon.", "Turret Weapon", "Turret weapon"],
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+2.", "Turret Weapon"
"" );
replaceAbilityWithType(
[
"Each time an attack made with this weapon targets an enemy 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.",
"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"
);
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"
); );
if (type) {
type += ", Melta 2";
} else {
type = "Melta 2";
}
} */
if ( if (
abilities?.includes( abilities?.includes(
@@ -183,6 +189,9 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
) || ) ||
abilities?.includes( abilities?.includes(
"Each time an attack is made with this weapon, make 2 hit rolls instead of 1." "Each time an attack is made with this weapon, make 2 hit rolls instead of 1."
) ||
abilities?.includes(
"Each time an attack is made wit this weapon profile, make 2 hit rolls instead of 1."
) )
) { ) {
abilities = abilities abilities = abilities
@@ -197,9 +206,13 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
.replaceAll( .replaceAll(
"Each time an attack is made with this weapon, make 2 hit rolls instead of 1.", "Each time an attack is made with this weapon, make 2 hit rolls instead of 1.",
"" ""
)
.replaceAll(
"Each time an attack is made wit this weapon profile, make 2 hit rolls instead of 1.",
""
); );
meleeAttacks = meleeAttacks * 2; meleeAttacks = meleeAttacks.map((meleeAttack) => meleeAttack * 2);
} }
if ( if (
abilities?.includes( abilities?.includes(
@@ -219,7 +232,10 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
"" ""
); );
meleeAttacks = meleeAttacks * 3; meleeAttacks = meleeAttacks.map((meleeAttack) => meleeAttack * 3);
}
if (meleeAttacks.every((meleeAttack) => meleeAttack === meleeAttacks[0])) {
meleeAttacks = meleeAttacks[0];
} }
name = name.replaceAll(" (Shooting)", "").replaceAll(" (Melee)", ""); name = name.replaceAll(" (Shooting)", "").replaceAll(" (Melee)", "");
@@ -256,7 +272,13 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
</div> </div>
</td> </td>
<td>{range}</td> <td>{range}</td>
<td>{isMelee ? meleeAttacks : attacks}</td> <td>
{isMelee
? meleeAttacks.join
? meleeAttacks.join("|")
: meleeAttacks
: attacks}
</td>
<td>{isMelee ? ws : bs}</td> <td>{isMelee ? ws : bs}</td>
<td>{calculateWeaponStrength(strModel, str)}</td> <td>{calculateWeaponStrength(strModel, str)}</td>
<td>{ap}</td> <td>{ap}</td>