Page 1 of 1

Python Adventure game ============== For this project, your task is to continue the implementation of the adventure game

Posted: Fri Apr 29, 2022 6:45 am
by answerhappygod
Python
Adventure game
==============
For this project, your task is to continue the implementation of
the adventure game as shown in the starter code below.
The objective of this task is to create a single,
single-player interactive game using the Python console where
the user can:
- Explore at least 12 different rooms (these can be hard
hard-coded)
- Move between the rooms by s pecifying a compass
direction (N, E, S, W)
- Allow the user to pick up items
- Ask for directions to a particular room
- Search for items within any given set of rooms.
For each function in your code, you will need to state the
complexity of your solution, annotating this in big big-O
notation.
Appropriate comments and syntax should be used throughout your
code, as should object oriented styles.
Starter code is given
=====================
# Rooms have items, players can carry items
class Item:
def __init__(self, name='Unknown'):
self.name = name
# A player can enter a room from any of the compass
directions
class Room:
def __init__(self, name='Unknown', item = None, north =
None, east = None, south = None, west = None):
# Give each room a sensible name
self.name = name
# Setup other rooms the player can enter
self.north = north
self.east = east
self.south = south
self.west = west
# Represents the current player
class Player:
def __init__(self, name='Unknown'):
self.name = name
self.items = []
# Overall game code and logic
class Game:
def __init__(self, startRoom):
self.start = startRoom
def play(self, player):
self.player = player
# Add game play code here
# Setup the game board
r = Room("First room")
g = Game(r)
# Play as player
p = Player("Owain")
g.play(p)