Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mods/soldoros_doll/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
33 changes: 31 additions & 2 deletions mods/soldoros_doll/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isStatement,
loadListedPathById,
readEquDocument,
removeTopLevelSection,
replaceTopLevelSection,
updateListedPathDocument,
} from "@pvf/pvf-mod";
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions packages/pvf-mod/src/equ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)])]);
}
Expand Down
Loading