TorroesPrime

class_exit.py

Aug 8th, 2020 (edited)
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. import Room
  2. from Dungeon import TOP_LEVEL_DELIM, SECOND_LEVEL_DELIM
  3.  
  4. class Exit:
  5.     direction = ""
  6.     source_room = ""
  7.     destination_room = ""
  8.  
  9.     def manuel_exit(self,direction,source_room,destination_room):
  10.         self.dir = direction
  11.         self.source_room = source_room
  12.         self.destination_room = destination_room
  13.         self.source_room.addExit(self)
  14.         return self
  15.  
  16.     def __init__(self):
  17.         pass
  18.  
  19.     def scanner_exit(self,f,d):
  20.         self.__init__()
  21.         source_roomTitle = f.readline()
  22.         if source_roomTitle == TOP_LEVEL_DELIM:
  23.             raise Exception("No exit found")
  24.         self.source_room = d.getRoom(source_roomTitle)
  25.         self.direction=f.readline()
  26.         self.destination_room = d.getRoom(f.readline())
  27.         if(f.readline()!=DungeonInstance.SECOND_LEVEL_DELIM):
  28.             raise Exception(f"Dungeon format error: No {SECOND_LEVEL_DELIM} found after exit.")
  29.  
  30.     def describe(self):
  31.         return f"You can go {self.direction} to the {self.destination_room.getName()}."
  32.    
  33.     def get_direction(self):
  34.         return self.direction
  35.    
  36.     def get_source(self):
  37.         return self.source_room
  38.    
  39.     def get_destination_roomination(self):
  40.         return self.destination_room
  41.  
  42.  
  43.  
  44.  
Add Comment
Please, Sign In to add comment