Fog of War hides rooms until the player has visited them. The player shouldn't know that a ballroom is in the linked rooms until they have been there to find out. For this functionality we need to:
create a visited flag
change the get_details method
add a change to visited if the room has been visited
1. Create a visited flag
in room.py
class Room():
number_of_rooms = 0
def __init__(self, room_name):
self.name = room_name
self.description = None
self.linked_rooms = {}
self.character = None
self.item = None
# add a visited flag
self.visited = False
2. Change the get_details method
in room.py
def get_details(self):
print(self.name)
print("--------------------")
print(self.description)
for direction in self.linked_rooms:
room = self.linked_rooms[direction]
# add a conditional to check if room has been visited and change the text
if room.visited:
⇥⇥⇥print("The " + room.get_name() + " is " + direction)
else:
print(f"A door is {direction}")
3. Change the move method
in room.py
def move(self, direction):
if direction in self.linked_rooms:
# add conditional to change the visited flag if the visited flag is False
if not self.linked_rooms[direction].visited:
self.linked_rooms[direction].visited = True
return self.linked_rooms[direction]
else:
print("You can't go that way")
return self