rove/pkg/atlas/objects.go

55 lines
1 KiB
Go
Raw Normal View History

2020-07-10 18:39:33 +01:00
package atlas
2020-07-19 11:47:19 +01:00
// ObjectType represents an object type
type ObjectType byte
// Types of objects
const (
2020-07-10 18:39:33 +01:00
// ObjectNone represents no object at all
2020-07-19 11:47:19 +01:00
ObjectNone = ObjectType(GlyphNone)
2020-06-30 23:59:58 +01:00
2020-07-10 18:39:33 +01:00
// ObjectRover represents a live rover
2020-07-19 11:47:19 +01:00
ObjectRover = ObjectType(GlyphRover)
2020-06-30 23:59:58 +01:00
2020-07-10 18:39:33 +01:00
// ObjectSmallRock is a small stashable rock
2020-07-19 11:47:19 +01:00
ObjectSmallRock = ObjectType(GlyphSmallRock)
2020-06-30 23:59:58 +01:00
2020-07-10 18:39:33 +01:00
// ObjectLargeRock is a large blocking rock
2020-07-19 11:47:19 +01:00
ObjectLargeRock = ObjectType(GlyphLargeRock)
)
// Object represents an object in the world
type Object struct {
2020-07-19 11:47:19 +01:00
// The type of the object
Type ObjectType `json:"type"`
}
2020-06-30 23:59:58 +01:00
// IsBlocking checks if an object is a blocking object
func (o *Object) IsBlocking() bool {
2020-07-19 11:47:19 +01:00
var blocking = [...]ObjectType{
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 {
2020-07-19 11:47:19 +01:00
var stashable = [...]ObjectType{
2020-07-10 18:39:33 +01:00
ObjectSmallRock,
}
for _, t := range stashable {
if o.Type == t {
return true
}
}
return false
}