Commit 00c812c7 authored by ceddral's avatar ceddral
Browse files

game: menu: show number of pieces placed/total

parent 02a55081
......@@ -45,7 +45,12 @@ func (m *GameMenu) Redraw(s GameState) {
if sip, ok := s.(*StateImpossiblePiece); ok {
sip.p.render(v, 0, line, nil, 0, 0, 0, PMPlayers, nil)
}
v.DrawTextClearLine(fg, bg, []byte(fmt.Sprintf("%d/%d pieces", 0, 1337)), 6, line)
g := s.getGame()
g.Lock()
piecesUsed := g.pieceCount - len(g.pieceOrder)
piecesTotal := g.pieceCount
g.Unlock()
v.DrawTextClearLine(fg, bg, []byte(fmt.Sprintf("%d/%d pieces", piecesUsed, piecesTotal)), 6, line)
line += 4
p := m.p
a := s.getAgent()
......@@ -264,6 +269,7 @@ type Game struct {
board *Board
pieces []Piece
pieceOrder []int
pieceCount int
}
func (g *Game) Lock() {
......@@ -336,6 +342,7 @@ func NewGame(pns []string, extensions []string) (g *Game) {
g.pieceOrder = append(g.pieceOrder, i)
}
}
g.pieceCount = len(g.pieceOrder)
// shuffle but leave starting piece (pieceOrder[0]) in place
rand.Shuffle(len(g.pieceOrder) - 1, func(i, j int) { i++; j++; g.pieceOrder[i], g.pieceOrder[j] = g.pieceOrder[j], g.pieceOrder[i] })
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment