rove/pkg/atlas/objects.go

60 lines
1.1 KiB
Go
Raw Normal View History

2020-07-10 18:39:33 +01:00
package atlas
import (
"log"
"github.com/mdiluz/rove/proto/roveapi"
)
// ObjectGlyph returns the glyph for this object type
func ObjectGlyph(o roveapi.Object) Glyph {
switch o {
case roveapi.Object_ObjectNone:
return GlyphNone
case roveapi.Object_RoverLive:
2020-07-19 11:56:05 +01:00
return GlyphRoverLive
case roveapi.Object_RockSmall:
2020-07-19 11:56:05 +01:00
return GlyphRockSmall
case roveapi.Object_RockLarge:
2020-07-19 11:56:05 +01:00
return GlyphRockLarge
}
log.Fatalf("Unknown object type: %c", o)
return GlyphNone
}
// Object represents an object in the world
type Object struct {
2020-07-19 11:47:19 +01:00
// The type of the object
Type roveapi.Object `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 = [...]roveapi.Object{
roveapi.Object_RoverLive,
roveapi.Object_RockLarge,
}
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 = [...]roveapi.Object{
roveapi.Object_RockSmall,
}
for _, t := range stashable {
if o.Type == t {
return true
}
}
return false
}