{sortedUnits.map((unit, index) => {
let { name, cost, models } = unit;
- const count = models?.[0]?.count || 1;
+ const count =
+ models?.length === 1 ? models?.[0]?.count || 1 : 1;
return (
{
{unit.modelStats?.reduce((sum, stat, index) => {
- const count = unit.models?.[index]?.count || 1;
- return sum + (stat.wounds || 0) * count;
+ const modelName = unit.models?.reduce(
+ (bestMatch, model) => {
+ const similarity = (str1, str2) => {
+ let matches = 0;
+ for (
+ let i = 0;
+ i < Math.min(str1.length, str2.length);
+ i++
+ ) {
+ if (str1[i] === str2[i]) matches++; // Match only if characters are at the same position
+ }
+ return matches;
+ };
+ const currentSimilarity = similarity(
+ stat.name,
+ model.name,
+ );
+
+ return currentSimilarity >
+ similarity(stat.name, bestMatch.name)
+ ? model
+ : bestMatch;
+ },
+ unit.models[0],
+ );
+
+ const modelCount = modelName?.count || 1;
+ return sum + (stat.wounds || 0) * modelCount;
}, 0)}
diff --git a/src/assets/custodesBackground.png b/src/assets/custodesBackground.png
new file mode 100644
index 0000000..eddc149
Binary files /dev/null and b/src/assets/custodesBackground.png differ