def end_everyones_turn(self): line = "_" * 30 print('END TURN EFFECTS') print('================') print(line) cprint('Player:', 'green') player = self.player_character player.end_turn() for enemy in player.opponents: print(line) cprint(f'{enemy.name}:', 'green') enemy.end_turn() print(line) unfucked_input('press enter to continue: ') os.system('cls')
def get_fight_option( self): # get what option the player actually wants to do while True: # error handling while loop # choice will be of form: A1,B1,A2,B2...A12,B12... choice = unfucked_input('choose an attack or consumable: ') if choice.lower() == 'pass': return 'pass' if len(choice) < 2: print( 'ERROR: please type a letter, A for attack or B for consumable, and then the index of the attack/consumable' ) continue type = choice[0].upper( ) # A for (A)ttack, B for consumable from (B)ag index = choice[1:] if type not in ['A', 'B']: print('ERROR: first character should be A or B') continue try: index = int(index) - 1 # we have a -1 here, as the player input will be one more than the index, as list indexing starts at 0 except ValueError: print( 'ERROR: you should have a number after the first character' ) continue if type.upper() == 'B': # if the option choses is an consumable if index >= len(self.bag) or index < 0: # because we subtracted 1 from the player submitted index, we check index < 0 and not index < 1 print( 'ERROR: index error, choose a valid number for consumable index' ) continue else: consumable = self.bag.pop(index) self.use_consumable(consumable) os.system('cls') self.show_fight_status() self.show_fight_options() continue if index >= len(self.moveset) or index < 0: # because we subtracted 1 from the player submitted index, we check index < 0 and not index < 1 print( 'ERROR: index error, choose a valid number for attack index' ) continue if self.moveset[index].mana_cost > self.mana: print('you dont have enough mana for that') continue choice = {'type': type, 'index': index} return choice
def end_battle(self): self.status_conditions.clear() self.ATK = self.base_ATK self.mana_regen = self.base_mana_regen self.evasion = self.base_evasion self.DEF = self.base_DEF self.gold += Character.gold_from_battle print('you gained', colored(f'{self.gold_from_battle} gold', 'yellow'), 'from that encounter') Character.gold_from_battle = 0 self.next_shop -= 1 print('you now have', colored(f'{self.gold} gold', 'yellow')) drop = random.choice(Consumable.ALL_consumables) self.equip(drop) cprint(f'you found a {drop.name}', 'green') unfucked_input('press ented to continue: ') os.system('cls')
from Character import * from Move import * import os from Misc_functions import unfucked_input from Consumable import * from Weapon import * os.system('color') print("make sure you're running this in command line and not in python Idle") unfucked_input('press enter to continue') os.system('cls') player = Player() Character.player_character = player player.equip(medium_mana_potion) player.equip(big_health_potion) player.equip(big_bomb) def check_if_all_enemies_are_alive(): they_are_all_alive = True for enemy in player.opponents: if enemy.dead: they_are_all_alive = False return they_are_all_alive def remove_dead_enemies(): for i in range(len(player.opponents)): if player.opponents[i].dead:
def use_move(self, user, opponents): # opponents is the list of enemies the enemy has to fight user.mana -= self.mana_cost if self.base_dmg > 0: if user.weapon is not None: dmg_multiplier = user.weapon.damage_multiplier else: dmg_multiplier = 1 dmg = int(((user.ATK) / 10) * (self.base_dmg) * (dmg_multiplier)) if user.has_status('Weakness'): dmg = int(dmg * 0.75) if user.isPlayer: # checks if the user is the player or an enemy if self.AoE: # checks if the move hits all enemies or just one Enemy for enemy in opponents: # hit chance cant be less that 50% hit_chance = self.accuracy - enemy.evasion if enemy.has_status('unhittable'): hit_chance = 0 hit_roll = random.randint(0, 99) if hit_roll > hit_chance: # if this triggers its a miss print(colored(f'{user.name} missed {enemy.name}', 'green',)) continue dmg = dmg * random.uniform(0.9, 1.1) # cprint(f'{user.name} used {self.name} on {enemy.name}', 'green') user.deal_damage(enemy, dmg) self.apply_debuffs(enemy) # TODO: add status effect check here else: if len(opponents) > 1: show_opponents(opponents) while True: target_index = unfucked_input('which enemy do you want to attack?: ') try: target_index = int(target_index) except ValueError: print('ERROR:input must be a number') continue try: target = opponents[target_index - 1] # we have a - 1 here, as indexing starts at 0 for the Player # the player types a number from 1 to {number of enemies}, not 0 to {number of enemies - 1} # but the opponents list indexing starts at 0 except IndexError: print('ERROR: IndexError') continue break os.system('cls') else: target = opponents[0] # target = opponents[int(input('which enemy do you want to attack?: '))] hit_chance = max(50, self.accuracy - target.evasion) hit_roll = random.randint(0, 99) if target.has_status('unhittable'): hit_chance = 0 if hit_roll > hit_chance: # if this triggers its a miss print(colored(f'{user.name} missed {target.name}', 'green')) return None dmg = dmg * random.uniform(0.9, 1.1) # cprint(f'{user.name} used {self.name} on {target.name}', 'green') user.deal_damage(target, dmg) self.apply_debuffs(target) # TODO: add status effect check here for enemy in opponents: if enemy.hp <= 0: enemy.dead = True ''' if enemy.dead: enemy.die(opponents) ''' show_opponents(opponents) # TODO: make enemies attack too u idiot else: # this is for if the user of the attack is an enemy. player = opponents # sets 'player' as the enemy's opponent hit_chance = max(50, self.accuracy - player.evasion) hit_roll = random.randint(0, 99) if player.has_status('unhittable'): hit_chance = 0 if hit_roll > hit_chance: # this is a miss print(colored(f'{user.name} missed {player.name}', 'green')) else: # cprint(f'{user.name} used {self.name} on {player.name}', 'green') dmg *= 1 - (min(player.DEF, 90) / 100) user.deal_damage(player, dmg) self.apply_debuffs(player) player.show_healthbar() self.apply_buffs(user) for effect in self.effects: effect.parent = self effect.trigger()