-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
167 lines (154 loc) · 7.51 KB
/
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#Import the Rooms
import Locations.entrance
import Locations.tavernHall
import Locations.tavernSnug
import Locations.barArea
import Locations.kitchen
import Locations.masterBedroom
import Locations.mastersSonsBedroom
import Locations.yardNorth
import Locations.yardEast
import Locations.greenHouse
import Locations.upstairsHall
import Locations.puzzleRoom1
import Locations.puzzleRoom2
import Locations.puzzleRoom3
import Locations.basement
import Locations.endGameDeath
import Locations.endGamePuzzle
import Locations.endGameComplete
class Game:
def __init__(self):
self.lives = 3
self.keys = {
'starKey': 'N',
'triangleKey': 'N',
'squareKey': 'N',
}
self.puzzlecomplete = {
'Puzzle1': 'N',
'Puzzle2': 'N',
'Puzzle3': 'N',
}
self.name = None
self.rooms = {
'Entrance': Locations.entrance.entrance(),
'Tavern Hall': Locations.tavernHall.tavernHall(),
'Tavern Snug': Locations.tavernSnug.tavernSnug(),
'Bar Area': Locations.barArea.barArea(),
'Kitchen': Locations.kitchen.kitchen(),
'Masters Bedroom': Locations.masterBedroom.masterBedroom(),
'Masters Sons Bedroom': Locations.mastersSonsBedroom.mastersSonsBedroom(),
'Yard North': Locations.yardNorth.yardNorth(),
'Yard East': Locations.yardEast.yardEast(),
'Greenhouse': Locations.greenHouse.greenHouse(),
'Upstairs Hall': Locations.upstairsHall.upstairsHall(),
'Puzzle Room One': Locations.puzzleRoom1.puzzleRoom1(),
'Puzzle Room Two': Locations.puzzleRoom2.puzzleRoom2(),
'Puzzle Room Three': Locations.puzzleRoom3.puzzleRoom3(),
'Basement': Locations.basement.basement(),
'End Game Death': Locations.endGameDeath.endGameDeath(),
'End Game Puzzle': Locations.endGamePuzzle.endGamePuzzle(),
'End Game Complete': Locations.endGameComplete.endGameComplete(),
}
self.current_room = 'Entrance'
self.just_entered = True
def start_menu(self):
welcome = """
************************************************************************************
* ████████ ██ ██ ███████ ████████ █████ ██ ██ ███████ ██████ ███ ██ *
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ *
* ██ ███████ █████ ██ ███████ ██ ██ █████ ██████ ██ ██ ██ *
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ *
* ██ ██ ██ ███████ ██ ██ ██ ████ ███████ ██ ██ ██ ████ *
************************************************************************************
_ _._
|_|-'_~_`-._
_.-'-_~_-~_-~-_`-._
_.-'_~-_~-_-~-_~_~-_~-_`-._
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| [] [] [] [] [] |
| __ ___ |
._| [] [] | .| [___] |_._._._._._._._._._._._._._._._._.
|=|________()|__|()_______|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|
^^^^^^^^^^^^^^^ === ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Created by: Louis Goldsbrough
Please select an option:
1|START GAME 2|INSTRUCTIONS 3|QUIT
"""
print(welcome)
option = input("> ")
if option == '1':
self.name = input("Enter your name: ")
self.play()
elif option == '2':
print("""Instructions:
This game will provide a mixture of story telling and puzzles to solve. Instructions
will be provided to you throughout the game.
To access your stats at any time, simply type 'stats' into the command line and hit enter.
To quit the game simply type 'q' into the command line and hit enter.
""")
instruction_choice = input("Would you like to play? (Y/N): ")
if instruction_choice == "Y".lower:
self.name = input("Enter your name: ")
self.play()
elif instruction_choice == "N".lower:
exit()
elif option == '3':
exit()
else:
print("Invalid option. Please try again.")
self.start_menu()
def track_keys(self, key):
if key in self.keys:
if self.keys[key] == 'N':
self.keys[key] = 'Y'
print("You found a {}!".format(key))
else:
print("You already have the {} key.".format(key))
else:
print("Invalid key.")
def play(self):
while True:
room = self.rooms[self.current_room]
if self.just_entered:
print(room.description)
self.just_entered = False
action = input("> ")
if action == 'q':
break
result = room.perform_action(self, action)
# Descriptive Story
if result == 'story':
print(room.story)
# Puzzle Attempt
elif result == 'puzzleAttempt':
print("LOG:",room.puzzleResult)
print("LOG:",room.puzzleCount)
if room.puzzleResult == True:
if room.puzzleCount > 1:
print ("You have already completed this puzzle.")
else:
print("Well done you completed the puzzle.")
self.keys +=1
print("You have gained an extra Key! you now have", self.keys, "Keys!")
else:
print("Incorrect.")
self.lives -= 1
print ("You now have",self.lives, "lives.")
# Write Stats
elif result == 'stats':
print(self.name,"'s Currents Stats")
print("---------------")
print("Lives Left:", self.lives)
print("Keys Obtained:", self.keys)
# Move Room
elif result in self.rooms:
self.current_room = result
self.just_entered = True
print("You moved to the {}.".format(self.current_room))
else:
print("Invalid action.")
game = Game()
game.start_menu()
game.play()