Exemplo n.º 1
0
func _TestAddTile(t *testing.T) {
	var cont *env.Controller
	var state TileState
	var tile env.ITile
	var neigh env.ITile
	var x, y int

	cont = createDummyEnvController()
	tile = cont.GetStartingTile()
	state.AddDiscovery(tile)
	x, y = tile.GetIndices()

	if state.tiles[x][y].tile != tile {
		t.Error("Non-matching tile-state")
	}

	if !state.tiles[x][y].explored {
		t.Error("Discovered tile is not flagged as explored")
	}

	neigh = tile.GetNeighbour(env.RIGHT)
	state.AddDiscovery(neigh)

	if state.tiles[x+1][y].tile != neigh {
		t.Error("Non-matching tile-state")
	}
}
Exemplo n.º 2
0
func (t *TileState) GetTileStatus(tile env.ITile, dir env.Direction) Status {
	var x, y int

	x, y = tile.GetIndices()
	dx, dy := env.GetIndices(dir)
	x += dx
	y += dy

	return t.GetTileStatusAtCoord(x, y)
}
Exemplo n.º 3
0
/*
=======================
Implementation
=======================
*/
func (t *TileState) AddDiscovery(tile env.ITile) {
	var x, y int
	var twrap TileWrapper

	x, y = tile.GetIndices()

	// Create a new TileWrapper
	twrap.tile = tile
	t.tiles[x][y] = twrap
	t.tiles[x][y].explored = true
}