Strangely Consistent

Theory, practice, and languages, braided together

July 5 2012 — moving around II (up/down, in/out)

First, by request, I'm implementing 'help' in the game. (seldon++) Better sooner than later, I guess.

$ bin/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...

> help
Here are some (made-up) examples of commands you can use:

[walk] north/south/east/west

> quit

I'll make sure to keep the help message up-to-date as I add functions to the game.

I implemented the up/down directions. As part of this, because it was easier to test it that way, I cleared up the misplaced 'clearing' initialization from yesterday. This quite naturally required the new event Adventure::PlayerWasPlaced (for giving the player an initial position) and X::Adventure::PlayerIsNowhere (for trying to move when this wasn't done). Things are in the right place now and everyone's happy.

Hm, it also means I just implemented a teleportation mechanism! Probably not such a bad idea for a general adventure game. Though I won't need it in Crypt.

Implementing in/out is a little more involved, since we're now out of primary directions. The compass directions and up/down are all primary directions. "In" and "out" are just aliases for one of those. So we wire up the event Adventure::DirectionAliased which lets us call some of the existing directions "in" or "out".

None of this actually allows us to play the game any further. So it's a good thing I implemented 'help' so I have something to show today apart from passing tests!

Also, note that I'm quite aware that connections are not yet two-way. They should be. That is, when we connect 'clearing' to 'hill' in the east direction, then 'hill' should also connect to 'clearing' in the west direction. We'll need this soon, maybe as soon as tomorrow.

Anyway, tomorrow we'll tackle room descriptions in earnest. Probably I'll add all rooms in one go, and make sure walking between them works.