Refactor coordinates in Tile from X,Y to col,row

master
Peter Babič 8 years ago
parent 1eb064a478
commit 22beb4cede
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 4
      .idea/deployment.xml
  2. 293
      .idea/workspace.xml
  3. 50
      src/Coffee/Table.php
  4. 167
      src/Coffee/Tile.php
  5. 31
      tests/TableTest.php
  6. 67
      tests/TileTest.php

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" persistUploadOnCheckin="false" />
</project>

@ -2,11 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Create Spot and SpotTest">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/codeStyleSettings.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/Coffee/Spot.php" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/tests/SpotTest.php" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/deployment.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Table.php" afterPath="$PROJECT_DIR$/src/Coffee/Table.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/TableTest.php" afterPath="$PROJECT_DIR$/tests/TableTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/TileTest.php" afterPath="$PROJECT_DIR$/tests/TileTest.php" />
</list>
<ignored path="coffeetable.iws" />
<ignored path=".idea/workspace.xml" />
@ -35,8 +36,8 @@
<file leaf-file-name="Table.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="69" column="5" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
<state vertical-scroll-proportion="-15.333333">
<caret line="58" column="9" selection-start-line="53" selection-start-column="62" selection-end-line="58" selection-end-column="9" />
<folding />
</state>
</provider>
@ -45,8 +46,8 @@
<file leaf-file-name="TableTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-42.0">
<caret line="63" column="26" selection-start-line="63" selection-start-column="26" selection-end-line="63" selection-end-column="26" />
<state vertical-scroll-proportion="-21.703703">
<caret line="93" column="52" selection-start-line="93" selection-start-column="52" selection-end-line="93" selection-end-column="52" />
<folding />
</state>
</provider>
@ -55,38 +56,28 @@
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-36.666668">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
<state vertical-scroll-proportion="-18.37037">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false">
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/tests/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
<state vertical-scroll-proportion="0.8315508">
<caret line="92" column="0" selection-start-line="92" selection-start-column="0" selection-end-line="92" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Spot.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../coffeetable_/src/CoffeeTable/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-17.222221">
<caret line="42" column="0" selection-start-line="42" selection-start-column="0" selection-end-line="43" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Spot.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.553719">
<caret line="32" column="19" selection-start-line="32" selection-start-column="19" selection-end-line="32" selection-end-column="19" />
<state vertical-scroll-proportion="-1.8888888">
<caret line="18" column="18" selection-start-line="18" selection-start-column="18" selection-end-line="18" selection-end-column="18" />
<folding />
</state>
</provider>
@ -95,8 +86,8 @@
<file leaf-file-name="SpotTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-6.6666665">
<caret line="15" column="30" selection-start-line="15" selection-start-column="30" selection-end-line="15" selection-end-column="30" />
<state vertical-scroll-proportion="0.0">
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
<folding />
</state>
</provider>
@ -132,13 +123,13 @@
<option value="$PROJECT_DIR$/tests/CoffeeTest.php" />
<option value="$PROJECT_DIR$/tests/Table.php" />
<option value="$PROJECT_DIR$/composer.json" />
<option value="$PROJECT_DIR$/tests/TileTest.php" />
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/tests/SpotTest.php" />
<option value="$PROJECT_DIR$/tests/TableTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/tests/SpotTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/tests/TileTest.php" />
</list>
</option>
</component>
@ -188,12 +179,81 @@
<State>
<id />
</State>
<State>
<id>Assignment issuesJavaScript</id>
</State>
<State>
<id>Bitwise operation issuesJavaScript</id>
</State>
<State>
<id>Code StylePHP</id>
</State>
<State>
<id>Code quality toolsJavaScript</id>
</State>
<State>
<id>Code style issuesJavaScript</id>
</State>
<State>
<id>CoffeeScript</id>
</State>
<State>
<id>Control flow issuesJavaScript</id>
</State>
<State>
<id>Data flow issuesJavaScript</id>
</State>
<State>
<id>Error handlingJavaScript</id>
</State>
<State>
<id>General</id>
</State>
<State>
<id>GeneralJavaScript</id>
</State>
<State>
<id>GeneralPHP</id>
</State>
<State>
<id>JavaScript</id>
</State>
<State>
<id>JavaScript function metricsJavaScript</id>
</State>
<State>
<id>JavaScript validity issuesJavaScript</id>
</State>
<State>
<id>PHP</id>
</State>
<State>
<id>PHPDocPHP</id>
</State>
<State>
<id>Potentially confusing code constructsJavaScript</id>
</State>
<State>
<id>Probable bugsCoffeeScript</id>
</State>
<State>
<id>Probable bugsJavaScript</id>
</State>
<State>
<id>Probable bugsPHP</id>
</State>
<State>
<id>Spelling</id>
</State>
<State>
<id>UndefinedPHP</id>
</State>
<State>
<id>XML</id>
</State>
<State>
<id>XPath</id>
</State>
</expanded-state>
<selected-state>
<State>
@ -228,6 +288,21 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<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="ProjectPane">
<subPane>
<PATH>
@ -280,21 +355,6 @@
</PATH>
</subPane>
</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>
</component>
<component name="PropertiesComponent">
@ -302,8 +362,8 @@
<property name="options.splitter.main.proportions" value="0.3" />
<property name="options.splitter.details.proportions" value="0.2" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="SearchEverywhereHistoryKey" value="commit&#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;commit &#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;phpunit&#9;null&#9;null&#10;exte&#9;ACTION&#9;EditorSelectWord&#10;composer&#9;ACTION&#9;ComposerGroup&#10;test&#9;ACTION&#9;RerunTests&#10;rer&#9;ACTION&#9;RerunTests&#10;tests&#9;ACTION&#9;RerunTests&#10;hpunit&#9;ACTION&#9;PhpUnitGenerateTestMethod&#10;phpuni&#9;ACTION&#9;PhpUnitNewTest&#10;rear&#9;ACTION&#9;RearrangeCode" />
<property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
<property name="SearchEverywhereHistoryKey" value="keyma&#9;ACTION&#9;ChangeKeymap&#10;commit&#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;commit &#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;phpunit&#9;null&#9;null&#10;exte&#9;ACTION&#9;EditorSelectWord&#10;composer&#9;ACTION&#9;ComposerGroup&#10;test&#9;ACTION&#9;RerunTests&#10;rer&#9;ACTION&#9;RerunTests&#10;tests&#9;ACTION&#9;RerunTests&#10;hpunit&#9;ACTION&#9;PhpUnitGenerateTestMethod&#10;phpuni&#9;ACTION&#9;PhpUnitNewTest&#10;rear&#9;ACTION&#9;RearrangeCode" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="last_directory_selection" value="$PROJECT_DIR$" />
@ -384,37 +444,44 @@
<option name="number" value="Default" />
<updated>1458074387240</updated>
</task>
<task id="LOCAL-00001" summary="Create Spot and SpotTest">
<created>1458136416618</created>
<option name="number" value="00001" />
<option name="project" value="LOCAL" />
<updated>1458136416618</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.16 at 11h 23m 52s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 08m 02s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 11h 23m 58s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 08m 26s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 11h 24m 49s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 09m 28s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 11h 24m 58s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 13m 38s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 11h 27m 01s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 14m 04s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 11h 27m 09s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 47m 53s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 11h 27m 12s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 54m 34s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 14h 45m 40s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 55m 31s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 14h 50m 41s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 56m 10s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.16 at 14h 51m 10s.xml">
<history-entry file="Tests - 2016.03.16 at 15h 57m 21s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -424,23 +491,23 @@
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="TODO" 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="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="PHP-CGI Server" 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="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" 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="7" side_tool="true" 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="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="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.28553617" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.31670824" sideWeight="0.5" order="2" 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.25" 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="7" 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="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3840399" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Messages" 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="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" 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="0" side_tool="false" content_ui="tabs" />
<window_info id="PHP-CGI Server" 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="7" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Command Line Tools Console" 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="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<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="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
@ -468,6 +535,62 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="69" column="5" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="63" column="26" selection-start-line="63" selection-start-column="26" selection-end-line="63" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../coffeetable_/src/CoffeeTable/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="42" column="0" selection-start-line="42" selection-start-column="0" selection-end-line="43" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
@ -730,65 +853,65 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
<folding />
<caret line="0" column="7" selection-start-line="0" selection-start-column="7" selection-end-line="0" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore">
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="7" selection-start-line="0" selection-start-column="7" selection-end-line="0" selection-end-column="7" />
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<entry file="file://$PROJECT_DIR$/tests/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="69" column="5" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
<state vertical-scroll-proportion="-21.703703">
<caret line="93" column="52" selection-start-line="93" selection-start-column="52" selection-end-line="93" selection-end-column="52" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/TableTest.php">
<entry file="file://$PROJECT_DIR$/../coffeetable_/src/CoffeeTable/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-42.0">
<caret line="63" column="26" selection-start-line="63" selection-start-column="26" selection-end-line="63" selection-end-column="26" />
<state vertical-scroll-proportion="0.03468208">
<caret line="42" column="0" selection-start-line="42" selection-start-column="0" selection-end-line="43" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-36.666668">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
<state vertical-scroll-proportion="-1.8888888">
<caret line="18" column="18" selection-start-line="18" selection-start-column="18" selection-end-line="18" selection-end-column="18" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-6.6666665">
<caret line="15" column="30" selection-start-line="15" selection-start-column="30" selection-end-line="15" selection-end-column="30" />
<state vertical-scroll-proportion="-15.333333">
<caret line="58" column="9" selection-start-line="53" selection-start-column="62" selection-end-line="58" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../coffeetable_/src/CoffeeTable/Spot.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-17.222221">
<caret line="42" column="0" selection-start-line="42" selection-start-column="0" selection-end-line="43" selection-end-column="20" />
<state vertical-scroll-proportion="-18.37037">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<entry file="file://$PROJECT_DIR$/tests/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.553719">
<caret line="32" column="19" selection-start-line="32" selection-start-column="19" selection-end-line="32" selection-end-column="19" />
<state vertical-scroll-proportion="0.8315508">
<caret line="92" column="0" selection-start-line="92" selection-start-column="0" selection-end-line="92" selection-end-column="0" />
<folding />
</state>
</provider>

@ -20,7 +20,7 @@ class Table {
/**
* @var array
*/
private $remainingTiles = [];
private $remainingPositions = [];
/**
* @var int
@ -31,6 +31,10 @@ class Table {
* @var int
*/
private $width = 0;
/**
* @var Spot[]
*/
private $spots = [];
/**
* Table constructor.
@ -45,7 +49,14 @@ class Table {
$this->height = $this->calculateMapHeight($coffeeMap);
$this->width = $this->calculateMapWidth($coffeeMap);
$this->remainingTiles = $coffeeMap;
$this->remainingPositions = $coffeeMap;
// foreach ($this->remainingPositions as $rowIndex => $tableRow) {
// foreach ($tableRow as $columnIndex => $containsCoffee) {
// if ($containsCoffee)
// $tile = new Tile($columnIndex, $rowIndex);
// }
// }
}
/**
@ -65,8 +76,8 @@ class Table {
/**
* @return array
*/
public function getRemainingTiles() {
return $this->remainingTiles;
public function getRemainingPositions() {
return $this->remainingPositions;
}
/**
@ -100,15 +111,42 @@ class Table {
* @return bool
*/
public function isValidForTile(Tile $tile) {
if ($tile->getX() < 0 || $tile->getY() < 0) {
if ($tile->getColumn() < 0 || $tile->getRow() < 0) {
return false;
}
// Dimensions start from 1 but coordinates from 0, need to compensate
if ($tile->getX() > ($this->getWidth() - 1) || $tile->getY() > ($this->getHeight() - 1)) {
if ($tile->getColumn() > ($this->getWidth() - 1) || $tile->getRow() > ($this->getHeight() - 1)) {
return false;
}
return true;
}
/**
* @param Spot $spot
* @return bool
*/
public function addSpot(Spot $spot) {
if (is_null($spot)) {
return false;
}
$this->spots[] = $spot;
return true;
}
/**
* @return Spot[]
*/
public function getSpots() {
return $this->spots;
}
/**
* @return int
*/
public function getSpotsCount() {
return count($this->spots);
}
}

@ -12,49 +12,49 @@ class Tile {
/**
* @var int
*/
private $X = 0;
private $column = 0;
/**
* @var int
*/
private $Y = 0;
private $row = 0;
/**
* @param $X
* @param $Y
* @param $column
* @param $row
*/
function __construct($X, $Y) {
$this->X = $X;
$this->Y = $Y;
function __construct($column, $row) {
$this->column = $column;
$this->row = $row;
}
/**
* @return int
*/
public function getX() {
return $this->X;
public function getColumn() {
return $this->column;
}
/**
* @return int
*/
public function getY() {
return $this->Y;
public function getRow() {
return $this->row;
}
/**
* @param Tile $tile
* @return bool
*/
public function isTheSameX(Tile $tile) {
return $this->getX() == $tile->getX();
public function isTheSameColumn(Tile $tile) {
return $this->getColumn() == $tile->getColumn();
}
/**
* @param Tile $tile
* @return bool
*/
public function isTheSameY(Tile $tile) {
return $this->getY() == $tile->getY();
public function isTheSameRow(Tile $tile) {
return $this->getRow() == $tile->getRow();
}
/**
@ -62,180 +62,63 @@ class Tile {
* @return bool
*/
public function isTheSameTile(Tile $tile) {
return $this->isTheSameX($tile) && $this->isTheSameY($tile);
return $this->isTheSameColumn($tile) && $this->isTheSameRow($tile);
}
/**
* @return Tile
*/
public function getNorthEastTile() {
return new Tile($this->getX() + 1, $this->getY() - 1);
return new Tile($this->getColumn() + 1, $this->getRow() - 1);
}
/**
* @return Tile
*/
public function getEastTile() {
return new Tile($this->getX() + 1, $this->getY());
return new Tile($this->getColumn() + 1, $this->getRow());
}
/**
* @return Tile
*/
public function getSouthEastTile() {
return new Tile($this->getX() + 1, $this->getY() + 1);
return new Tile($this->getColumn() + 1, $this->getRow() + 1);
}
/**
* @return Tile
*/
public function getSouthTile() {
return new Tile($this->getX(), $this->getY() + 1);
return new Tile($this->getColumn(), $this->getRow() + 1);
}
/**
* @return Tile
*/
public function getSouthWestTile() {
return new Tile($this->getX() - 1, $this->getY() + 1);
return new Tile($this->getColumn() - 1, $this->getRow() + 1);
}
/**
* @return Tile
*/
public function getWestTile() {
return new Tile($this->getX() - 1, $this->getY());
return new Tile($this->getColumn() - 1, $this->getRow());
}
/**
* @return Tile
*/
public function getNorthWestTile() {
return new Tile($this->getX() - 1, $this->getY() - 1);
return new Tile($this->getColumn() - 1, $this->getRow() - 1);
}
/**
* @return Tile
*/
public function getNorthTile() {
return new Tile($this->getX(), $this->getY() - 1);
return new Tile($this->getColumn(), $this->getRow() - 1);
}
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isNorthOf(Tile $tile) {
// return $this->isTheSameX($tile) && $this->isInRowNorthOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isSouthOf(Tile $tile) {
// return $this->isTheSameX($tile) && $this->isInRowSouthOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isEastOf(Tile $tile) {
// return $this->isTheSameY($tile) && $this->isInColumnEastOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isWestOf(Tile $tile) {
// return $this->isTheSameY($tile) && $this->isInColumnWestOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isNorthEastOf(Tile $tile) {
// return $this->isInRowNorthOf($tile) && $this->isInColumnEastOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isNorthWestOf(Tile $tile) {
// return $this->isInRowNorthOf($tile) && $this->isInColumnWestOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isSouthEastOf(Tile $tile) {
// return $this->isInRowSouthOf($tile) && $this->isInColumnEastOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isSouthWestOf(Tile $tile) {
// return $this->isInRowSouthOf($tile) && $this->isInColumnWestOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
//
//
// /**
// * @param Tile $tile
// * @return bool
// */
// public function isNeighborOf(Tile $tile) {
// // Guard; not necessary but to be completely clear
// if ($this->isTheSameTile($tile)) {
// return false;
// }
//
// return
// $this->isNorthOf($tile) || $this->isSouthOf($tile) ||
// $this->isEastOf($tile) || $this->isWestOf($tile) ||
// $this->isNorthEastOf($tile) || $this->isNorthWestOf($tile) ||
// $this->isSouthEastOf($tile) || $this->isSouthWestOf($tile);
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// protected function isInRowNorthOf(Tile $tile) {
// return ($this->getY() - $tile->getY()) == 1;
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// protected function isInRowSouthOf(Tile $tile) {
// return ($this->getY() - $tile->getY()) == -1;
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// protected function isInColumnEastOf(Tile $tile) {
// return ($this->getX() - $tile->getX()) == 1;
// }
//
// /**
// * @param Tile $tile
// * @return bool
// */
// protected function isInColumnWestOf(Tile $tile) {
// return ($this->getX() - $tile->getX()) == -1;
// }
}

@ -16,7 +16,7 @@ class TableTest extends \PHPUnit_Framework_TestCase {
];
$table = new Table($tableMap);
$this->assertEquals($tableMap, $table->getRemainingTiles());
$this->assertEquals($tableMap, $table->getRemainingPositions());
}
public function testHeight() {
@ -64,4 +64,33 @@ class TableTest extends \PHPUnit_Framework_TestCase {
$tile = new Tile(2, 1);
$this->assertFalse($table->isValidForTile($tile));
}
public function testGetSpots() {
$tableMap = [
[0, 1],
[1, 0],
];
$tile = new Tile(0, 0);
$spot = new Spot();
$table = new Table($tableMap);
$spot->addTile($tile);
$table->addSpot($spot);
$this->assertEquals([$spot], $table->getSpots());
}
public function testSpotsCount() {
$tableMap = [
[0, 1],
[1, 0],
];
$tile = new Tile(0, 0);
$spot = new Spot();
$table = new Table($tableMap);
$spot->addTile($tile);
$table->addSpot($spot);
$table->addSpot($spot);
$this->assertEquals(2, $table->getSpotsCount());
}
}

@ -10,14 +10,14 @@ class TileTest extends \PHPUnit_Framework_TestCase {
$tileA = new Tile(2, 2);
$tileB = new Tile(2, 2);
$this->assertTrue($tileA->isTheSameX($tileB));
$this->assertTrue($tileA->isTheSameColumn($tileB));
}
public function testTheSameY() {
$tileA = new Tile(2, 2);
$tileB = new Tile(2, 2);
$this->assertTrue($tileA->isTheSameY($tileB));
$this->assertTrue($tileA->isTheSameRow($tileB));
}
public function testTheSameTile() {
@ -91,67 +91,4 @@ class TileTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
// public function testNorthOf() {
// $tileA = new Tile(2, 2);
// $tileB = new Tile(2, 1);
//
// $this->assertTrue($tileA->isNorthOf($tileB));
// }
//
// public function testSouthOf() {
// $tileA = new Tile(2, 1);
// $tileB = new Tile(2, 2);
//
// $this->assertTrue($tileA->isSouthOf($tileB));
// }
//
// public function testEastOf() {
// $tileA = new Tile(2, 2);
// $tileB = new Tile(1, 2);
//
// $this->assertTrue($tileA->isEastOf($tileB));
// }
//
// public function testWestOf() {
// $tileA = new Tile(1, 2);
// $tileB = new Tile(2, 2);
//
// $this->assertTrue($tileA->isWestOf($tileB));
// }
//
// public function testNorthEastOf() {
// $tileA = new Tile(2, 2);
// $tileB = new Tile(1, 1);
//
// $this->assertTrue($tileA->isNorthEastOf($tileB));
// }
//
// public function testNorthWestOf() {
// $tileA = new Tile(1, 2);
// $tileB = new Tile(2, 1);
//
// $this->assertTrue($tileA->isNorthWestOf($tileB));
// }
//
// public function testSouthEastOf() {
// $tileA = new Tile(2, 1);
// $tileB = new Tile(1, 2);
//
// $this->assertTrue($tileA->isSouthEastOf($tileB));
// }
//
// public function testSouthWestOf() {
// $tileA = new Tile(1, 1);
// $tileB = new Tile(2, 2);
//
// $this->assertTrue($tileA->isSouthWestOf($tileB));
// }
//
// public function testNeighborOf() {
// $tileA = new Tile(1, 1);
// $tileB = new Tile(2, 2);
//
// $this->assertTrue($tileA->isNeighborOf($tileB));
// }
}
Loading…
Cancel
Save