Fix appendages parsing to handle multiple appendages

This commit is contained in:
Yaroslav (Ice) Sheremet
2026-02-01 19:02:11 +02:00
parent 119a9ce62c
commit d034ef44cc
3 changed files with 112 additions and 15 deletions

View File

@@ -486,23 +486,42 @@ function parseAppendages(token) {
// Remove 'P' prefix
let content = token.substring(1);
// Check for Pw' (wings as arms) special case
if (content.startsWith("w'")) {
const modifiers = content.substring(2);
return {
baseType: "w'",
modifiers: modifiers,
raw: token
const appendagesList = [];
let i = 0;
while (i < content.length) {
let appendage = {
baseType: null,
modifiers: ''
};
// Check for Pw' (wings as arms) special case
if (content.substring(i, i + 2) === "w'") {
appendage.baseType = "w'";
i += 2;
} else {
// Get base type (single character)
appendage.baseType = content[i];
i++;
}
// Collect modifiers for this appendage (until we hit another letter that's a base type)
while (i < content.length) {
const char = content[i];
// Check if this is a new appendage base type (a, f, h, k, l, p, t, v, w)
if ('afhklptvw'.includes(char.toLowerCase())) {
break;
}
// Otherwise it's a modifier
appendage.modifiers += char;
i++;
}
appendagesList.push(appendage);
}
// Get base type (first character after P)
const baseType = content[0];
const modifiers = content.substring(1);
return {
baseType: baseType,
modifiers: modifiers,
appendages: appendagesList,
raw: token
};
}