-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
263 lines (217 loc) · 14.6 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#Jake Eaton
from room import Room
from character import Character, Enemy
from item import Item
import time #Imports requried Programs and Modules
import os
import sys
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" #Hides the "Welcome to Pygame" Message
from pygame import mixer
def type(string):
for char in string:
sys.stdout.write(char) #Defines what "type" command does
sys.stdout.flush()
time.sleep(0.02)
sys.stdout.write("\n") #Writes out a new line at the end of every type
def type2(string):
for char in string:
sys.stdout.write(char) #Defines what "type2" command does
sys.stdout.flush()
time.sleep(0.75)
sys.stdout.write("\n") #Writes out a new line at the end of every type2
mixer.init() #Initializes Music Player
mixer.music.load("Duel.of.the.Fates.mp3") #Loads the Music
mixer.music.play(5) #Plays Music 5 times
lift = Room("Lift")
lift.set_description("You can go up or down!") #Sets name and description for Lift
command_center = Room("Command Center")
command_center.set_description("A vast room filled with your minions working to keep your ship working\n") #Sets name and description for Command Center
hangar = Room("Hangar Bay")
hangar.set_description("A wide bay bustling with pilots and engineers ready to fly out into battle when they are called upon\n") #Sets name and description for Hangar Bay
engine_room = Room("Engine Room")
engine_room.set_description("The room where your fusion engines are managed\n") #Sets name and description for Engine Room
communications_center = Room("Communications Center")
communications_center.set_description("All your communication flows through here. You can see everyones communication over the network\n") #Sets name and description for Communications Center
lift.link_room(command_center, "Top")
lift.link_room(hangar, "Bottom") #Links all the rooms to the Lift
lift.link_room(engine_room, "42")
lift.link_room(communications_center, "66")
command_center.link_room(lift, "Back")
hangar.link_room(lift, "Back") #Links the Lift to all the rooms
engine_room.link_room(lift, "Back")
communications_center.link_room(lift, "Back")
tom = Character("Tom", "Your micromanager. He will keep watch on your minions\n")
tom.set_conversation("Hello There Sir! All systems functioning normally!\n") #Sets name, conversation and place for Tom
command_center.set_character(tom)
jerry = Character("Jerry", "Radar Manager. He watches the radar and will update you with any updates\n")
jerry.set_conversation("Hello There Sir! FF Warships are flanking us! Fighters incoming! We need you to command the Infinity to push the enemy back!\n") #Sets name, conversation and place for Jerry
command_center.set_character(jerry)
penny = Character("Penny", "Your Hangar Commander. She gives the orders around here\n")
penny.set_conversation("Hello There Sir! Let me know if you want to deploy fighters!\n") #Sets name, conversation and place for Penny
hangar.set_character(penny)
terry = Character("Terry", "Your Comms Master. He can read through chatter like its his job\n")
terry.set_conversation("Hello There Sir! No suspicous activity flowing through the network. Yet...\n") #Sets name, conversation and place for Terry
communications_center.set_character(terry)
clara = Character("Clara", "Your Head Engineer. Not only can she create a cold fusion reactor blindfolded with her hands tied behind her back, she doesn't like tea...\n")
clara.set_conversation("Hello There Sir! I am working to repair the engines now! We got hit pretty bad!\n") #Sets name, conversation and place for Clara
engine_room.set_character(clara)
soldier = Enemy("FF Soldier", "A Formula Front soldier equipped with a rifle\n")
soldier.set_conversation("Prepare to die scum!\n") #Sets name, conversation, weakness and place for FF Soldier
soldier.set_weakness("Pistol")
engine_room.set_character(soldier)
swordsman = Enemy("FF Swordsman", "A Formula Front Swordsman wielding a long shining sword\n")
swordsman.set_conversation("Face me and prepare to feel the pain of head landing on the floor!\n") #Sets name, conversation, weakness and place for FF Swordsman
swordsman.set_weakness("Sword")
communications_center.set_character(swordsman)
cruiser = Enemy("FF Cruiser", "A Formula Front Cruiser quickly approaching with its guns blazing\n")
cruiser.set_weakness("Infinity's Guns") #Sets name, weakness and place for FF Cruiser
command_center.set_character(cruiser) #Enemy is in multiple rooms
hangar.set_character(cruiser)
fighters = Enemy("FF Fighters", "A Formula Front Fighter Squadron zooming towards you\n")
fighters.set_weakness("WSC Fighters") #Sets name, weakness and place for FF Fighters
command_center.set_character(fighters) #Enemy is in multiple rooms
hangar.set_character(fighters)
battleship = Enemy("FF Battleship", "A Formula Front Battleship. Heavy armour. Heavy firepower. Treat with care\n")
battleship.set_weakness("Infinity's Guns")
command_center.set_character(battleship)
destroyer = Enemy("FF Destroyer", "A Formula Front Destroyer. Fast... but not fast enough\n")
destroyer.set_weakness("Infinity's Guns") #Sets name, weakness and place for FF Destroyer
engine_room.set_character(destroyer) #Enemy is in multiple rooms
communications_center.set_character(destroyer)
gun = Item("Pistol")
gun.set_description("Your trusty pistol. One shot, one kill\n") #Sets name, description and location for Pistol
command_center.set_item(gun)
sword = Item("Sword")
sword.set_description("It may not be a lightsaber, but it will slice you clean in half\n") #Sets name, description and location for Sword
lift.set_item(sword)
infinity = Item("Infinity's Guns")
infinity.set_description("The controls for the guns of the most powerful warship ever created. Use these to destroy any ship attempting to bring you down\n") #Sets name, description and location for Infinity's Guns
command_center.set_item(infinity)
fighters = Item("WSC Fighters")
fighters.set_description("Command your fighters to attack the enemy as they approach\n") #Sets name, description and location for WSC Fighters
hangar.set_item(fighters)
current_room = lift #Places User in that room for start of program
on_hand = [] #Empty list containing what the User is able to use in fights
dead = False #Identifies the User as not dead
type("Read the epic story as it is published at https://www.wattpad.com/story/245646734-the-formula-front-war-part-of-the-world-space")
time.sleep(2)
type("Your mission... should you choose to accept it...\n") #Type calls upon the type() above and places the characters down one by one
time.sleep(2) #Pauses Program for that many seconds
type("Fend off the Formula Front from taking Geneva...\n") #\n moves to a new line
time.sleep(2)
type("Take everything you can")
type("Type 'Take' to take items")
type("Type 'Talk' to talk to friendlies")
type("Type 'Fight' to fight enemies")
type("Type where you want to go from the selection exactly as you see it\n")
time.sleep(5)
type("Now... you are The Captain of the brand new Spacecraft... the WSC Infinity...\n")
time.sleep(2)
type("You must command your crew to victory.\n")
time.sleep(2)
type("Defeat all enemies in your path.\n")
time.sleep(2)
type("You lost your sword recently. You may need that. See if you can find it on your mission\n")
time.sleep(2)
type("The WSC Vengeance has recently disabled the enemies shields.\n")
time.sleep(2)
type("Use your gun turrets and fighters to your advantage and outskill the Formula Front Fleet.\n")
time.sleep(2)
type("Be careful though...\n")
time.sleep(2)
type("Our orbital defences are down and the WSC Home Fleet is crumbling...\n")
time.sleep(2)
type("As the most powerful warship ever... you are our last hope...\n")
time.sleep(2)
type("You must lead the charge with the WSC Home Fleet by your side\n")
time.sleep(2)
type("Wait...\n")
time.sleep(2)
type("Command is moving the Home Fleet further out to crush incoming FF Reinforcements...\n")
time.sleep(2)
type("You're on your own now...\n")
time.sleep(2)
type("Let us go forth and defend Geneva!\n")
time.sleep(2)
while dead == False: #While loop to run the main game until the user is dead - Which happens if they win or lose...
print("") #Prints blank line for a better UI
current_room.get_details() #Gets the details of the current room the user is up to
print("") #Prints blank line for a better UI
inhabitant = current_room.get_character() #Gets the characters in the current room the user is in and assigns it to a variable for easy working
if inhabitant is not None: #If there is an inhabitant, the indented code will run
for person in inhabitant: #For Loop that scans list for the right character in the room
person.describe() #Describes the person in the room
items = current_room.get_item() #Gets the current items in the room and assigns them to a variable for easy working
if items is not None: #If there is an item, the indented code will run
for item in items: #For Loop that scans list for the right item in the room
item.describe() #Describes the item
print(" ")
command = input("> ")
if command in ["Top", "Bottom", "42", "66", "Back"]: #If the command is one of the ones in the list, the user will be moved to the room accordingly
current_room = current_room.move(command)
elif command == "Talk": #If the user wants to talk, the indented code will run
print("Who do you want to talk with? ")
talker = input("> ")
found = False #True or False Boolean deciding if there is a person there
for person in inhabitant: #If there is an inhabitant, the following code will run
if person.get_name() == talker: #Gets the name of the Person if they are registered as a talker
found = True #Changes Boolean to True
person.talk() #Makes the person talk
time.sleep(4)
if not found: #If the person is not there the indented code runs
print("That person is not here!")
elif command == "Fight": #If the user wants to fight, the indented code will run
print("Who do you want to fight?")
fighter = input("> ") #Allows user to input who they want to fight
there = False #True or False Boolean deciding if there is a fighter there or not
for person in inhabitant: #If there is a person who fights then the following code will run
if person.get_name() == fighter:
print("What will you fight with?")
fight_with = input("> ") #Fight with variable allowing user to input what they want to fight with
if fight_with in on_hand: #If what the user wants to fight with is on hand (as determined by list), the indented code will run
if person.fight(fight_with) == True: #If the weapon is the enemies weakness
print("You destroy your enemy...\n")
time.sleep(3)
current_room.get_character().remove(person) #Removes the person if they are defeated
if person.get_defeated() == 9: #When all the enemies are defeated, the indented code will run
mixer.music.load("imperial_alert.mp3")
mixer.music.stop()
mixer.music.play()
print("INCOMING!\n")
time.sleep(2)
type("The Infinity has taken critical damage!\n")
time.sleep(1)
type("The ship is going down!\n")
time.sleep(2)
type("BRACE FOR IMPACT!\n")
time.sleep(3)
mixer.music.load("Explosion-Fixed2.mp3")
mixer.music.stop()
mixer.music.play()
type("The Infinity crash landed in Lake Geneva... killing all on board...\n")
time.sleep(3)
type("War has begun...\n")
time.sleep(2)
type2("Prepare...\n")
time.sleep(1)
type("Coming 2020...")
dead = True #dead Boolean made True
else:
if isinstance(person, Enemy):
mixer.music.fadeout(3000) #Music fades away for 3 seconds
time.sleep(3)
dead = True #If the user loses the fight, the dead Boolean is made True
else:
print("You don't have a " + fight_with + "\n") #If the weapon is not in the list, it prints this
there = True
if not there:
print("That person is not here") #If the person the user has typed is not there, this code is run
elif command == "Take": #If the user wants to take an item, the indented code is run
if item is not None:
print("You take the " + item.get_name() + " along with you\n")
on_hand.append(item.get_name()) #Adds the item to the on_hand list so that the user can use it in fights
current_room.get_item().remove(item) #Removes the item from the room
else:
print("There is nothing here to take!\n") #If there is no item in the room, this code gets printed
else:
print("You can't do that!\n") #If the user types in something that isn't an option, this code gets printed