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

@@ -39,6 +39,30 @@ function land(name: string, color: string): CardDefinition {
})
}
function exoticOrchard(): CardDefinition {
return card('Exotic Orchard', {
typeLine: 'Land',
power: undefined,
toughness: undefined,
abilities: [{
kind: 'activated',
costs: [{ kind: 'tap' }],
effects: [{
op: 'add_mana',
player: 'you',
mana: {
kind: 'any_color',
amount: { kind: 'number', value: 1 },
oneColor: false,
restriction: 'a land an opponent controls could produce',
},
}],
optional: false,
text: '{T}: Add one mana of any color that a land an opponent controls could produce.',
}],
})
}
function setup(players: { id: string; deck?: CardDefinition[]; life?: number }[]): Game {
const game = new Game({
seed: 7,
@@ -77,6 +101,51 @@ test('turns start at the first main phase, draw opening hands, and pass to the n
assert.equal(game.getPlayer('p1').hand.length, 7)
})
test('mulligans draw a new seven and bottom one more card each time', () => {
const game = new Game({
seed: 3,
startingHandSize: 7,
mulligans: true,
players: [
{ id: 'p1', deck: Array.from({ length: 40 }, (_, index) => card(`P1 Card ${index}`)) },
{ id: 'p2', deck: Array.from({ length: 40 }, (_, index) => card(`P2 Card ${index}`)) },
],
})
game.start()
assert.equal(game.status, 'mulligan')
assert.equal(game.getPlayer('p1').hand.length, 7)
game.keepHand('p2')
game.mulligan('p1')
assert.equal(game.getPlayer('p1').hand.length, 7)
assert.equal(game.mulligans.get('p1')?.count, 1)
assert.equal(game.mulligans.get('p1')?.bottom, 0)
game.mulligan('p1')
assert.equal(game.mulligans.get('p1')?.count, 2)
assert.equal(game.mulligans.get('p1')?.bottom, 1)
assert.throws(() => game.keepHand('p1'), /bottom/)
const bottomCard = game.getPlayer('p1').hand[0]
game.putOnBottom('p1', bottomCard)
assert.equal(game.getPlayer('p1').hand.length, 6)
assert.equal(game.getPlayer('p1').library.at(-1), bottomCard)
assert.equal(game.mulligans.get('p1')?.bottom, 0)
game.mulligan('p1')
assert.equal(game.mulligans.get('p1')?.count, 3)
assert.equal(game.mulligans.get('p1')?.bottom, 2)
for (const cardId of [...game.getPlayer('p1').hand.slice(0, 2)]) game.putOnBottom('p1', cardId)
assert.equal(game.getPlayer('p1').hand.length, 5)
game.keepHand('p1')
assert.equal(game.status, 'active')
assert.equal(game.turn, 1)
assert.equal(game.step, 'main')
assert.equal(game.getPlayer('p1').hand.length, 5)
})
test('passing priority twice advances from the main phase into combat', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
@@ -290,6 +359,73 @@ test('activated mana abilities produce mana and creatures have summoning sicknes
assert.equal(game.getPlayer('p1').manaPool.G, 1)
})
test('Exotic Orchard is limited to colors an opponent land could produce', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const orchard = game.addCard('p1', exoticOrchard(), 'battlefield')
game.addCard('p2', land('Forest', 'G'), 'battlefield')
const green = game.addCard('p1', spell('Green Spell', [], '{G}'), 'hand')
const blue = game.addCard('p1', spell('Blue Spell', [], '{U}'), 'hand')
assert.equal(game.canPlayCard('p1', green.id), true)
assert.equal(game.canPlayCard('p1', blue.id), false)
assert.throws(() => game.castSpell('p1', blue.id), GameError)
assert.equal(orchard.tapped, false)
assert.deepEqual(game.getPlayer('p1').manaPool, { W: 0, U: 0, B: 0, R: 0, G: 0, C: 0 })
game.castSpell('p1', green.id)
assert.equal(orchard.tapped, true)
assert.equal(game.getPlayer('p1').manaPool.G, 0)
})
test('Exotic Orchard adds an opponent land color when activated manually', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const orchard = game.addCard('p1', exoticOrchard(), 'battlefield')
game.addCard('p2', land('Island', 'U'), 'battlefield')
game.activateAbility('p1', orchard.id, 0)
assert.equal(game.getPlayer('p1').manaPool.U, 1)
assert.equal(game.getPlayer('p1').manaPool.W, 0)
})
test('Exotic Orchard produces nothing without an opponent land', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const orchard = game.addCard('p1', exoticOrchard(), 'battlefield')
game.activateAbility('p1', orchard.id, 0)
assert.equal(orchard.tapped, true)
assert.deepEqual(game.getPlayer('p1').manaPool, { W: 0, U: 0, B: 0, R: 0, G: 0, C: 0 })
})
test('a restricted mana source is used before an unrestricted one', () => {
const rainbow = card('Rainbow Land', {
typeLine: 'Land',
power: undefined,
toughness: undefined,
abilities: [{
kind: 'activated',
costs: [{ kind: 'tap' }],
effects: [{ op: 'add_mana', player: 'you', mana: { kind: 'any_color', amount: { kind: 'number', value: 1 }, oneColor: false } }],
optional: false,
text: '{T}: Add one mana of any color.',
}],
})
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const rainbowLand = game.addCard('p1', rainbow, 'battlefield')
const orchard = game.addCard('p1', exoticOrchard(), 'battlefield')
game.addCard('p2', land('Forest', 'G'), 'battlefield')
const gold = game.addCard('p1', spell('Gold Spell', [], '{G}{U}'), 'hand')
assert.equal(game.canPlayCard('p1', gold.id), true)
game.castSpell('p1', gold.id)
assert.equal(orchard.tapped, true)
assert.equal(rainbowLand.tapped, true)
assert.deepEqual(game.getPlayer('p1').manaPool, { W: 0, U: 0, B: 0, R: 0, G: 0, C: 0 })
})
test('static pump effects apply to matching creatures only', () => {
const anthem = card('Glorious Anthem', {
typeLine: 'Enchantment',
@@ -625,6 +761,63 @@ test('static replacement effects make permanents enter tapped with counters', ()
assert.equal(game.getToughness(bear), 3)
})
function shockLand(): CardDefinition {
return card('Steam Vents', {
typeLine: 'Land — Island Mountain',
power: undefined,
toughness: undefined,
abilities: [{
kind: 'static',
effects: [{ op: 'enters_tapped', target: { kind: 'self' }, unlessCost: { kind: 'pay_life', amount: { kind: 'number', value: 2 } } }],
text: "As this land enters, you may pay 2 life. If you don't, it enters tapped.",
}, {
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}.',
}],
})
}
test('a land can pay life to enter untapped or enter tapped', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const vents = game.addCard('p1', shockLand(), 'hand')
game.playLand('p1', vents.id)
assert.equal(vents.tapped, false)
assert.equal(game.pendingChoice?.what, 'pay_cost')
assert.equal(game.pendingChoice?.amount, 2)
assert.throws(() => game.chooseCostPayment('p2', true), GameError)
game.chooseCostPayment('p1', true)
assert.equal(game.getPlayer('p1').life, 38)
assert.equal(vents.tapped, false)
assert.equal(game.pendingChoice, undefined)
const second = game.addCard('p1', shockLand(), 'hand')
game.moveToZone(second, 'battlefield', { controller: 'p1', silent: false })
assert.equal(game.pendingChoice?.what, 'pay_cost')
game.chooseCostPayment('p1', false)
assert.equal(second.tapped, true)
assert.equal(game.getPlayer('p1').life, 38)
})
test('a choice mana ability adds only the color the spell needs', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const vents = game.addCard('p1', shockLand(), 'battlefield')
const red = game.addCard('p1', spell('Red Spell', [], '{R}'), 'hand')
game.castSpell('p1', red.id)
assert.equal(vents.tapped, true)
assert.equal(game.getPlayer('p1').manaPool.R, 0)
assert.equal(game.getPlayer('p1').manaPool.U, 0)
})
test('a player who runs out of cards loses and the last player wins', () => {
const game = new Game({
seed: 3,
@@ -658,6 +851,43 @@ test('lethal damage to a player ends the game', () => {
assert.equal(game.getPlayer('p2').life, 0)
})
test('the legend rule leaves one legendary permanent per name under one controller', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const legend = card('Kiora, the Rising Tide', {
typeLine: 'Legendary Creature — Merfolk Wizard',
power: 1,
toughness: 1,
})
const first = game.addCard('p1', legend, 'battlefield')
const second = game.addCard('p1', legend, 'battlefield')
const forest = game.addCard('p1', land('Forest', 'G'), 'hand')
game.playLand('p1', forest.id)
assert.equal(first.zone, 'battlefield')
assert.equal(second.zone, 'graveyard')
assert.ok(game.getPlayer('p1').graveyard.includes(second.id))
})
test('the legend rule does not apply across controllers', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()
const legend = card('Kiora, the Rising Tide', {
typeLine: 'Legendary Creature — Merfolk Wizard',
power: 1,
toughness: 1,
})
const mine = game.addCard('p1', legend, 'battlefield')
const theirs = game.addCard('p2', legend, 'battlefield')
const forest = game.addCard('p1', land('Forest', 'G'), 'hand')
game.playLand('p1', forest.id)
assert.equal(mine.zone, 'battlefield')
assert.equal(theirs.zone, 'battlefield')
})
test('a failed mana payment leaves mana sources untapped and the pool unchanged', () => {
const game = setup([{ id: 'p1' }, { id: 'p2' }])
game.start()