This commit is contained in:
2026-10-29 15:21:05 +01:00
parent bb85881cac
commit bc05b63083
36 changed files with 4654 additions and 5080 deletions

View File

@@ -2,6 +2,7 @@ import assert from 'node:assert/strict'
import test from 'node:test'
import type { Card } from '../src/cards.js'
import { matchesCardFilters } from '../src/cards.js'
import { cardDefinitionFromCard } from '../src/game/catalog.js'
function card(overrides: Partial<Card> = {}): Card {
return {
@@ -51,3 +52,41 @@ test('card filters match format legality, color identity, type, rarity, and mana
assert.equal(matchesCardFilters(cardByIdentity, { cmcMin: 4 }), false)
assert.equal(matchesCardFilters(cardByIdentity, { cmcMax: 2 }), false)
})
test('compiled card types reach the engine definition', () => {
const definition = cardDefinitionFromCard(card(), {
oracle_id: 'test',
name: 'Test Card',
typeLine: 'Artifact Creature — Golem',
status: 'supported',
abilities: [],
})
assert.equal(definition.typeLine, 'Artifact Creature — Golem')
})
test('lands with basic land types get one intrinsic mana ability for their colors', () => {
const vents = cardDefinitionFromCard(card({
name: 'Steam Vents',
type_line: 'Land — Island Mountain',
colors: [],
color_identity: ['U', 'R'],
}))
assert.deepEqual(vents.abilities, [{
kind: 'activated',
costs: [{ kind: 'tap' }],
effects: [{
op: 'add_mana',
player: 'you',
mana: { kind: 'symbols', symbols: ['{U}', '{R}'], oneOf: true },
}],
optional: false,
text: '{T}: Add {U} or {R}.',
}])
const forest = cardDefinitionFromCard(card({ name: 'Forest', type_line: 'Basic Land — Forest' }))
assert.deepEqual(forest.abilities?.[0]?.effects, [{
op: 'add_mana',
player: 'you',
mana: { kind: 'symbols', symbols: ['{G}'] },
}])
})