July 18 2012 — finding the door in the grass
Many small commits went in today. First, I decided to fix the things that were missing from yesterday:
- You can take the rope and flashlight from the car.
- But not without opening the car first. Happy path, sad path, see?
- Also, you can examine things in the car.
look
includes the things in the room. Bit of a temp solution, and some duplication, but works for now.- When you take something, the game says you take it.
- Added a quit message, just like last year.
Therefore, now it looks like this:
$ bin/crypt
CRYPT
=====
You've heard there's supposed to be an ancient hidden crypt in these
woods. One containing a priceless treasure. Well, there's only one way
to find out...
Clearing
The forest road stops here, and the gaps between the trees widen into a
patch of un-forest. The sky above is clear apart from a few harmless clouds.
There is a car here.
You can go east.
> examine car
Small, kind of old, and beginning to rust. But it still gets you places.
> examine flashlight
You see no flashlight here.
> open car
Opening the car reveals a flashlight and a rope.
> examine flashlight
The flashlight, a trusty Flexmann 520, has been serving you for countless
adventures.
> take flashlight
You take the flashlight.
> quit
Thanks for playing.
The only small detail that's wrong now is that there should be a "custom description" for the car, and the game should really say "Your car is parked here." I have a plan for how to fix this. But not today. All in due time.
Now, what I really meant to do today was this:
- You can open the door on the hill.
- But not without first examining the grass where the door is hidden.
- Or, as it happens, the bushes.
- Then, let's open the door and walk through.
- But walking south is only supposed to work if you open the door first, silly.
Implementing this game is great; today more than previous days I'm feeling just how great. The foundation I've built in the first part of the month is not just suitable for building adventure games, it's perfect. It's fantastic. Look at this:
# Things on hill
.place_thing('grass', 'hill');
.make_thing_implicit('grass');
.place_thing('bushes', 'hill');
.make_thing_implicit('bushes');
.place_thing('door', 'hill');
.make_thing_openable('door');
.hide_thing('door');
.on_examine('grass', { .unhide_thing('door') });
.on_examine('bushes', { .unhide_thing('door') });
.on_open('door', { .connect(<hill chamber>, 'south') });
It's an adventure game world building API! (Yes, others will be able to take it
and run with it too, as long as I separate Adventure::Engine
out into its own
module and publish it on modules.perl6.org).
And not just that. The tests are wonderful, too!
my $game = Crypt::Game.new();
$game.open('car');
is $game.examine('flashlight'),
Adventure::PlayerExamined.new(
:thing<flashlight>,
),
'examining the flashlight in the car';
I'm very happy about how this is turning out. All programming should be like this.