diff --git a/mods/soldoros_doll/src/index.test.ts b/mods/soldoros_doll/src/index.test.ts index f758e0f..bd35d59 100644 --- a/mods/soldoros_doll/src/index.test.ts +++ b/mods/soldoros_doll/src/index.test.ts @@ -63,6 +63,9 @@ test("soldoros mod creates a doll APC overlay and list entry", async () => { assert.ok(aiCharacterListOverlay); assert.match(String(summonApcOverlay.content), /\[minimum info\][\s\S]*索德罗斯/u); assert.match(String(summonApcOverlay.content), /\[attack damage rate\]\r?\n1\.0/u); + assert.doesNotMatch(String(summonApcOverlay.content), /\[armor subtype\]/u); + assert.match(String(summonApcOverlay.content), /\[etc action\][\s\S]*action\/ex\.act/u); + assert.doesNotMatch(String(summonApcOverlay.content), /ex2\.act/u); assert.match( String(aiCharacterListOverlay.content), /1520\t`_jojochan\/swordman\/soldoros\/soldoros_doll\.aic`/u, diff --git a/mods/soldoros_doll/src/index.ts b/mods/soldoros_doll/src/index.ts index fa7e39c..9f2c47c 100644 --- a/mods/soldoros_doll/src/index.ts +++ b/mods/soldoros_doll/src/index.ts @@ -7,6 +7,7 @@ import { isStatement, loadListedPathById, readEquDocument, + removeTopLevelSection, replaceTopLevelSection, updateListedPathDocument, } from "@pvf/pvf-mod"; @@ -80,13 +81,41 @@ function replaceMinimumInfoName( export function buildSupportSummonDollDocument( sourceDocument: EquDocument, ): EquDocument { - return replaceTopLevelSection( - replaceMinimumInfoName(sourceDocument, SUPPORT_SUMMON_DOLL_NAME), + const withName = replaceMinimumInfoName(sourceDocument, SUPPORT_SUMMON_DOLL_NAME); + const withDamageRate = replaceTopLevelSection( + withName, createSingleFloatLiteralSection( "attack damage rate", SUPPORT_SUMMON_ATTACK_DAMAGE_RATE, ), ); + const withoutArmorSubtype = removeTopLevelSection(withDamageRate, "armor subtype"); + return filterEtcAction(withoutArmorSubtype); +} + +function filterEtcAction(document: EquDocument): EquDocument { + const etcActionSection = getFirstSection(document.children, "etc action"); + + if (!etcActionSection) { + return document; + } + + const filteredSection: EquSectionNode = { + ...etcActionSection, + children: etcActionSection.children.filter((child) => { + if (!isStatement(child)) { + return true; + } + + return !child.tokens.some( + (token) => + (token.kind === "string" || token.kind === "identifier") + && token.value === "action/ex2.act", + ); + }), + }; + + return replaceTopLevelSection(document, filteredSection); } export async function tryFindAiCharacterByName( diff --git a/packages/pvf-mod/src/equ.ts b/packages/pvf-mod/src/equ.ts index bf8caf9..ef605cb 100644 --- a/packages/pvf-mod/src/equ.ts +++ b/packages/pvf-mod/src/equ.ts @@ -103,6 +103,18 @@ export function replaceTopLevelSection( }; } +export function removeTopLevelSection( + document: EquDocument, + name: string, +): EquDocument { + return { + ...document, + children: document.children.filter( + (node) => !isSection(node) || node.name !== name, + ), + }; +} + export function createSingleStringSection(name: string, value: string): EquSectionNode { return createSection(name, [createStatement([createStringToken(value)])]); }