Permalink
Browse files

Version21

Adding exits and dimensions to rooms for a fuller experience.
  • Loading branch information...
jenkoian committed Jan 19, 2015
1 parent b8ebbea commit 73bb68c1d9fe6a9d125191b3e535af3fb1165c09
@@ -2,6 +2,7 @@
namespace Jenko\House\Factory;
use Jenko\House\Dimensions;
use Jenko\House\Garden;
use Jenko\House\House;
use Jenko\House\Room;
@@ -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);
@@ -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.