home *** CD-ROM | disk | FTP | other *** search
-
- {INIT.PA2}
-
- PROCEDURE PAD(VAR sentence : s);
- CONST
- Blanks = ' ';
- VAR
- LongLine : String[255];
- BEGIN
- LongLine := sentence+Blanks;
- sentence := Copy(LongLine, 1, 79);
- END;
-
-
- FUNCTION NOT_END(sentence : s) : Boolean;
- {Returns YES if sentence does not begin with END_ or end_}
- BEGIN
- sentence := Copy(sentence, 1, 4);
- Capitalize(sentence);
- IF sentence = 'END_'
- THEN NOT_END := False
- ELSE NOT_END := True;
- END; {NOT_END}
-
-
- { Initialize }
- {Initialize the noun and creature arrays; }
- {also initialize player data and locate the }
- {the player in room 2 or STARTING_ROOM value.}
-
- {Initialize Part 1}
- PROCEDURE Initialize_Part1;
- {all variables are global to INITIALIZE}
- VAR i, vv : Integer;
- sentence, TopSen, InSen : s;
- st : words;
- Dir : Direction;
- BEGIN
- {initialize_part1}
- Word_Chars := ['0'..'9', 'A'..'Z', 'a'..'z', '-', '_'];
- Skip_A_Line := True;
- player_dead := False;
- Current_Life := 1;
- Num_turns := 0;
- Num_saves := 0; num_restores := 0;
- verbose := True; {default is to describe every room}
- game_won := False;
- game_end := False;
- Treasure_Room := 3000;
- Maximum_Score := 0;
- Resurrection_Room := 2;
- Max_Lives := 3;
- FOR i := 0 TO MaxCounter DO counter[i] := 0; {zero counters}
- FOR i := 0 TO MaxVariable DO Variable[i] := 0; {zero variable}
- FOR i := 0 TO MaxFlag DO Flag[i] := False; {make all flags FALSE}
- FOR i := 0 TO MaxQuestion DO
- BEGIN
- Question[i] := 'NONE';
- Answer[i] := 'NONE';
- END;
- QuestionStatus := False;
- FOR i := 0 TO Last_Creature DO
- BEGIN
- StartingIndex[i] := MaxCommand+10; {used for index sequential search}
- EndingIndex[i] := -1;
- END; { for i := 0 to num_verbs }
-
- Subject_IT[Thing] := 'it'; {Subject pronouns for Creature = Thing}
- Cap_Subject_IT[Thing] := 'It';
- Object_IT[Thing] := 'it';
- Snarls[Thing] := 'snarls'; {verbs for Creature = Thing}
- Screeches[Thing] := 'screeches';
- Subject_IT[Man] := 'he'; {Subject pronouns for Creature = Man}
- Cap_Subject_IT[Man] := 'He';
- Object_IT[Man] := 'him';
- Snarls[Man] := 'scowls'; {verbs for Creature = Man}
- Screeches[Man] := 'screams';
- Subject_IT[Woman] := 'she'; {Subject pronouns for Creature = Woman}
- Cap_Subject_IT[Woman] := 'She';
- Object_IT[Woman] := 'her';
- Snarls[Woman] := 'scowls'; {verbs for Creature = Woman}
- Screeches[Woman] := 'screams';
- IsOrAre[Singular] := 'is';
- IsOrAre[Plural] := 'are';
- ItOrThem[Singular] := 'it';
- ItOrThem[Plural] := 'them';
-
- {zero out the room information}
- Current_room := First_Room; {start off in first room (as default)}
- Starting_room := First_Room; {default}
- FOR i := First_Room TO Last_Room DO
- BEGIN
- New(Room[i]); {must create space in heap}
- WITH Room[i]^ DO
- BEGIN
- name := 'none';
- Replaced_Word := 'none'; {Room Synonyms}
- Replacing_Words := 'none';
- FOR Dir := NORTH TO Exit DO Path[Dir] := 0;
- special := 0;
- has_seen := False;
- locked_door := False;
- key := 0;
- light := 0;
- points := 0;
- nouns_inside := 0;
- game_end := False;
- game_win := False;
- player_dead := False;
- END;
- Room_Ptr[i].start := -1;
- Room_Ptr[i].len := 0;
- Help_Ptr[i].start := -1; {Room Helps}
- Help_Ptr[i].len := 0;
- Special_Ptr[i].start := -1;
- Special_Ptr[i].len := 0;
- END; {for i := first_room..last_room}
-
- Intro_Ptr.start := -1;
- Intro_Ptr.len := 0;
-
- {now zero-out the message information}
- FOR i := First_Message TO Last_Message DO
- BEGIN
- Message_Ptr[i].start := -1; {Messages}
- Message_Ptr[i].len := 0;
- END;
-
- {now zero-out the noun information}
- FOR i := First_noun TO Last_noun DO
- BEGIN
- New(N[i]); {must create space in heap}
- WITH N[i]^ DO
- BEGIN
- name := 'none';
- position := 'none';
- SingOrPlur := Singular;
- SomethingPositionedNearThisNoun := False;
- ThisNounPositionedNearNounNumber := 0;
- adj := '';
- Has_Synonyms := False;
- synonyms := ''; {Synonyms for this noun}
- readable := False;
- closable := False;
- wearable := False;
- open := False;
- on := False;
- pushable := False;
- turnable := False;
- playable := False;
- pullable := False;
- lockable := False;
- locked := False;
- poisonous := False;
- edible := False;
- drinkable := False;
- movable := True;
- weight := 1;
- size := 1;
- location := 0;
- key := 0;
- is_light := False;
- points := 0;
- nouns_inside := 0;
- can_shoot := False;
- num_shots := 0;
- game_win := False;
- END;
- Noun_Ptr[i].start := -1; Push_Ptr[i].start := -1;
- Pull_Ptr[i].start := -1; Text_Ptr[i].start := -1;
- Turn_Ptr[i].start := -1; Play_Ptr[i].start := -1;
- Noun_Ptr[i].len := 0; Push_Ptr[i].len := 0;
- Pull_Ptr[i].len := 0; Text_Ptr[i].len := 0;
- Turn_Ptr[i].len := 0; Play_Ptr[i].len := 0;
- Intro_Ptr.start := 0; Intro_Ptr.len := 0;
- END;
-
- {now zero out the creature information}
- FOR i := First_creature TO Last_Creature DO
- BEGIN
- New(M[i]); {must create space in heap}
- WITH M[i]^ DO
- BEGIN
- location := 0;
- name := 'none';
- adj := '';
- Has_Synonyms := False;
- synonyms := ''; {Synonyms for this creature}
- groupmember := False;
- weapon := 0;
- hostile := False;
- points := 0;
- nouns_inside := 0;
- counter := 0;
- threshhold := 3;
- timethresh := -1;
- timecounter := 0;
- gender := Thing; {beast/animal/default creature}
- END;
- Creature_Ptr[i].start := -1;
- Creature_Ptr[i].len := 0;
- END;
- MaxRoom := 0; {zero upper index limit to start with}
- MaxNoun := 0; {zero upper index limit to start with}
- MaxCreature := 0; {zero upper index limit to start with}
- {finished zeroing out}
-
- {now -- read data files}
- Assign(descr_file, descr_file_name);
- Rewrite(descr_file);
- sentence := ' >> Temporary data file of strings for AGT << ';
- Write(descr_file, sentence); {fill line 0 in file}
-
- IF File_Exists(message_file_name) THEN
- BEGIN {message file exists}
- Assign(datafile, message_file_name); {message file}
- Reset(datafile);
- REPEAT {until (sentence = 'END OF FILE') or (EOF(datafile))}
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- st := first_word(sentence);
- IF st <> '' THEN
- IF st = 'MESSAGE' THEN
- BEGIN
- vv := Value(sentence);
- (* *) IF vv > MaxMessage THEN MaxMessage := vv; (** Set new upper limit **)
- InSen := sentence;
- (* *) TestParameter(vv, '', InSen, MessageTest);
- Message_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Message_Ptr[vv].len := Message_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END;
- UNTIL (POS('END OF FILE', sentence) <> 0) OR (EOF(datafile));
- Close(datafile);
- END; {message file exists}
-
- Assign(datafile, data_file_name); {normal datafile}
- Reset(datafile);
-
- END; {initialize_part1}
-
- {Initialize Part 2}
- PROCEDURE Initialize_Part2;
- VAR i, vv, zz, qLoc : Integer;
- qst, qst2, sentence : s;
- TopSen, InSen : s;
- st, st2 : words;
- match : Boolean;
-
- PROCEDURE TestForFatalError(num : Integer; FromNum : Integer; ToNum : Integer);
- BEGIN
- IF (num < FromNum) OR (num > ToNum) THEN
- BEGIN
- WriteLn('This is a FATAL error!!! Fix it, then COMPILE again.');
- Halt;
- END;
- END;
-
- BEGIN {initialize_part2}
- REPEAT {until (sentence = 'END OF FILE') or (EOF(datafile))}
- ReadLn(datafile, sentence);
- (* *) TopSen := sentence;
- Capitalize(sentence);
- st := first_word(sentence);
- IF st <> '' THEN
- IF (st = 'ROOM') THEN
- BEGIN
- i := Value(sentence);
- (* *) TestParameter(i, '', TopSen, RoomTest);
- (* *) TestForFatalError(i, First_Room, Last_Room);
- IF i > MaxRoom THEN MaxRoom := i; {new upper limit defined}
- ReadLn(datafile, Room[i]^.name); {get room name}
- WHILE ((Room[i]^.name[1] = ' ') AND (Length(Room[i]^.name) > 0)) DO
- Room[i]^.name := Copy(Room[i]^.name, 2, Length(Room[i]^.name));
- REPEAT
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- st := first_word(sentence);
- IF (st = 'N') OR (st = 'NORTH') THEN
- Room[i]^.Path[NORTH] := Value(sentence)
- ELSE IF (st = 'S') OR (st = 'SOUTH') THEN
- Room[i]^.Path[SOUTH] := Value(sentence)
- ELSE IF (st = 'E') OR (st = 'EAST') THEN
- Room[i]^.Path[EAST] := Value(sentence)
- ELSE IF (st = 'W') OR (st = 'WEST') THEN
- Room[i]^.Path[WEST] := Value(sentence)
- ELSE IF (st = 'NE') OR (st = 'NORTHEAST') THEN
- Room[i]^.Path[northeast] := Value(sentence)
- ELSE IF (st = 'NW') OR (st = 'NORTHWEST') THEN
- Room[i]^.Path[northwest] := Value(sentence)
- ELSE IF (st = 'SE') OR (st = 'SOUTHEAST') THEN
- Room[i]^.Path[southeast] := Value(sentence)
- ELSE IF (st = 'SW') OR (st = 'SOUTHWEST') THEN
- Room[i]^.Path[southwest] := Value(sentence)
- ELSE IF (st = 'U') OR (st = 'UP') THEN
- Room[i]^.Path[up] := Value(sentence)
- ELSE IF (st = 'D') OR (st = 'DOWN') THEN
- Room[i]^.Path[down] := Value(sentence)
- ELSE IF (st = 'ENTER') THEN
- Room[i]^.Path[enter] := Value(sentence)
- ELSE IF (st = 'EXIT') THEN
- Room[i]^.Path[Exit] := Value(sentence)
- ELSE IF (st = 'SPECIAL') THEN
- Room[i]^.special := Value(sentence)
- ELSE IF (st = 'KEY') THEN
- Room[i]^.key := Value(sentence)
- ELSE IF (st = 'LOCKED_DOOR') THEN
- Room[i]^.locked_door := True
- ELSE IF (st = 'ROOM_SYNONYMS') THEN
- BEGIN
- st2 := second_word(sentence);
- IF st2 = 'CHANGE_LOCATION' THEN st2 := 'CHANGE_LOCATIONS';
- IF NOT Is_Verb(st2)
- THEN WriteLn('ERROR: "', st2, '" is not a valid verb!');
- Room[i]^.Replaced_Word := st2;
- zz := POS(st2, sentence)+Length(st2);
- st := Copy(sentence, zz, 255)+' ';
- {has leading and trailing space}
- Room[i]^.Replacing_Words := ' '+st+' ';
- END {Room Synonyms}
- ELSE IF (st = 'PLAYER_DEAD') OR (sentence = 'KILLPLAYER') THEN
- Room[i]^.player_dead := True
- ELSE IF (st = 'GAME_END') OR (sentence = 'GAME-END') THEN
- Room[i]^.game_end := True
- ELSE IF (st = 'GAME_WIN') OR (st = 'GAME_WON')
- OR (sentence = 'GAME-WIN') OR (sentence = 'GAME-WON') THEN
- Room[i]^.game_win := True
- ELSE IF (st = 'LIGHT') THEN
- Room[i]^.light := Value(sentence)
- ELSE IF (st = 'POINTS') OR (st = 'SCORE') THEN
- Room[i]^.points := Value(sentence); {last statement in IF}
- UNTIL (st = 'END_ROOM');
- END {if ROOM}
-
- ELSE IF (st = 'NOUN') THEN
- BEGIN
- i := Value(sentence);
- (* *) TestParameter(i, '', TopSen, NounTest);
- (* *) TestForFatalError(i, First_noun, Last_noun);
- IF i > MaxNoun THEN MaxNoun := i; {new upper limit defined}
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- N[i]^.name := sentence; {get noun name}
- N[i]^.synonyms := ' '+sentence+' ';
- {create synonym list containing Name to begin with}
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- N[i]^.adj := sentence;
- ReadLn(datafile, N[i]^.short);
- REPEAT
- ReadLn(datafile, sentence);
- (* *) InSen := sentence;
- Capitalize(sentence);
- st := first_word(sentence);
- IF (st = 'WEIGHT') THEN
- N[i]^.weight := Value(sentence)
- ELSE
- IF (st = 'SIZE') THEN
- N[i]^.size := Value(sentence)
- ELSE
- IF (st = 'LOCATION') THEN
- BEGIN
- N[i]^.location := Value(sentence);
- (* *) TestParameter(Value(sentence), TopSen, InSen, LocationTest);
- END ELSE
- IF (st = 'KEY') THEN
- BEGIN
- N[i]^.key := Value(sentence);
- (* *) TestParameter(Value(sentence), TopSen, InSen, ZNounTest);
- END
- ELSE IF (st = 'POINTS') OR (st = 'SCORE') THEN
- N[i]^.points := Value(sentence)
- ELSE IF (st = 'CAN_SHOOT') OR (st = 'IS_GUN') THEN
- N[i]^.can_shoot := True
- ELSE IF (st = 'BULLETS') OR (st = 'NUM_SHOTS') THEN
- N[i]^.num_shots := Value(sentence)
- ELSE IF (st = 'NOUN_SYNONYMS') THEN
- BEGIN
- qst2 := But_First(sentence);
- N[i]^.synonyms := N[i]^.synonyms+' '+qst2+' ';
- {add synonyms to normal name for this noun}
- N[i]^.Has_Synonyms := True;
- END
- ELSE IF (st = 'POSITION') THEN
- BEGIN
- qst2 := But_First(sentence);
- Normalize(qst2);
- N[i]^.position := qst2;
- END
- ELSE {Position} IF (st = 'READABLE') THEN
- N[i]^.readable := True
- ELSE IF (st = 'PUSHABLE') OR (st = 'TOUCHABLE') THEN
- N[i]^.pushable := True
- ELSE IF (st = 'TURNABLE') THEN
- N[i]^.turnable := True
- ELSE IF (st = 'PLAYABLE') THEN
- N[i]^.playable := True
- ELSE IF (st = 'PULLABLE') THEN
- N[i]^.pullable := True
- ELSE IF (st = 'PLURAL') THEN
- N[i]^.SingOrPlur := Plural
- ELSE IF (st = 'ON') THEN
- N[i]^.on := True
- ELSE IF (st = 'OFF') THEN
- N[i]^.on := False
- ELSE IF (st = 'UNREADABLE') THEN
- N[i]^.readable := False
- ELSE IF (st = 'CLOSABLE') OR (st = 'CLOSEABLE') THEN
- N[i]^.closable := True
- ELSE IF (st = 'UNCLOSABLE') OR (st = 'UNCLOSEABLE') THEN
- N[i]^.closable := False
- ELSE IF (st = 'WEARABLE') THEN
- N[i]^.wearable := True
- ELSE IF (st = 'UNWEARABLE') THEN
- N[i]^.wearable := False
- ELSE IF (st = 'OPEN') THEN
- N[i]^.open := True
- ELSE IF (st = 'CLOSED') THEN
- N[i]^.open := False
- ELSE IF (st = 'LOCKABLE') THEN
- N[i]^.lockable := True
- ELSE IF (st = 'UNLOCKABLE') THEN
- N[i]^.lockable := False
- ELSE IF (st = 'LOCKED') THEN
- N[i]^.locked := True
- ELSE IF (st = 'UNLOCKED') THEN
- N[i]^.locked := False
- ELSE IF (st = 'EDIBLE') THEN
- N[i]^.edible := True
- ELSE IF (st = 'INEDIBLE') THEN
- N[i]^.edible := False
- ELSE IF (st = 'DRINKABLE') THEN
- N[i]^.drinkable := True
- ELSE IF (st = 'UNDRINKABLE') THEN
- N[i]^.drinkable := False
- ELSE IF (st = 'POISONOUS') THEN
- N[i]^.poisonous := True
- ELSE IF (st = 'NON-POISONOUS') OR (st = 'NONPOISONOUS') THEN
- N[i]^.poisonous := False
- ELSE IF (st = 'MOVABLE') OR (st = 'MOVEABLE') THEN
- N[i]^.movable := True
- ELSE IF (st = 'UNMOVABLE') OR (st = 'UNMOVEABLE') THEN
- N[i]^.movable := False
- ELSE IF (st = 'LIGHT') OR (st = 'IS_LIGHT') THEN
- N[i]^.is_light := True
- ELSE IF (st = 'GAME_WIN') THEN
- N[i]^.game_win := True; {last line of IF}
- UNTIL (st = 'END_NOUN');
- END {if NOUN}
-
- ELSE IF (st = 'CREATURE') THEN
- BEGIN
- i := Value(sentence);
- (* *) TestParameter(i, '', TopSen, CreatureTest);
- (* *) TestForFatalError(i, First_creature, Last_Creature);
- IF i > MaxCreature THEN MaxCreature := i; {new upper limit defined}
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- M[i]^.name := sentence; {get creature name}
- M[i]^.synonyms := ' '+sentence+' ';
- {create synonym list containing Name to begin with}
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- M[i]^.adj := sentence;
- ReadLn(datafile, M[i]^.short);
- REPEAT
- ReadLn(datafile, sentence);
- Capitalize(sentence);
- (* *) InSen := sentence;
- st := first_word(sentence);
- IF (st = 'LOCATION') THEN
- BEGIN
- M[i]^.location := Value(sentence);
- (* *) TestParameter(Value(sentence), TopSen, InSen, ZRoomTest);
- END
- ELSE IF (st = 'WEAPON') THEN
- M[i]^.weapon := Value(sentence)
- ELSE IF (st = 'POINTS') THEN
- M[i]^.points := Value(sentence)
- ELSE IF (st = 'CREATURE_SYNONYMS') THEN
- BEGIN
- qst2 := But_First(sentence);
- M[i]^.synonyms := M[i]^.synonyms+' '+qst2+' ';
- {add synonyms to normal name for this creature}
- M[i]^.Has_Synonyms := True;
- END
- ELSE IF (st = 'GROUPMEMBER') THEN
- M[i]^.groupmember := True
- ELSE IF (st = 'HOSTILE') THEN
- M[i]^.hostile := True
- ELSE IF (st = 'FRIENDLY') THEN
- M[i]^.hostile := False
- ELSE IF ((st = 'WOMAN') OR (st = 'FEMALE')) THEN
- M[i]^.gender := Woman
- ELSE IF ((st = 'MAN') OR (st = 'MALE')) THEN
- M[i]^.gender := Man
- ELSE { Below handles most common misspellings }
- IF POS('THRESH', st) <> 0 THEN
- IF POS('TIME', st) <> 0 THEN
- M[i]^.timethresh := Value(sentence)
- ELSE
- M[i]^.threshhold := Value(sentence); {Last line of IF}
- UNTIL (st = 'END_CREATURE');
- END {if Creature}
-
- {else it's a description, set appropriate pointer}
- ELSE IF st = 'TEXT' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
- Text_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Text_Ptr[vv].len := Text_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'QUESTION' THEN
- BEGIN
- sentence := But_First(sentence);
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, QuestionTest);
- sentence := But_First(sentence);
- Question[vv] := sentence;
- END
- ELSE IF st = 'ANSWER' THEN
- BEGIN
- sentence := But_First(sentence);
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, QuestionTest);
- sentence := But_First(sentence);
- Answer[vv] := sentence;
- END
- ELSE IF st = 'HELP' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
- Help_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Help_Ptr[vv].len := Help_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'PLAY_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
- Play_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Play_Ptr[vv].len := Play_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'PUSH_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
- Push_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Push_Ptr[vv].len := Push_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'PULL_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
- Pull_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Pull_Ptr[vv].len := Pull_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'TURN_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
- Turn_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Turn_Ptr[vv].len := Turn_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'CREATURE_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, CreatureTest);
- Creature_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Creature_Ptr[vv].len := Creature_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'ROOM_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
- Room_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Room_Ptr[vv].len := Room_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'SPECIAL' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
- Special_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Special_Ptr[vv].len := Special_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF st = 'RESURRECTION_ROOM' THEN
- BEGIN
- Resurrection_Room := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
- END
- ELSE IF st = 'MAX_LIVES' THEN Max_Lives := Value(sentence)
- ELSE IF st = 'TREASURE_ROOM' THEN Treasure_Room := Value(sentence)
- ELSE IF st = 'MAXIMUM_SCORE' THEN Maximum_Score := Value(sentence)
- ELSE IF st = 'STARTING_ROOM' THEN
- BEGIN
- Current_room := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
- Starting_room := Current_room;
- END
- ELSE IF st = 'NOUN_DESCR' THEN
- BEGIN
- vv := Value(sentence);
- (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
- Noun_Ptr[vv].start := FilePos(descr_file);
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Noun_Ptr[vv].len := Noun_Ptr[vv].len+1;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF (st = 'INTRO') OR (st = 'INTRODUCTION') THEN
- BEGIN
- ReadLn(datafile, sentence); {skip past line with 'INTRO' on it}
- IF CreatingFinalVersion THEN Intro_Ptr.start := FilePos(descr_file);
- WHILE NOT_END(sentence) DO
- BEGIN
- IF CreatingFinalVersion THEN
- BEGIN
- PAD(sentence); {Pads out sentence with blanks}
- sentence := Encode(sentence);
- Write(descr_file, sentence);
- Intro_Ptr.len := Intro_Ptr.len+1;
- END;
- ReadLn(datafile, sentence);
- END;
- END
- ELSE IF (st = 'VERB') OR (st = 'SYNONYM')
- OR (st = 'VERBS') OR (st = 'SYNONYMS')
- {user-defined verb synonym}
- THEN BEGIN
- ReadLn(datafile, sentence);
- WHILE NOT_END(sentence) DO
- BEGIN
- Capitalize(sentence);
- st := first_word(sentence);
- IF NOT Is_Verb(st)
- THEN WriteLn('ERROR: "', st, '" is not a valid verb!');
- qst2 := ' '+But_First(sentence)+' * ';
- {has leading and trailing space}
- i := 1;
- match := False;
- WHILE (i <= Num_Verbs) AND (NOT match) DO
- BEGIN
- IF (V[i] = st) THEN
- BEGIN
- SYN[i] := qst2;
- match := True;
- END;
- i := i+1;
- END; {while}
- IF NOT match THEN WriteLn(' >>> Ignored: "', sentence, '"');
- ReadLn(datafile, sentence);
- END; {while}
- END; {'VERB' synonyms}
-
- UNTIL (POS('END OF FILE', sentence) <> 0) OR (EOF(datafile));
- sentence := 'END OF FILE';
- Write(descr_file, sentence); {mark end of this file}
- Close(descr_file);
- Close(datafile);
- IF (Starting_room <> 2) AND (Resurrection_Room = 2)
- THEN Resurrection_Room := Starting_room; {default condition}
-
- {zero counts of nouns located various places}
- Items_Being_Carried := 0;
- Items_Being_Worn := 0;
- FOR i := First_Room TO MaxRoom DO Room[i]^.nouns_inside := 0;
- FOR i := First_noun TO MaxNoun DO N[i]^.nouns_inside := 0;
- FOR i := First_creature TO MaxCreature DO M[i]^.nouns_inside := 0;
-
- {now count how many are located in various places}
- FOR i := First_noun TO MaxNoun DO Adjust_Count(N[i]^.location, 1);
-
- END; {initialize_part2}
-
- { Init_Verbs }
- {Set up the list of valid verbs}
- PROCEDURE Init_verbs;
- {initialize verbs list}
- VAR i : Integer;
- BEGIN
- FOR i := 0 TO Num_Verbs DO V[i] := 'none';
- FOR i := 0 TO Num_Verbs DO SYN[i] := 'none';
- V[0] := 'ANY';
- V[1] := 'NORTH';
- V[2] := 'SOUTH';
- V[3] := 'EAST';
- V[4] := 'WEST';
- V[5] := 'SOUTHEAST';
- V[6] := 'SOUTHWEST';
- V[7] := 'NORTHEAST';
- V[8] := 'NORTHWEST';
- V[9] := 'UP';
- V[10] := 'DOWN';
- V[11] := 'ENTER';
- V[12] := 'EXIT';
- V[13] := 'SPECIAL';
- V[14] := 'THROW';
- V[15] := 'OPEN';
- V[16] := 'CLOSE';
- V[17] := 'LOCK';
- V[18] := 'UNLOCK';
- V[19] := 'LOOK';
- V[20] := 'EXAMINE';
- V[21] := 'CHANGE_LOCATIONS';
- V[22] := 'READ';
- V[23] := 'EAT';
- V[24] := 'DRINK';
- V[25] := 'SCORE';
- V[26] := 'ATTACK';
- V[27] := 'WAIT';
- V[28] := 'YELL';
- V[29] := 'PUT';
- V[30] := 'QUIT';
- V[31] := 'TELL';
- V[32] := 'INVENTORY';
- V[33] := 'GET';
- V[34] := 'ASK';
- V[35] := 'TURN';
- V[36] := 'PUSH';
- V[37] := 'PULL';
- V[38] := 'PLAY';
- V[39] := 'LIST';
- V[40] := 'SHOW';
- V[41] := 'DROP';
- V[42] := 'LIST_EXITS';
- V[43] := 'BRIEF';
- V[44] := 'VERBOSE';
- V[45] := 'SAVE';
- V[46] := 'RESTORE';
- V[47] := 'LIGHT';
- V[48] := 'EXTINGUISH';
- V[49] := 'FIRE';
- V[50] := 'HELP';
- V[51] := 'WEAR';
- V[52] := 'REMOVE';
- V[53] := 'SCRIPT';
- V[54] := 'UNSCRIPT';
- V[55] := 'MAGIC_WORD';
- V[56] := 'DUMMY_VERB1'; V[57] := 'DUMMY_VERB26';
- V[58] := 'DUMMY_VERB2'; V[59] := 'DUMMY_VERB27';
- V[60] := 'DUMMY_VERB3'; V[61] := 'DUMMY_VERB28';
- V[62] := 'DUMMY_VERB4'; V[63] := 'DUMMY_VERB29';
- V[64] := 'DUMMY_VERB5'; V[65] := 'DUMMY_VERB30';
- V[66] := 'DUMMY_VERB6'; V[67] := 'DUMMY_VERB31';
- V[68] := 'DUMMY_VERB7'; V[69] := 'DUMMY_VERB32';
- V[70] := 'DUMMY_VERB8'; V[71] := 'DUMMY_VERB33';
- V[72] := 'DUMMY_VERB9'; V[73] := 'DUMMY_VERB34';
- V[74] := 'DUMMY_VERB10'; V[75] := 'DUMMY_VERB35';
- V[76] := 'DUMMY_VERB11'; V[77] := 'DUMMY_VERB36';
- V[78] := 'DUMMY_VERB12'; V[79] := 'DUMMY_VERB37';
- V[80] := 'DUMMY_VERB13'; V[81] := 'DUMMY_VERB38';
- V[82] := 'DUMMY_VERB14'; V[83] := 'DUMMY_VERB39';
- V[84] := 'DUMMY_VERB15'; V[85] := 'DUMMY_VERB40';
- V[86] := 'DUMMY_VERB16'; V[87] := 'DUMMY_VERB41';
- V[88] := 'DUMMY_VERB17'; V[89] := 'DUMMY_VERB42';
- V[90] := 'DUMMY_VERB18'; V[91] := 'DUMMY_VERB43';
- V[92] := 'DUMMY_VERB19'; V[93] := 'DUMMY_VERB44';
- V[94] := 'DUMMY_VERB20'; V[95] := 'DUMMY_VERB45';
- V[96] := 'DUMMY_VERB21'; V[97] := 'DUMMY_VERB46';
- V[98] := 'DUMMY_VERB22'; V[99] := 'DUMMY_VERB47';
- V[100] := 'DUMMY_VERB23'; V[101] := 'DUMMY_VERB48';
- V[102] := 'DUMMY_VERB24'; V[103] := 'DUMMY_VERB49';
- V[104] := 'DUMMY_VERB25'; V[105] := 'DUMMY_VERB50';
- MaxVerb := 105;
- END; {initialize verbs}
-