diff --git a/src/models/cardCollection/hand.interface.ts b/src/models/cardCollection/hand.interface.ts index 6642059..147e89e 100644 --- a/src/models/cardCollection/hand.interface.ts +++ b/src/models/cardCollection/hand.interface.ts @@ -1,8 +1,8 @@ import { ICard } from '../card/card.interface' -import { ICardCollection } from './cardCollection.interface' +import { ICardPile } from './cardPile.interface' import { IRankSet } from '../card/rankSet.interface' -export interface IHand extends ICardCollection { +export interface IHand extends ICardPile { sortCards (cardRank: IRankSet): IHand playCard (card: ICard): void } diff --git a/src/models/cardCollection/hand.model.ts b/src/models/cardCollection/hand.model.ts index a4d19db..5b89c4d 100644 --- a/src/models/cardCollection/hand.model.ts +++ b/src/models/cardCollection/hand.model.ts @@ -1,5 +1,5 @@ import { Suit } from '../card/suit.model' -import { CardCollection } from './cardCollection.model' +import { CardPile } from './cardPile.model' import { MapExtensions } from '../../common/mapExtensions.model' import { IHand } from './hand.interface' import { ICard } from '../card/card.interface' @@ -8,14 +8,12 @@ import { IRankSet } from '../card/rankSet.interface' /** * Represents a group of cards assigned to an IPlayer */ -export class Hand extends CardCollection implements IHand { - +export class Hand extends CardPile implements IHand { + public name = 'Hand' public suitOrder: Suit[] = [Suit.Clubs, Suit.Spades, Suit.Diamonds, Suit.Hearts] constructor (cards: ICard[] = []) { - super(cards) // CardCollection.constructor - - this.friendlyName = 'Hand' // default name + super(cards) // CardPile.constructor } /** diff --git a/src/models/cardCollection/hand.spec.ts b/src/models/cardCollection/hand.spec.ts index 2a4a4ed..2f21561 100644 --- a/src/models/cardCollection/hand.spec.ts +++ b/src/models/cardCollection/hand.spec.ts @@ -12,6 +12,17 @@ test('is empty with no cards', async t => { t.true(hand.isEmpty(), 'isEmpty() should have been true') }) +test('has default name', async t => { + const hand = new Hand() + t.deepEqual(hand.name, 'Hand') +}) + +test('can assign name', async t => { + const hand = new Hand() + hand.name = 'Player 1 Hand' + t.deepEqual(hand.name, 'Player 1 Hand') +}) + test('has cards when initialized with them', async t => { const cards: ICard[] = [ new PlayingCard(CardName.Eight, Suit.Diamonds),