RCRPG/Perl: Difference between revisions

m
Fixed syntax highlighting.
m (Collection/cat)
m (Fixed syntax highlighting.)
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{collection|RCRPG}}
{{collection|RCRPG}}This [[Category:Perl]]This version of [[:Category:RCRPG|RCRPG]] implements a text interface.
 
===Language idiomsIdioms===
(Add to this list if you see anything of interest not mentioned.)
 
Line 12 ⟶ 13:
* [[Linked list|Linked lists]] (The rooms are linked by keeping a list of keys to connected rooms in each room. This adds a lookup step, but each key could be thought of a pointer in the classic sense of a linked list.)
 
===Commands===
 
Here is a description of all of the commands:
Line 46 ⟶ 47:
Give an existsing command an alias. Starting aliases are n,s,e,w,u,d. i and inv are the same as inventory, a is the same as attack.
 
===Use===
 
None of the rooms are connected. In fact, at the start of the game, only two rooms really exist; the Start and the Prize room. There’s a third room, but it exists outside of the 3D coordinate space, and it’s used to initialize each room the player creates by moving around.
Line 60 ⟶ 61:
The player can make their way to the Prize Room at (1,1,5), but there's nothing useful there; just gold.
 
===Code===
 
<langsyntaxhighlight lang="perl">#!/usr/bin/perl -w
use strict;
use Data::Dumper;
Line 439 ⟶ 440:
unless( defined $directions{$direction})
{
print "I don't nowknow that direction. Try:";
foreach my $exdir ( keys %directions )
{
Line 758 ⟶ 759:
print "\n";
}
}</syntaxhighlight>
}
</lang>
9,476

edits