RCRPG/Ruby: Difference between revisions

m
Fixed syntax highlighting.
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user not shown)
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
 
== =Objective ===
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.
 
Attack:<pre>attack &lt;''direction''&gt;</pre>Break a hole in the wall in the specified direction. You must have a sledge equipped to do this.
 
Take/Drop:<pre>take &lt;item&gt;
Line 29:
Create an alias:<pre>alias &lt;old command&gt; &lt;new command&gt;</pre>Make it so that whenever you type <i>new command</i> it means the same thing as <i>old command</i>.
 
===Code===
<langsyntaxhighlight lang="ruby">require 'matrix'
 
class Vector
Line 265:
print "> "
process_cmd gets.chop.downcase
end</langsyntaxhighlight>
9,482

edits