@hopebrooke/

adventure game

Python

No description

fork
loading
Files
  • main.py
  • character.py
  • item.py
  • room.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
from character import Enemy 

leo = Enemy("leo", "a mad scientist")
leo.set_conversation("i will conduct thorough surgical procedures on you")
leo.set_weakness("knife")


hope = Enemy("hope", "a demon child")
hope.set_conversation("HAHAHA")
hope.set_weakness("a doll")

from room import Room

kitchen = Room("kitchen")
kitchen.set_description("a room glowing with natural light and full of flowers")
dining_room = Room("dining room")
dining_room.set_description("a gloomy room")
ballroom = Room("ballroom")
ballroom.set_description("a room bursting with colour")

kitchen.link_room(dining_room, "south")
dining_room.link_room(kitchen, "north")
dining_room.link_room(ballroom, "west")
ballroom.link_room(dining_room , "east")

dining_room.set_character(leo)
ballroom.set_character(hope)

current_room = kitchen

while True:
  print("\n")
  current_room.get_details()
  inhabitant = current_room.get_character()
  if inhabitant is not None:
    inhabitant.describe()
  command = input("-->")
  if command in ["north", "south", "east", "west"]:
    current_room = current_room.move(command)
  elif command == "talk":
    speak = input("Say Hello to the inhabitant in this room!")
    print(inhabitant.talk())
  elif command == "fight":
    weapon = input("What would you like to fight with?")
    if inhabitant is not None:
      if (inhabitant.fight(weapon)) == False:
        break
      else:
        current_room.set_character(None)
    else:
      print("There is noone to fight in this room")



print("The game is over")