Implement Tile.isVisited

master
Peter Babič 8 years ago
parent f7b58eeb0e
commit 3e81e4d424
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 114
      .idea/workspace.xml
  2. 4
      src/Coffee/Map.php
  3. 37
      src/Coffee/Tile.php
  4. 2
      tests/Coffee/MapTest.php
  5. 18
      tests/Coffee/TileTest.php

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Map.getTileByPosition and do some refactoring"> <list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Tile.representsVoid">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.php" afterPath="$PROJECT_DIR$/index.php" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Map.php" afterPath="$PROJECT_DIR$/src/Coffee/Map.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Tile.php" afterPath="$PROJECT_DIR$/src/Coffee/Tile.php" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Tile.php" afterPath="$PROJECT_DIR$/src/Coffee/Tile.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/MapTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TileTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TileTest.php" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TileTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
</list> </list>
<ignored path="coffeetable.iws" /> <ignored path="coffeetable.iws" />
@ -34,7 +35,7 @@
<file leaf-file-name="index.php" pinned="false" current-in-tab="false"> <file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.php"> <entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-4.6666665"> <state vertical-scroll-proportion="0.0">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="5" /> <caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="5" />
<folding /> <folding />
</state> </state>
@ -64,7 +65,7 @@
<file leaf-file-name="Position.php" pinned="false" current-in-tab="false"> <file leaf-file-name="Position.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-11.333333"> <state vertical-scroll-proportion="0.0">
<caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" /> <caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" />
<folding /> <folding />
</state> </state>
@ -74,7 +75,7 @@
<file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false"> <file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php"> <entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-7.9259257"> <state vertical-scroll-proportion="0.0">
<caret line="125" column="45" selection-start-line="125" selection-start-column="45" selection-end-line="125" selection-end-column="45" /> <caret line="125" column="45" selection-start-line="125" selection-start-column="45" selection-end-line="125" selection-end-column="45" />
<folding /> <folding />
</state> </state>
@ -84,7 +85,7 @@
<file leaf-file-name="Map.php" pinned="false" current-in-tab="false"> <file leaf-file-name="Map.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-13.407408"> <state vertical-scroll-proportion="-19.703703">
<caret line="133" column="0" selection-start-line="133" selection-start-column="0" selection-end-line="133" selection-end-column="0" /> <caret line="133" column="0" selection-start-line="133" selection-start-column="0" selection-end-line="133" selection-end-column="0" />
<folding /> <folding />
</state> </state>
@ -94,7 +95,7 @@
<file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false"> <file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php"> <entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="22.962963"> <state vertical-scroll-proportion="-12.0">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" /> <caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<folding /> <folding />
</state> </state>
@ -114,8 +115,8 @@
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="true"> <file leaf-file-name="Tile.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.99642855"> <state vertical-scroll-proportion="0.30213904">
<caret line="58" column="65" selection-start-line="58" selection-start-column="65" selection-end-line="58" selection-end-column="65" /> <caret line="58" column="0" selection-start-line="58" selection-start-column="0" selection-end-line="58" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -124,8 +125,8 @@
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false"> <file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-14.666667"> <state vertical-scroll-proportion="-22.37037">
<caret line="22" column="61" selection-start-line="22" selection-start-column="61" selection-end-line="22" selection-end-column="61" /> <caret line="36" column="44" selection-start-line="36" selection-start-column="44" selection-end-line="36" selection-end-column="44" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -345,6 +346,21 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
<PATH_ELEMENT USER_OBJECT="coffeetable">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<PATH> <PATH>
@ -401,21 +417,6 @@
</PATH> </PATH>
</subPane> </subPane>
</pane> </pane>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
<PATH_ELEMENT USER_OBJECT="coffeetable">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -671,38 +672,44 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1458244258939</updated> <updated>1458244258939</updated>
</task> </task>
<option name="localTasksCounter" value="24" /> <task id="LOCAL-00024" summary="Implement Tile.representsVoid">
<created>1458246771404</created>
<option name="number" value="00024" />
<option name="project" value="LOCAL" />
<updated>1458246771405</updated>
</task>
<option name="localTasksCounter" value="25" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
<history-entry file="Tests - 2016.03.17 at 20h 37m 08s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 07m 14s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 38m 52s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 08m 05s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 39m 58s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 29m 32s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 40m 42s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 29m 53s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 49m 33s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 30m 49s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 58m 59s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 31m 34s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 21h 01m 47s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 35m 51s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 21h 02m 30s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 41m 27s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 21h 07m 14s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 42m 03s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 21h 08m 05s.xml"> <history-entry file="Tests - 2016.03.17 at 21h 42m 28s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
</component> </component>
@ -717,7 +724,7 @@
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23441397" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" x="0" y="355" width="1446" height="188" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.23441397" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" x="0" y="355" width="1446" height="188" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24964234" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24964234" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
@ -768,7 +775,8 @@
<MESSAGE value="Implement Map.visitedTile as private Tile[]" /> <MESSAGE value="Implement Map.visitedTile as private Tile[]" />
<MESSAGE value="Normalize Position bounds for rows and columns" /> <MESSAGE value="Normalize Position bounds for rows and columns" />
<MESSAGE value="Implement Map.getTileByPosition and do some refactoring" /> <MESSAGE value="Implement Map.getTileByPosition and do some refactoring" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Map.getTileByPosition and do some refactoring" /> <MESSAGE value="Implement Tile.representsVoid" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Tile.representsVoid" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
@ -1116,7 +1124,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php"> <entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-7.9259257"> <state vertical-scroll-proportion="0.0">
<caret line="125" column="45" selection-start-line="125" selection-start-column="45" selection-end-line="125" selection-end-column="45" /> <caret line="125" column="45" selection-start-line="125" selection-start-column="45" selection-end-line="125" selection-end-column="45" />
<folding /> <folding />
</state> </state>
@ -1124,7 +1132,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-11.333333"> <state vertical-scroll-proportion="0.0">
<caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" /> <caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" />
<folding /> <folding />
</state> </state>
@ -1132,40 +1140,40 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/index.php"> <entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-4.6666665"> <state vertical-scroll-proportion="0.0">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="5" /> <caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="22.962963"> <state vertical-scroll-proportion="-19.703703">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" /> <caret line="133" column="0" selection-start-line="133" selection-start-column="0" selection-end-line="133" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php"> <entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-13.407408"> <state vertical-scroll-proportion="-22.37037">
<caret line="133" column="0" selection-start-line="133" selection-start-column="0" selection-end-line="133" selection-end-column="0" /> <caret line="36" column="44" selection-start-line="36" selection-start-column="44" selection-end-line="36" selection-end-column="44" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-14.666667"> <state vertical-scroll-proportion="-12.0">
<caret line="22" column="61" selection-start-line="22" selection-start-column="61" selection-end-line="22" selection-end-column="61" /> <caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.99642855"> <state vertical-scroll-proportion="0.30213904">
<caret line="58" column="65" selection-start-line="58" selection-start-column="65" selection-end-line="58" selection-end-column="65" /> <caret line="58" column="0" selection-start-line="58" selection-start-column="0" selection-end-line="58" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>

@ -109,11 +109,11 @@ class Map {
$array = []; $array = [];
foreach ($this->getUnVisitedTiles() as $tile) { foreach ($this->getUnVisitedTiles() as $tile) {
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->representsElement(); $array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->isRepresentingSpot();
} }
foreach ($this->getVisitedTiles() as $tile) { foreach ($this->getVisitedTiles() as $tile) {
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->representsElement(); $array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->isRepresentingSpot();
} }
return $array; return $array;

@ -7,12 +7,17 @@ namespace Coffee;
* *
* @package Coffee * @package Coffee
*/ */
/**
* Class Tile
*
* @package Coffee
*/
class Tile extends Position { class Tile extends Position {
/** /**
* Representation on the map, that element exists on the given tile * Representation on the map, that element exists on the given tile
*/ */
const REPRESENTS_ELEMENT = 1; const REPRESENTS_SPOT = 1;
/** /**
* Representation on the map, that element does not exist on the given tile * Representation on the map, that element does not exist on the given tile
*/ */
@ -22,7 +27,10 @@ class Tile extends Position {
*/ */
private $representsElement = false; private $representsElement = false;
// private $isVisited = false; /**
* @var bool
*/
private $visited = false;
/** /**
* Tile constructor. * Tile constructor.
@ -33,7 +41,7 @@ class Tile extends Position {
* @throws \Exception * @throws \Exception
*/ */
public function __construct($row, $column, $tileRepresentation) { public function __construct($row, $column, $tileRepresentation) {
if (!$this->representsElement() && !$this->representsVoid()) { if (!$this->isRepresentingSpot() && !$this->isRepresentingVoid()) {
throw new \Exception('The map contains invalid representations'); throw new \Exception('The map contains invalid representations');
} }
@ -45,11 +53,28 @@ class Tile extends Position {
/** /**
* @return boolean * @return boolean
*/ */
public function representsElement() { public function isVisited() {
return $this->representsElement == self::REPRESENTS_ELEMENT; return $this->visited;
}
/**
* Flags this Tile as "visited"
*/
public function visit() {
$this->visited = true;
}
/**
* @return boolean
*/
public function isRepresentingSpot() {
return $this->representsElement == self::REPRESENTS_SPOT;
} }
public function representsVoid() { /**
* @return bool
*/
public function isRepresentingVoid() {
return $this->representsElement == self::REPRESENTS_VOID; return $this->representsElement == self::REPRESENTS_VOID;
} }

@ -29,7 +29,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$column = 1; $column = 1;
$position = new Position($row, $column); $position = new Position($row, $column);
$tile = new Tile($row, $column, Tile::REPRESENTS_ELEMENT); $tile = new Tile($row, $column, Tile::REPRESENTS_SPOT);
$this->assertEquals($tile, $map->getTileByPosition($position)); $this->assertEquals($tile, $map->getTileByPosition($position));
} }

@ -7,16 +7,16 @@ require __DIR__ . '/../../vendor/autoload.php';
class TileTest extends \PHPUnit_Framework_TestCase { class TileTest extends \PHPUnit_Framework_TestCase {
public function testRepresentsElement() { public function testRepresentingSpot() {
$tile = new Tile(2, 2, Tile::REPRESENTS_ELEMENT); $tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
$this->assertTrue($tile->representsElement()); $this->assertTrue($tile->isRepresentingSpot());
} }
public function testRepresentsVoid() { public function testRepresentingVoid() {
$tile = new Tile(2, 2, Tile::REPRESENTS_VOID); $tile = new Tile(2, 2, Tile::REPRESENTS_VOID);
$this->assertTrue($tile->representsVoid()); $this->assertTrue($tile->isRepresentingVoid());
} }
public function testGetPosition() { public function testGetPosition() {
@ -29,4 +29,12 @@ class TileTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($position, $tile->getPosition()); $this->assertEquals($position, $tile->getPosition());
} }
public function testIsVisited() {
$tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
$tile->visit();
$this->assertTrue($tile->isVisited());
}
} }

Loading…
Cancel
Save