more weapon types

This commit is contained in:
NilsUeter
2023-04-19 22:18:53 +02:00
parent 5bcff97ff5
commit f2e813d5d7
2 changed files with 120 additions and 26 deletions
+44 -24
View File
@@ -115,6 +115,7 @@ const Unit = ({ unit, catalog }) => {
modelStats, modelStats,
modelList, modelList,
psykers, psykers,
cost,
} = unit; } = unit;
const hasDifferentProfiles = weapons.some( const hasDifferentProfiles = weapons.some(
@@ -214,9 +215,15 @@ const Unit = ({ unit, catalog }) => {
textTransform: "uppercase", textTransform: "uppercase",
zIndex: 1, zIndex: 1,
position: "relative", position: "relative",
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}} }}
> >
{name} {name}
<span style={{ textTransform: "initial", fontSize: "1.1rem" }}>
{cost.points}pts
</span>
</div> </div>
<div <div
style={{ style={{
@@ -235,6 +242,9 @@ const Unit = ({ unit, catalog }) => {
modelList={modelList} modelList={modelList}
index={index} index={index}
showName={modelStats.length > 1} showName={modelStats.length > 1}
showWeapons={
modelList.length > 1 || modelList[0].includes("x ") // show Weapons when multiple weapons of same type, for example (2x Atomiser Beam, Reanimator's Claws)
}
/> />
))} ))}
</div> </div>
@@ -321,7 +331,13 @@ const Unit = ({ unit, catalog }) => {
); );
}; };
const ModelStats = ({ modelStats, index, showName, modelList }) => { const ModelStats = ({
modelStats,
index,
showName,
showWeapons,
modelList,
}) => {
let { move, toughness, save, wounds, leadership, name } = modelStats; let { move, toughness, save, wounds, leadership, name } = modelStats;
if (!wounds) { if (!wounds) {
wounds = "/"; wounds = "/";
@@ -348,29 +364,30 @@ const ModelStats = ({ modelStats, index, showName, modelList }) => {
<Characteristic title="SV" characteristic={save} index={index} /> <Characteristic title="SV" characteristic={save} index={index} />
<Characteristic title="W" characteristic={wounds} index={index} /> <Characteristic title="W" characteristic={wounds} index={index} />
<Characteristic title="LD" characteristic={leadership} index={index} /> <Characteristic title="LD" characteristic={leadership} index={index} />
{showName && ( {showName && (
<> <div
<div style={{
style={{ marginTop: index === 0 ? 16 : 0,
marginTop: index === 0 ? 16 : 0, marginLeft: -10,
marginLeft: -10, whiteSpace: "nowrap",
whiteSpace: "nowrap", }}
}} >
> {name}
{name} </div>
</div> )}
<div {showWeapons && (
style={{ <div
marginTop: index === 0 ? 16 : 0, style={{
marginLeft: -10, marginTop: index === 0 ? 16 : 0,
fontSize: "0.7em", marginLeft: -10,
}} fontSize: "0.7em",
> }}
{modelListMatches.map((model, index) => ( >
<div>{model}</div> {modelListMatches.map((model, index) => (
))} <div>{model}</div>
</div> ))}
</> </div>
)} )}
</div> </div>
); );
@@ -548,9 +565,12 @@ const FancyBox = ({ children }) => {
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
background: "linear-gradient(315deg, transparent 3px, #E8EDE7 0)", background: "linear-gradient(315deg, transparent 3px, #E8EDE7 0)",
padding: 3,
fontSize: "1.6em",
fontWeight: 800,
}} }}
> >
<div style={{ fontSize: "1.6em", fontWeight: 800 }}>{children}</div> {children}
</div> </div>
</div> </div>
); );
+76 -2
View File
@@ -19,7 +19,7 @@ export const Weapons = ({ title, weapons, modelStats }) => {
<img src={isMelee ? meleeIcon : rangedIcon} /> <img src={isMelee ? meleeIcon : rangedIcon} />
</div> </div>
</th> </th>
<th style={{ textAlign: "left", width: "44%" }}>{title}</th> <th style={{ textAlign: "left" }}>{title}</th>
<th>RANGE</th> <th>RANGE</th>
<th>A</th> <th>A</th>
<th>{isMelee ? "WS" : "BS"}</th> <th>{isMelee ? "WS" : "BS"}</th>
@@ -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;
const meleeAttacks = modelStats[0].attacks; let meleeAttacks = modelStats[0].attacks;
if (name === "Krak grenades") { if (name === "Krak grenades") {
name = "Krak grenade"; name = "Krak grenade";
@@ -97,6 +97,30 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
type = "Plague Weapon"; type = "Plague Weapon";
} }
} }
if (
abilities?.includes(
"Each time an attack made with this weapon targets an enemy within half range, that attack has a Damage characteristic of D6+2."
) ||
abilities?.includes(
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+2."
)
) {
abilities = abilities
.replaceAll(
"Each time an attack made with this weapon targets an enemy within half range, that attack has a Damage characteristic of D6+2.",
""
)
.replaceAll(
"Each time an attack made with this weapon targets a unit within half range, that attack has a Damage characteristic of D6+2.",
""
);
if (type) {
type += ", Melta 2";
} else {
type = "Melta 2";
}
}
if ( if (
abilities?.includes( abilities?.includes(
"Each time an attack is made with this weapon, subtract 1 from that attacks hit roll." "Each time an attack is made with this weapon, subtract 1 from that attacks hit roll."
@@ -137,6 +161,55 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
); );
ws = `${parseInt(ws, 10) + 1}+`; ws = `${parseInt(ws, 10) + 1}+`;
} }
if (
abilities?.includes(
"Each time an attack is made with this weapon profile, make 2 hit rolls instead of 1."
) ||
abilities?.includes(
"Each time an attack is made with this weapon, make 2 attack rolls instead of 1."
) ||
abilities?.includes(
"Each time an attack is made with this weapon, make 2 hit rolls instead of 1."
)
) {
abilities = abilities
.replaceAll(
"Each time an attack is made with this weapon profile, make 2 hit rolls instead of 1.",
""
)
.replaceAll(
"Each time an attack is made with this weapon, make 2 attack rolls instead of 1.",
""
)
.replaceAll(
"Each time an attack is made with this weapon, make 2 hit rolls instead of 1.",
""
);
meleeAttacks = meleeAttacks * 2;
}
if (
abilities?.includes(
"Each time an attack is made with this weapon profile, make 3 hit rolls instead of 1."
) ||
abilities?.includes(
"Each time an attack is made with this weapon, make 3 hit rolls instead of 1."
)
) {
abilities = abilities
.replaceAll(
"Each time an attack is made with this weapon profile, make 3 hit rolls instead of 1.",
""
)
.replaceAll(
"Each time an attack is made with this weapon, make 3 hit rolls instead of 1.",
""
);
meleeAttacks = meleeAttacks * 3;
}
name = name.replaceAll(" (Shooting)", "").replaceAll(" (Melee)", ""); name = name.replaceAll(" (Shooting)", "").replaceAll(" (Melee)", "");
return ( return (
@@ -162,6 +235,7 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
fontSize: ".8em", fontSize: ".8em",
fontWeight: 700, fontWeight: 700,
color: "var(--primary-color)", color: "var(--primary-color)",
textTransform: "uppercase",
}} }}
> >
[{type}] [{type}]