#!/usr/bin/perl
#################
#
# A simplistic Zork-like program that demonstrates some object oriented ideas.
#
#################

use Room;

my $entrance = Room->new;
$entrance->setDescription("You are at the top of a long stairway.");

my $stairBottom = Room->new();
$stairBottom->setDescription("The bottom of the stair is dark and dank.");
$stairBottom->addItem("toothbrush");
$stairBottom->addItem("comb");

$entrance->addExit( South => $stairBottom );
$stairBottom->addExit( North => $entrance );

print "The dungeon has " . Room->countRooms() . " rooms.\n";

my $currentRoom = $entrance;
my $alive       = 1;

print " ** Welcome to the dungeon. ** \n";

while ($alive){
  print "\n" . $currentRoom->asText() . "\n";  
  print " Where do you want to go? ";
  chomp(my $where = <>);
  my $result = $currentRoom->getExit( $where );
  if (ref $result){
    $currentRoom = $result;
  }
  else {
    print " Oops - $result\n";
  }
}



