rove/pkg/atlas/glyph.go

61 lines
1.2 KiB
Go
Raw Normal View History

package atlas
import (
"log"
"github.com/mdiluz/rove/proto/roveapi"
)
// Glyph represents the text representation of something in the game
type Glyph byte
const (
2020-07-19 11:56:05 +01:00
// GlyphGroundRock is solid rock ground
GlyphGroundRock = Glyph('-')
2020-07-19 11:56:05 +01:00
// GlyphGroundGravel is loose rocks
GlyphGroundGravel = Glyph(':')
2020-07-19 11:56:05 +01:00
// GlyphGroundSand is sand
GlyphGroundSand = Glyph('~')
2020-07-19 11:56:05 +01:00
// GlyphRoverLive represents a live rover
GlyphRoverLive = Glyph('R')
2020-07-19 11:56:05 +01:00
// GlyphRockSmall is a small stashable rock
GlyphRockSmall = Glyph('o')
2020-07-19 11:56:05 +01:00
// GlyphRockLarge is a large blocking rock
GlyphRockLarge = Glyph('O')
)
// TileGlyph returns the glyph for this tile type
func TileGlyph(t roveapi.Tile) Glyph {
switch t {
case roveapi.Tile_Rock:
return GlyphGroundRock
case roveapi.Tile_Gravel:
return GlyphGroundGravel
case roveapi.Tile_Sand:
return GlyphGroundSand
}
log.Fatalf("Unknown tile type: %c", t)
return 0
}
// ObjectGlyph returns the glyph for this object type
func ObjectGlyph(o roveapi.Object) Glyph {
switch o {
case roveapi.Object_RoverLive:
return GlyphRoverLive
case roveapi.Object_RockSmall:
return GlyphRockSmall
case roveapi.Object_RockLarge:
return GlyphRockLarge
}
log.Fatalf("Unknown object type: %c", o)
return 0
}