Fix appendages parsing to handle multiple appendages
This commit is contained in:
45
js/parser.js
45
js/parser.js
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user