Add PF2e action cost icons to ability names
All checks were successful
CI / check (push) Successful in 2m21s
CI / build-image (push) Successful in 17s

Show Unicode action icons (◆/◆◆/◆◆◆ for actions, ◇ for free,
↺ for reaction) in ability names from the activity field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-07 16:31:24 +02:00
parent f9cfaa2570
commit 57278e0c82
2 changed files with 87 additions and 4 deletions

View File

@@ -170,7 +170,7 @@ describe("normalizePf2eBestiary", () => {
});
});
describe("ability traits formatting", () => {
describe("ability formatting", () => {
it("includes traits from abilities in the text", () => {
const [creature] = normalizePf2eBestiary({
creature: [
@@ -179,6 +179,7 @@ describe("normalizePf2eBestiary", () => {
bot: [
{
name: "Change Shape",
activity: { number: 1, unit: "action" },
traits: [
"concentrate",
"divine",
@@ -196,6 +197,7 @@ describe("normalizePf2eBestiary", () => {
});
const ability = creature.abilitiesBot?.[0];
expect(ability).toBeDefined();
expect(ability?.name).toBe("\u25C6 Change Shape");
expect(ability?.segments[0]).toEqual(
expect.objectContaining({
type: "text",
@@ -206,7 +208,68 @@ describe("normalizePf2eBestiary", () => {
);
});
it("renders ability without traits normally", () => {
it("shows free action icon", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
abilities: {
bot: [
{
name: "Adaptive Strike",
activity: { number: 1, unit: "free" },
entries: ["The naunet chooses adamantine."],
},
],
},
}),
],
});
expect(creature.abilitiesBot?.[0]?.name).toBe("\u25C7 Adaptive Strike");
});
it("shows reaction icon", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
abilities: {
mid: [
{
name: "Attack of Opportunity",
activity: { number: 1, unit: "reaction" },
entries: ["Trigger description."],
},
],
},
}),
],
});
expect(creature.abilitiesMid?.[0]?.name).toBe(
"\u21BA Attack of Opportunity",
);
});
it("shows multi-action icons", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
abilities: {
bot: [
{
name: "Breath Weapon",
activity: { number: 2, unit: "action" },
entries: ["Fire breath."],
},
],
},
}),
],
});
expect(creature.abilitiesBot?.[0]?.name).toBe(
"\u25C6\u25C6 Breath Weapon",
);
});
it("renders ability without activity or traits normally", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
@@ -223,6 +286,7 @@ describe("normalizePf2eBestiary", () => {
});
const ability = creature.abilitiesBot?.[0];
expect(ability).toBeDefined();
expect(ability?.name).toBe("Constrict");
expect(ability?.segments[0]).toEqual(
expect.objectContaining({
type: "text",