always show modelStats to see weapon loadouts
This commit is contained in:
+5
-1
@@ -16,7 +16,11 @@
|
||||
/>
|
||||
<script>
|
||||
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
|
||||
posthog.init('phc_QqImEAwwTBa3yh4DhiQ1bCHWA3DBr3lPuosKNRwSuEq',{api_host:'https://eu.posthog.com'})
|
||||
// if localhost then return
|
||||
if(window.location.hostname !== 'localhost')
|
||||
{
|
||||
posthog.init('phc_QqImEAwwTBa3yh4DhiQ1bCHWA3DBr3lPuosKNRwSuEq',{api_host:'https://eu.posthog.com'})
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+24
-22
@@ -120,6 +120,25 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const areAllModelsTheSame = (modelStats) => {
|
||||
if (modelStats.length === 1) return true;
|
||||
const firstModel = modelStats[0];
|
||||
return modelStats.every(
|
||||
(model) =>
|
||||
model.move === firstModel.move &&
|
||||
model.toughness === firstModel.toughness &&
|
||||
model.save === firstModel.save &&
|
||||
model.wounds === firstModel.wounds &&
|
||||
model.leadership === firstModel.leadership &&
|
||||
model.oc === firstModel.oc &&
|
||||
model.bs === firstModel.bs &&
|
||||
model.ws === firstModel.ws &&
|
||||
model.attacks === firstModel.attacks
|
||||
);
|
||||
};
|
||||
if (areAllModelsTheSame(modelStats)) {
|
||||
modelStats = [modelStats[0]];
|
||||
}
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
@@ -246,9 +265,6 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
|
||||
modelList={modelList}
|
||||
index={index}
|
||||
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>
|
||||
@@ -417,37 +433,23 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const ModelStats = ({ modelStat, index, showName, showWeapons, modelList }) => {
|
||||
const ModelStats = ({ modelStat, index, showName, modelList }) => {
|
||||
let { move, toughness, save, wounds, leadership, name, oc, bs, ws, attacks } =
|
||||
modelStat;
|
||||
if (!wounds) {
|
||||
wounds = "/";
|
||||
}
|
||||
if (!name.includes("Sgt")) {
|
||||
modelList = modelList.filter((model) => !model.includes("Sgt"));
|
||||
}
|
||||
if (!name.includes("Sergeant")) {
|
||||
modelList = modelList.filter((model) => !model.includes("Sergeant"));
|
||||
}
|
||||
let modelListMatches = modelList.filter((model) =>
|
||||
model.includes(name + " w")
|
||||
);
|
||||
if (modelListMatches.length === 0) {
|
||||
modelListMatches = modelList.filter((model) => model.includes(name));
|
||||
}
|
||||
modelListMatches = modelListMatches.map((model) =>
|
||||
model.replaceAll(name, "")
|
||||
);
|
||||
|
||||
const showWeapons = index === 0;
|
||||
return (
|
||||
<div style={{ display: "flex", gap: 16, alignItems: "center" }}>
|
||||
<div style={{ display: "flex", gap: 16 }}>
|
||||
<Characteristic title="M" characteristic={move} index={index} />
|
||||
<Characteristic title="T" characteristic={toughness} index={index} />
|
||||
<Characteristic title="SV" characteristic={save} index={index} />
|
||||
<Characteristic title="W" characteristic={wounds} index={index} />
|
||||
<Characteristic title="LD" characteristic={leadership} index={index} />
|
||||
<Characteristic title="OC" characteristic={oc} index={index} />
|
||||
<div>
|
||||
<div style={{ display: "flex", alignItems: "center" }}>
|
||||
{showName && (
|
||||
<div
|
||||
style={{
|
||||
@@ -467,7 +469,7 @@ const ModelStats = ({ modelStat, index, showName, showWeapons, modelList }) => {
|
||||
fontSize: "0.7em",
|
||||
}}
|
||||
>
|
||||
{modelListMatches.map((model, index) => (
|
||||
{modelList.map((model, index) => (
|
||||
<div key={model}>{model}</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -198,6 +198,7 @@ export class Model extends BaseNotes {
|
||||
|
||||
getDedupedWeaponsAndUpgrades() {
|
||||
const deduped = [];
|
||||
|
||||
for (const upgrade of [
|
||||
...this.rangedWeapons,
|
||||
...this.meleeWeapons,
|
||||
@@ -833,7 +834,7 @@ function ParseUnit(root) {
|
||||
const unitUpgradesModel = new Model();
|
||||
unitUpgradesModel.name = "Unit Upgrades";
|
||||
ParseModelProfiles(unseenProfiles, unitUpgradesModel, unit);
|
||||
if (unitUpgradesModel.meleeWeapons.length > 0 && unit.models.length > 0) {
|
||||
/* if (unitUpgradesModel.meleeWeapons.length > 0 && unit.models.length > 0) {
|
||||
// Apply weapons at the unit level to all models in the unit.
|
||||
for (const model of unit.models) {
|
||||
model.meleeWeapons.push(...unitUpgradesModel.meleeWeapons);
|
||||
@@ -846,7 +847,7 @@ function ParseUnit(root) {
|
||||
model.rangedWeapons.push(...unitUpgradesModel.rangedWeapons);
|
||||
}
|
||||
unitUpgradesModel.rangedWeapons.length = 0; // Clear the array.
|
||||
}
|
||||
} */
|
||||
if (unitUpgradesModel.psychicPowers.length > 0) {
|
||||
// Add spells to the unit's spell list. However, we'll still need
|
||||
// to add spell upgrade selections to the upgrade list, below.
|
||||
|
||||
Reference in New Issue
Block a user