rove/pkg/atlas/objects.go

54 lines
941 B
Go
Raw Normal View History

2020-07-10 18:39:33 +01:00
package atlas
// Type represents an object type
type Type byte
// Types of objects
const (
2020-07-10 18:39:33 +01:00
// ObjectNone represents no object at all
ObjectNone = Type(0)
2020-06-30 23:59:58 +01:00
2020-07-10 18:39:33 +01:00
// ObjectRover represents a live rover
ObjectRover = Type('R')
2020-06-30 23:59:58 +01:00
2020-07-10 18:39:33 +01:00
// ObjectSmallRock is a small stashable rock
ObjectSmallRock = Type('o')
2020-06-30 23:59:58 +01:00
2020-07-10 18:39:33 +01:00
// ObjectLargeRock is a large blocking rock
ObjectLargeRock = Type('O')
)
// Object represents an object in the world
type Object struct {
Type Type `json:"type"`
}
2020-06-30 23:59:58 +01:00
// IsBlocking checks if an object is a blocking object
func (o *Object) IsBlocking() bool {
var blocking = [...]Type{
2020-07-10 18:39:33 +01:00
ObjectRover,
ObjectLargeRock,
}
for _, t := range blocking {
if o.Type == t {
return true
}
}
return false
}
2020-06-30 23:59:58 +01:00
// IsStashable checks if an object is stashable
func (o *Object) IsStashable() bool {
var stashable = [...]Type{
2020-07-10 18:39:33 +01:00
ObjectSmallRock,
}
for _, t := range stashable {
if o.Type == t {
return true
}
}
return false
}