Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Re: Moduals

Expand Messages
  • Jenda Krynicky
    From: Mike Flannigan ... I think you are exagerating here. I don t think there needs to be any complex math or anything like that.
    Message 1 of 15 , Oct 29, 2004
      From: Mike Flannigan <mikeflan@...>
      > > Date: Wed, 27 Oct 2004 14:19:31 -0400
      > > From: "Luinrandir Hernsen" <Luinrandir@...>
      > > Subject: Re: Re: Moduals
      > >
      > > It is an adventure game.
      > > www.mysticadventures.com
      > > It is an interactive story, here your decisions effect the options
      > > given to you.
      > >
      > > I am currently working on storing your stuff in your castle...
      > > next comes combat for others castles...
      > >
      > > Lou
      >
      > OK. I'm still thinking about this, but my first thought is
      > to move all the textural data out to a text file (or multiple
      > text files might be better) and read it into a hash at the
      > beginning of the program. Then develop a complex
      > mathematical formula to query different hash keys as
      > the game progresses and populate "player" hashes to
      > keep track of what they have acquired, used up, etc.

      I think you are exagerating here. I don't think there needs to be any
      complex math or anything like that.

      You'd just need to have the whole "world" in a data-structure and
      create a "driver" that would understand that datastructure and would
      navigate it.

      Let me give you a short and incomplete example:

      %world = (
      rooms => {
      room1 => {
      description => "You are standing in ....",
      things => [ 'knife', 'rope'],
      moves => {
      south => 'room2',
      north => 'room3',
      }
      }
      },
      things => {
      knife => {
      description => 'You see a nice sharp knife ...",
      actions => {
      cut => [ 'rope', 'grase', 'alien'],
      }
      }
      }
      );


      my $actRoom = "room1";
      my @haveThings = ();
      my $action;
      while (1) {
      my $ActRoom = $world{rooms}->{$actRoom};
      print $ActRoom->{description}, "\n";
      print "What should I do? >";
      $action = lc(<STDIN>) or exit();
      chomp($action);
      my ($verb, $subject) = split ' ', $action, 2;
      if ($verb eq 'go') {
      if (exists $ActRoom->{moves}->{$subject}) {
      $actRoom = $ActRoom->{moves}->{$subject};
      } else {
      print "You can't go $subject from this room.\n";
      }
      } elsif ($action eq 'take') {
      if (grep {$_ eq $subject} @{$ActRoom->{things}}) {
      print "You take $subject\n";
      push @haveThings, $subject;
      @{$ActRoom->{things} = grep {$_ ne $subject} @{$ActRoom->{things};
      } else {
      print "There is no $subject in this room.\n"
      }
      } elsif ...
      ...
      } else {
      print "I don't know what do you mean by '$action'!\n";
      }
      }

      Jenda
      ===== Jenda@... === http://Jenda.Krynicky.cz =====
      When it comes to wine, women and song, wizards are allowed
      to get drunk and croon as much as they like.
      -- Terry Pratchett in Sourcery
    Your message has been successfully submitted and would be delivered to recipients shortly.