func TestPlayerCreation(t *testing.T) { strategy := noLieStrategy.New() centerDeck := deck.NewRandomCenter() playerDeck := deck.New(centerDeck.TakeCards(2)) player := New("p1", strategy, playerDeck, 2) if !(player.Name() == "p1") { t.Errorf("Table name wrong: expected %q, got %q", "p1", player.Name()) } }
func TestPlayerDeckCreation(t *testing.T) { centerDeck := deck.NewRandomCenter() playerDeck := deck.New(centerDeck.TakeCards(2)) if !(playerDeck.Size() == 2) { t.Errorf("Player deck size wrong: expected %d, got %d", 2, playerDeck) } if !(centerDeck.Size() == 13) { t.Errorf("Player deck size wrong: expected %d, got %d", 13, centerDeck) } }
func New(strategies []*strategy.Interface, playerNames []string) *Entity { centerDeck := deck.NewRandomCenter() faceupDecks := make([]*deck.Entity, len(strategies)) players := make([]*player.Entity, len(strategies)) for i := 0; i < len(strategies); i++ { players[i] = player.New(playerNames[i], strategies[i], deck.New(centerDeck.TakeCards(2)), 2) } for i := 0; i < len(faceupDecks); i++ { faceupDecks[i] = deck.New(make([]int, 2)) } var entity = Entity{ players, centerDeck, faceupDecks, 40, } return &entity }