From cb725c96d27a772dc3a11c990440d002cf30aedf Mon Sep 17 00:00:00 2001
From: Marc Di Luzio <marc.diluzio@gmail.com>
Date: Sun, 7 Jun 2020 18:38:46 +0100
Subject: [PATCH] Rename Kind -> Tile

---
 pkg/game/atlas.go      | 11 ++++-------
 pkg/game/atlas_test.go | 16 ++++++++--------
 pkg/game/tile.go       | 10 ++++++++++
 3 files changed, 22 insertions(+), 15 deletions(-)
 create mode 100644 pkg/game/tile.go

diff --git a/pkg/game/atlas.go b/pkg/game/atlas.go
index 90144ee..88bc73e 100644
--- a/pkg/game/atlas.go
+++ b/pkg/game/atlas.go
@@ -5,13 +5,10 @@ import (
 	"log"
 )
 
-// Kind represents the type of a tile on the map
-type Kind byte
-
 // Chunk represents a fixed square grid of tiles
 type Chunk struct {
 	// Tiles represents the tiles within the chunk
-	Tiles []Kind `json:"tiles"`
+	Tiles []Tile `json:"tiles"`
 }
 
 // Atlas represents a grid of Chunks
@@ -42,7 +39,7 @@ func NewAtlas(size int, chunkSize int) Atlas {
 	// Initialise all the chunks
 	for i := range a.Chunks {
 		a.Chunks[i] = Chunk{
-			Tiles: make([]Kind, chunkSize*chunkSize),
+			Tiles: make([]Tile, chunkSize*chunkSize),
 		}
 	}
 
@@ -50,7 +47,7 @@ func NewAtlas(size int, chunkSize int) Atlas {
 }
 
 // SetTile sets an individual tile's kind
-func (a *Atlas) SetTile(v Vector, tile Kind) error {
+func (a *Atlas) SetTile(v Vector, tile Tile) error {
 	chunk := a.ToChunk(v)
 	if chunk >= len(a.Chunks) {
 		return fmt.Errorf("location outside of allocated atlas")
@@ -66,7 +63,7 @@ func (a *Atlas) SetTile(v Vector, tile Kind) error {
 }
 
 // GetTile will return an individual tile
-func (a *Atlas) GetTile(v Vector) (Kind, error) {
+func (a *Atlas) GetTile(v Vector) (Tile, error) {
 	chunk := a.ToChunk(v)
 	if chunk > len(a.Chunks) {
 		return 0, fmt.Errorf("location outside of allocated atlas")
diff --git a/pkg/game/atlas_test.go b/pkg/game/atlas_test.go
index f0f32f7..99fe5f4 100644
--- a/pkg/game/atlas_test.go
+++ b/pkg/game/atlas_test.go
@@ -80,13 +80,13 @@ func TestAtlas_GetSetTile(t *testing.T) {
 	assert.NoError(t, a.SetTile(Vector{0, 0}, 1))
 	tile, err := a.GetTile(Vector{0, 0})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(1), tile)
+	assert.Equal(t, Tile(1), tile)
 
 	// Set another tile to 1 and test it
 	assert.NoError(t, a.SetTile(Vector{5, -2}, 2))
 	tile, err = a.GetTile(Vector{5, -2})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(2), tile)
+	assert.Equal(t, Tile(2), tile)
 }
 
 func TestAtlas_Grown(t *testing.T) {
@@ -107,15 +107,15 @@ func TestAtlas_Grown(t *testing.T) {
 
 	tile, err := a.GetTile(Vector{0, 0})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(1), tile)
+	assert.Equal(t, Tile(1), tile)
 
 	tile, err = a.GetTile(Vector{-1, -1})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(2), tile)
+	assert.Equal(t, Tile(2), tile)
 
 	tile, err = a.GetTile(Vector{1, -2})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(3), tile)
+	assert.Equal(t, Tile(3), tile)
 
 	// Grow it again even bigger
 	err = a.Grow(10)
@@ -124,13 +124,13 @@ func TestAtlas_Grown(t *testing.T) {
 
 	tile, err = a.GetTile(Vector{0, 0})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(1), tile)
+	assert.Equal(t, Tile(1), tile)
 
 	tile, err = a.GetTile(Vector{-1, -1})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(2), tile)
+	assert.Equal(t, Tile(2), tile)
 
 	tile, err = a.GetTile(Vector{1, -2})
 	assert.NoError(t, err)
-	assert.Equal(t, Kind(3), tile)
+	assert.Equal(t, Tile(3), tile)
 }
diff --git a/pkg/game/tile.go b/pkg/game/tile.go
new file mode 100644
index 0000000..9500cfe
--- /dev/null
+++ b/pkg/game/tile.go
@@ -0,0 +1,10 @@
+package game
+
+// Tile represents the type of a tile on the map
+type Tile byte
+
+const (
+	TileEmpty = '_'
+
+	TileRock = 'o'
+)