repl.it
@TheCoiledViper/

WW2 War Plane Game

Python

Welcome To WW2! You have just stolen a German ME-109 to try and get back home. Survive your skyward trek and outrun the Germans!

fork
loading
Files
  • main.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
import sys
from time import sleep
from termcolor import cprint
import replit
import random


magenta = '\u001b[35m'
cyan = '\u001b[36m'
red = '\u001b[31m'
white = '\u001b[37m'

def typer(words):
  for char in words:
    	sleep(0.05)
    	sys.stdout.write(char)
    	sys.stdout.flush()
    	
oneupgrade = {'speed' : [5,5.4,5.8], 'fueldepletion' : [4,3.5,3]}
germandistance = 10
fuel = 50
miles = 0
fatigue=6
money = 150
speedleveltwo = False
speedlevelthree = False
fuelefficiencyleveltwo = False
fuelefficiencylevelthree = False
planelevel = "Level One (Stock)"
fuelefficiency = oneupgrade['fueldepletion'][0]
upgradespeed = oneupgrade['speed'][0]
gameloop = True
restartgame = False
playagaingame = False
  
print("\n")	
typer("Welcome to WW2 War Plane Escape! Created by TheCoiledViper.")
cprint(cyan + "\nNew Features: Plane Upgrades, In-Game Currency, Enhanced User Interface!", attrs=['blink'])
userName = input(white + "\nWhat is your name, soldier? ")
print(cyan + "\nHello",userName,"and Welcome to World War II!")
print("\nYou have stolen a German ME-109 to try to get back home. Home is 600 miles away.You have 50 gallons of fuel.")
print("\nThe Germans want their plane back and are flying after you! Survive your skyward trek and outrun the Germans!")
print("\nThere are Germans at almost every fuel up stop along the way, you can land if you want, but beware.")
sleep(2)
input(magenta + "\nPress Enter To Go To Start Screen.")
replit.clear()

while True:
		print("\n")
		typer("-WW2 War Plane Escape!-")
		while True:
			startgame = input(white + "\nType 'Start' to start the game, or type 'Tutorial' to see the tutorial: ").upper()
			if startgame == "START":
				if playagaingame == True:
					germandistance = 10
					fuel = 50
					miles = 0
					fatigue=6
				else:
					germandistance = 10
					fuel = 50
					miles = 0
					fatigue=6
					money = 150
					speedleveltwo = False
					speedlevelthree = False
					fuelefficiencyleveltwo = False
					fuelefficiencylevelthree = False
					planelevel = "Level One (Stock)"
					fuelefficiency = oneupgrade['fueldepletion'][0]
					upgradespeed = oneupgrade['speed'][0]
					
				gameplayloop = True
				sleep(0.2)
				cprint(cyan + "\nLoading Game...",attrs=['blink'])
				sleep(2.5)
				replit.clear()
				print(white + "\n\n-WW2 War Plane Escape-")
				break
			elif startgame == "TUTORIAL":
				print(magenta + "\n-Tutorial-")
				print(cyan + "Objective: To make reational decisions in order to fly home safely, without being captured by Germans")
				print(magenta + "\nIn-Game Factors:")
				print(cyan + "Fatigue - To get home safely, you have to make sure that you are not too fatigued to fly the plane. You can rest either by either landing for the night or landing at a fuel stop.")
				print (magenta + "\nFuel - Fuel is finite in this game, so make sure you are conservtive. If your fuel supply is low, you can refill it at a fuel stop.")
				print (cyan + "\nDistance From Germans - The aim of the game is to get home safely without being captured by Germans, so make sure that when you stop, either at a fuel stop or to land for the night, the Germans are far enough behind you.")
				print (magenta + "\nMoney - In this game, money can be used to purchase upgrades for you plane. You can earn money after each turn, or collect it randomly at fuel stops. Note - Money carries over to your next game if you win.")
				print(cyan + "You can purchase upgrades at every fuel stop, using the money you have earned. Currently, you can upgrade fuel efficiency to level 3, and speed to level 3 as well.")
				continue
			else:
				print(red + "Enter A Valid Option!")
				continue
			
		
		while gameplayloop == True:
			timetillrest = fatigue - 2
			if miles >= 600:
				print(cyan + "\nYou have made it 600 miles to home and are now nationally known! Congratulaions!")
				print("Reward: £5000!")
				money += 5000
				restart = input(magenta + "\nDo You Want To Play Again?(Note: Money Carries Over To Next Game) (Y/N) ").upper()
				if restart == "YES" or restart == "Y":
					playagaingame = True
					break
				elif restart == "NO" or restart == "N":
					print(cyan + "\nThank You For Playing.")
					sys.exit()
				else:
					print(cyan + "\nThank You For Playing.")
					sys.exit()
	
				
			elif germandistance <= 0:
				print(red + "\nThe Germans have caught you. Game over. Thanks for playing.")
				restart = input(magenta + "\nDo You Want To Restart? (Y/N) ").upper()
				if restart == "YES" or restart == "Y":
					playagaingame = False
					break
				elif restart == "NO" or restart == "N":
					print(cyan + "\nThank You For Playing.")
					sys.exit()
				else:
					print(cyan + "\nThank You For Playing.")
					sys.exit()
	
			elif fatigue <= 0:
				print(red + "\nYou are too exhausted to carry on flying. Game over. Thanks for playing.")
				restart = input(magenta + "\nDo You Want To Restart? (Y/N) ").upper()
				if restart == "YES" or restart == "Y":
					playagaingame = False
					break
				elif restart == "NO" or restart == "N":
					print(cyan + "\nThank You For Playing.")
					sys.exit()
				else:
					print(cyan + "\nThank You For Playing.")
					sys.exit()
			else:
				money += 20
				if (fuel) <= 0:
					print(red + "\nYou ran out of fuel. Game over. Thanks for playing.")
					restart = input(magenta + "\nDo You Want To Restart? (Y/N) ").upper()
					if restart == "YES" or restart == "Y":
						playagaingame = False
						break
					elif restart == "NO" or restart == "N":
						print(cyan + "\nThank You For Playing.")
						sys.exit()
					else:
						print(cyan + "\nThank You For Playing.")
						sys.exit()
				elif fuel <= 50:
					fuel -= 1
				
				if upgradespeed == oneupgrade['speed'][1] or fuelefficiency == oneupgrade['fueldepletion'][1]:
					planelevel = "Level 1 (Upgraded)"
				elif upgradespeed == oneupgrade['speed'][1] and fuelefficiency == oneupgrade['fueldepletion'][1]:
					planelevel = "Level 2"
				elif upgradespeed == oneupgrade['speed'][2] or fuelefficiency == oneupgrade['fueldepletion'][2]:
					planellevel = "Level 2 (Upgraded)"
				elif upgradespeed == oneupgrade['speed'][2] and fuelefficiency == oneupgrade['fueldepletion'][2]:
					planelevel = "Level 3"
				else:
					planelevel = "Level 1 (Stock)"
				
					
				print(cyan + "\nA. Land and Refuel.")
				print(cyan + "B. Fly at current speed.")
				print(cyan + "C. Fly faster and risk wasting fuel.")
				print(cyan + "D. Land for the night.")
				print(cyan + "E. Status.")
				print(cyan + "Q. Quit the game.")
				userinput = input(magenta + "What is your choice? ").upper()
					
				if userinput == "A":
					if germandistance > 30:
						fuel += 15
						fatigue = 4
						germandistance -= 5
						print(white + "\nYou Have Landed and Refueled In Safety.")
						luckymoney = (random.randrange(1,4))
						if luckymoney == 1:
							luckymoneyamount = (random.randrange(1,4))
							if luckymoneyamount == 1:
								print("How Lucky! You've found £200 worth of plane parts at the fuel stop!")
								money += 200
							elif luckymoneyamount == 2:
								print("How Lucky! You've found £300 worth of plane parts at the fuel stop!")
								money += 300
							elif luckymoneyamount == 3:
								print("How Lucky! You've found £350 worth of plane parts at the fuel stop!\n")
								money += 350
						else:
							pass
						
						while True:
							gotostore = input(magenta + "\nWould You Like To Visit The Upgrade Store?(Y/N) ").upper()
							if gotostore == "YES" or gotostore == "Y":
								upgradestore = True
								replit.clear()
								print(cyan + "\nWelcome To the Upgrade Store! Here You Can Purchase Upgrades For Your Plane! \nLeave at Any Time by Typing 'Exit'.")
								break
							elif gotostore == "NO" or gotostore == "N":
								upgradestore = False
								break
							else:
								print(red + "Enter A Valid Option!")
								continue
						while upgradestore == True:
							print(magenta + "\n-Upgrade Store Menu-")
							print(white + "Money To Spend: £" + str(money))
							print(cyan + "1. Upgrade Speed To Level Two\n2. Upgrade Fuel Efficiency To Level Two\n3. Upgrade Speed To Level Three\n4. Upgrade Fuel Efficiency To Level Three.")
							upgradechoice = input(magenta + "Enter An Upgrade Which You Would Like To Purchase (1/2/3/4): ").upper()
							
							if upgradechoice== "1":
								while True:
									upgradecertain = input(cyan + "\nPurchase Level Two Speed Upgrade For £800?(Y/N) ").upper()
									if upgradecertain == "Y" or upgradestore == "YES":
										if speedleveltwo == False:
											if money >= 800:
												money -= 800
												speedleveltwo = True
												upgradespeed = oneupgrade['speed'][1]
												cprint(cyan + "\nUpgrade Purchased!", attrs=['blink'])
												sleep(1.5)
												replit.clear()
												break
											else:
												print(red + "Insufficient Funds!")
												break
										else:
											print( red + "You Have Already Purchased This Item!")
											break
									elif upgradecertain == "N" or upgradecertain == "NO":
										break
									else:
										print(red + "Enter A Valid Option!")
										continue
							elif upgradechoice == "2":
								while True:
									upgradecertain = input(cyan + "\nPurchase Level Two Fuel Efficiency Upgrade For £800?(Y/N) ").upper()
									if upgradecertain == "Y" or upgradestore == "YES":
										if fuelefficiencyleveltwo == False:
											if money >= 800:
												money -= 800
												fuelefficiencyleveltwo = True
												fuelefficiency = oneupgrade['fueldepletion'][1]
												cprint(cyan + "\nUpgrade Purchased!", attrs=['blink'])
												sleep(1.5)
												replit.clear()
												break
											else:
												print(red + "Insufficient Funds!")
												break
										else:
											print( red + "You Have Already Purchased This Item!")
											break
									elif upgradecertain == "N" or upgradecertain == "NO":
										break
									else:
										print(red + "Enter A Valid Option!")
										continue
							elif upgradechoice == "3":
								while True:
									upgradecertain = input(cyan + "\nPurchase Level Three Speed Upgrade For £1000?(Y/N) ").upper()
									if upgradecertain == "Y" or upgradestore == "YES":
										if speedlevelthree == False:
											if speedleveltwo == True:
												if money >= 1000:
													money -= 1000
													speedevelthree = True
													upgradespeed = oneupgrade['speed'][2]
													cprint(cyan + "\nUpgrade Purchased!", attrs=['blink'])
													sleep(1.5)
													replit.clear()
													break
												else:
													print(red + "Insufficient Funds!")
													break
											else:
												print(red + "Purchase the Level Two Speed Upgrade To Unlock This Upgrade!")
												break
										else:
											print( red + "You Have Already Purchased This Item!")
											break
									elif upgradecertain == "N" or upgradecertain == "NO":
										break
									else:
										print(red + "Enter A Valid Option!")
										continue
							elif upgradechoice == "4":
								while True:
									upgradecertain = input(cyan + "\nPurchase Level Three Fuel Efficiency Upgrade For £1000?(Y/N) ").upper()
									if upgradecertain == "Y" or upgradestore == "YES":
										if fuelefficiencylevelthree == False:
											if fuelefficiencyleveltwo == True:
												if money >= 1000:
													money -= 1000
													fuelefficiencyevelthree = True
													fuelefficiency = oneupgrade['fueldepletion'][2]
													cprint(cyan + "\nUpgrade Purchased!", attrs=['blink'])
													sleep(1.5)
													replit.clear()
													break
												else:
													print(red + "Insufficient Funds!")
													break
											else:
												print(red + "Purchase the Level Two Fuel Efficiency Upgrade To Unlock This Upgrade!")
												break
										else:
											print( red + "You Have Already Purchased This Item!")
											break
									elif upgradecertain == "N" or upgradecertain == "NO":
										break
									else:
										print(red + "Enter A Valid Option!")
										continue
							elif upgradechoice == "EXIT":
								upgradestore = False
								cprint(cyan + "\nExiting Store...",attrs=['blink'])
								sleep(2)
								replit.clear()
							else: 
								print(red + "Enter A Valid Option!")
								continue
								
					elif germandistance <= 30:
						print(red + "\nYou have decided to land to refuel and the germans caught up with you. Game Over.")
						restart = input(magenta + "\nDo You Want To Restart? (Y/N) ").upper()
						if restart == "YES" or restart == "Y":
							playagaingame = False
							break
						elif restart == "NO" or restart == "N":
							print(cyan + "\nThank You For Playing.")
							sys.exit()
						else:
							print(cyan + "\nThank You For Playing.")
							sys.exit()
							
					
				elif userinput == "B":
					fuel -= fuelefficiency
					speed = int(round(upgradespeed * 10))
					fatigue -= 1
					germandistance +=9
					miles += 55
					print(white + "\nYou are still flying at a speed of",speed,"MPH, and have " + str(timetillrest) + " turn(s) till you have to rest. Also, you have",fuel,"gallons of fuel left.\n")
						
				elif userinput == "C":
					speed = int(round(upgradespeed * 12))
					fuel -= fuelefficiency * 2
					fatigue -= 1
					germandistance += 14
					miles += 70
					print(white + "\nYou are risking your fuel consumption, but you are getting farther away from the Germans. You are now",germandistance,"miles away from the Germans. You have",fuel,"gallons of fuel left, and have " + str(timetillrest) + " turn(s) till you have to rest.\n")
					
				elif userinput == "D":
					if germandistance > 40:
						germandistance -= 15
						fatigue = 4
						print(white+ "\nYou have landed and slept the night away. When you wake up, you hear the germans planes and take off in safety in your plane.\n")
					elif germandistance <= 42:
						print(red + "\nYou have decided to land for the night and the germans caught you while you were sleeping. Game Over.")
						restart = input(magenta + "\nDo You Want To Restart? (Y/N) ").upper()
						if restart == "YES" or restart == "Y":
							playagaingame = False
							break
						elif restart == "NO" or restart == "N":
							print(cyan + "\nThank You For Playing.")
							sys.exit()
						else:
							print(cyan + "\nThank You For Playing.")
							sys.exit()
						
				elif userinput == "E":
					print(white + "\nDistance Travelled: " + str(miles) + " miles.\nTurns Till You Have To Rest: " + str(timetillrest) + "\nGallons of Fuel Remaining: " + str(fuel) + "\nDistance From Germans: " + str(germandistance) + " miles" + "\nLevel of Plane: " + str(planelevel) + "\nMoney Earned: " + str(money))
					germandistance -=4
					fuel -= fuelefficiency/2
						
				elif userinput =="Q":
					exit == input(red + "\nAre You Sure You Want To Quit? (Y/N) ").upper()
					if exit == "YES" or exit == "Y":
						print(cyan + "\nThank You For PLaying.")
						sys.exit()
					elif exit == "NO" or exit == "N":
						pass
					else:
						pass
							
				else:
					print (red + "Enter A Valid Option!\n")
						
					
?