1
1
from sty import fg , bg , ef , rs , RgbFg
2
+ from printables import print_case , print_chest
3
+ from save_game import Save_Game
2
4
from prompts import prompt_usr
3
5
from hero import Hero
4
6
from loot import Loot
32
34
33
35
def intro ():
34
36
#Display for Intro
35
- print ("""
37
+ print (fg . green , bg . black + """
36
38
******----******----******
37
39
Welcome to Dungeon Heroes!
38
- ******----******----******
40
+ ******----******----******""" + fg .red + """
41
+ \^~~~~\\ ) ( /~~~~^/
42
+ ) *** \\ {**} / *** (
43
+ ) *** \\ _ ^^ _/ *** (
44
+ ) **** vv **** (
45
+ )_**** ****_(
46
+ )*** m m ***( """ + fg .rs , bg .rs )
39
47
40
- \^~~~~\\ ) ( /~~~~^/
41
- ) *** \\ {**} / *** (
42
- ) *** \\ _ ^^ _/ *** (
43
- ) **** vv **** (
44
- )_**** ****_(
45
- )*** m m ***(
46
- """ )
47
-
48
48
def load_game ():
49
- response = prompt_usr (
50
- "Select (N)ew game or (C)ontinue: \t " , "string" ).upper ()
49
+ response = prompt_usr ("Select (N)ew game or (C)ontinue: \t " , "string" ).upper ()
51
50
if (response == "C" ):
52
- # try:
53
- # hero = SaveGame .load("saveGame.txt")
54
- # print("File Loaded")
55
- #catch(FileNotFoundException e) :
56
- # print("SaveGame not found")
57
- #createCharacter(g_input )
58
- hero = Hero ("bill" , "warrior" )
51
+ try :
52
+ hero = Save_Game .load ("saveGame.txt" )
53
+ print ("File Loaded" )
54
+ except FileNotFoundError :
55
+ print ("SaveGame not found" )
56
+ create_character ( )
57
+ # hero = Hero("bill", "warrior")
59
58
return hero
60
59
elif (response == "N" ):
61
60
hero = restart ()
@@ -121,16 +120,16 @@ def enter_room():
121
120
print ("***************************" )
122
121
print ("You have entered a new room" )
123
122
treasure = 0
124
- """
123
+
125
124
levelUp = False
126
125
127
126
if (hero .level == 4 or hero .level == 8 or hero .level == 12 ):
128
127
if (hero .xp == 0 ):
129
- print()
130
- treasure = (int)(Math.floor(Math.random( )*2) + 1) * 1 #1 or 2
131
- getlevelUp(treasure)
132
- levelUp = False
133
- """
128
+ print ()
129
+ treasure = random . randint ( )* 2 + 1 * 1 #1 or 2
130
+ #self. getlevelUp(treasure)
131
+ levelUp = False
132
+
134
133
#get our random room
135
134
room_type = random .random ()* 100 # 0.0 --> 99.9999
136
135
#are we at the end of the dungeon?
@@ -141,19 +140,19 @@ def enter_room():
141
140
if (room_type >= EPIC_TREASURE_CHANCE ):
142
141
print ("$$$EPIC TREASURE ROOM$$$" )
143
142
print_chest ()
144
- # treasure = (int)(Math.floor(Math.random( )*2) + 1) * 100 #100 or 200
143
+ treasure = random . randint ( )* 2 + 1 * 100 #100 or 200
145
144
146
145
#is this an advanced treasure room?
147
146
elif (room_type >= ADVANCED_TREASURE_CHANCE ):
148
147
print ("$$$Advanced Treasure Room$$" )
149
148
print_chest ()
150
- # treasure = (int)(Math.floor(Math.random( )*2) + 1) * 10 #10 or 20
149
+ treasure = random . randint ( )* 2 + 1 * 10 #10 or 20
151
150
152
151
#is this a basic treasure room?
153
152
elif (room_type >= BASIC_TREASURE_CHANCE ):
154
153
print ("Basic Treasure Room!" )
155
154
print_chest ()
156
- # treasure = (int)(Math.floor(Math.random( )*2) + 1) * 1 #1 or 2
155
+ treasure = random . randint ( )* 2 + 1 * 1 #1 or 2
157
156
158
157
#otherwise we fight a monster.
159
158
else :
@@ -162,7 +161,7 @@ def enter_room():
162
161
return False #they have died... game over
163
162
164
163
#gives the player randomly rolled treasure
165
- #self. get_treasure(treasure)
164
+ get_treasure (treasure )
166
165
167
166
#handle Choosing whats next
168
167
return choice ()
@@ -195,84 +194,60 @@ def choice():
195
194
# quit game
196
195
elif (response == "Q" ):
197
196
return False
198
- """
199
197
try :
200
- SaveGame .save(hero, "save_game.txt")
198
+ Save_Game .save (hero , "save_game.txt" )
201
199
return False
202
200
except FileNotFoundError :
203
201
print ("There was a problem Saving, file not found" )
204
202
return False
205
- """
206
203
return True
207
204
208
205
#getTreasure - rolls random treasure and allows the user to take it(or convert to money)
209
206
#@param int treasure(1s are basic, 10s are advanced, 100s are epic treasure)
210
207
def get_treasure (treasure ):
211
- # build a list of items that dropped
212
- lootItems = []
213
- # number of basic items
214
- basic = treasure % 10
215
- # advanced items
216
- advanced = treasure / 10 % 10
217
- # epic items
218
- epic = treasure / 100 % 10
219
- # setup the basic items
220
- for i in range (basic ):
221
- lootItems .append (loot .getBasic (hero ))
222
- # setup the advanced items
223
- for i in range (advanced ):
224
- lootItems .append (loot .getAdvanced (hero ))
225
- # setup the epic items
226
- for i in range (epic ):
227
- lootItems .append (loot .getEpic (hero ))
208
+ # build a list of items that dropped
209
+ lootItems = []
210
+ # number of basic items
211
+ basic = treasure % 10
212
+ # advanced items
213
+ advanced = treasure / 10 % 10
214
+ # epic items
215
+ epic = treasure / 100 % 10
216
+ # setup the basic items
217
+ for i in range (basic ):
218
+ lootItems .append (loot .getBasic (hero ))
219
+ # setup the advanced items
220
+ for i in range (advanced ):
221
+ lootItems .append (loot .getAdvanced (hero ))
222
+ # setup the epic items
223
+ for i in range (epic ):
224
+ lootItems .append (loot .getEpic (hero ))
228
225
229
- if (len (lootItems ) > 0 ):
230
- # print a list of the items
231
- print ()
232
- print ("***************" )
233
- print ("Treasure Items" )
234
- print ("**************" )
235
- for i in lootItems :
236
- print ("{} {}\n " .format (i .uniqueID , i .name ))
237
- # ask the user whether they want to(S)ell items or (K)eep items
238
- valid_response = False
239
- response = ""
240
- while (not response == "S" and not response == "K" ):
241
- response = prompt_usr (
242
- "Do you want to (S)ell or (K)eep the items (duplicates will be added to your current weapons): \t " , "string" )
243
- # sell
244
- if (response == "S" ):
245
- for i in lootItems :
246
- hero .gold += i .price / 10
247
- print ("You wisely sell the items" )
248
- else :
249
- # put items in inventory(upgrade if duplicate)
250
- for i in lootItems :
251
- hero .gold += hero .inventory .append (i )
252
- print_case ()
253
- print ("You wisely put the items in your backpack." )
254
-
255
- def print_case ():
256
- print ("""
257
- ____
258
- .--[[__]]---.
259
- .-----------.|
260
- | ||
261
- | ||
262
- |___________|/ """ )
263
-
264
- def print_chest ():
265
- print ("""
266
-
267
- __________
268
- /\\ ____;;___\\
269
- | / /
270
- `. ()()vv() .
271
- |\\ ()()^^() \\
272
- | |---------|
273
- \\ | )) |
274
- \\ |_________|
275
- """ )
226
+ if (len (lootItems ) > 0 ):
227
+ # print a list of the items
228
+ print ()
229
+ print ("***************" )
230
+ print ("Treasure Items" )
231
+ print ("**************" )
232
+ for i in lootItems :
233
+ print ("{} {}\n " .format (i .uniqueID , i .name ))
234
+ # ask the user whether they want to(S)ell items or (K)eep items
235
+ valid_response = False
236
+ response = ""
237
+ while (not response == "S" and not response == "K" ):
238
+ response = prompt_usr (
239
+ "Do you want to (S)ell or (K)eep the items (duplicates will be added to your current weapons): \t " , "string" )
240
+ # sell
241
+ if (response == "S" ):
242
+ for i in lootItems :
243
+ hero .gold += i .price / 10
244
+ print ("You wisely sell the items" )
245
+ else :
246
+ # put items in inventory(upgrade if duplicate)
247
+ for i in lootItems :
248
+ hero .gold += hero .inventory .append (i )
249
+ print_case ()
250
+ print ("You wisely put the items in your backpack." )
276
251
277
252
if __name__ == "__main__" :
278
253
#Print a cool intro
0 commit comments