File : camel.sp


What is your command? 2
Your camel likes this pace.
The pygmies are  7 miles behind you.
You have travelled  17 miles altogether.

What is your command? 4
Your camel thanks you !
-------------------W A R N I N G------------
GET A DRINK
The pygmies are  12 miles behind you.
You have travelled  17 miles altogether.

What is your command? 1
BETTER WATCH FOR AN OASES  !
The pygmies have captured you.  Camel and people soup is their
favorite dish !!!!!!
You died in the desert.
The local sheik now uses your skull for a change purse !!!!

Want a new camel and a new game? 


#!/usr/local/bin/spar

pragma annotate( summary, "camel" )
       @( description, "Outrun pygmies across the GOBI Desert." )
       @( description, "Originally written in BASIC by David Ahl, Creative Computing" )
       @( description, "From his book 'BASIC COmputer Games'" )
       @( description, "SparForte port by Ken O. Burtch, March 2003" )
       @( description, "Usage: camel" )
       @( see_also, "http://www.swapmeetdave.com" )
       @( author, "Ken O. Burth" );
pragma license( unrestricted );

pragma restriction( no_external_commands );

reply   : character;
thirst  : integer := 4;     -- commands until dying by thirst
canteen : natural := 6;     -- drinks left, start with 6
dist    : integer := 0;     -- distance travelled
pdist   : integer := 0;     -- distance pygmies travelled
pdelay  : natural := 0;     -- pygmy delay
camel   : integer := 0;     -- camel health
scene   : positive;

type a_player_status is (alive, captured, dead, won);
status : a_player_status := alive;

put_line( "CAMEL" )
       @( "Originally by David Ahl, Creative Computing" );
new_line;
put( "WOUD YOU LIKE INSTRUCTIONS? (Y/N) " );
reply := inkey;
put_line( reply );
if reply = 'y' or reply = 'Y' then
   put_line( "  Welcome to Camel.  The object is to travel 200 miles" )
          @( "across the great GOBI Desert." )
          @( "A tribe of knocked kneed pygmies will be chasing you.  You will" )
          @( "be asked for commands every so often." );
   new_line;
   put_line( "C O M M A N D S :" )
          @( "1# Drink form your canteen" )
          @( "2# Ahead modrate speed" )
          @( "3# ahead full speed" )
          @( "4# stop for the night" )
          @( "5# Status check" )
          @( "6# Hope for help" );
   new_line;
   put_line( "You have one quart of water which will last you six drinks." )
          @( "You must renew your water supply completely at an oases." )
          @( "You get a half a quart if found by help." )
          @( "If help does not find you after command six, you lose." );
end if;
put_line( "Good luck and good cameling!!!" );
new_line;

put_line("You are in the middle of the desert at an oasis." );

loop
  loop
    if reply /= '5' then -- didn't move on status
       thirst := @-1;
       if thirst = 1 then
          put_line( "-------------------W A R N I N G------------" )
                 @( "GET A DRINK" );
       elsif thirst < 0 then
          put_line( "You ran out of water......sorry chum!!!" );
          status := dead;
       end if;
       pdelay := @+1;
       if pdelay > 3 then
          pdist := @+integer(numerics.rnd(10))-1;
          if pdist >= dist then
             put_line( "The pygmies have captured you.  Camel and people soup is their" )
                    @( "favorite dish !!!!!!" );
             status := dead;
           end if;
       end if;
    end if;
    if status /= dead then
       put( "The pygmies are " )
         @( pdist )
         @( " miles behind you." )
         @( "You have travelled " )
         @( dist )
         @( " miles altogether." );
       new_line;
    end if;
    if status = captured then
       new_line;
       put_line( "You have a new choice of sub-commands:" )
              @( "#1 TAKE A DRINK" )
              @( "#7 ATTEMPT AN ESCAPE" )
              @( "#8 WAIT FOR PAYMENT" )
              @( "Your sub-command? " );
       reply := inkey;
       put_line( reply );
       case reply is
       when '1' =>
            canteen := @-1;
       when '7' =>
            if numerics.rnd(2) = 1 then
               put_line( "CONGRADULATIONS, YOU SUCCESSFULLY ESCAPED!!!!!!!!" );
               status := alive;
            else
               put_line( "You were mortally wounded by a pig stabber while escaping." );
               status := dead;
            end if;
       when '8' =>
            if numerics.rnd(4) = 1 then
               put_line( "Your ransom has been paid and you are free to go." );
               status := alive;
            else
               put_line( "The local sultain is collecting......just wait.................." );
            end if;
       when others => null;
       end case;
    elsif status = dead then
       put_line( "You died in the desert." );
       scene := numerics.rnd( 5 );
       case scene is
       when 1 => put_line( "The National Camel's Union is not attending your funeral!!!" );
       when 2 => put_line( "Your body was eaten by vultures and imported canninbals !!!" );
       when 3 => put_line( "The local sheik now uses your skull for a change purse !!!!" );
       when 4 => put_line( "People with little intellegence should stay out of the desert!" );
       when 5 => put_line( "TURKEYS SHOULD FLY, NOT RIDE CAMELS !!!!!!!!!!!!!!!!!!!!!!" );
       when others =>
          put( "error: unexpected scene: '" )
            @( scene );
          put_line( "'" );
       end case;
       exit;
    elsif status = won then
       put_line( "You win, a party is being given in your honor............" )
              @( "............The pygmies are planning to attend..............." );
       exit;
    else
      new_line;
      put( "What is your command? " );
      reply := inkey;
      put_line( reply );
      case reply is
      when '1' =>
           if canteen = 0 then
              put_line( "The canteen is empty" );
           else
              thirst := 4;
              canteen := @-1;
              put_line( "BETTER WATCH FOR AN OASES  !" );
           end if;
      when '2' =>
           camel := @+1;
           if camel > 7 then
              status := dead;
              put_line( "You dirty rapscallion!  You ran your poor camel to DEATH!!" );
           else
              dist := @+integer(numerics.rnd(10));
              put_line( "Your camel likes this pace." );
           end if;
      when '3' =>
           camel := @+3;
           if camel > 7 then
              status := dead;
              put_line( "You dirty rapscallion!  You ran your poor camel to DEATH!!" );
           else
              dist := @+2*integer(numerics.rnd(10));
              new_line;
              put_line( "Your camel is burning across the desert sands." );
           end if;
      when '4' =>
           camel := 0;
           put_line( "Your camel thanks you !" );
      when '5' =>
           put( "Your camel has " )
             @( 7-camel );
           put_line( " good days left." );
           put( "You have " )
             @( canteen );
           put_line( " drinks left in your canteen." );
           put( "You can go " )
             @( thirst );
           put_line( " commands without drinking." );
      when '6' =>
           if numerics.rnd(10) = 1 then
              thirst := 4;
              canteen := 3;
              put_line( "Help has found you in a state of unconsciousness." );
           else
              status := dead;
           end if;
      when others => null;
      end case;

      if status = alive and reply /= '5' then
         scene := numerics.rnd( 1000 );
         if scene in 1..50 then
            new_line;
            put_line( "WILD BERBERS HIDDEN IN THE SAND HAVE CAPTURED YOU." )
                   @( "Luckily the local sheik has agreed to their ransom----" )
                   @( "demands.....but........watch for the pygmies!!!!!!" );
            status := captured;
         elsif scene in 51..240 then
            thirst := 4;
            canteen := 6;
            new_line;
            put_line( "You have arrived at an oases--------Your camel is filling " )
                   @( "your canteen and eating figs." );
         elsif scene in 241..277 then
            dist := @+integer(numerics.rnd(19)-10);
            new_line;
            put_line( "You have been caught in a sandstorm......GOOD LUCK!" );
            put( "Your new postion is " )
              @( dist );
            put_line( " miles so far!" );
         elsif scene in 278..312 then
            pdist := @+1;
            new_line;
            put_line( "Your camel hurt his hump." )
                   @( "Luckily the pygmies were footweary  !!!" );
         end if;
       end if;
     end if;
  end loop;

  new_line;
  put( "Want a new camel and a new game? " );
  reply := inkey;
  put_line( reply );
  if reply = 'y' or reply = 'Y' then
     thirst := 4;
     canteen := 6;
     dist := 0;
     pdist := 0;
     pdelay := 0;
     camel := 0;
     status := alive;
  else
     put( "------------------" )
       @( "     CHICKEN     " )
       @( "------------------" );
     new_line;
     exit;
  end if;
end loop;
command_line.set_exit_status( 0 );

-- VIM editor formatting instructions
-- vim: ft=spar