Skip to content

Commit

Permalink
Fixed #66 by rendering turn information for every player.
Browse files Browse the repository at this point in the history
  • Loading branch information
beefsack committed Apr 16, 2015
1 parent d4d0f38 commit f0b6ed9
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions game/farkle/farkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,11 @@ func (g *Game) Decode(data []byte) error {
}

func (g *Game) RenderForPlayer(player string) (string, error) {
playerNum, err := g.GetPlayerNum(player)
if err != nil {
return "", err
}
buf := bytes.NewBufferString("")
cells := [][]interface{}{}
if playerNum == g.Player {
cells = append(cells,
[]interface{}{"{{b}}Remaining dice{{_b}}", RenderDice(g.RemainingDice)},
[]interface{}{"{{b}}Score this turn{{_b}}", strconv.Itoa(g.TurnScore)})
cells := [][]interface{}{
{"{{b}}Remaining dice{{_b}}", RenderDice(g.RemainingDice)},
{"{{b}}Score this turn{{_b}}", strconv.Itoa(g.TurnScore)},
}
cells = append(cells,
[]interface{}{"{{b}}Your score{{_b}}", strconv.Itoa(g.Scores[playerNum])})
t := render.Table(cells, 0, 1)
buf.WriteString(t)
buf.WriteString("\n\n")
Expand Down

0 comments on commit f0b6ed9

Please sign in to comment.