Change positioning system to start at [1, 1] not [0, 0]

master
Peter Babič 8 years ago
parent be1bb7ba9b
commit f2ce51ec14
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 314
      .idea/workspace.xml
  2. 22
      src/Coffee/Map.php
  3. 22
      src/Coffee/Position.php
  4. 8
      tests/Coffee/MapTest.php
  5. 12
      tests/Coffee/PositionTest.php
  6. 4
      tests/Coffee/TableTest.php

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Decouple Map and Position">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Decouple Map, Position and Tile even more">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<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/Position.php" afterPath="$PROJECT_DIR$/src/Coffee/Position.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/PositionTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TableTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
</list>
<ignored path="coffeetable.iws" />
<ignored path=".idea/workspace.xml" />
@ -30,21 +33,21 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="SpotTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<file leaf-file-name="Spot.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.3333333">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="47" />
<state vertical-scroll-proportion="-3.4074075">
<caret line="44" column="7" selection-start-line="44" selection-start-column="7" selection-end-line="44" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.php">
<file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.666667">
<caret line="19" column="16" selection-start-line="19" selection-start-column="16" selection-end-line="19" selection-end-column="16" />
<state vertical-scroll-proportion="-12.0">
<caret line="18" column="55" selection-start-line="18" selection-start-column="55" selection-end-line="18" selection-end-column="55" />
<folding />
</state>
</provider>
@ -53,8 +56,8 @@
<file leaf-file-name="TableTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.3333333">
<caret line="5" column="23" selection-start-line="5" selection-start-column="23" selection-end-line="5" selection-end-column="23" />
<state vertical-scroll-proportion="-9.407408">
<caret line="21" column="37" selection-start-line="21" selection-start-column="37" selection-end-line="21" selection-end-column="37" />
<folding />
</state>
</provider>
@ -63,28 +66,18 @@
<file leaf-file-name="Position.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="2.6666667">
<caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="9.333333">
<caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<state vertical-scroll-proportion="49.25926">
<caret line="57" column="27" selection-start-line="57" selection-start-column="27" selection-end-line="57" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Map.php" pinned="false" current-in-tab="true">
<file leaf-file-name="Map.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.4876033">
<caret line="104" column="47" selection-start-line="104" selection-start-column="47" selection-end-line="104" selection-end-column="47" />
<state vertical-scroll-proportion="-62.11111">
<caret line="116" column="0" selection-start-line="116" selection-start-column="0" selection-end-line="116" selection-end-column="0" />
<folding />
</state>
</provider>
@ -93,28 +86,28 @@
<file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.6666667">
<caret line="70" column="24" selection-start-line="70" selection-start-column="24" selection-end-line="70" selection-end-column="24" />
<state vertical-scroll-proportion="-44.0">
<caret line="66" column="37" selection-start-line="66" selection-start-column="37" selection-end-line="66" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<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="-23.333334">
<caret line="35" column="1" selection-start-line="35" selection-start-column="1" selection-end-line="35" selection-end-column="1" />
<state vertical-scroll-proportion="-18.0">
<caret line="27" column="31" selection-start-line="27" selection-start-column="31" selection-end-line="27" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-7.3333335">
<caret line="11" column="52" selection-start-line="11" selection-start-column="52" selection-end-line="11" selection-end-column="52" />
<state vertical-scroll-proportion="0.58214283">
<caret line="33" column="0" selection-start-line="33" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
<folding />
</state>
</provider>
@ -152,19 +145,22 @@
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="$PROJECT_DIR$/tests/PositionTest.php" />
<option value="$PROJECT_DIR$/tests/MapTest.php" />
<option value="$PROJECT_DIR$/tests/TableTest.php" />
<option value="$PROJECT_DIR$/tests/SpotTest.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/tests/TileTest.php" />
<option value="$PROJECT_DIR$/phpunit.xml" />
<option value="$PROJECT_DIR$/composer.json" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Map.php" />
</list>
@ -409,7 +405,7 @@
<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="replace in pa&#9;ACTION&#9;ReplaceInPath&#10;histor&#9;ACTION&#9;Vcs.ShowTabbedFileHistory&#10;rep in pa&#9;ACTION&#9;ReplaceInPath&#10;replace in&#9;ACTION&#9;ReplaceInPath&#10;rearr&#9;ACTION&#9;RearrangeCode&#10;rea&#9;ACTION&#9;RearrangeCode&#10;orde&#9;null&#9;null&#10;next hi&#9;ACTION&#9;GotoNextError&#10;next&#9;ACTION&#9;GotoNextError&#10;comm cha&#9;ACTION&#9;ChangesView.Commit&#10;comple&#9;ACTION&#9;CodeCompletionGroup&#10;complet&#9;ACTION&#9;CodeCompletionGroup&#10;sear&#9;ACTION&#9;SearchEverywhere&#10;breakpoint&#9;ACTION&#9;ToggleLineBreakpoint&#10;comm ch&#9;ACTION&#9;ChangesView.Commit&#10;smart&#9;ACTION&#9;SmartTypeCompletion&#10;para&#9;ACTION&#9;IntroduceParameter&#10;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="SearchEverywhereHistoryKey" value="rear &#9;ACTION&#9;RearrangeCode&#10;replace in pa&#9;ACTION&#9;ReplaceInPath&#10;histor&#9;ACTION&#9;Vcs.ShowTabbedFileHistory&#10;rep in pa&#9;ACTION&#9;ReplaceInPath&#10;replace in&#9;ACTION&#9;ReplaceInPath&#10;rearr&#9;ACTION&#9;RearrangeCode&#10;rea&#9;ACTION&#9;RearrangeCode&#10;orde&#9;null&#9;null&#10;next hi&#9;ACTION&#9;GotoNextError&#10;next&#9;ACTION&#9;GotoNextError&#10;comm cha&#9;ACTION&#9;ChangesView.Commit&#10;comple&#9;ACTION&#9;CodeCompletionGroup&#10;complet&#9;ACTION&#9;CodeCompletionGroup&#10;sear&#9;ACTION&#9;SearchEverywhere&#10;breakpoint&#9;ACTION&#9;ToggleLineBreakpoint&#10;comm ch&#9;ACTION&#9;ChangesView.Commit&#10;smart&#9;ACTION&#9;SmartTypeCompletion&#10;para&#9;ACTION&#9;IntroduceParameter&#10;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.sourceCode.PHP" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/tests" />
@ -452,6 +448,9 @@
<configuration default="false" name="index.php" type="PhpLocalRunConfigurationType" factoryName="PHP Console" temporary="true" path="$PROJECT_DIR$/index.php">
<method />
</configuration>
<configuration default="false" name="MapTest.php" type="PhpLocalRunConfigurationType" factoryName="PHP Console" temporary="true" path="$PROJECT_DIR$/tests/Coffee/MapTest.php">
<method />
</configuration>
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
@ -487,19 +486,21 @@
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" directory="$PROJECT_DIR$/tests" options="--bootstrap vendor/autoload.php" use_alternative_configuration_file="true" />
<method />
</configuration>
<list size="5">
<list size="6">
<item index="0" class="java.lang.String" itemvalue="PHPUnit.Tests" />
<item index="1" class="java.lang.String" itemvalue="PHP Script.PositionTest.php" />
<item index="2" class="java.lang.String" itemvalue="PHPUnit.TableTest" />
<item index="3" class="java.lang.String" itemvalue="JavaScript Debug.PositionTest.php" />
<item index="4" class="java.lang.String" itemvalue="PHP Script.index.php" />
<item index="5" class="java.lang.String" itemvalue="PHP Script.MapTest.php" />
</list>
<recent_temporary>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="PHP Script.index.php" />
<item index="1" class="java.lang.String" itemvalue="JavaScript Debug.PositionTest.php" />
<item index="2" class="java.lang.String" itemvalue="PHPUnit.TableTest" />
<item index="3" class="java.lang.String" itemvalue="PHP Script.PositionTest.php" />
<list size="5">
<item index="0" class="java.lang.String" itemvalue="PHP Script.MapTest.php" />
<item index="1" class="java.lang.String" itemvalue="PHP Script.index.php" />
<item index="2" class="java.lang.String" itemvalue="JavaScript Debug.PositionTest.php" />
<item index="3" class="java.lang.String" itemvalue="PHPUnit.TableTest" />
<item index="4" class="java.lang.String" itemvalue="PHP Script.PositionTest.php" />
</list>
</recent_temporary>
</component>
@ -604,38 +605,50 @@
<option name="project" value="LOCAL" />
<updated>1458217350499</updated>
</task>
<option name="localTasksCounter" value="16" />
<task id="LOCAL-00016" summary="Decouple Map and Position">
<created>1458219149902</created>
<option name="number" value="00016" />
<option name="project" value="LOCAL" />
<updated>1458219149902</updated>
</task>
<task id="LOCAL-00017" summary="Decouple Map, Position and Tile even more">
<created>1458223743752</created>
<option name="number" value="00017" />
<option name="project" value="LOCAL" />
<updated>1458223743752</updated>
</task>
<option name="localTasksCounter" value="18" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.17 at 13h 19m 50s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 42m 09s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 30m 00s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 42m 48s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 40m 47s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 44m 12s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 45m 03s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 47m 15s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 46m 26s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 47m 18s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 47m 24s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 47m 44s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 49m 08s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 48m 45s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 49m 56s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 48m 52s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 51m 12s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 50m 27s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 13h 51m 34s.xml">
<history-entry file="Tests - 2016.03.17 at 15h 50m 31s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -644,10 +657,10 @@
<editor active="true" />
<layout>
<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="7" 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="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="12" side_tool="true" 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="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="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="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="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.16875" sideWeight="0.5" order="0" 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" />
@ -692,45 +705,19 @@
<MESSAGE value="Move tests to separate namespaced directory" />
<MESSAGE value="Implemet Tile extends Position" />
<MESSAGE value="Decouple Map and Position" />
<option name="LAST_COMMIT_MESSAGE" value="Decouple Map and Position" />
<MESSAGE value="Decouple Map, Position and Tile even more" />
<option name="LAST_COMMIT_MESSAGE" value="Decouple Map, Position and Tile even more" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="19" />
<option name="time" value="30" />
</breakpoint-manager>
<watches-manager>
<configuration name="PhpLocalRunConfigurationType">
<watch expression="$this-&gt;description[$row][$column]" language="PHP" />
</configuration>
</watches-manager>
<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$/../coffeetable_/src/CoffeeTable/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" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/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/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
@ -903,20 +890,6 @@
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.4074073">
<caret line="919" column="0" selection-start-line="919" selection-start-column="0" selection-end-line="919" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestResult.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.35227272">
<caret line="688" column="0" selection-start-line="688" selection-start-column="0" selection-end-line="688" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/sebastian-global-state/Restorer.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.35227272">
@ -931,13 +904,6 @@
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/Assert.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.35227272">
<caret line="504" column="0" selection-start-line="504" selection-start-column="0" selection-end-line="504" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/composer.lock">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-20.949677">
@ -988,106 +954,162 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<entry file="file://$PROJECT_DIR$/phpunit.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-6.5555553">
<caret line="27" column="0" selection-start-line="27" selection-start-column="2" selection-end-line="42" selection-end-column="5" />
<state vertical-scroll-proportion="0.36096257">
<caret line="15" column="35" selection-start-line="15" selection-start-column="35" selection-end-line="15" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<entry file="file://$PROJECT_DIR$/composer.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-11.333333">
<caret line="17" column="0" selection-start-line="17" selection-start-column="2" selection-end-line="33" selection-end-column="5" />
<state vertical-scroll-proportion="0.14438502">
<caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="2.6666667">
<caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
<state vertical-scroll-proportion="-3.3333333">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.php">
<entry file="file:///usr/share/nginx/html/coffeetable/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.666667">
<caret line="19" column="16" selection-start-line="19" selection-start-column="16" selection-end-line="19" selection-end-column="16" />
<state vertical-scroll-proportion="0.47678572">
<caret line="45" column="67" selection-start-line="45" selection-start-column="51" selection-end-line="45" selection-end-column="67" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/phpunit.xml">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.36096257">
<caret line="15" column="35" selection-start-line="15" selection-start-column="35" selection-end-line="15" selection-end-column="35" />
<state vertical-scroll-proportion="-4.6666665">
<caret line="7" column="17" selection-start-line="7" selection-start-column="17" selection-end-line="7" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/composer.json">
<entry file="file:///usr/share/nginx/html/coffeetable/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.14438502">
<caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
<state vertical-scroll-proportion="0.46964285">
<caret line="37" column="0" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.3333333">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="47" />
<state vertical-scroll-proportion="-5.3333335">
<caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.3333333">
<caret line="5" column="23" selection-start-line="5" selection-start-column="23" selection-end-line="5" selection-end-column="23" />
<state vertical-scroll-proportion="-9.407408">
<caret line="21" column="37" selection-start-line="21" selection-start-column="37" selection-end-line="21" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="9.333333">
<caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<state vertical-scroll-proportion="-12.0">
<caret line="18" column="55" selection-start-line="18" selection-start-column="55" selection-end-line="18" selection-end-column="55" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestFailure.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-7.3333335">
<caret line="11" column="52" selection-start-line="11" selection-start-column="52" selection-end-line="11" selection-end-column="52" />
<state vertical-scroll-proportion="-5.740741">
<caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestResult.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-23.333334">
<caret line="35" column="1" selection-start-line="35" selection-start-column="1" selection-end-line="35" selection-end-column="1" />
<state vertical-scroll-proportion="-5.4074073">
<caret line="846" column="0" selection-start-line="846" selection-start-column="0" selection-end-line="846" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.4074073">
<caret line="802" column="0" selection-start-line="802" selection-start-column="0" selection-end-line="802" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestSuite.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.740741">
<caret line="734" column="0" selection-start-line="734" selection-start-column="0" selection-end-line="734" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/Assert.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.2767857">
<caret line="951" column="0" selection-start-line="951" selection-start-column="0" selection-end-line="951" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.6666667">
<caret line="70" column="24" selection-start-line="70" selection-start-column="24" selection-end-line="70" selection-end-column="24" />
<state vertical-scroll-proportion="-44.0">
<caret line="66" column="37" selection-start-line="66" selection-start-column="37" selection-end-line="66" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.4876033">
<caret line="104" column="47" selection-start-line="104" selection-start-column="47" selection-end-line="104" selection-end-column="47" />
<state vertical-scroll-proportion="-62.11111">
<caret line="116" column="0" selection-start-line="116" selection-start-column="0" selection-end-line="116" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="49.25926">
<caret line="57" column="27" selection-start-line="57" selection-start-column="27" selection-end-line="57" selection-end-column="27" />
<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="-3.4074075">
<caret line="44" column="7" selection-start-line="44" selection-start-column="7" selection-end-line="44" selection-end-column="7" />
<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="-18.0">
<caret line="27" column="31" selection-start-line="27" selection-start-column="31" selection-end-line="27" selection-end-column="31" />
<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.58214283">
<caret line="33" column="0" selection-start-line="33" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
<folding />
</state>
</provider>

@ -42,18 +42,21 @@ class Map {
// This data processing could be written more read-ably in multiple cycles,
// but at a cost of reduced performance (minor).
foreach ($description as $mapRowIndex => $mapRow) {
foreach ($mapRow as $mapColumnIndex => $mapTileRepresentation) {
foreach ($description as $rowIndex => $row) {
foreach ($row as $columnIndex => $tileRepresentation) {
// All tiles are inherently unvisited at first
$this->unVisitedTiles[] = new Tile($mapRowIndex, $mapColumnIndex, $mapTileRepresentation);
// Also we need to convert indices to positions
$this->unVisitedTiles[] = new Tile($rowIndex + 1, $columnIndex + 1, $tileRepresentation);
$width = $mapColumnIndex > $width ? $mapColumnIndex : $width;
// Find maximum
$width = $columnIndex > $width ? $columnIndex : $width;
}
$height = $mapRowIndex > $height ? $mapRowIndex : $height;
// Find maximum
$height = $rowIndex > $height ? $rowIndex : $height;
}
// We are in a business of one off
// Convert indices to dimensions
$this->height = $height + 1;
$this->width = $width + 1;
}
@ -80,11 +83,11 @@ class Map {
$array = [];
foreach ($this->getUnVisitedTiles() as $tile) {
$array[$tile->getRow()][$tile->getColumn()] = $tile->containsElement();
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->containsElement();
}
foreach ($this->getVisitedTiles() as $tile) {
$array[$tile->getRow()][$tile->getColumn()] = $tile->containsElement();
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->containsElement();
}
return $array;
@ -112,8 +115,7 @@ class Map {
return false;
}
// Map dimensions start from 1 but row/col positions start from 0, need to compensate
if ($position->getRow() >= $this->getHeight() || $position->getColumn() >= $this->getWidth()) {
if ($position->getRow() > $this->getHeight() || $position->getColumn() > $this->getWidth()) {
return false;
}

@ -24,13 +24,13 @@ class Position {
* @throws \Exception
*/
function __construct($row, $column) {
// if ($row <= 0) {
// throw new \Exception('The row argument must be positive non-zero number.');
// }
//
// if ($column <= 0) {
// throw new \Exception('The columns argument must be positive non-zero number.');
// }
if ($row <= 0) {
throw new \Exception('The row argument must be positive non-zero number.');
}
if ($column <= 0) {
throw new \Exception('The columns argument must be positive non-zero number.');
}
$this->column = $column;
$this->row = $row;
@ -43,6 +43,10 @@ class Position {
return $this->column;
}
public function getColumnIndex() {
return $this->column - 1;
}
/**
* @return int
*/
@ -50,6 +54,10 @@ class Position {
return $this->row;
}
public function getRowIndex() {
return $this->row - 1;
}
/**
* @param Position $position
* @return bool

@ -51,7 +51,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
];
$map = new Map($description);
$position = new Position(3, 0);
$position = new Position(3, 1);
$this->assertTrue($map->isValidPosition($position));
}
@ -64,7 +64,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
];
$map = new Map($description);
$position = new Position(3, 4);
$position = new Position(4, 5);
$this->assertFalse($map->isValidPosition($position));
}
@ -77,7 +77,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
];
$map = new Map($description);
$position = new Position(0, 0);
$position = new Position(1, 1);
$this->assertFalse($map->isVisitedPosition($position));
}
@ -90,7 +90,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
];
$map = new Map($description);
$position = new Position(0, 0);
$position = new Position(1, 1);
$map->visitTile($position);
$this->assertTrue($map->isVisitedPosition($position));
}

@ -7,6 +7,18 @@ require __DIR__ . '/../../vendor/autoload.php';
class PositionTest extends \PHPUnit_Framework_TestCase {
public function testColumnIndex() {
$position = new Position(2, 2);
$this->assertEquals(1, $position->getColumnIndex());
}
public function testRowIndex() {
$position = new Position(2, 2);
$this->assertEquals(1, $position->getRowIndex());
}
public function testTheSameX() {
$positionA = new Position(2, 2);
$positionB = new Position(2, 2);

@ -9,7 +9,7 @@ class TableTest extends \PHPUnit_Framework_TestCase {
public function testGetSpots() {
$position = new Position(0, 0);
$position = new Position(1, 1);
$spot = new Spot();
$table = new Table();
$spot->addPosition($position);
@ -19,7 +19,7 @@ class TableTest extends \PHPUnit_Framework_TestCase {
public function testSpotsCount() {
$position = new Position(0, 0);
$position = new Position(1, 1);
$spot = new Spot();
$table = new Table();
$spot->addPosition($position);

Loading…
Cancel
Save