Skip to content

Commit 7b36e5b

Browse files
authored
soldoros_doll: strip [armor subtype] and remove ex2.act from [etc action] (#9)
1 parent e2f02df commit 7b36e5b

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

mods/soldoros_doll/src/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ test("soldoros mod creates a doll APC overlay and list entry", async () => {
6363
assert.ok(aiCharacterListOverlay);
6464
assert.match(String(summonApcOverlay.content), /\[minimum info\][\s\S]*/u);
6565
assert.match(String(summonApcOverlay.content), /\[attack damage rate\]\r?\n1\.0/u);
66+
assert.doesNotMatch(String(summonApcOverlay.content), /\[armor subtype\]/u);
67+
assert.match(String(summonApcOverlay.content), /\[etc action\][\s\S]*action\/ex\.act/u);
68+
assert.doesNotMatch(String(summonApcOverlay.content), /ex2\.act/u);
6669
assert.match(
6770
String(aiCharacterListOverlay.content),
6871
/1520\t`_jojochan\/swordman\/soldoros\/soldoros_doll\.aic`/u,

mods/soldoros_doll/src/index.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
isStatement,
88
loadListedPathById,
99
readEquDocument,
10+
removeTopLevelSection,
1011
replaceTopLevelSection,
1112
updateListedPathDocument,
1213
} from "@pvf/pvf-mod";
@@ -80,13 +81,41 @@ function replaceMinimumInfoName(
8081
export function buildSupportSummonDollDocument(
8182
sourceDocument: EquDocument,
8283
): EquDocument {
83-
return replaceTopLevelSection(
84-
replaceMinimumInfoName(sourceDocument, SUPPORT_SUMMON_DOLL_NAME),
84+
const withName = replaceMinimumInfoName(sourceDocument, SUPPORT_SUMMON_DOLL_NAME);
85+
const withDamageRate = replaceTopLevelSection(
86+
withName,
8587
createSingleFloatLiteralSection(
8688
"attack damage rate",
8789
SUPPORT_SUMMON_ATTACK_DAMAGE_RATE,
8890
),
8991
);
92+
const withoutArmorSubtype = removeTopLevelSection(withDamageRate, "armor subtype");
93+
return filterEtcAction(withoutArmorSubtype);
94+
}
95+
96+
function filterEtcAction(document: EquDocument): EquDocument {
97+
const etcActionSection = getFirstSection(document.children, "etc action");
98+
99+
if (!etcActionSection) {
100+
return document;
101+
}
102+
103+
const filteredSection: EquSectionNode = {
104+
...etcActionSection,
105+
children: etcActionSection.children.filter((child) => {
106+
if (!isStatement(child)) {
107+
return true;
108+
}
109+
110+
return !child.tokens.some(
111+
(token) =>
112+
(token.kind === "string" || token.kind === "identifier")
113+
&& token.value === "action/ex2.act",
114+
);
115+
}),
116+
};
117+
118+
return replaceTopLevelSection(document, filteredSection);
90119
}
91120

92121
export async function tryFindAiCharacterByName(

packages/pvf-mod/src/equ.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ export function replaceTopLevelSection(
103103
};
104104
}
105105

106+
export function removeTopLevelSection(
107+
document: EquDocument,
108+
name: string,
109+
): EquDocument {
110+
return {
111+
...document,
112+
children: document.children.filter(
113+
(node) => !isSection(node) || node.name !== name,
114+
),
115+
};
116+
}
117+
106118
export function createSingleStringSection(name: string, value: string): EquSectionNode {
107119
return createSection(name, [createStatement([createStringToken(value)])]);
108120
}

0 commit comments

Comments
 (0)