From 12e6c3b10ba348082fbfb7dbb57fd067e46ca9a8 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 21 Apr 2014 00:59:45 +1000 Subject: [PATCH] changing the workflow for starting a game. --- main_test.go | 8 ++++---- round.go | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/main_test.go b/main_test.go index 988934f..10806b1 100644 --- a/main_test.go +++ b/main_test.go @@ -6,7 +6,6 @@ import ( func TestEndToEnd(t *testing.T) { players := []*Player{NewPlayer("Player1"), NewPlayer("Player2")} - p1 := players[0] r := NewRound(players) if r.Deck.Active() != true { @@ -16,10 +15,11 @@ func TestEndToEnd(t *testing.T) { t.Error("Expected the round to have active, but it was not.") } - for i := 0; i < 14; i++ { - r.DrawForCurrentPlayer() - err := p1.Discard() + r.DrawForCurrentPlayer() + for i := 0; i < 13; i++ { + err := r.CurrentPlayer().Discard() if err != nil { + t.Log(r.ActivityLog) t.Fatal(err) } } diff --git a/round.go b/round.go index 27a01b3..2b7afeb 100644 --- a/round.go +++ b/round.go @@ -42,14 +42,20 @@ func (r *Round) Init(players []*Player) *Round { func (r *Round) nextPlayer() { r.currentPlayerIndex = (r.currentPlayerIndex + 1) % r.NumberOfPlayers() r.Log(fmt.Sprintf("It's now %s's turn", r.CurrentPlayer().Name)) + if r.Active() { + r.DrawForCurrentPlayer() + } } func (r *Round) Discard(player *Player, card Card) { r.Log(fmt.Sprintf("%s just discarded card: %s", player.Name, card.Name())) + r.Log(fmt.Sprintf("it has the effect of %s", player.Name, card.Action())) r.Deck.Discard(card) + r.nextPlayer() } func (r *Round) DrawForCurrentPlayer() { var err error var card Card + r.Log(fmt.Sprintf("%s draws a new card", r.CurrentPlayer().Name)) err, card = r.Deck.Draw() if err != nil { //end round.