Skip to content

Commit

Permalink
changing the workflow for starting a game.
Browse files Browse the repository at this point in the history
  • Loading branch information
preflightsiren committed Apr 20, 2014
1 parent 4797333 commit 12e6c3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}
Expand Down
6 changes: 6 additions & 0 deletions round.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 12e6c3b

Please sign in to comment.