Skip to content

Commit

Permalink
Version21
Browse files Browse the repository at this point in the history
Adding exits and dimensions to rooms for a fuller experience.
  • Loading branch information
jenkoian committed Jan 20, 2015
1 parent b8ebbea commit 73bb68c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
37 changes: 31 additions & 6 deletions src/Jenko/House/Factory/HomeAloneHouseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jenko\House\Factory;

use Jenko\House\Dimensions;
use Jenko\House\Garden;
use Jenko\House\House;
use Jenko\House\Room;
Expand All @@ -26,12 +27,36 @@ public static function getHouse($currentLocation = null)
return static::$house;
}

$locations = [
Garden::named('front garden'),
Room::named('hallway'),
Room::named('living room'),
Room::named('kitchen'),
];
/**
* You could take this further and introduce factories for creating gardens, rooms etc. but for our use it's
* fine.
*/
$garden = Garden::named('front-garden');
$hallway = Room::named('hallway');
$livingRoom = Room::named('living-room');
$kitchen = Room::named('kitchen');
$diningRoom = Room::named('dining-room');
$bathroom = Room::named('bathroom');

$garden->setDimensions(Dimensions::fromWidthAndHeight(1000, 300));
$garden->setExits([$hallway]);

$hallway->setDimensions(Dimensions::fromWidthAndHeight(500, 50));
$hallway->setExits([$garden, $livingRoom, $diningRoom, $kitchen, $bathroom]);

$livingRoom->setDimensions(Dimensions::fromWidthAndHeight(600, 300));
$livingRoom->setExits([$hallway, $diningRoom]);

$kitchen->setDimensions(Dimensions::fromWidthAndHeight(400, 300));
$kitchen->setExits([$hallway, $diningRoom]);

$kitchen->setDimensions(Dimensions::fromWidthAndHeight(300, 200));
$diningRoom->setExits([$hallway, $kitchen, $livingRoom]);

$bathroom->setDimensions(Dimensions::fromWidthAndHeight(400, 100));
$bathroom->setExits([$hallway]);

$locations = [$garden, $hallway, $livingRoom, $kitchen, $diningRoom, $bathroom];

static::$house = House::build($locations);

Expand Down
2 changes: 0 additions & 2 deletions src/Jenko/HouseBundle/Resources/views/room.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@

{% if previousRoom is not null %}
<p><a href="{{ path('jenko_house_enter_room', {location: previousRoom.name}) }}">Go back to {{ previousRoom.name }}</a></p>
{% else %}
<p><a href="{{ path('jenko_house_outside') }}">Go outside</a></p>
{% endif %}

0 comments on commit 73bb68c

Please sign in to comment.