diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e898004..db313b7 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,10 @@
-
+
-
-
+
+
@@ -37,17 +37,17 @@
-
+
-
+
-
-
+
+
@@ -56,7 +56,7 @@
-
+
@@ -66,7 +66,7 @@
-
+
@@ -76,7 +76,7 @@
-
+
@@ -86,7 +86,7 @@
-
+
@@ -96,38 +96,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -174,20 +174,20 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -481,7 +481,7 @@
-
+
@@ -763,38 +763,50 @@
1458500376151
-
+
+ 1458502044397
+
+
+ 1458502044397
+
+
+ 1458504793092
+
+
+ 1458504793092
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -809,20 +821,20 @@
-
+
-
+
-
+
-
+
@@ -850,8 +862,6 @@
-
-
@@ -875,7 +885,9 @@
-
+
+
+
@@ -1192,104 +1204,105 @@
-
+
-
-
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
diff --git a/src/Coffee/Map.php b/src/Coffee/Map.php
index d35b1de..67ba5eb 100644
--- a/src/Coffee/Map.php
+++ b/src/Coffee/Map.php
@@ -70,28 +70,6 @@ class Map {
return $this->tiles;
}
- /**
- * @return Tile[]
- */
- public function getUnvisitedTiles() {
- $array = [];
- foreach ($this->getTiles() as $tile) {
- if (!$tile->isVisited()) {
- $array[] = $tile;
- }
- }
- return $array;
- }
-
- public function getUnvisitedTile() {
- foreach ($this->getTiles() as $tile) {
- if (!$tile->isVisited()) {
- return $tile;
- }
- }
-
- return false;
- }
/**
* @param Position $position
diff --git a/src/Coffee/Table.php b/src/Coffee/Table.php
index eb5ecb9..0fed0a8 100644
--- a/src/Coffee/Table.php
+++ b/src/Coffee/Table.php
@@ -98,7 +98,7 @@ class Table {
$this->updateCurrentSpot($currentTile->getPosition());
- // Recursion
+ // TODO: Replace recursion by iteration
$this->recurseMap($currentTile);
$this->addCurrentSpot(); // (to this table)
diff --git a/src/Coffee/Tile.php b/src/Coffee/Tile.php
index 66f2032..7759c40 100644
--- a/src/Coffee/Tile.php
+++ b/src/Coffee/Tile.php
@@ -29,11 +29,17 @@ class Tile extends Position {
/**
* Tiles are inherently unvisited
- *
* @var bool
*/
private $visited = false;
+ /**
+ * Zero means that the tile is not in the spot
+ *
+ * @var int
+ */
+ private $spotNumber = 0;
+
/**
* Tile constructor.
*
@@ -94,4 +100,18 @@ class Tile extends Position {
return new Position($this->getRow(), $this->getColumn());
}
+ /**
+ * @return int
+ */
+ public function getSpotNumber() {
+ return $this->spotNumber;
+ }
+
+ /**
+ * @param int $spotNumber
+ */
+ public function setSpotNumber($spotNumber) {
+ $this->spotNumber = $spotNumber;
+ }
+
}
\ No newline at end of file
diff --git a/tests/Coffee/MapTest.php b/tests/Coffee/MapTest.php
index af7f95c..4612c16 100644
--- a/tests/Coffee/MapTest.php
+++ b/tests/Coffee/MapTest.php
@@ -15,38 +15,6 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals([$tileA, $tileB], $map->getTiles());
}
- public function testUnvisitedTile() {
- $description = [
- [1, 0],
- [0, 1],
- ];
-
- $map = new Map($description);
- $tiles = $map->getTiles();
- $tiles[0]->visit();
- $tiles[3]->visit();
-
- $tile = new Tile(1, 2, Tile::REPRESENTS_VOID);
-
- $this->assertEquals($tile, $map->getUnvisitedTile());
- }
-
- public function testUnVisitedTiles() {
- $description = [
- [1, 0],
- [0, 1],
- ];
-
- $map = new Map($description);
- $tiles = $map->getTiles();
- $tiles[2]->visit();
- $tiles[3]->visit();
-
- $tileA = new Tile(1, 1, Tile::REPRESENTS_SPOT);
- $tileB = new Tile(1, 2, Tile::REPRESENTS_VOID);
-
- $this->assertEquals([$tileA, $tileB], $map->getUnvisitedTiles());
- }
public function testDescribedByArray() {
$description = [
@@ -121,57 +89,4 @@ class MapTest extends \PHPUnit_Framework_TestCase {
}
-// public function testValidPosition() {
-// $description = [
-// [0, 1, 0, 1],
-// [1, 0, 0, 0],
-// [0, 0, 0, 1],
-// [0, 0, 0, 1]
-// ];
-//
-// $map = new Map($description);
-// $position = new Position(3, 1);
-// $this->assertTrue($map->hasValidPosition($position));
-// }
-//
-// public function testInvalidPosition() {
-// $description = [
-// [0, 1, 0, 1],
-// [1, 0, 0, 0],
-// [0, 0, 0, 1],
-// [0, 0, 0, 1]
-// ];
-//
-// $map = new Map($description);
-// $position = new Position(4, 5);
-// $this->assertFalse($map->hasValidPosition($position));
-// }
-//
-// public function testUnvisitedPosition() {
-// $description = [
-// [0, 1, 0, 1],
-// [1, 0, 0, 0],
-// [0, 0, 0, 1],
-// [0, 0, 0, 1]
-// ];
-//
-// $map = new Map($description);
-// $position = new Position(1, 1);
-// $this->assertFalse($map->isVisitedPosition($position));
-// }
-//
-// public function testVisitedPosition() {
-// $description = [
-// [0, 1, 0, 1],
-// [1, 0, 0, 0],
-// [0, 0, 0, 1],
-// [0, 0, 0, 1]
-// ];
-//
-// $map = new Map($description);
-// $position = new Position(1, 1);
-// $map->visitPosition($position);
-// $this->assertTrue($map->isVisitedPosition($position));
-// }
-
}
diff --git a/tests/Coffee/TileTest.php b/tests/Coffee/TileTest.php
index 2ea3cb2..c74c8b3 100644
--- a/tests/Coffee/TileTest.php
+++ b/tests/Coffee/TileTest.php
@@ -37,4 +37,11 @@ class TileTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue($tile->isVisited());
}
+ public function testSpotNumber() {
+ $tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
+ $tile->setSpotNumber(4);
+
+ $this->assertEquals(4, $tile->getSpotNumber());
+ }
+
}