| 1 |
(* Copyright (C) 2005-2025 Free Software Foundation, Inc. *) |
| 2 |
(* This file is part of GNU Modula-2. |
| 3 |
|
| 4 |
GNU Modula-2 is free software; you can redistribute it and/or modify it under |
| 5 |
the terms of the GNU General Public License as published by the Free |
| 6 |
Software Foundation; either version 3, or (at your option) any later |
| 7 |
version. |
| 8 |
|
| 9 |
GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License along |
| 15 |
with gm2; see the file COPYING. If not, write to the Free Software |
| 16 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *) |
| 17 |
DEFINITION MODULE AdvMap ; |
| 18 |
|
| 19 |
|
| 20 |
EXPORT QUALIFIED Rooms, Line, DoorStatus, Door, Room, Treasure, |
| 21 |
ActualNoOfRooms, MaxNoOfTreasures, MaxNoOfRooms, |
| 22 |
NoOfRoomsToHidePlayers, NoOfRoomsToSpring, |
| 23 |
NoOfRoomsToHideCoal, NoOfRoomsToHideGrenade, |
| 24 |
ReadAdvMap, Adjacent, IncPosition, |
| 25 |
FileName, MaxLengthOfFileName ; |
| 26 |
|
| 27 |
|
| 28 |
CONST |
| 29 |
MaxNoOfRooms = 350 ; (* An upper limit *) |
| 30 |
WallsPerRoom = 8 ; (* An upper limit *) |
| 31 |
DoorsPerRoom = 6 ; (* An upper limit *) |
| 32 |
MaxNoOfTreasures = 15 ; (* An upper limit *) |
| 33 |
MaxLengthOfFileName = 11 ; |
| 34 |
NoOfRoomsToHidePlayers = 50 ; |
| 35 |
NoOfRoomsToSpring = 50 ; |
| 36 |
NoOfRoomsToHideCoal = 50 ; |
| 37 |
NoOfRoomsToHideGrenade = 50 ; |
| 38 |
|
| 39 |
|
| 40 |
TYPE |
| 41 |
|
| 42 |
Line = RECORD |
| 43 |
X1 : CARDINAL ; |
| 44 |
Y1 : CARDINAL ; |
| 45 |
X2 : CARDINAL ; |
| 46 |
Y2 : CARDINAL |
| 47 |
END ; |
| 48 |
|
| 49 |
DoorStatus = (Open, Closed, Secret) ; |
| 50 |
|
| 51 |
Door = RECORD |
| 52 |
Position : Line ; |
| 53 |
StateOfDoor : DoorStatus ; |
| 54 |
LeadsTo : CARDINAL |
| 55 |
END ; |
| 56 |
|
| 57 |
TreasureInfo = RECORD |
| 58 |
Xpos : CARDINAL ; |
| 59 |
Ypos : CARDINAL ; |
| 60 |
Rm : CARDINAL ; |
| 61 |
Tweight : CARDINAL ; |
| 62 |
TreasureName : ARRAY [0..12] OF CHAR |
| 63 |
END ; |
| 64 |
|
| 65 |
Room = RECORD |
| 66 |
RoomNo : CARDINAL ; |
| 67 |
NoOfWalls : CARDINAL ; |
| 68 |
NoOfDoors : CARDINAL ; |
| 69 |
Walls : ARRAY [1..WallsPerRoom] OF Line ; |
| 70 |
Doors : ARRAY [1..DoorsPerRoom] OF Door ; |
| 71 |
Treasures : BITSET ; |
| 72 |
END ; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
VAR |
| 77 |
ActualNoOfRooms : CARDINAL ; |
| 78 |
Treasure : ARRAY [1..MaxNoOfTreasures] OF TreasureInfo ; |
| 79 |
Rooms : ARRAY [1..MaxNoOfRooms] OF Room ; |
| 80 |
|
| 81 |
FileName : ARRAY [0..MaxLengthOfFileName] OF CHAR ; |
| 82 |
|
| 83 |
|
| 84 |
(* |
| 85 |
ReadAdvMap - read map, Name, into memory. |
| 86 |
TRUE is returned if the operation was successful. |
| 87 |
*) |
| 88 |
|
| 89 |
PROCEDURE ReadAdvMap (Name: ARRAY OF CHAR) : BOOLEAN ; |
| 90 |
|
| 91 |
|
| 92 |
(* |
| 93 |
Adjacent - tests to see if two rooms are Adjacent to each other. |
| 94 |
*) |
| 95 |
|
| 96 |
PROCEDURE Adjacent (R1, R2: CARDINAL) : BOOLEAN ; |
| 97 |
|
| 98 |
|
| 99 |
(* |
| 100 |
IncPosition - increments the position of x, y by the direction that are facing. |
| 101 |
*) |
| 102 |
|
| 103 |
PROCEDURE IncPosition (VAR x, y: CARDINAL ; Dir: CARDINAL) ; |
| 104 |
|
| 105 |
|
| 106 |
END AdvMap. |