Implement Map.getTileByPosition and do some refactoring

master
Peter Babič 8 years ago
parent 5e840726d5
commit 790181fec3
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 6
      .idea/codeStyleSettings.xml
  2. 164
      .idea/workspace.xml
  3. 22
      index.php
  4. 35
      src/Coffee/Map.php
  5. 26
      src/Coffee/Position.php
  6. 16
      src/Coffee/Tile.php
  7. 23
      tests/Coffee/MapTest.php
  8. 12
      tests/Coffee/PositionTest.php
  9. 2
      tests/Coffee/TileTest.php

@ -2,7 +2,11 @@
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value />
<value>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
</component>

@ -1,11 +1,14 @@
<?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="Normalize Position bounds for rows and columns">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Map.getTileByPosition and do some refactoring">
<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/Position.php" afterPath="$PROJECT_DIR$/src/Coffee/Position.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/PositionTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TileTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
</list>
<ignored path="coffeetable.iws" />
<ignored path=".idea/workspace.xml" />
@ -30,12 +33,12 @@
<favorites_list name="coffeetable" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="index.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.0">
<caret line="15" column="0" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
<state vertical-scroll-proportion="0.10743801">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="20" selection-end-column="5" />
<folding />
</state>
</provider>
@ -44,7 +47,7 @@
<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="-26.0">
<state vertical-scroll-proportion="0.0">
<caret line="44" column="7" selection-start-line="44" selection-start-column="7" selection-end-line="44" selection-end-column="7" />
<folding />
</state>
@ -54,7 +57,7 @@
<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="-14.0">
<state vertical-scroll-proportion="0.0">
<caret line="21" column="37" selection-start-line="21" selection-start-column="37" selection-end-line="21" selection-end-column="37" />
<folding />
</state>
@ -64,8 +67,8 @@
<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="-115.59259">
<caret line="186" column="28" selection-start-line="186" selection-start-column="28" selection-end-line="186" selection-end-column="28" />
<state vertical-scroll-proportion="-11.333333">
<caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" />
<folding />
</state>
</provider>
@ -74,18 +77,18 @@
<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="-34.74074">
<caret line="125" column="44" selection-start-line="125" selection-start-column="44" selection-end-line="125" selection-end-column="44" />
<state vertical-scroll-proportion="-7.9259257">
<caret line="125" column="45" selection-start-line="125" selection-start-column="45" selection-end-line="125" selection-end-column="45" />
<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.021428572">
<caret line="44" column="100" selection-start-line="44" selection-start-column="100" selection-end-line="44" selection-end-column="100" />
<state vertical-scroll-proportion="-98.666664">
<caret line="148" column="22" selection-start-line="148" selection-start-column="22" selection-end-line="148" selection-end-column="22" />
<folding />
</state>
</provider>
@ -94,8 +97,8 @@
<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="-16.074074">
<caret line="96" column="0" selection-start-line="96" selection-start-column="0" selection-end-line="96" selection-end-column="0" />
<state vertical-scroll-proportion="-10.0">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<folding />
</state>
</provider>
@ -104,7 +107,7 @@
<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="-18.0">
<state vertical-scroll-proportion="0.0">
<caret line="27" column="31" selection-start-line="27" selection-start-column="31" selection-end-line="27" selection-end-column="31" />
<folding />
</state>
@ -114,8 +117,8 @@
<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="-16.74074">
<caret line="40" column="5" selection-start-line="40" selection-start-column="5" selection-end-line="40" selection-end-column="5" />
<state vertical-scroll-proportion="-21.037037">
<caret line="45" column="37" selection-start-line="45" selection-start-column="37" selection-end-line="45" selection-end-column="37" />
<folding />
</state>
</provider>
@ -162,13 +165,13 @@
<option value="$PROJECT_DIR$/composer.json" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.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$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="$PROJECT_DIR$/index.php" />
</list>
@ -335,7 +338,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -406,6 +408,7 @@
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@ -413,18 +416,18 @@
<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="paste&#9;ACTION&#9;EditorPasteSimple&#10;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="SearchEverywhereHistoryKey" value="replace in pa&#9;ACTION&#9;ReplaceInPath&#10;hist&#9;ACTION&#9;Vcs.ShowTabbedFileHistory&#10;paste&#9;ACTION&#9;EditorPasteSimple&#10;rear &#9;ACTION&#9;RearrangeCode&#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" />
<property name="last_directory_selection" value="$PROJECT_DIR$" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="104" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="103" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth1" value="129" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth1" value="128" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder1" value="1" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth2" value="134" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth2" value="133" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder2" value="2" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="1043" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="1033" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder3" value="3" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth0" value="115" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder0" value="0" />
@ -649,38 +652,44 @@
<option name="project" value="LOCAL" />
<updated>1458235032718</updated>
</task>
<option name="localTasksCounter" value="22" />
<task id="LOCAL-00022" summary="Implement Map.getTileByPosition and do some refactoring">
<created>1458243697414</created>
<option name="number" value="00022" />
<option name="project" value="LOCAL" />
<updated>1458243697414</updated>
</task>
<option name="localTasksCounter" value="23" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.17 at 18h 28m 45s.xml">
<history-entry file="Tests - 2016.03.17 at 18h 38m 42s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 31m 37s.xml">
<history-entry file="Tests - 2016.03.17 at 18h 41m 22s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 33m 05s.xml">
<history-entry file="Tests - 2016.03.17 at 19h 14m 06s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 33m 27s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 29m 36s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 33m 55s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 33m 59s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 36m 43s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 37m 08s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 37m 50s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 38m 52s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 38m 42s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 39m 58s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 41m 22s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 40m 42s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 19h 14m 06s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 49m 33s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -688,17 +697,16 @@
<frame x="-2" y="0" width="1444" height="899" extended-state="0" />
<editor active="true" />
<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.16875" 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="false" 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="true" 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="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" />
<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="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="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="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" />
@ -707,9 +715,13 @@
<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="11" 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="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>
<component name="UpdateCopyrightCheckinHandler">
<option name="UPDATE_COPYRIGHT" value="true" />
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
@ -722,6 +734,7 @@
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<option name="CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT" value="true" />
<option name="USE_COMMIT_MESSAGE_MARGIN" value="true" />
<MESSAGE value="Create Spot and SpotTest" />
<MESSAGE value="Refactor coordinates in Tile from X,Y to col,row" />
@ -741,7 +754,8 @@
<MESSAGE value="Change positioning system to start at [1, 1] not [0, 0]" />
<MESSAGE value="Implement Map.visitedTile as private Tile[]" />
<MESSAGE value="Normalize Position bounds for rows and columns" />
<option name="LAST_COMMIT_MESSAGE" value="Normalize Position bounds for rows and columns" />
<MESSAGE value="Implement Map.getTileByPosition and do some refactoring" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Map.getTileByPosition and do some refactoring" />
<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" />
@ -985,7 +999,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.3319838">
<caret line="35" column="0" selection-start-line="35" selection-start-column="0" selection-end-line="35" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
@ -1001,7 +1014,6 @@
<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" />
<folding />
</state>
</provider>
</entry>
@ -1009,7 +1021,6 @@
<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" />
<folding />
</state>
</provider>
</entry>
@ -1017,7 +1028,6 @@
<provider selected="true" editor-type-id="text-editor">
<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>
@ -1025,7 +1035,6 @@
<provider selected="true" editor-type-id="text-editor">
<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>
@ -1073,21 +1082,12 @@
<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$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-16.74074">
<caret line="40" column="5" selection-start-line="40" selection-start-column="5" selection-end-line="40" selection-end-column="5" />
<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="-14.0">
<state vertical-scroll-proportion="0.0">
<caret line="21" column="37" selection-start-line="21" selection-start-column="37" selection-end-line="21" selection-end-column="37" />
<folding />
</state>
@ -1095,56 +1095,64 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-26.0">
<state vertical-scroll-proportion="0.0">
<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$/index.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.0">
<caret line="15" column="0" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
<state vertical-scroll-proportion="0.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/Table.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.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" />
<state vertical-scroll-proportion="-7.9259257">
<caret line="125" column="45" selection-start-line="125" selection-start-column="45" selection-end-line="125" selection-end-column="45" />
<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="-16.074074">
<caret line="96" column="0" selection-start-line="96" selection-start-column="0" selection-end-line="96" selection-end-column="0" />
<state vertical-scroll-proportion="-10.0">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-34.74074">
<caret line="125" column="44" selection-start-line="125" selection-start-column="44" selection-end-line="125" selection-end-column="44" />
<state vertical-scroll-proportion="-98.666664">
<caret line="148" column="22" selection-start-line="148" selection-start-column="22" selection-end-line="148" selection-end-column="22" />
<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="-21.037037">
<caret line="45" column="37" selection-start-line="45" selection-start-column="37" selection-end-line="45" selection-end-column="37" />
<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="-115.59259">
<caret line="186" column="28" selection-start-line="186" selection-start-column="28" selection-end-line="186" selection-end-column="28" />
<state vertical-scroll-proportion="-11.333333">
<caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.021428572">
<caret line="44" column="100" selection-start-line="44" selection-start-column="100" selection-end-line="44" selection-end-column="100" />
<state vertical-scroll-proportion="0.10743801">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="20" selection-end-column="5" />
<folding />
</state>
</provider>

@ -5,16 +5,20 @@ namespace Coffee;
require __DIR__ . '/vendor/autoload.php';
try {
$map = new Map([
[0, 1, 0, 1],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 1]
]);
// $map = new Map([
// [0, 1, 0, 1],
// [1, 0, 0, 0],
// [0, 0, 0, 1],
// [0, 0, 1, 1]
// ]);
//
// $table = new Table();
var_dump($map->describedByArray());
//
// foreach ($map->getUnVisitedTiles() as $unVisitedTile) {
// foreach ($unVisitedTile->getNeighbouringPositions() as $neighbouringPosition) {
// ;
// }
// }
}
catch (\Exception $e) {
echo 'Caught exception: ' . $e->getMessage() . "\n";

@ -2,6 +2,11 @@
namespace Coffee;
/**
* Class Map
*
* @package Coffee
*/
/**
* Class Map
*
@ -63,6 +68,26 @@ class Map {
$this->width = $width + 1;
}
/**
* @param Position $position
* @return Tile|null
*/
public function getTileByPosition(Position $position) {
foreach ($this->getUnVisitedTiles() as $unVisitedTile) {
if ($unVisitedTile->isTheSamePosition($position)) {
return $unVisitedTile;
}
}
foreach ($this->getVisitedTiles() as $visitedTile) {
if ($visitedTile->isTheSamePosition($position)) {
return $visitedTile;
}
}
return null;
}
/**
* @return Tile[]
*/
@ -84,11 +109,11 @@ class Map {
$array = [];
foreach ($this->getUnVisitedTiles() as $tile) {
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->containsElement();
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->representsElement();
}
foreach ($this->getVisitedTiles() as $tile) {
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->containsElement();
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->representsElement();
}
return $array;
@ -98,8 +123,8 @@ class Map {
* @param Position $position
* @return bool
*/
public function visitTile(Position $position) {
if ($this->isValidPosition($position)) {
public function visitPosition(Position $position) {
if ($this->hasValidPosition($position)) {
foreach ($this->unVisitedTiles as $unVisitedTileIndex => $unVisitedTile) {
if ($unVisitedTile->isTheSamePosition($position)) {
@ -121,7 +146,7 @@ class Map {
* @param Position $position
* @return bool
*/
public function isValidPosition(Position $position) {
public function hasValidPosition(Position $position) {
if ($position->getRow() > $this->getHeight() || $position->getColumn() > $this->getWidth()) {
return false;
}

@ -98,64 +98,64 @@ class Position {
* @return Position
*/
public function getNorthEastPosition() {
return $this->getSafeNeighbor($this->getRow() - 1, $this->getColumn() + 1);
return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn() + 1);
}
/**
* @return Position
*/
public function getEastPosition() {
return $this->getSafeNeighbor($this->getRow(), $this->getColumn() + 1);
return $this->getSafeNeighbourPosition($this->getRow(), $this->getColumn() + 1);
}
/**
* @return Position
*/
public function getSouthEastPosition() {
return $this->getSafeNeighbor($this->getRow() + 1, $this->getColumn() + 1);
return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn() + 1);
}
/**
* @return Position
*/
public function getSouthPosition() {
return $this->getSafeNeighbor($this->getRow() + 1, $this->getColumn());
return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn());
}
/**
* @return Position
*/
public function getSouthWestPosition() {
return $this->getSafeNeighbor($this->getRow() + 1, $this->getColumn() - 1);
return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn() - 1);
}
/**
* @return Position
*/
public function getWestPosition() {
return $this->getSafeNeighbor($this->getRow(), $this->getColumn() - 1);
return $this->getSafeNeighbourPosition($this->getRow(), $this->getColumn() - 1);
}
/**
* @return Position
*/
public function getNorthWestPosition() {
return $this->getSafeNeighbor($this->getRow() - 1, $this->getColumn() - 1);
return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn() - 1);
}
/**
* @return Position
*/
public function getNorthPosition() {
return $this->getSafeNeighbor($this->getRow() - 1, $this->getColumn());
return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn());
}
/**
* @return array Neighbors of position from NE to N; CW direction
* @return array Positions of neighbours from NE to N; CW direction
*/
public function getNeighbors() {
public function getNeighbouringPositions() {
// null values from out-of-lower-bound neighbors are filtered out and indices are fixed
// null values from out-of-lower-bound neighbours are filtered out and indices are fixed
return array_values(array_filter([
$this->getNorthEastPosition(),
$this->getEastPosition(),
@ -173,7 +173,7 @@ class Position {
* @param $column
* @return bool
*/
private function fitsIntoLowerBound($row, $column) {
protected function fitsIntoLowerBound($row, $column) {
if ($row < self::LOWER_BOUND || $column < self::LOWER_BOUND) {
return false;
}
@ -186,7 +186,7 @@ class Position {
* @param $column
* @return Position|null
*/
private function getSafeNeighbor($row, $column) {
protected function getSafeNeighbourPosition($row, $column) {
if ($this->fitsIntoLowerBound($row, $column)) {
return new Position($row, $column);
}

@ -12,11 +12,11 @@ class Tile extends Position {
/**
* Representation on the map, that element exists on the given tile
*/
const CONTAINS_ELEMENT = 1;
const REPRESENTS_ELEMENT = 1;
/**
* Representation on the map, that element does not exist on the given tile
*/
const NOT_CONTAINS_ELEMENT = 0;
const REPRESENTS_VOID = 0;
/**
* @var bool
*/
@ -27,24 +27,24 @@ class Tile extends Position {
*
* @param $row
* @param $column
* @param $mapTileRepresentation
* @param $tileRepresentation
* @throws \Exception
*/
public function __construct($row, $column, $mapTileRepresentation) {
if ($mapTileRepresentation != self::CONTAINS_ELEMENT && $mapTileRepresentation != self::NOT_CONTAINS_ELEMENT) {
public function __construct($row, $column, $tileRepresentation) {
if ($tileRepresentation != self::REPRESENTS_ELEMENT && $tileRepresentation != self::REPRESENTS_VOID) {
throw new \Exception('The map contains invalid representations');
}
parent::__construct($row, $column);
$this->containsElement = $mapTileRepresentation;
$this->containsElement = $tileRepresentation;
}
/**
* @return boolean
*/
public function containsElement() {
return $this->containsElement == self::CONTAINS_ELEMENT;
public function representsElement() {
return $this->containsElement == self::REPRESENTS_ELEMENT;
}
}

@ -17,6 +17,23 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($description, $map->describedByArray());
}
public function testTileByPosition() {
$description = [
[1, 0],
[0, 1],
];
$map = new Map($description);
$row = 1;
$column = 1;
$position = new Position($row, $column);
$tile = new Tile($row, $column, Tile::REPRESENTS_ELEMENT);
$this->assertEquals($tile, $map->getTileByPosition($position));
}
public function testHeight() {
$description = [
[0, 1, 0, 1],
@ -52,7 +69,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$map = new Map($description);
$position = new Position(3, 1);
$this->assertTrue($map->isValidPosition($position));
$this->assertTrue($map->hasValidPosition($position));
}
public function testInvalidPosition() {
@ -65,7 +82,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$map = new Map($description);
$position = new Position(4, 5);
$this->assertFalse($map->isValidPosition($position));
$this->assertFalse($map->hasValidPosition($position));
}
public function testUnvisitedPosition() {
@ -91,7 +108,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$map = new Map($description);
$position = new Position(1, 1);
$map->visitTile($position);
$map->visitPosition($position);
$this->assertTrue($map->isVisitedPosition($position));
}

@ -104,9 +104,9 @@ class PositionTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testOpenSpaceNeighbors() {
public function testOpenSpaceNeighbours() {
$position = new Position(2, 2);
// Neighbors from NE to N, in CW direction
// Neighbours from NE to N, in CW direction
$neighbours = [
new Position(1, 3),
new Position(2, 3),
@ -118,18 +118,18 @@ class PositionTest extends \PHPUnit_Framework_TestCase {
new Position(1, 2),
];
$this->assertEquals($neighbours, $position->getNeighbors());
$this->assertEquals($neighbours, $position->getNeighbouringPositions());
}
public function testCornerNeighbors() {
public function testCornerNeighbours() {
$position = new Position(1, 1);
// Return just E, SE and S neighbors
// Return just E, SE and S neighbours
$neighbours = [
new Position(1, 2),
new Position(2, 2),
new Position(2, 1),
];
$this->assertEquals($neighbours, $position->getNeighbors());
$this->assertEquals($neighbours, $position->getNeighbouringPositions());
}
}

@ -10,6 +10,6 @@ class TileTest extends \PHPUnit_Framework_TestCase {
public function testContainsElement() {
$tile = new Tile(2, 2, true);
$this->assertTrue($tile->containsElement());
$this->assertTrue($tile->representsElement());
}
}

Loading…
Cancel
Save