rove/pkg/objects/objects.go

54 lines
877 B
Go
Raw Normal View History

package objects
// Type represents an object type
type Type byte
// Types of objects
const (
// None represents no object at all
None = Type(0)
2020-06-30 23:59:58 +01:00
// Rover represents a live rover
Rover = Type('R')
2020-06-30 23:59:58 +01:00
// SmallRock is a small stashable rock
SmallRock = Type('o')
2020-06-30 23:59:58 +01:00
// LargeRock is a large blocking rock
LargeRock = 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{
Rover,
LargeRock,
}
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{
SmallRock,
}
for _, t := range stashable {
if o.Type == t {
return true
}
}
return false
}