freego/player.go

36 lines
613 B
Go
Raw Normal View History

2022-02-21 19:07:28 -05:00
package freego
2022-02-18 18:36:18 -05:00
//Player represents a player of the game
type Player interface {
ID() int
Colour() Colour
}
//DummyPlayer is the simplest implementation of a player
type DummyPlayer struct {
id Colour
}
//ID returns player ID
func (d *DummyPlayer) ID() int {
return int(d.id)
}
//Colour returns player colour (same as ID)
func (d *DummyPlayer) Colour() Colour {
return d.id
}
//NewDummyPlayer creates a new player
func NewDummyPlayer(i Colour) *DummyPlayer {
return &DummyPlayer{i}
}
func (d *DummyPlayer) String() string {
if d.id == Red {
return "Red Player"
} else {
return "Blue Player"
}
}