cards/pile.ts
2026-01-16 21:14:50 -07:00

24 lines
447 B
TypeScript

import { arrayShuffle } from './utils'
import type Card from './card'
export default class Pile {
cards: Card[]
constructor(cards: Card[]) {
this.cards = cards
}
get pretty() {
return this.cards.map(card => card.pretty).join('\n')
}
shuffle(times = 1) {
let cards = this.cards
for (let index = 0; index < times; index++) {
cards = arrayShuffle(cards)
}
this.cards = cards
return this.cards
}
}