@a5rocks/

help me plz

Python

i really need help

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
import os
import sys
import time
import replit
import random

buy_shop = """
Add a floor: {1} (f)
Add a room: {0} (r)
Exit shop (e)
"""

def quit_angrily(why = 'You were bad.'):
	replit.clear()
	print('I\'m very, very disappointed in you... >:(')
	print('So BEGONE LET THE KICK HAMMER DESCEND!')
	print('PS this is why:')
	print(why)
	sys.exit()

term_x, term_y = os.get_terminal_size()

print('Welcome to A5rocks\'s quickly made dungeon simulator.')
print('Yes I did steal a lot of "inspiration" from all the dungeon webfictions. Got a problem?')

# reset screen
time.sleep(5)
replit.clear()

# config / start
name = input('What do you want your dungeon to be named? ').strip() or quit_angrily('Don\'t try exploiting! :angery:')

if len(name) > 20:
	print('Um... No? Your new name is "urbad"')
	name = 'urbad'

floors = [[]]
mana = 300
multiplier = 1

# finally onto the main code
while True:
	replit.clear()
	action = input('(b)uy / (u)pgrade / (a)dvertise / (w)ait / (e)xit : ')[:1]

	if action == 'b':  # buy something
		print(buy_shop.format(300, 10*300))
		what_to_buy = input('Purchase: ')[:1]

		if what_to_buy == 'e':
			continue
		
		elif what_to_buy == 'r':
			if not mana >= 300 + 300*(multiplier/2):
				print('You\'re too poor!')
				time.sleep(2)
				continue
			
			floor_number = 0
			if len(floors) > 1:
				floor_number = input('On what floor? (1 to {}) '.format(len(floors)))
				if not floor_number.isdigit():
					print('\nNope!')
					time.sleep(1)
					continue

				floor_number = int(floor_number)
				if not 1 <= floor_number <= len(floors):
					print('\nNope')
					time.sleep(1)
					continue
				
				floor_number -= 1
			
			value_added = input('How much value do you want to add? (you can add at most {0}) '.format(((mana-(300 + 300*(multiplier/2)))//(30 + 30*(multiplier/2)))))

			if not value_added.isdigit():
				print('\nNope!')
				time.sleep(1)
				continue
			
			if int(value_added) > ((mana-(300 + 300*(multiplier/2)))//(30 + 30*(multiplier/2))):
				print('\nNope')
				time.sleep(1)
				continue

			mana -= (300 + 300*(multiplier/2)) + int(value_added)*(30 + 30*(multiplier/2))

			floors[floor_number].append(10 + int(value_added))
			continue
		elif what_to_buy == 'f':
			floors.append([])
			continue
		else:
			print('Sorry, that\'s not an option.')
			time.sleep(1)
			continue
	elif action == 'a':
		added_mana = sum([val for sublist in floors for val in sublist]) * multiplier * 0.5
		mana += added_mana
		print('Got {} mana from people visiting the dungeon.'.format(added_mana))
		time.sleep(10)
		continue
	elif action == 'u':
		yes_or_no = input('That costs {} mana, are you sure? (y/n) '.format(len([val for sublist in floors for val in sublist])*20*(1 + multiplier/2)))[:1]
		if not yes_or_no == 'y' or mana < len([val for sublist in floors for val in sublist])*20*(1 + multiplier/2):
			print('\nNope')
			time.sleep(1)
			continue
		
		mana -= len([val for sublist in floors for val in sublist])*20*(1 + multiplier/2)

		multiplier += 1
	elif action == 'e': # exit the game
		print('Bye! See you next time!')
		sys.exit()