def useItem(player, party, enemies): player.choose_item() item_choice = checkForGoodInput("\tChoose item: ", len(player.items)) if item_choice == -1: return False if player.items[item_choice].qnty == 0: print(bcolors.FAIL + "\nNone left..." + bcolors.ENDC) return False item = player.items[item_choice] player.items[item_choice].qnty -= 1 if item.type == "potion": healAmount = item.rollForAffect() player.heal(healAmount) if player.hp > player.maxHp: player.hp == player.maxHp print(bcolors.OKGREEN + "\n" + item.name + " heals for " + str(healAmount) + " HP" + bcolors.ENDC) elif item.type == "elixer": if item.name == "megaElixer": for player in party: elixerBoost(player, item) else: elixerBoost(player, item) elif item.type == "attack": enemy = enemies[choose_target(enemies)] enemy.take_damage(item.prop) print(bcolors.FAIL + "\n" + item.name + " deals " + str(item.prop) + " points of damage to " + enemies[enemy].name + "." + bcolors.ENDC) deathCheck(enemies, enemy) return True
def choose_target(enemies): i = 1 choice = 0 print("\n" + bcolors.FAIL + bcolors.BOLD + "\tTarget:" + bcolors.ENDC) for enemy in enemies: enemy.get_enemy_stats(i) i += 1 choice = checkForGoodInput("\tChoose target: ", len(enemies)) return choice
def options(): options = ["Quit Game","Back"] print("Options: ") for i in range(0,len(options)): print("[" + str(i + 1) + "] " + options[i]) optionIndex = checkForGoodInput(": ", len(options)) option = options[optionIndex] if option == "Quit Game": sys.exit(0) elif option == "Back": return False
def castMagic(player, enemies): player.choose_magic() magic_choice = checkForGoodInput("\tChoose magic: ", len(player.magic)) spell = player.magic[magic_choice] current_mp = player.get_mp() if spell.cost > current_mp: print(bcolors.FAIL + "\nNot enough MP\n" + bcolors.ENDC) return False player.reduce_mp(spell.cost) spell.castSpell(player, enemies) return True
def buildCharacter(name, dice): print("Which class would you like to play as?") classes = ["paladin", "mage", "ranger"] for i in range(0, 3): print("[" + str(i + 1) + "] " + classes[i]) classIndex = checkForGoodInput(": ", len(classes)) startingClass = classes[classIndex] chosen = [] stats = [] for i in range(0, 4): diceIndex = chooseStat(i, chosen) chosen.append(diceIndex) stats.append(dice[diceIndex - 1]) if startingClass == "paladin": return Paladin(name, stats[0], stats[1], stats[2], stats[3]) elif startingClass == "mage": return Mage(name, stats[0], stats[1], stats[2], stats[3]) elif startingClass == "ranger": return Ranger(name, stats[0], stats[1], stats[2], stats[3])
def combat(party, enemies): combat = True print(bcolors.FAIL + bcolors.BOLD + "AN ENEMY ATTACKS!" + bcolors.ENDC) while combat: print("-----------------------------------") print("\n") print(bcolors.OKBLUE + bcolors.BOLD + "Party Members" + bcolors.ENDC) print( "NAME HP MP" ) for player in party: player.getStats() print("\n") print(bcolors.FAIL + bcolors.BOLD + "Enemies Members" + bcolors.ENDC) print("NAME HP") for enemy in enemies: enemy.get_enemy_stats(False) for player in party: player.choose_action() index = checkForGoodInput("\tChoose action: ", len(player.actions)) success = combatMenu(index, player, enemies, party) if not success: continue combat = checkWinCon(party, enemies) if not combat: break baddiesTurn(party, enemies) if combat: combat = checkWinCon(party, enemies)