A preliminary design for a MapT
- Overview: The MapT will be the primary container for the game. It will hold the map and any data associated with that map. It will have responsibilities such as
- Storing all information related to the dungeon
- Room layouts
- Hallway layouts
- Door locations/status
- Entity locations
- Constructing the original dungeon
- Adding rooms to the dungeon
- Checking navigation for entities moving in the dungeon
- Is a proposed move along a given path valid.
- Move the entity along the proposed path to a new location.
- Components:
- A Direction Type (DirT)
- This will be used to specify paths for entities: For example, the archer might wish to move Left,Left,Up,Left. It may be used for other operations as well.
- A strongly typed enumeration.
- Domain: UP, Down, Left, Right, None
- Constants:
- Operations:
- DirTToString: convert a direction to a string.
- StringToDirT: convert a string to a direction
- NextDirT(DirT): Up->Right->Down->Left->None->None
- RandomDirT: Generate a random direction, not including none.
- A coordinate type (CoordT)
- This is most likely just a structure
- Domain
- an x, y coordinate pair, integer local to the room
- a room id
- A valid field might be added indicating if the coordinate is valid or not.
- There are no specific operations on this type at this point.
- Given a SpaceT and a direction, a room will return the next SpaceT in the given direction, or the same one if this is not possible.
- This policy may need revisited.
- Note this may involve a different room number if the passage is through a door.
- Perhaps an overloaded comparison operator would be useful.
- SpaceT
- This is an abstraction for spaces in a room.
- A class
- Domain:
- The data associated with a room. At least
- EntityTRef , a reference (id, pointer, ...) to any entity in the space.
- DoorTRef, a reference (id, pointer, ...) to any door in the room.
- Operations
- AddDoor(DirT)
- HasDoor(): DirT
- GetDoors(): DoorTRef
- AddEntity(EntityTRef)
- HasEntity(): bool
- GetEntity(): EntityTRef
- RemoveEntity()
- RoomT
- This is either a room or a hallway.
- This will be a class.
- Domain:
- An two dimensional array of SpaceT
- A hallway will either be 1x4 or 4x1
- A room will be 3x3.
- The lowest left most square will be local coordinate (0,0) or CoordT(0,0,roomNumber)
- Note, this will NOT necessarily correspond to the array index
- A room number, height and width
- A world coordinate (x,y) which maps to the (0,0) coordinate in the room.
- Operations:
- Constructor (width, height, room number, worldx, worldy)
- Height(), Width(), Number() return the associated data.
- WorldX(), WorldY(): return the world coordinates.
- AddDoor(CoordT, DirT, DoorTRef)
- HasDoor(CoordT): bool
- GetDoor(CoordT) : DoorRefT
- GetDoors(): DoorRefT[]
- AddEntityAt(CoordT, EntityTRef)
- HasEntityAt(CoordT): bool
- GetEntityAt(CoordT): EntityTRef
- RemoveEntityAt(CoordT)
- GetCoordT(CoordT, DirT): CoordT, given a coordinate and a direction, return the next coordinate in that direction. If not possible either return the same coordinate or a coordinate marked invalid.
- DoorT
- A door
- This will be a class
- Domain:
- CoordT of the rooms on either side of the door.
- Status (open, closed, ?)
- Integrity : an integer 0 = broken
- Operations
- GetSides(): CoordT[]
- Status(): (open, closed, ?)
- Integrity(): integer
- Open()
- Close()
- Damage(int)
- I believe that the MapT should have an array of rooms.
- Operations:
- I am less clear on these.
- Initialize(): This will create the original hall and room
- Create a hallway at world 0,0. (room[0])
- Decide direction and create the appropriate room (1x4 or 4x1)
- Create a Room at either (4,-1) or (-1,4) of size 3x3 (room[1])
- Create a door between the two.
- AddRoom(): This does the algorithm in step 5, Build Phase
- Note, there will need to be a check to make sure rooms don't overlap. Don't add a room that will overlap, or a hallway where the room at the end will overlap.
- For now, I think we will add a restriction that each side of a room may only have one door, and that door must be in the middle of a room.
- GetDoorAt(CoordT)
- GetEntityAt(CoordT):EntityTRef
- RemoveEntityAt(CoordT)
- GetCoord(CoordT, DirT): CoordT