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

@@ -1,7 +1,7 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { findCardByName } from '../src/cards.js'
import { createMatch, getMatchView, joinMatch, leaveMatch, setDeck, startMatch } from '../src/game/rooms.js'
import { createMatch, getMatchView, joinMatch, leaveMatch, performAction, setDeck, startMatch } from '../src/game/rooms.js'
function deck(commanderName: string) {
const commander = findCardByName(commanderName)
@@ -36,3 +36,20 @@ test('leaving a started game forfeits the seat instead of erroring', () => {
assert.equal(view.status, 'finished')
assert.equal(view.players.find(player => player.id === host.playerId)?.lost, true)
})
test('started matches wait for both players to keep their opening hands', () => {
const host = createMatch('Host', deck("Atraxa, Praetors' Voice"), 2)
const guest = joinMatch(host.matchId, 'Guest', deck('Kenrith, the Returned King'))
startMatch(host.matchId, host.token)
let view = getMatchView(host.matchId, host.token)
assert.equal(view.status, 'active')
assert.equal(view.game?.status, 'mulligan')
assert.equal(view.game?.mulligans?.length, 2)
performAction(host.matchId, host.token, { type: 'keep_hand' })
performAction(host.matchId, guest.token, { type: 'keep_hand' })
view = getMatchView(host.matchId, host.token)
assert.equal(view.game?.status, 'active')
})