Rename the glyphs
This commit is contained in:
parent
f665436007
commit
7e41ac0028
7 changed files with 52 additions and 52 deletions
|
@ -29,11 +29,11 @@ func (t Tile) Glyph() Glyph {
|
||||||
case TileNone:
|
case TileNone:
|
||||||
return GlyphNone
|
return GlyphNone
|
||||||
case TileRock:
|
case TileRock:
|
||||||
return GlyphRock
|
return GlyphGroundRock
|
||||||
case TileGravel:
|
case TileGravel:
|
||||||
return GlyphGravel
|
return GlyphGroundGravel
|
||||||
case TileSand:
|
case TileSand:
|
||||||
return GlyphSand
|
return GlyphGroundSand
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatalf("Unknown tile type: %c", t)
|
log.Fatalf("Unknown tile type: %c", t)
|
||||||
|
|
|
@ -185,14 +185,14 @@ func TestAtlas_GetSetObject(t *testing.T) {
|
||||||
assert.NotNil(t, a)
|
assert.NotNil(t, a)
|
||||||
|
|
||||||
// Set the origin tile to 1 and test it
|
// Set the origin tile to 1 and test it
|
||||||
a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: ObjectLargeRock})
|
a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: ObjectRockLarge})
|
||||||
_, obj := a.QueryPosition(maths.Vector{X: 0, Y: 0})
|
_, obj := a.QueryPosition(maths.Vector{X: 0, Y: 0})
|
||||||
assert.Equal(t, Object{Type: ObjectLargeRock}, obj)
|
assert.Equal(t, Object{Type: ObjectRockLarge}, obj)
|
||||||
|
|
||||||
// Set another tile to 1 and test it
|
// Set another tile to 1 and test it
|
||||||
a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: ObjectSmallRock})
|
a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: ObjectRockSmall})
|
||||||
_, obj = a.QueryPosition(maths.Vector{X: 5, Y: -2})
|
_, obj = a.QueryPosition(maths.Vector{X: 5, Y: -2})
|
||||||
assert.Equal(t, Object{Type: ObjectSmallRock}, obj)
|
assert.Equal(t, Object{Type: ObjectRockSmall}, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAtlas_Grown(t *testing.T) {
|
func TestAtlas_Grown(t *testing.T) {
|
||||||
|
@ -238,11 +238,11 @@ func TestAtlas_GetSetCorrect(t *testing.T) {
|
||||||
|
|
||||||
pos := maths.Vector{X: x, Y: y}
|
pos := maths.Vector{X: x, Y: y}
|
||||||
a.SetTile(pos, TileRock)
|
a.SetTile(pos, TileRock)
|
||||||
a.SetObject(pos, Object{Type: ObjectLargeRock})
|
a.SetObject(pos, Object{Type: ObjectRockLarge})
|
||||||
tile, obj := a.QueryPosition(pos)
|
tile, obj := a.QueryPosition(pos)
|
||||||
|
|
||||||
assert.Equal(t, TileRock, Tile(tile))
|
assert.Equal(t, TileRock, Tile(tile))
|
||||||
assert.Equal(t, Object{Type: ObjectLargeRock}, obj)
|
assert.Equal(t, Object{Type: ObjectRockLarge}, obj)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,9 +123,9 @@ func (a *chunkBasedAtlas) populate(chunk int) {
|
||||||
var obj = ObjectNone
|
var obj = ObjectNone
|
||||||
switch {
|
switch {
|
||||||
case o > 0.6:
|
case o > 0.6:
|
||||||
obj = ObjectLargeRock
|
obj = ObjectRockLarge
|
||||||
case o > 0.5:
|
case o > 0.5:
|
||||||
obj = ObjectSmallRock
|
obj = ObjectRockSmall
|
||||||
}
|
}
|
||||||
if obj != ObjectNone {
|
if obj != ObjectNone {
|
||||||
c.Objects[j*a.ChunkSize+i] = Object{Type: ObjectType(obj)}
|
c.Objects[j*a.ChunkSize+i] = Object{Type: ObjectType(obj)}
|
||||||
|
@ -136,9 +136,9 @@ func (a *chunkBasedAtlas) populate(chunk int) {
|
||||||
// Set up any objects
|
// Set up any objects
|
||||||
for i := 0; i < len(c.Tiles); i++ {
|
for i := 0; i < len(c.Tiles); i++ {
|
||||||
if rand.Intn(16) == 0 {
|
if rand.Intn(16) == 0 {
|
||||||
c.Objects[i] = Object{Type: ObjectLargeRock}
|
c.Objects[i] = Object{Type: ObjectRockLarge}
|
||||||
} else if rand.Intn(32) == 0 {
|
} else if rand.Intn(32) == 0 {
|
||||||
c.Objects[i] = Object{Type: ObjectSmallRock}
|
c.Objects[i] = Object{Type: ObjectRockSmall}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,21 @@ const (
|
||||||
// GlyphNone is a keyword for nothing
|
// GlyphNone is a keyword for nothing
|
||||||
GlyphNone = Glyph(0)
|
GlyphNone = Glyph(0)
|
||||||
|
|
||||||
// GlyphRock is solid rock ground
|
// GlyphGroundRock is solid rock ground
|
||||||
GlyphRock = Glyph('-')
|
GlyphGroundRock = Glyph('-')
|
||||||
|
|
||||||
// GlyphGravel is loose rocks
|
// GlyphGroundGravel is loose rocks
|
||||||
GlyphGravel = Glyph(':')
|
GlyphGroundGravel = Glyph(':')
|
||||||
|
|
||||||
// GlyphSand is sand
|
// GlyphGroundSand is sand
|
||||||
GlyphSand = Glyph('~')
|
GlyphGroundSand = Glyph('~')
|
||||||
|
|
||||||
// GlyphRover represents a live rover
|
// GlyphRoverLive represents a live rover
|
||||||
GlyphRover = Glyph('R')
|
GlyphRoverLive = Glyph('R')
|
||||||
|
|
||||||
// GlyphSmallRock is a small stashable rock
|
// GlyphRockSmall is a small stashable rock
|
||||||
GlyphSmallRock = Glyph('o')
|
GlyphRockSmall = Glyph('o')
|
||||||
|
|
||||||
// GlyphLargeRock is a large blocking rock
|
// GlyphRockLarge is a large blocking rock
|
||||||
GlyphLargeRock = Glyph('O')
|
GlyphRockLarge = Glyph('O')
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,13 +11,13 @@ const (
|
||||||
ObjectNone = iota
|
ObjectNone = iota
|
||||||
|
|
||||||
// ObjectRover represents a live rover
|
// ObjectRover represents a live rover
|
||||||
ObjectRover
|
ObjectRoverLive
|
||||||
|
|
||||||
// ObjectSmallRock is a small stashable rock
|
// ObjectSmallRock is a small stashable rock
|
||||||
ObjectSmallRock
|
ObjectRockSmall
|
||||||
|
|
||||||
// ObjectLargeRock is a large blocking rock
|
// ObjectLargeRock is a large blocking rock
|
||||||
ObjectLargeRock
|
ObjectRockLarge
|
||||||
)
|
)
|
||||||
|
|
||||||
// Glyph returns the glyph for this object type
|
// Glyph returns the glyph for this object type
|
||||||
|
@ -25,12 +25,12 @@ func (o ObjectType) Glyph() Glyph {
|
||||||
switch o {
|
switch o {
|
||||||
case ObjectNone:
|
case ObjectNone:
|
||||||
return GlyphNone
|
return GlyphNone
|
||||||
case ObjectRover:
|
case ObjectRoverLive:
|
||||||
return GlyphRover
|
return GlyphRoverLive
|
||||||
case ObjectSmallRock:
|
case ObjectRockSmall:
|
||||||
return GlyphSmallRock
|
return GlyphRockSmall
|
||||||
case ObjectLargeRock:
|
case ObjectRockLarge:
|
||||||
return GlyphLargeRock
|
return GlyphRockLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatalf("Unknown object type: %c", o)
|
log.Fatalf("Unknown object type: %c", o)
|
||||||
|
@ -46,8 +46,8 @@ type Object struct {
|
||||||
// IsBlocking checks if an object is a blocking object
|
// IsBlocking checks if an object is a blocking object
|
||||||
func (o *Object) IsBlocking() bool {
|
func (o *Object) IsBlocking() bool {
|
||||||
var blocking = [...]ObjectType{
|
var blocking = [...]ObjectType{
|
||||||
ObjectRover,
|
ObjectRoverLive,
|
||||||
ObjectLargeRock,
|
ObjectRockLarge,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range blocking {
|
for _, t := range blocking {
|
||||||
|
@ -61,7 +61,7 @@ func (o *Object) IsBlocking() bool {
|
||||||
// IsStashable checks if an object is stashable
|
// IsStashable checks if an object is stashable
|
||||||
func (o *Object) IsStashable() bool {
|
func (o *Object) IsStashable() bool {
|
||||||
var stashable = [...]ObjectType{
|
var stashable = [...]ObjectType{
|
||||||
ObjectSmallRock,
|
ObjectRockSmall,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range stashable {
|
for _, t := range stashable {
|
||||||
|
|
|
@ -401,7 +401,7 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err
|
||||||
if dist.X <= r.Range && dist.Y <= r.Range {
|
if dist.X <= r.Range && dist.Y <= r.Range {
|
||||||
relative := r.Pos.Added(radarMin.Negated())
|
relative := r.Pos.Added(radarMin.Negated())
|
||||||
index := relative.X + relative.Y*radarSpan
|
index := relative.X + relative.Y*radarSpan
|
||||||
objs[index] = byte(atlas.ObjectRover)
|
objs[index] = byte(atlas.ObjectRoverLive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) {
|
||||||
assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move")
|
assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move")
|
||||||
|
|
||||||
// Place a tile in front of the rover
|
// Place a tile in front of the rover
|
||||||
world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: atlas.ObjectLargeRock})
|
world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: atlas.ObjectRockLarge})
|
||||||
newPos, err = world.MoveRover(a, b)
|
newPos, err = world.MoveRover(a, b)
|
||||||
assert.NoError(t, err, "Failed to move rover")
|
assert.NoError(t, err, "Failed to move rover")
|
||||||
assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall")
|
assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall")
|
||||||
|
@ -120,8 +120,8 @@ func TestWorld_RadarFromRover(t *testing.T) {
|
||||||
assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length")
|
assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length")
|
||||||
|
|
||||||
// Test the expected values
|
// Test the expected values
|
||||||
assert.Equal(t, byte(atlas.ObjectRover), objs[1+fullRange])
|
assert.Equal(t, byte(atlas.ObjectRoverLive), objs[1+fullRange])
|
||||||
assert.Equal(t, byte(atlas.ObjectRover), objs[4+4*fullRange])
|
assert.Equal(t, byte(atlas.ObjectRoverLive), objs[4+4*fullRange])
|
||||||
|
|
||||||
// Check the radar results are stable
|
// Check the radar results are stable
|
||||||
radar1, objs1, err := world.RadarFromRover(a)
|
radar1, objs1, err := world.RadarFromRover(a)
|
||||||
|
@ -154,12 +154,12 @@ func TestWorld_RoverStash(t *testing.T) {
|
||||||
|
|
||||||
for i := 0; i < rover.Capacity; i++ {
|
for i := 0; i < rover.Capacity; i++ {
|
||||||
// Place an object
|
// Place an object
|
||||||
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock})
|
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall})
|
||||||
|
|
||||||
// Pick it up
|
// Pick it up
|
||||||
o, err := world.RoverStash(a)
|
o, err := world.RoverStash(a)
|
||||||
assert.NoError(t, err, "Failed to stash")
|
assert.NoError(t, err, "Failed to stash")
|
||||||
assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object")
|
assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object")
|
||||||
|
|
||||||
// Check it's gone
|
// Check it's gone
|
||||||
_, obj := world.Atlas.QueryPosition(pos)
|
_, obj := world.Atlas.QueryPosition(pos)
|
||||||
|
@ -169,7 +169,7 @@ func TestWorld_RoverStash(t *testing.T) {
|
||||||
inv, err := world.RoverInventory(a)
|
inv, err := world.RoverInventory(a)
|
||||||
assert.NoError(t, err, "Failed to get inventory")
|
assert.NoError(t, err, "Failed to get inventory")
|
||||||
assert.Equal(t, i+1, len(inv))
|
assert.Equal(t, i+1, len(inv))
|
||||||
assert.Equal(t, atlas.Object{Type: atlas.ObjectSmallRock}, inv[i])
|
assert.Equal(t, atlas.Object{Type: atlas.ObjectRockSmall}, inv[i])
|
||||||
|
|
||||||
// Check that this did reduce the charge
|
// Check that this did reduce the charge
|
||||||
info, err := world.GetRover(a)
|
info, err := world.GetRover(a)
|
||||||
|
@ -186,7 +186,7 @@ func TestWorld_RoverStash(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place an object
|
// Place an object
|
||||||
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock})
|
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall})
|
||||||
|
|
||||||
// Try to pick it up
|
// Try to pick it up
|
||||||
o, err := world.RoverStash(a)
|
o, err := world.RoverStash(a)
|
||||||
|
@ -195,7 +195,7 @@ func TestWorld_RoverStash(t *testing.T) {
|
||||||
|
|
||||||
// Check it's still there
|
// Check it's still there
|
||||||
_, obj := world.Atlas.QueryPosition(pos)
|
_, obj := world.Atlas.QueryPosition(pos)
|
||||||
assert.Equal(t, atlas.ObjectSmallRock, obj.Type, "Stash failed to remove object from atlas")
|
assert.Equal(t, atlas.ObjectRockSmall, obj.Type, "Stash failed to remove object from atlas")
|
||||||
|
|
||||||
// Check we don't have it
|
// Check we don't have it
|
||||||
inv, err := world.RoverInventory(a)
|
inv, err := world.RoverInventory(a)
|
||||||
|
@ -224,7 +224,7 @@ func TestWorld_RoverDamage(t *testing.T) {
|
||||||
info, err := world.GetRover(a)
|
info, err := world.GetRover(a)
|
||||||
assert.NoError(t, err, "couldn't get rover info")
|
assert.NoError(t, err, "couldn't get rover info")
|
||||||
|
|
||||||
world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectLargeRock})
|
world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectRockLarge})
|
||||||
|
|
||||||
vec, err := world.MoveRover(a, maths.North)
|
vec, err := world.MoveRover(a, maths.North)
|
||||||
assert.NoError(t, err, "Failed to move rover")
|
assert.NoError(t, err, "Failed to move rover")
|
||||||
|
@ -256,12 +256,12 @@ func TestWorld_RoverRepair(t *testing.T) {
|
||||||
assert.NoError(t, err, "couldn't get rover info")
|
assert.NoError(t, err, "couldn't get rover info")
|
||||||
|
|
||||||
// Pick up something to repair with
|
// Pick up something to repair with
|
||||||
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock})
|
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall})
|
||||||
o, err := world.RoverStash(a)
|
o, err := world.RoverStash(a)
|
||||||
assert.NoError(t, err, "Failed to stash")
|
assert.NoError(t, err, "Failed to stash")
|
||||||
assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object")
|
assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object")
|
||||||
|
|
||||||
world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectLargeRock})
|
world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectRockLarge})
|
||||||
|
|
||||||
// Try and bump into the rock
|
// Try and bump into the rock
|
||||||
vec, err := world.MoveRover(a, maths.North)
|
vec, err := world.MoveRover(a, maths.North)
|
||||||
|
@ -281,10 +281,10 @@ func TestWorld_RoverRepair(t *testing.T) {
|
||||||
assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair")
|
assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair")
|
||||||
|
|
||||||
// Check again that it can't repair past the max
|
// Check again that it can't repair past the max
|
||||||
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock})
|
world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall})
|
||||||
o, err = world.RoverStash(a)
|
o, err = world.RoverStash(a)
|
||||||
assert.NoError(t, err, "Failed to stash")
|
assert.NoError(t, err, "Failed to stash")
|
||||||
assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object")
|
assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object")
|
||||||
|
|
||||||
err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a)
|
err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a)
|
||||||
assert.NoError(t, err, "Failed to repair rover")
|
assert.NoError(t, err, "Failed to repair rover")
|
||||||
|
|
Loading…
Add table
Reference in a new issue