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:
 | 
			
		||||
		return GlyphNone
 | 
			
		||||
	case TileRock:
 | 
			
		||||
		return GlyphRock
 | 
			
		||||
		return GlyphGroundRock
 | 
			
		||||
	case TileGravel:
 | 
			
		||||
		return GlyphGravel
 | 
			
		||||
		return GlyphGroundGravel
 | 
			
		||||
	case TileSand:
 | 
			
		||||
		return GlyphSand
 | 
			
		||||
		return GlyphGroundSand
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Fatalf("Unknown tile type: %c", t)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -185,14 +185,14 @@ func TestAtlas_GetSetObject(t *testing.T) {
 | 
			
		|||
	assert.NotNil(t, a)
 | 
			
		||||
 | 
			
		||||
	// 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})
 | 
			
		||||
	assert.Equal(t, Object{Type: ObjectLargeRock}, obj)
 | 
			
		||||
	assert.Equal(t, Object{Type: ObjectRockLarge}, obj)
 | 
			
		||||
 | 
			
		||||
	// 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})
 | 
			
		||||
	assert.Equal(t, Object{Type: ObjectSmallRock}, obj)
 | 
			
		||||
	assert.Equal(t, Object{Type: ObjectRockSmall}, obj)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestAtlas_Grown(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -238,11 +238,11 @@ func TestAtlas_GetSetCorrect(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
				pos := maths.Vector{X: x, Y: y}
 | 
			
		||||
				a.SetTile(pos, TileRock)
 | 
			
		||||
				a.SetObject(pos, Object{Type: ObjectLargeRock})
 | 
			
		||||
				a.SetObject(pos, Object{Type: ObjectRockLarge})
 | 
			
		||||
				tile, obj := a.QueryPosition(pos)
 | 
			
		||||
 | 
			
		||||
				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
 | 
			
		||||
			switch {
 | 
			
		||||
			case o > 0.6:
 | 
			
		||||
				obj = ObjectLargeRock
 | 
			
		||||
				obj = ObjectRockLarge
 | 
			
		||||
			case o > 0.5:
 | 
			
		||||
				obj = ObjectSmallRock
 | 
			
		||||
				obj = ObjectRockSmall
 | 
			
		||||
			}
 | 
			
		||||
			if obj != ObjectNone {
 | 
			
		||||
				c.Objects[j*a.ChunkSize+i] = Object{Type: ObjectType(obj)}
 | 
			
		||||
| 
						 | 
				
			
			@ -136,9 +136,9 @@ func (a *chunkBasedAtlas) populate(chunk int) {
 | 
			
		|||
	// Set up any objects
 | 
			
		||||
	for i := 0; i < len(c.Tiles); i++ {
 | 
			
		||||
		if rand.Intn(16) == 0 {
 | 
			
		||||
			c.Objects[i] = Object{Type: ObjectLargeRock}
 | 
			
		||||
			c.Objects[i] = Object{Type: ObjectRockLarge}
 | 
			
		||||
		} 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 = Glyph(0)
 | 
			
		||||
 | 
			
		||||
	// GlyphRock is solid rock ground
 | 
			
		||||
	GlyphRock = Glyph('-')
 | 
			
		||||
	// GlyphGroundRock is solid rock ground
 | 
			
		||||
	GlyphGroundRock = Glyph('-')
 | 
			
		||||
 | 
			
		||||
	// GlyphGravel is loose rocks
 | 
			
		||||
	GlyphGravel = Glyph(':')
 | 
			
		||||
	// GlyphGroundGravel is loose rocks
 | 
			
		||||
	GlyphGroundGravel = Glyph(':')
 | 
			
		||||
 | 
			
		||||
	// GlyphSand is sand
 | 
			
		||||
	GlyphSand = Glyph('~')
 | 
			
		||||
	// GlyphGroundSand is sand
 | 
			
		||||
	GlyphGroundSand = Glyph('~')
 | 
			
		||||
 | 
			
		||||
	// GlyphRover represents a live rover
 | 
			
		||||
	GlyphRover = Glyph('R')
 | 
			
		||||
	// GlyphRoverLive represents a live rover
 | 
			
		||||
	GlyphRoverLive = Glyph('R')
 | 
			
		||||
 | 
			
		||||
	// GlyphSmallRock is a small stashable rock
 | 
			
		||||
	GlyphSmallRock = Glyph('o')
 | 
			
		||||
	// GlyphRockSmall is a small stashable rock
 | 
			
		||||
	GlyphRockSmall = Glyph('o')
 | 
			
		||||
 | 
			
		||||
	// GlyphLargeRock is a large blocking rock
 | 
			
		||||
	GlyphLargeRock = Glyph('O')
 | 
			
		||||
	// GlyphRockLarge is a large blocking rock
 | 
			
		||||
	GlyphRockLarge = Glyph('O')
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,13 +11,13 @@ const (
 | 
			
		|||
	ObjectNone = iota
 | 
			
		||||
 | 
			
		||||
	// ObjectRover represents a live rover
 | 
			
		||||
	ObjectRover
 | 
			
		||||
	ObjectRoverLive
 | 
			
		||||
 | 
			
		||||
	// ObjectSmallRock is a small stashable rock
 | 
			
		||||
	ObjectSmallRock
 | 
			
		||||
	ObjectRockSmall
 | 
			
		||||
 | 
			
		||||
	// ObjectLargeRock is a large blocking rock
 | 
			
		||||
	ObjectLargeRock
 | 
			
		||||
	ObjectRockLarge
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Glyph returns the glyph for this object type
 | 
			
		||||
| 
						 | 
				
			
			@ -25,12 +25,12 @@ func (o ObjectType) Glyph() Glyph {
 | 
			
		|||
	switch o {
 | 
			
		||||
	case ObjectNone:
 | 
			
		||||
		return GlyphNone
 | 
			
		||||
	case ObjectRover:
 | 
			
		||||
		return GlyphRover
 | 
			
		||||
	case ObjectSmallRock:
 | 
			
		||||
		return GlyphSmallRock
 | 
			
		||||
	case ObjectLargeRock:
 | 
			
		||||
		return GlyphLargeRock
 | 
			
		||||
	case ObjectRoverLive:
 | 
			
		||||
		return GlyphRoverLive
 | 
			
		||||
	case ObjectRockSmall:
 | 
			
		||||
		return GlyphRockSmall
 | 
			
		||||
	case ObjectRockLarge:
 | 
			
		||||
		return GlyphRockLarge
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Fatalf("Unknown object type: %c", o)
 | 
			
		||||
| 
						 | 
				
			
			@ -46,8 +46,8 @@ type Object struct {
 | 
			
		|||
// IsBlocking checks if an object is a blocking object
 | 
			
		||||
func (o *Object) IsBlocking() bool {
 | 
			
		||||
	var blocking = [...]ObjectType{
 | 
			
		||||
		ObjectRover,
 | 
			
		||||
		ObjectLargeRock,
 | 
			
		||||
		ObjectRoverLive,
 | 
			
		||||
		ObjectRockLarge,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, t := range blocking {
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ func (o *Object) IsBlocking() bool {
 | 
			
		|||
// IsStashable checks if an object is stashable
 | 
			
		||||
func (o *Object) IsStashable() bool {
 | 
			
		||||
	var stashable = [...]ObjectType{
 | 
			
		||||
		ObjectSmallRock,
 | 
			
		||||
		ObjectRockSmall,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	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 {
 | 
			
		||||
			relative := r.Pos.Added(radarMin.Negated())
 | 
			
		||||
			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")
 | 
			
		||||
 | 
			
		||||
	// 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)
 | 
			
		||||
	assert.NoError(t, err, "Failed to move rover")
 | 
			
		||||
	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")
 | 
			
		||||
 | 
			
		||||
	// Test the expected values
 | 
			
		||||
	assert.Equal(t, byte(atlas.ObjectRover), objs[1+fullRange])
 | 
			
		||||
	assert.Equal(t, byte(atlas.ObjectRover), objs[4+4*fullRange])
 | 
			
		||||
	assert.Equal(t, byte(atlas.ObjectRoverLive), objs[1+fullRange])
 | 
			
		||||
	assert.Equal(t, byte(atlas.ObjectRoverLive), objs[4+4*fullRange])
 | 
			
		||||
 | 
			
		||||
	// Check the radar results are stable
 | 
			
		||||
	radar1, objs1, err := world.RadarFromRover(a)
 | 
			
		||||
| 
						 | 
				
			
			@ -154,12 +154,12 @@ func TestWorld_RoverStash(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	for i := 0; i < rover.Capacity; i++ {
 | 
			
		||||
		// Place an object
 | 
			
		||||
		world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock})
 | 
			
		||||
		world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall})
 | 
			
		||||
 | 
			
		||||
		// Pick it up
 | 
			
		||||
		o, err := world.RoverStash(a)
 | 
			
		||||
		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
 | 
			
		||||
		_, obj := world.Atlas.QueryPosition(pos)
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ func TestWorld_RoverStash(t *testing.T) {
 | 
			
		|||
		inv, err := world.RoverInventory(a)
 | 
			
		||||
		assert.NoError(t, err, "Failed to get inventory")
 | 
			
		||||
		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
 | 
			
		||||
		info, err := world.GetRover(a)
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +186,7 @@ func TestWorld_RoverStash(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	// 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
 | 
			
		||||
	o, err := world.RoverStash(a)
 | 
			
		||||
| 
						 | 
				
			
			@ -195,7 +195,7 @@ func TestWorld_RoverStash(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	// Check it's still there
 | 
			
		||||
	_, 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
 | 
			
		||||
	inv, err := world.RoverInventory(a)
 | 
			
		||||
| 
						 | 
				
			
			@ -224,7 +224,7 @@ func TestWorld_RoverDamage(t *testing.T) {
 | 
			
		|||
	info, err := world.GetRover(a)
 | 
			
		||||
	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)
 | 
			
		||||
	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")
 | 
			
		||||
 | 
			
		||||
	// 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)
 | 
			
		||||
	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
 | 
			
		||||
	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")
 | 
			
		||||
 | 
			
		||||
	// 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)
 | 
			
		||||
	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)
 | 
			
		||||
	assert.NoError(t, err, "Failed to repair rover")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue