Add card data module with ironclad starter deck

This commit is contained in:
Jared Miller 2026-02-23 17:34:05 -05:00
parent 690ffbe43c
commit 08214fc8cb
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
4 changed files with 92 additions and 0 deletions

19
data/enemies.json Normal file
View file

@ -0,0 +1,19 @@
{
"jaw_worm": {
"id": "jaw_worm",
"name": "Jaw Worm",
"hp": 6,
"actionType": "die",
"actions": {
"1": { "intent": "attack", "effects": [{ "type": "hit", "value": 2 }] },
"2": { "intent": "attack", "effects": [{ "type": "hit", "value": 2 }] },
"3": { "intent": "defend", "effects": [{ "type": "block", "value": 2 }] },
"4": { "intent": "defend", "effects": [{ "type": "block", "value": 2 }] },
"5": {
"intent": "buff",
"effects": [{ "type": "strength", "value": 1 }]
},
"6": { "intent": "buff", "effects": [{ "type": "strength", "value": 1 }] }
}
}
}

View file

@ -0,0 +1,35 @@
{
"strike_r": {
"id": "strike_r",
"name": "Strike",
"cost": 1,
"type": "attack",
"effects": [{ "type": "hit", "value": 1 }],
"keywords": [],
"description": "1 hit.",
"image": "assets/images/ironclad/starter/1.png"
},
"defend_r": {
"id": "defend_r",
"name": "Defend",
"cost": 1,
"type": "skill",
"effects": [{ "type": "block", "value": 1 }],
"keywords": [],
"description": "1 Block.",
"image": "assets/images/ironclad/starter/2.png"
},
"bash": {
"id": "bash",
"name": "Bash",
"cost": 2,
"type": "attack",
"effects": [
{ "type": "hit", "value": 2 },
{ "type": "vulnerable", "value": 1 }
],
"keywords": [],
"description": "2 hit. Apply 1 Vulnerable.",
"image": "assets/images/ironclad/starter/0.png"
}
}

14
src/cards.js Normal file
View file

@ -0,0 +1,14 @@
import starterIronclad from "../data/starter-ironclad.json";
const cardDb = { ...starterIronclad };
export function getCard(id) {
return cardDb[id];
}
export function getStarterDeck(character) {
if (character === "ironclad") {
return [...Array(5).fill("strike_r"), ...Array(4).fill("defend_r"), "bash"];
}
return [];
}

24
src/cards.test.js Normal file
View file

@ -0,0 +1,24 @@
import { describe, expect, test } from "bun:test";
import { getCard, getStarterDeck } from "./cards.js";
describe("cards", () => {
test("getCard returns card by id", () => {
const card = getCard("strike_r");
expect(card.name).toBe("Strike");
expect(card.cost).toBe(1);
expect(card.type).toBe("attack");
expect(card.effects[0].type).toBe("hit");
});
test("getCard returns undefined for unknown id", () => {
expect(getCard("nonexistent")).toBeUndefined();
});
test("getStarterDeck returns 10 card ids for ironclad", () => {
const deck = getStarterDeck("ironclad");
expect(deck).toHaveLength(10);
expect(deck.filter((id) => id === "strike_r")).toHaveLength(5);
expect(deck.filter((id) => id === "defend_r")).toHaveLength(4);
expect(deck.filter((id) => id === "bash")).toHaveLength(1);
});
});