Advertisement
Critscan

Untitled

Apr 10th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.20 KB | None | 0 0
  1. # Python Text Dungeon Game
  2. # Zachary Privee 2024
  3.  
  4. '''
  5. To-Do List
  6. - Level up point gain
  7. '''
  8.  
  9. # Imports
  10. import os, random, time
  11.  
  12. pName = "PLAYER"
  13. pHealth = 20
  14. pMana = 20
  15. # Max Health, Max Mana, Attack, Agility, Defense
  16. playerStats = [20, 20, 1, 1, 1]
  17. pExp = 100
  18. levelUpPts = 0
  19. pLevel = 1
  20. spellList = ["Fireball", "Heal", "Barrier"]
  21. itemNames = ["Health Potion", "Mana Potion", "Gold"]
  22. itemAmount = [0, 0, 0]
  23. totalGold = 0
  24. critChance = 20
  25. killCount = 0
  26. artifactCount = 0
  27. # Technical
  28. myList = ""
  29. levelUpMenu = ["Health", "Mana", "Agility", "Back"]
  30. dashboard = ["Stats", "Inventory", "Actions", "Quit"]
  31. combatMenu = ["Attack", "Spells", "Defend", "Inventory", "Quit"]
  32. startMenu = ["Start", "Help", "Quit"]
  33. townMenu = ["Alter", "Shop", "Smith", "Return", "Quit"]
  34. shopMenu = ["Health Potion", "Mana Potion", "Back"]
  35. smithMenu = ["Sword", "Armor", "Back"]
  36. actionMenu = ["Search", "Proceed", "Back"]
  37. currentFloor = 1
  38. difficulty = 1
  39. gameLoop = False
  40. inCombat = False
  41. finalBoss = False
  42. alreadySearched = False
  43. moving = False
  44. enemyList = ["Goblin", "Skeleton", "Giant Rat", "Slime", "Kobold", "Giant Spider"]
  45. currentEnemy = ""
  46. wizardStats = [100, 10, 10, 100, 500]
  47.  
  48.  
  49. def enemy_stats(enemy):
  50. # HP, ATK, AGL, Max gold, EXP
  51. enemies = {
  52. "Giant Rat": [15, 2, 4, 2, 3],
  53. "Giant Spider": [15, 5, 4, 2, 10],
  54. "Goblin": [30, 2, 3, 20, 5],
  55. "Skeleton": [20, 4, 5, 5, 8],
  56. "Slime": [45, 2, 1, 8, 8],
  57. "Kobold": [35, 4, 3, 9, 10],
  58. }
  59. if enemy in enemies:
  60. return enemies[enemy]
  61. else:
  62. print("Enemy not found")
  63. return None
  64.  
  65. # Dice roll
  66. def dice_roll(x, y, show):
  67. show = str(show).capitalize()
  68. dice = random.randint(x, y)
  69. if show == "No":
  70. return dice
  71. elif show == "Yes":
  72. print("Rolling dice...")
  73. time.sleep(1)
  74. print(dice)
  75. return dice
  76. else:
  77. return dice
  78.  
  79. # Convert list to text
  80. def list_to_text(myLists):
  81. combinedText = ""
  82. for i in range(len(myLists)):
  83. combinedText += str(i + 1) + ". " + "[" + myLists[i].capitalize() + "] " + "\n"
  84. return combinedText
  85.  
  86. # Menu selection
  87. def option_menu(question, listName):
  88. print(question + "\n" + list_to_text(listName)) # Display the question prompt and list of options
  89. while True:
  90. user_input = input("> ").strip().lower()
  91. if user_input.isdigit(): # Check if input is a number
  92. index = int(user_input) - 1 # Convert to zero-based index
  93. if 0 <= index < len(listName):
  94. return listName[index]
  95. else:
  96. print("Invalid, try again.")
  97. else:
  98. for i, option in enumerate(listName):
  99. if user_input == option.lower():
  100. return option
  101. print("Invalid, try again.")
  102.  
  103. # Clears screen
  104. def clear():
  105. os.system('cls' if os.name == 'nt' else 'clear')
  106.  
  107. def game_over():
  108. global pName, pLevel, currentFloor, killCount, totalGold, currentEnemy
  109. clear()
  110. print(
  111. f"""========= GAME OVER =========
  112.  
  113. You have died. Killed by {currentEnemy}
  114.  
  115. Name: {pName}
  116. LVL: {pLevel}
  117. Floor: {currentFloor}
  118. Kills: {killCount}
  119. Total Gold Collected: {totalGold}
  120.  
  121. Rest in peace...""")
  122. input("> ")
  123. quit()
  124.  
  125. # Start screen
  126. def intro_prompt():
  127. clear()
  128. while True:
  129. clear()
  130. print('''
  131. ================= Dungeon Delver =================
  132. Version 0.1
  133. A game by Captain-Arbiter, 2024
  134.  
  135. How to play:
  136. When prompted with a ">", type out the word or
  137. number that corresponds with the action you wish
  138. to perform and press enter. If no actions are present
  139. then you may simply press enter to continue. \n''')
  140. choice = option_menu("", startMenu)
  141. if choice == "Start":
  142. clear()
  143. print("Starting game...")
  144. break
  145. elif choice == "Help":
  146. clear()
  147. help_screen()
  148. clear()
  149. elif choice == "Quit":
  150. if confirm_loop() == True:
  151. print("Closing game...")
  152. time.sleep(0.5)
  153. sys.exit()
  154. break
  155. else:
  156. intro_prompt()
  157.  
  158. def help_screen():
  159. print(
  160. """==================== Game Guide ====================
  161. Page 1: Room Dashboard
  162.  
  163. When in the dungeon, and not in combat you may perform
  164. a few actions:
  165.  
  166. - [STATS] Will open the character sheet for you to
  167. inspect your character's status.
  168. - [INVENTORY] will open your inventory and
  169. show you all currently held items, as well as give you
  170. acces to the Homeward Ring, which we'll cover later.
  171. - [ACTIONS] Will let you either, [SEARCH] for any
  172. treasure in the room, or [PROCEED] to the next
  173. floor in the dungeon.
  174. - [QUIT] will ask if you wish to close the game.
  175. Progress will not be saved.\n""")
  176. input("Next Page > ")
  177. clear()
  178. print(
  179. """==================== Game Guide ====================
  180. Page 2: Combat
  181.  
  182. Everytime you enter a room. There is a 1 in 3 chance
  183.  
  184.  
  185.  
  186.  
  187. """)
  188.  
  189.  
  190. def combat():
  191. global pHealth, pMana, enemyList, playerStats, critChance, pExp, inCombat, moving, currentEnemy, killCount
  192. moving = False
  193. inCombat = True
  194. dice = dice_roll(1, 6, "No")
  195. currentEnemy = enemyList[dice - 1] if 1 <= dice <= 6 else "ERROR: ENEMY ID NOT FOUND"
  196. currentEnemyStats = enemy_stats(currentEnemy)
  197. if finalBoss == True:
  198. currentEnemy = "Dark-Wizard Telinoir"
  199. currentEnemyStats = wizardStats
  200. print("Telinoir, the dark wizard, appears before you!")
  201. else:
  202. print(f"A {currentEnemy} appears!")
  203. input("> ")
  204. while True:
  205. if pHealth <= 0:
  206. game_over()
  207. defend = playerStats[4] * 1.12
  208. crHit = False
  209. clear()
  210. print(
  211. f'''========= floor {currentFloor} =========
  212.  
  213. {currentEnemy}:
  214. HP: {currentEnemyStats[0]}
  215.  
  216. {pName}:
  217. HP: {pHealth}/{playerStats[0]} MP: {pMana}/{playerStats[1]}
  218. ''')
  219. choice = option_menu("What will you do?\n", combatMenu)
  220. if choice == "Attack":
  221. dice = dice_roll(1, 20, "No")
  222. attackMulti = playerStats[2] / 2 + 1
  223. round(attackMulti, 2)
  224. damageDealt = 5 * attackMulti
  225. if dice >= critChance:
  226. damageDealt += damageDealt * 1.75
  227. damageDealt = round(damageDealt)
  228. currentEnemyStats[0] -= damageDealt
  229. print("Critcal hit!")
  230. time.sleep(1)
  231. print(f"You attack for {damageDealt} damage")
  232. elif dice <= currentEnemyStats[2]:
  233. print("You missed!")
  234. else:
  235. damageDealt = round(damageDealt)
  236. currentEnemyStats[0] -= damageDealt
  237. print("Hit!")
  238. time.sleep(1)
  239. print(f"You attack for {damageDealt} damage")
  240. input("> ")
  241. clear()
  242. elif choice == "Spells":
  243. if pMana < 10:
  244. print("Insufficient Mana")
  245. continue
  246. pMana -= 10
  247. spellChoice = option_menu(
  248. """What spell will you cast?
  249. -10 MP per spell""", spellList)
  250. if spellChoice == "Fireball":
  251. currentEnemyStats[0] -= 20
  252. print("You cast fireball")
  253. time.sleep(1)
  254. print("Your attack deals 20 damage")
  255. elif spellChoice == "Heal":
  256. heal_amount = 25
  257. pHealth += heal_amount
  258. print("You cast heal")
  259. if pHealth > playerStats[0]:
  260. hOverflow = pHealth - playerStats[0]
  261. pHealth = playerStats[0]
  262. print(f"You healed {heal_amount - hOverflow} HP.\n")
  263. else:
  264. print(f"You healed {heal_amount} HP.\n")
  265. elif spellChoice == "Barrier":
  266. defend = defend * 5.5
  267. print("You cast barrier")
  268. print("Your magic sheild stands strong...")
  269. else:
  270. print("INVALID SPELL")
  271. input("> ")
  272. elif choice == "Defend":
  273. defend = defend * 2.5
  274. print("You raise your guard...")
  275. time.sleep(1)
  276. input("> ")
  277. elif choice == "Inventory":
  278. show_inventory()
  279. continue
  280. elif choice == "Quit":
  281. if confirm_loop():
  282. quit
  283. if currentEnemyStats[0] <= 0:
  284. print(f"The {currentEnemy} has died!")
  285. killCount += 1
  286. break
  287. dice = dice_roll(1, 100, "No")
  288. if dice <= playerStats[3] * 1.75:
  289. print(
  290. f'''========= floor {currentFloor} =========
  291.  
  292. {currentEnemy}:
  293. HP: {currentEnemyStats[0]}
  294.  
  295. {pName}:
  296. HP: {pHealth}/{playerStats[0]} MP: {pMana}/{playerStats[1]}
  297. ''')
  298. print(f"The {currentEnemy} goes to attack\n")
  299. time.sleep(1)
  300. print(f"The {currentEnemy} missed!")
  301. input("> ")
  302. elif dice > playerStats[3] * 1.75:
  303. enemyCrit = dice_roll(1, 20, "No")
  304. enemyAttack = currentEnemyStats[1] * 1.75 / defend
  305. enemyAttack = round(enemyAttack)
  306. if enemyCrit == 1:
  307. crHit = True
  308. enemyAttack += enemyAttack * 0.75
  309. enemyAttack = round(enemyAttack)
  310. if enemyAttack <= 0:
  311. enemyAttack = 0
  312. pHealth -= enemyAttack
  313. print(
  314. f'''========== floor {currentFloor} ==========
  315.  
  316. {currentEnemy}:
  317. HP: {currentEnemyStats[0]}
  318. ''')
  319. print(f"The {currentEnemy} goes to attack!\n")
  320. time.sleep(1)
  321. if crHit == True:
  322. print("Critical Hit!")
  323. print(f"The {currentEnemy} deals {enemyAttack} damage!")
  324. else:
  325. print("Hit!")
  326. print(f"The {currentEnemy} deals {enemyAttack} damage!")
  327. input("> ")
  328. else:
  329. print("ERROR IN DAMAGE OUTPUT")
  330.  
  331. goldFound = dice_roll(0, currentEnemyStats[3], "No")
  332. add_gold(goldFound)
  333. pExp += currentEnemyStats[4]
  334. print(f"{currentEnemyStats[4]} XP gained")
  335.  
  336. # Confirm message
  337. def confirm_loop():
  338. confirm = input(str("Are you sure about this? [y/n]: \n> ")).lower()
  339. if confirm == "y":
  340. clear()
  341. return True
  342. elif confirm == "n":
  343. clear()
  344. return False
  345. else:
  346. clear()
  347. print("Invalid, try again")
  348.  
  349. # Decorative line creator
  350. def line_flair(character, numRows, pause):
  351. line = "=" * 20 + " " + character + " " + "=" * 20
  352. for i in range(numRows):
  353. print(line)
  354. time.sleep(pause)
  355.  
  356. # Text box function
  357. def dialogue_box(character, text, pause):
  358. line_flair(character, 1, 0.5)
  359. print(text)
  360. time.sleep(pause)
  361.  
  362. # All of the games item effects. Must add items to itemName list and increase the size of the itemAmount list
  363. # if you want to add new items.
  364. def item_effects(itm):
  365. global pHealth
  366. global pMana
  367. if itm == "Health Potion":
  368. heal_amount = 50
  369. pHealth += heal_amount
  370. if pHealth > playerStats[0]:
  371. hOverflow = pHealth - playerStats[0]
  372. pHealth = playerStats[0]
  373. print(f"You healed {heal_amount - hOverflow} HP.\n")
  374. else:
  375. print(f"You healed {heal_amount} HP.\n")
  376. elif itm == "Mana Potion":
  377. mana_amount = 50
  378. pMana += mana_amount
  379. if pMana > playerStats[1]:
  380. mOverflow = pMana - playerStats[1]
  381. pMana = playerStats[1]
  382. print(f"You restored {mana_amount - mOverflow} MP.\n")
  383. else:
  384. print(f"You restored {mana_amount} mana.\n")
  385.  
  386. else:
  387. print("Error")
  388.  
  389. # Use an item
  390. def use_item(item_name):
  391. index = itemNames.index(item_name)
  392. if itemAmount[index] > 0:
  393. clear()
  394. print(f"You used {item_name}.")
  395. itemAmount[index] -= 1
  396. item_effects(item_name)
  397. else:
  398. print("You don't have any of that item.")
  399.  
  400. # Function to show inventory
  401. def show_inventory():
  402. global inCombat
  403. clear()
  404. print("======== Inventory ========")
  405. for item, amount in zip(itemNames, itemAmount):
  406. if amount > 0:
  407. print(f"{item}: {amount}")
  408. print("Homeward Ring")
  409. # Display the options menu
  410. pInventory_updated = [item for item, amount in zip(itemNames, itemAmount) if amount > 0] + ["Homeward Ring"] + ["Back"]
  411. # Remove "Gold" from the options menu if it's present
  412. if "Gold" in pInventory_updated:
  413. pInventory_updated.remove("Gold")
  414. choice = option_menu("\nWhat item do you want to use?\n", pInventory_updated)
  415. if choice == "Back":
  416. # Go back to action menu
  417. return
  418. elif choice == "Homeward Ring":
  419. if inCombat == True:
  420. print("The evil presence disrupts the ring\n")
  421. input("> ")
  422. return
  423. print(
  424. """This ring teleports you back to town.
  425. When you return to the dungeon you will
  426. go back one floor.""")
  427. if confirm_loop():
  428. homeward_ring()
  429. else:
  430. return
  431. else:
  432. use_item(choice)
  433. # Use selected item
  434.  
  435. # Item add system: 1 = HP Potion, 2 = MA Potion
  436. def add_inventory(item, amount):
  437. if item == 1:
  438. itemAmount[0] += amount
  439. if amount == 1:
  440. print("Health Potion added to inventory")
  441. else:
  442. print(f"{amount} Health Potions added to inventory")
  443. elif item == 2:
  444. itemAmount[1] += amount
  445. if amount == 1:
  446. print("Mana Potion added to inventory")
  447. else:
  448. print(f"{amount} Mana Potions added to inventory")
  449. else:
  450. print("ERROR INVALID ITEM CODE")
  451.  
  452. # Add gold to player inventory
  453. def add_gold(amount):
  454. global itemAmount, totalGold
  455. totalGold += amount
  456. if amount > 0:
  457. itemAmount[2] += amount
  458. print(f"{amount} gold added to inventory")
  459. elif amount == 0:
  460. print("No gold found")
  461. else:
  462. itemAmount[2] += amount
  463. print(f"{amount} gold removed from inventory")
  464.  
  465. # Player sheet
  466. def stat_menu():
  467. clear()
  468. print(f"""
  469. ======== {pName} ========
  470. Level: {pLevel}
  471. XP: {pExp}
  472. Health: {pHealth} / {playerStats[0]}
  473. Mana: {pMana} / {playerStats[1]}
  474. ATK: {playerStats[2]}
  475. AGL: {playerStats[3]}
  476. DFS: {playerStats[4]}""")
  477. input("\n> ")
  478.  
  479. # Name creator
  480. def name_selection():
  481. global pName
  482. while True:
  483. dialogue_box("Stranger",
  484. """Hello there, you're far from home arent you?
  485. You must be here for the bounty on the wizard, what else
  486. could an adventurer like you be doing here. Fine then.
  487. Beyond the valley and over the hill will take you to
  488. Vindleheim Ruins, where the rogue wizard Telinoir has
  489. made his lair. We're counting on you. Oh where are my
  490. manners!""", 0.5)
  491. input("> ")
  492. pName = input(str("What is your name?\n> ")).title()
  493. print(f"Your name is {pName}?")
  494. if confirm_loop():
  495. break
  496.  
  497. # Primary tool menu
  498. def dashboard_menu():
  499. inCombat = False
  500. while True:
  501. if moving == True:
  502. break
  503. print(
  504. f"""========= floor {currentFloor} =========\n""")
  505. choice = option_menu("What do you want to do?\n", dashboard)
  506. print(choice)
  507. time.sleep(0.5)
  508. if choice == "Stats":
  509. stat_menu()
  510. elif choice == "Inventory":
  511. show_inventory()
  512. elif choice == "Actions":
  513. action_menu()
  514. elif choice == "Quit":
  515. if confirm_loop():
  516. print("Closing Game...")
  517. exit()
  518. else:
  519. print("Invalid Input")
  520.  
  521. # Hub village ring.
  522. def homeward_ring():
  523. global currentFloor, inCombat
  524. print("A warm glow emmits from the ring...")
  525. if currentFloor > 1:
  526. currentFloor -= 1
  527. time.sleep(1)
  528. print("In a flash you find yourself back in Hartswell.\n")
  529. print(
  530. """========== Hartswell ==========
  531.  
  532. You can:
  533. - Visit the church, and level up at the alter
  534. - Go to the Apothocary's potion shop
  535. - Get your gear upgraded at the blacksmith
  536. """)
  537. while True:
  538. choice = option_menu("What will you do?\n", townMenu)
  539. if choice == "Alter":
  540. church_menu()
  541. elif choice == "Shop":
  542. shop_menu()
  543. elif choice == "Smith":
  544. blacksmith_menu()
  545. elif choice == "Return":
  546. if confirm_loop():
  547. print("You focus on the ring, and return to the dungeon.")
  548. break
  549. elif choice == "Quit":
  550. if confirm_loop():
  551. print("Closing Game...")
  552. exit()
  553. else:
  554. print("Invalid")
  555.  
  556. # Potion shop menu
  557. def shop_menu():
  558. NPC = "Apothocary Zelmik"
  559. global itemAmount
  560. clear()
  561. print("You go to the potion shop")
  562. dialogue_box(NPC,
  563. f"""Hello {pName}. Come in, come, don't worry about the smell,
  564. just a new brew I'm working on.""", 0.5)
  565. input("> ")
  566. clear()
  567. while True:
  568. dialogue_box(NPC,
  569. '''What can I provide for you today? All potions are 25 gold.''', 0.5)
  570. print(f"""
  571. Gold: {itemAmount[2]}
  572. Healh Potions: {itemAmount[0]}
  573. Mana Potions: {itemAmount[1]}
  574. """)
  575. choice = option_menu("",shopMenu)
  576. if choice == "Health Potion" or choice == "Mana Potion":
  577. if itemAmount[2] < 25:
  578. clear()
  579. dialogue_box(NPC,"We don't take credit here. Get out!", 0.5)
  580. print("\nYou leave the shop and return to the town square.")
  581. break
  582. elif choice == "Health Potion":
  583. add_gold(-25)
  584. add_inventory(1, 1)
  585. clear()
  586. print("Thank you kind sir!")
  587. print(f"1 Health Potion added to inventory. Held: {itemAmount[0]}")
  588. continue
  589. elif choice == "Mana Potion":
  590. add_gold(-25)
  591. add_inventory(2, 1)
  592. clear()
  593. print("Thank you kind sir!")
  594. print(f"1 Mana Potion added to inventory. Held: {itemAmount[1]}")
  595. continue
  596. elif choice == "Back":
  597. clear()
  598. dialogue_box(NPC, "Come again soon!", 0.5)
  599. print("\nYou leave the shop and return to the town square.")
  600. break
  601. else:
  602. print("What was that?")
  603.  
  604. # Attack and defense level up
  605. def blacksmith_menu():
  606. NPC = "Blacksmith Gilligan"
  607. global playerStats
  608. global itemAmount
  609. clear()
  610. print("You go to the blacksmith")
  611. dialogue_box(NPC,
  612. f"""Haha! Come in {pName}, ya gear be needin' a tune-up?
  613. Nothin' me hammer can't forge.""", 0.5)
  614. input("> ")
  615. clear()
  616. while True:
  617. dialogue_box(NPC,
  618. """So what'll it be? Sword need sharpenin' or yer
  619. armor need reinforcin'? 50 gold service charge of course.""", 0.5)
  620. print(f"""
  621. Gold: {itemAmount[2]}
  622. Sword ATK: {playerStats[2]}
  623. Armor DFS: {playerStats[4]}
  624. """)
  625. choice = option_menu("", smithMenu)
  626. if choice == "Sword" or choice == "Armor":
  627. if itemAmount[2] < 50:
  628. clear()
  629. dialogue_box(NPC,"Oi! Come back when ya got some coin! No freebies here.", 0.5)
  630. print("\nYou leave the shop and return to the town square.")
  631. break
  632. elif choice == "Sword":
  633. add_gold(-50)
  634. playerStats[2] += 1
  635. clear()
  636. print("A fine piece, but finer now I've got me hands on it.")
  637. print("+1 to sword ATK")
  638. continue
  639. elif choice == "Armor":
  640. add_gold(-50)
  641. playerStats[4] += 1
  642. clear()
  643. print("Some hardened plates here, tighter fastenins' there, and\nthis armor'll keep ya safe.")
  644. print("+1 to armor DFS")
  645. elif choice == "Back":
  646. clear()
  647. print("Ya know were to find me.")
  648. print("\nYou leave the shop and return to the town square.")
  649. break
  650. else:
  651. print("What was that?")
  652.  
  653. # Level up menu
  654. def church_menu():
  655. NPC = "Sister Charlotte"
  656. global pExp
  657. global levelUpPts
  658. global playerStats
  659. clear()
  660. print("You go to the church")
  661. dialogue_box(NPC,
  662. """Come O' weary soul. Shed thine burdens, and find
  663. strength in ones faith.""", 0.5)
  664. input("> ")
  665. clear()
  666. while True:
  667. dialogue_box(NPC,
  668. """Sit beside me, and reach within thineself. In what
  669. way doth wish to revieve blessing""", 0.5)
  670. print(f"""
  671. Points to spend: {levelUpPts}
  672. Max HP: {playerStats[0]}
  673. Max MP: {playerStats[1]}
  674. AGL: {playerStats[3]}
  675. """)
  676. choice = option_menu("", levelUpMenu)
  677. if choice == "Health" or choice == "Mana" or choice == "Agility":
  678. if levelUpPts < 1:
  679. clear()
  680. dialogue_box(NPC,
  681. """You must grow thine soul further to revieve blessing. May you find strength.""", 0.5)
  682. print("\nYou leave the church and return to the town square.")
  683. break
  684. elif choice == "Health":
  685. levelUpPts -= 1
  686. playerStats[0] += 10
  687. pHealth = playerStats[0]
  688. pMana = playerStats[1]
  689. clear()
  690. print("May thine heart remain steadfast and true, always.")
  691. print("+10 to max HP")
  692. elif choice == "Mana":
  693. levelUpPts -= 1
  694. playerStats[1] += 10
  695. pHealth = playerStats[0]
  696. pMana = playerStats[1]
  697. clear()
  698. print("Free thine mind, to reach thous't true potential.")
  699. print("+10 to max Mana")
  700. elif choice == "Agility":
  701. levelUpPts -= 1
  702. playerStats[3] += 10
  703. pHealth = playerStats[0]
  704. pMana = playerStats[1]
  705. clear()
  706. print("Keep up thine wits and reflexes, may harm elude you.")
  707. print("+1 to Agility")
  708. elif choice == "Back":
  709. clear()
  710. print("Come again child, may faith guide thine path.")
  711. print("\nYou leave the church and return to the town square.")
  712. break
  713. else:
  714. print("I don't understand.")
  715.  
  716. def action_menu():
  717. global currentFloor, moving, pHealth, alreadySearched, artifactCount
  718. while True:
  719. clear()
  720. print(
  721. f"""========= floor {currentFloor} =========\n""")
  722. choice = option_menu("What will you do?\n", actionMenu)
  723. print(choice)
  724. if choice == "Search":
  725. if alreadySearched == True:
  726. print("You've aleady searched this room")
  727. return
  728. if alreadySearched != True:
  729. alreadySearched = True
  730. print("You look around for anything of use...")
  731. time.sleep(1)
  732. dice = dice_roll(1, 10, "No")
  733. if dice <= 4:
  734. dice2 = dice_roll(1, 10, "No")
  735. print("You find a treasure chest in the room!")
  736. input("> ")
  737. if dice2 == 1:
  738. pHealth -= 5
  739. print("The chest is trapped!\nYou take 5 damage!")
  740. input("> ")
  741. if pHealth <= 0:
  742. currentEnemy = "Trapped Chest"
  743. game_over()
  744. else:
  745. return
  746. elif dice2 <= 6:
  747. print("You found some gold inside!")
  748. add_gold(dice_roll(5, 30, "No"))
  749. input("> ")
  750. return
  751. elif dice2 <= 9:
  752. print("You found a potion inside!")
  753. add_inventory(dice_roll(1, 2, "No"), 1)
  754. input("> ")
  755. return
  756. else:
  757. print("You found an artifact inside!\nIt swells with warmth to your touch.")
  758. artifactCount += 1
  759. dice3 = dice_roll(1, 5, "No")
  760. if dice3 == 1:
  761. print("The feel your vitality strengthen!\n+10 to max HP")
  762. playerStats[0] += 10
  763. pHealth = playerStats[0]
  764. elif dice3 == 2:
  765. print("Your mind grows sharper!\n+10 to max MP")
  766. playerStats[1] += 10
  767. pMana = playerStats[1]
  768. elif dice3 == 3:
  769. print("You feel your strength rise!\n+1 to ATK")
  770. playerStats[2] += 1
  771. elif dice3 == 4:
  772. print("Your body loosens, you feel as nimble as a cat!\n+1 to AGL")
  773. playerStats[3] += 1
  774. elif dice3 == 5:
  775. print("Your body hardens, your skin becomes like stone!\n+1 to DFS")
  776. playerStats[4] += 1
  777. return
  778. else:
  779. print("You don't find anything\n")
  780. input("> ")
  781. clear()
  782. return
  783. elif choice == "Proceed":
  784. print("You move onward to the next floor")
  785. input("> ")
  786. currentFloor += 1
  787. moving = True
  788. return
  789. elif choice == "Back":
  790. return
  791.  
  792. add_inventory(1,1)
  793. add_inventory(2,1)
  794. add_gold(100)
  795. # Main gameplay body
  796. gameLoop = True
  797. while gameLoop == True:
  798. alreadySearched = False
  799. if pHealth <= 0:
  800. game_over()
  801. if pExp >= 100:
  802. pLevel += 1
  803. levelUpPts += 1
  804. pExp = 0
  805. print("You've leveled up!\nVisit the church in town to increase your stats.")
  806. input("> ")
  807. moving = False
  808. if currentFloor == 100:
  809. finalBoss = True
  810. combat()
  811. print("Congratulations! The wizard is beat!")
  812. gameLoop = False
  813. clear()
  814. roomResult = dice_roll(1,3, "no")
  815. if roomResult == 3: # Combat
  816. combat()
  817. inCombat = False
  818. else:
  819. print("The room seems clear")
  820. dashboard_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement