def deadMonster(): # Line 4890 global player delay(2) print("") print(f'You have killed the {monster.name}') print("\n") if (inroom < 6) and (inroom != 2): if level == 1: index = getIndex(player.x, player.y, 9) level1[index] = 1 else: index = getIndex(player.x, player.y, 9) level2[index] = 1 gold = 500 if inroom >= 6: gold = 250 givegold = int(rnd() * gold / level + 1) + 75 if inroom == 2: givegold = givegold * 2 player.gold = player.gold + givegold delay(2) print("You search the area....") delay(2) print(f'and find ... {givegold} gold pieces') player.monsterskilled = player.monsterskilled + 1 if player.haskey != True: if level == 1: checkKey() # GOTO 3190 else: getKey() # GOTO 3110 return
def getContents(c, d): index = getIndex(c, d, 9) if level == 1: r = level1[index] else: r = level2[index] return (r)
def get_table_names(exp): # eventual list list_of_exp_with_symbol = [] symbols = ["|", "^", ">"] # iterate through list and get the index the letter before and the letter after for i, j, k, l in zip(list(range(len(exp))), exp, exp[1:], exp[2:]): if k in symbols: # if the symbol before was a parentheses if j == ")": # start the expression from the other side of parentheses starting_point = getreversedindex(exp, i) else: starting_point = i if exp[i-1] != "~" else i-1 if l == "(": ending_point = getIndex(exp, i+2)+1 else: # if its a letter end at the letter if its a ~ sign end the next character ending_point = i+3 if exp[i+2] != "~" else i+4 list_of_exp_with_symbol.append(exp[starting_point:ending_point]) elif k == "~": if l == "(": ending_point = getIndex(exp, i+2)+1 else: ending_point = i+3 starting_point=i+1 list_of_exp_with_symbol.append(exp[starting_point:ending_point]) list_of_exp_with_symbol.sort(key= lambda x : len(x)) return(list_of_exp_with_symbol)
def showMap(): # Line 1570 & 1990 cls() if (player.hasmap == False): print("You don't have the map.") delay(1) else: print("The Dungeon of Danger Map: Level " + str(level)) print(" ") for q in range(1, 9): for n in range(1, 9): if (player.x == n) and (player.y == q): print("Pl ", end=" ") continue else: idx = getIndex(n, q, 9) if level == 1: s1 = level1[idx] else: s1 = level2[idx] if s1 == 1: # pass() # Line 2910 print("O ", end=" ") elif s1 == 2: # pass() # Line 2970 print("C ", end=" ") elif s1 == 3: # pass() # Line 2930 print("M ", end=" ") elif s1 == 4: # pass() # Line 2930 print("M ", end=" ") elif s1 == 5: # pass() # Line 2950 print("? ", end=" ") elif s1 == 6: # pass() # Line 2990 print("NS ", end=" ") elif s1 == 7: # pass() # Line 3010 print("EW ", end=" ") elif s1 == 8: # pass() # Line 3030 print("? ", end=" ") elif s1 == 9: # pass() # Line 3040 print("UP ", end=" ") print("\n") dummy = input("~~Press Enter to Continue~~") return
def fillArray(col, row): grid = createGrid(col, row) n = 0 for y in range(1, col): for x in range(1, row): i = getIndex(x, y, col) grid[i] = int(rnd() * 7 + 1) # Returns 1-7 h = int(rnd() * 3 + 1) # Returns 1-3 for n in range(1, h + 1): x = int(rnd() * col) y = int(rnd() * row) i = getIndex(x, y, col) grid[i] = 8 # Trap doors? s = int(rnd() * 4 + 1) + 2 for n in range(1, s + 1): x = int(rnd() * 8 + 1) y = int(rnd() * 8 + 1) i = getIndex(x, y, col) grid[i] = 9 # Stairs Up? return (grid)
def thief(): global player cls() print("There is a thief in this chamber") idx = getIndex(player.x, player.y, 9) if level == 1: level1[idx] = 1 else: level2[idx] = 1 delay(1) g4 = int(rnd() * 500 / level + 1) if (player.gold - g4 < 0): g4 = player.gold y = int(rnd() * 8 + 1) if y <= 3: print(" ") print("You suprised the thief . . . . ") delay(1) print("As he runs out, he drops . . . . ") g4 = int(rnd() * 400 / level + 1) print(f'. . . {g4} gold pieces.') print("You pick up the gold pieces") player.gold = player.gold + g4 print(" ") if player.hasmap: return ma = int(rnd() * 4 + 1) if ma <= 2: player.hasmap = True getMap() return else: print("\n. . . . . . . . He surprises you") delay(2) print("As he quickly passes by you, he") print(f'snatches . . . {g4} gold pieces.\n') player.gold = player.gold - g4 if player.hasmap: return else: ma = int(rnd() * 4 + 1) if ma <= 2: player.hasmap = True getMap() return
while gameloop: if (onload == True): # Do stuff for the first (and only) time introTop() monsterInfo = monsterSetup() # level2 = fillArray(9,9) # Probably should be done for # level1 = fillArray(9,9) # a new game, too. onload = False if (newgame == True): # Do stuff needed for a new game introMiddle() level2 = fillArray(9, 9) level1 = fillArray(9, 9) player.x = int(rnd() * 8 + 1) player.y = int(rnd() * 8 + 1) index = getIndex(player.x, player.y, 9) level2[index] = 1 level = 2 player.movesdepleted = False player.movesleft = 100 player.hasmap = False player.haskey = False player.gold = 500 difficulty = int(getDifficulty()) initialHP = 20 + int(rnd() * 15 + 1) initialHP = int(initialHP / difficulty) targetKills = int(rnd() * 4 + 1) + 4 player.name = getName() player.hp = initialHP teleportactive = False delay(2)