spacetea/simulator/player.go

32 lines
575 B
Go
Raw Normal View History

2022-05-17 23:29:59 -04:00
package simulator
2022-05-19 15:18:03 -04:00
import (
"fmt"
)
2022-05-17 23:29:59 -04:00
//Player is a player controlled mob
type Player struct {
2022-05-19 17:09:46 -04:00
Resources map[itemType]int
2022-05-19 15:18:03 -04:00
CurrentTile *Tile
2022-05-17 23:29:59 -04:00
}
//NewPlayer initializes a player
func NewPlayer() *Player {
2022-05-19 17:09:46 -04:00
return &Player{Resources: make(map[itemType]int)}
2022-05-17 23:29:59 -04:00
}
func (p *Player) String() string {
var res string
res += "Resources: \n"
2022-05-19 17:09:46 -04:00
for _, i := range GlobalItemList {
if p.Resources[i] != 0 {
res += fmt.Sprintf("%v: %v\n", Lookup(i).Name(), p.Resources[i])
}
2022-05-17 23:29:59 -04:00
}
2022-05-19 15:18:03 -04:00
res += "\nLocation: \n"
if p.CurrentTile != nil {
res += p.CurrentTile.String()
}
2022-05-17 23:29:59 -04:00
return res
}