RCRPG/Ruby: Difference between revisions
Content deleted Content added
No edit summary |
m Fixed syntax highlighting. |
||
Line 2:
This [[Ruby]] version of [[RCRPG]] implements a text interface.
===Language Idioms===
This program illustrates some of the interesting aspects of Ruby:
Line 11:
* higher-order functions like map and select, using blocks
==
The objective of the game is to find your way to the exit (which is located at 1, 1, 5).
===Commands===
Direction commands:<pre>north, south, east, west, up, down</pre>Type these in order to go in a certain direction. There must be a hole in the wall in that direction. All directions are aliased by their first letter (ie. you can go south by just typing s). In order to go up, you must have a ladder in your current room. In order to go down, the room below you must have a ladder in it.
Line 29:
Create an alias:<pre>alias <old command> <new command></pre>Make it so that whenever you type <i>new command</i> it means the same thing as <i>old command</i>.
===Code===
<
class Vector
Line 265:
print "> "
process_cmd gets.chop.downcase
end</
|