show degrading statline

This commit is contained in:
NilsUeter
2023-05-11 19:05:52 +02:00
parent ff151679d2
commit 5a3c43439b
4 changed files with 42 additions and 42 deletions
+2
View File
@@ -297,6 +297,8 @@ const getPrimaryColor = (catalog) => {
return "#44264C";
case "Ynnari":
return "#536766";
case "Leagues of Votann":
return "#7d4c08";
default:
console.log(catalog);
return "#536766";
+12 -36
View File
@@ -376,22 +376,6 @@ const ModelStats = ({
model.replaceAll(name, "")
);
const degradingStuff = [];
const bsChange = Math.abs(parseInt(modelStats[0].bs, 10) - parseInt(bs, 10));
if (bsChange > 0) {
degradingStuff.push(`${bsChange} from the balistic skill`);
}
const wsChange = Math.abs(parseInt(modelStats[0].ws, 10) - parseInt(ws, 10));
if (wsChange > 0) {
degradingStuff.push(`${wsChange} from the weapon skill`);
}
const attacksChange = Math.abs(
parseInt(modelStats[0].attacks, 10) - parseInt(attacks, 10)
);
if (attacksChange > 0) {
degradingStuff.push(`${attacksChange} from the number of attacks`);
}
return (
<div style={{ display: "flex", gap: 16, alignItems: "center" }}>
<Characteristic title="M" characteristic={move} index={index} />
@@ -424,19 +408,6 @@ const ModelStats = ({
))}
</div>
)}
{degradingStuff.length > 0 && (
<div
style={{
whiteSpace: "normal",
marginLeft: -10,
fontSize: "0.7em",
}}
>
{`Each time this model makes
an attack, subtract
${degradingStuff.join(" and ")}.`}
</div>
)}
</div>
</div>
);
@@ -475,9 +446,6 @@ const FactionIcon = ({ catalog }) => {
};
const Keywords = ({ keywords }) => {
keywords = Array.from(keywords).filter(
(keyword) => keyword !== "Configuration"
);
return (
<div
style={{
@@ -556,6 +524,10 @@ const Rules = ({ rules }) => {
const Abilities = ({ abilities }) => {
if (!abilities) return null;
let keys = [...abilities.keys()];
keys = keys.filter(
(key) => key !== "Stratagem: Warlord Trait" && key !== "Stratagem: Relic"
);
return (
<div
style={{
@@ -567,7 +539,7 @@ const Abilities = ({ abilities }) => {
}}
>
{abilities &&
[...abilities.keys()].map((ability) => (
keys.map((ability) => (
<div
key={ability}
style={{
@@ -640,10 +612,10 @@ const Psykers = ({ title, psykers }) => {
}}
>
<th style={{ textAlign: "left" }}>PSYKER</th>
<th>Cast</th>
<th>Deny</th>
<th>CAST</th>
<th>DENY</th>
<th style={{ textAlign: "left", width: "100%" }} colSpan="4">
Powers Known
POWERS KNOWN
</th>
</tr>
</thead>
@@ -845,6 +817,10 @@ const ForceRules = ({ rules, onePerPage }) => {
"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
+27 -5
View File
@@ -56,8 +56,8 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
const attacks = type.substring(lastWhiteSpace + 1);
type = type.substring(0, lastWhiteSpace);
const bs = modelStats[0].bs;
let ws = modelStats[0].ws;
let bs = modelStats.map((modelStat) => modelStat.bs);
let ws = modelStats.map((modelStat) => modelStat.ws);
const strModel = modelStats[0].str;
let meleeAttacks = modelStats.map((modelStat) => modelStat.attacks);
@@ -138,6 +138,12 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
],
"Melta 4"
);
replaceAbilityWithType(
[
"Each time an attack is made with this weapon profile, an unmodified hit roll of 6 automatically wounds the target.",
],
"Lethal Hits"
);
if (
abilities?.includes(
@@ -177,7 +183,7 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
"When attacking with this weapon, you must subtract 1 from the hit rolls.",
""
);
ws = `${parseInt(ws, 10) + 1}+`;
ws = ws.map((ws) => `${parseInt(ws, 10) + 1}+`);
}
if (
@@ -237,6 +243,12 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
if (meleeAttacks.every((meleeAttack) => meleeAttack === meleeAttacks[0])) {
meleeAttacks = meleeAttacks[0];
}
if (bs.every((b) => b === bs[0])) {
bs = bs[0];
}
if (ws.every((w) => w === ws[0])) {
ws = ws[0];
}
name = name.replaceAll(" (Shooting)", "").replaceAll(" (Melee)", "");
@@ -256,7 +268,9 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
}}
>
{differentProfiles && selectionName + " - "}
{differentProfiles ? name.replaceAll(selectionName, "") : name}
{differentProfiles
? name.replaceAll(selectionName, "").replaceAll(", ", "")
: name}
{type && (
<span
style={{
@@ -279,7 +293,15 @@ const Weapon = ({ weapon, modelStats, isMelee, className }) => {
: meleeAttacks
: attacks}
</td>
<td>{isMelee ? ws : bs}</td>
<td>
{isMelee
? ws.join
? ws.join("|")
: ws
: bs.join
? bs.join("|")
: bs}
</td>
<td>{calculateWeaponStrength(strModel, str)}</td>
<td>{ap}</td>
<td>{damage}</td>
+1 -1
View File
@@ -72,7 +72,7 @@ button:focus-visible {
justify-content: center;
gap: 8px;
padding: var(--size-24) var(--size-20);
max-width: 1100px;
max-width: 1150px;
margin-left: auto;
margin-right: auto;
}