73 lines
1.3 KiB
Go
73 lines
1.3 KiB
Go
package atlas
|
|
|
|
import "log"
|
|
|
|
// ObjectType represents an object type
|
|
type ObjectType byte
|
|
|
|
// Types of objects
|
|
const (
|
|
// ObjectNone represents no object at all
|
|
ObjectNone = ObjectType(0)
|
|
|
|
// ObjectRover represents a live rover
|
|
ObjectRoverLive = ObjectType(1)
|
|
|
|
// ObjectSmallRock is a small stashable rock
|
|
ObjectRockSmall = ObjectType(2)
|
|
|
|
// ObjectLargeRock is a large blocking rock
|
|
ObjectRockLarge = ObjectType(3)
|
|
)
|
|
|
|
// Glyph returns the glyph for this object type
|
|
func (o ObjectType) Glyph() Glyph {
|
|
switch o {
|
|
case ObjectNone:
|
|
return GlyphNone
|
|
case ObjectRoverLive:
|
|
return GlyphRoverLive
|
|
case ObjectRockSmall:
|
|
return GlyphRockSmall
|
|
case ObjectRockLarge:
|
|
return GlyphRockLarge
|
|
}
|
|
|
|
log.Fatalf("Unknown object type: %c", o)
|
|
return GlyphNone
|
|
}
|
|
|
|
// Object represents an object in the world
|
|
type Object struct {
|
|
// The type of the object
|
|
Type ObjectType `json:"type"`
|
|
}
|
|
|
|
// IsBlocking checks if an object is a blocking object
|
|
func (o *Object) IsBlocking() bool {
|
|
var blocking = [...]ObjectType{
|
|
ObjectRoverLive,
|
|
ObjectRockLarge,
|
|
}
|
|
|
|
for _, t := range blocking {
|
|
if o.Type == t {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// IsStashable checks if an object is stashable
|
|
func (o *Object) IsStashable() bool {
|
|
var stashable = [...]ObjectType{
|
|
ObjectRockSmall,
|
|
}
|
|
|
|
for _, t := range stashable {
|
|
if o.Type == t {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|