Ejemplo n.º 1
0
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())
	}
}
Ejemplo n.º 2
0
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)
	}
}
Ejemplo n.º 3
0
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
}