-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrack.go
More file actions
41 lines (33 loc) · 881 Bytes
/
Copy pathrack.go
File metadata and controls
41 lines (33 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"strconv"
"github.com/igungor/quackle"
termbox "github.com/nsf/termbox-go"
)
type rack struct {
player quackle.Player
x, y int
w, h int
}
func newRack(pl quackle.Player) rack {
return rack{
player: pl,
w: 7 * 2,
h: 1,
}
}
func (r *rack) draw() {
drawRect(r.x, r.y, r.w, r.h)
tbprint("┤"+r.player.Name()+"├", r.x, r.y-1, fgcolor, bgcolor)
playerScore := strconv.Itoa(r.player.Score())
tbprint(playerScore, r.x+r.w-len(playerScore), r.y-1, fgcolor, bgcolor)
// tbprint helper function is not used because letters have spacing between them
var i int
for _, ch := range r.player.Rack().ToString() {
termbox.SetCell(r.x+i*2, r.y, ch, fgcolor|termbox.AttrUnderline|termbox.AttrBold, bgcolor)
i++
}
}
func (r *rack) setActive() {
tbprint(r.player.Name(), r.x+1, r.y-1, termbox.ColorWhite, termbox.ColorMagenta)
}