-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.go
37 lines (32 loc) · 750 Bytes
/
player.go
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
package main
import (
"GoConsoleBT/controller"
"github.com/eiannone/keyboard"
"sync/atomic"
)
type Player struct {
*controller.Control
Keyboard <-chan keyboard.KeyEvent
Unit *Unit
*CustomizeMap
Name string
Blueprint string
Score int64
Retry int32
}
func (receiver *Player) IncScore(byValue int64) int64 {
return atomic.AddInt64(&receiver.Score, byValue)
}
func (receiver *Player) DecrRetry(byValue int32) int32 {
return atomic.AddInt32(&receiver.Retry, byValue*-1)
}
func NewPlayer(name string, control *controller.Control) (*Player, error) {
return &Player{
Control: control,
Unit: nil,
CustomizeMap: nil,
Name: name,
Score: 0,
Retry: 3, //good default :)
}, nil
}