In short, I'm currently working on developing a damage calculation system for my turn-based RPG project. I have one of the main functions completely developed; however, when I try to call it in a "For" loop, nothing prints to the terminal (the function returns multiple printed values) despite the function working perfectly fine when called on its own. I'm not really sure what the problem is, as I'm not getting an error of any kind. Any help would be much appreciated!
*Please note that the function is defined before I try to call it in my actual program (also, all of the tuples such as move_data have been imported from my other file within the project. The lists are also defined as well). I only pasted the function definition below the problem area to be more courteous to those willing to help me solve this problem.
Here is my current code (I know it's very long, so I apologize in advance):
if move_data[move_data.index(party_info[party_info.index('Zeke') + 1][3]) + 1][-6] == 'all':
for target in range(len(enemy_info)):
if isinstance(target, str):
party_move('Zeke', target, party_info[party_info.index('Zeke') + 1][3], character_data[character_data.index('Zeke') + 1][0], 'Colosseum')
else:
party_move('Zeke', party_info[party_info.index('Zeke') + 1][4], party_info[party_info.index('Zeke') + 1][3], character_data[character_data.index('Zeke') + 1][0], 'Colosseum')
def party_move(user, target, move, user_class, location):
# Grabbing the attack stat of the user and the defense stat of the target after stat mods for single target attacks
# *Change character_data to enemy_data when enemy data is added*
user_attack = round(character_data[character_data.index(user) + 1][4] * party_info[party_info.index(user) + 1][7])
# Determines whether or not summons are present and if the target is being protected. If so, use the summon's defense sat
if len(enemy_summons) > 0:
for item in enemy_summons:
if target in item[1]:
target_defense = summon_data[summon_data.index(item[0]) + 1][4]
break
target_defense = round(character_data[character_data.index(target) + 1][5] * enemy_info[enemy_info.index(target) + 1][8])
if enemy_info[enemy_info.index(target) + 1][0] == 'Guard': # Checking for Guard stance and applies bonus
target_defense = target_defense * 2
else:
target_defense = round(character_data[character_data.index(target) + 1][5] * enemy_info[enemy_info.index(target) + 1][8])
if enemy_info[enemy_info.index(target) + 1][0] == 'Guard': # Checking for Guard stance and applies bonus
target_defense = target_defense * 2
if enemy_info[enemy_info.index(target) + 1][1] == 'Frostbite':
target_defense = target_defense / 2
# Setting the move cost and creating a list of damage values based on how many hits the attack has
damage = []
critical = []
stat_changes = []
status_effects = []
cost = move_data[move_data.index(move) + 1][4]
stat_index = 0
# Determining whether or not the base power is set or mana dependent from the tuple
if isinstance(move_data[move_data.index(move) + 1][0], int) == True:
power = move_data[move_data.index(move) + 1][0]
else:
power = (character_data[party_info.index(user) + 1][6] / 2) + 30
# Adjusting location and critical bonus damage mods respectively for each hit
for i in range(move_data[move_data.index(move) + 1][3]):
modifier = 1
if random.randint(party_info[party_info.index(user) + 1][-2], 25) == 25:
modifier = modifier * 1.5
critical.append(True)
else:
critical.append(False)
for index in class_bonuses:
if user_class in index and location in index:
modifier = modifier * 1.5
break
# Checking and applying applicable token bonuses before damage is calculated
if party_info[party_info.index(user) + 1][2] in token_data and token_data[token_data.index(party_info[party_info.index(user) + 1][2]) + 1][1] == 'Preattack':
ldic = locals()
exec(str(token_check(user)), globals(), ldic)
power = ldic['power']
print(power)
# Determining if the move landed for each hit. If so, calculate damage
if random.randint(1, 100) <= round(party_info[party_info.index(user) + 1][-1] * move_data[move_data.index(move) + 1][1]) or move_data[move_data.index(move) + 1][1] == 101:
damage.append(round(((((2 * level / 5 + 2) * power * user_attack / target_defense) / 50) + 2) * modifier))
else:
damage.append('miss')
# Recoil calculation
if len(damage) == 1 and isinstance(damage[0], int):
recoil = round(damage[0] * move_data[move_data.index(move) + 1][6])
else:
recoil = 0
# Determining stat drops & stat boosts
count = 0
if len(enemy_summons) > 0 and move_data[move_data.index(move) + 1][-1] == 'Target':
for lst in enemy_summons:
if target in lst:
break
else:
count += 1
if count == len(enemy_summons):
if move_data[move_data.index(move) + 1][-5] == 'Stats':
for stat in move_data[move_data.index(move) + 1][-3].split(', '):
stat_index = stat_boost_stages.index(enemy_info[enemy_info.index(target) + 1][stat_organization.index(stat) + 3]) + move_data[move_data.index(move) + 1][-2]
if stat_index > len(stat_boost_stages) - 1:
stat_index = len(stat_boost_stages)
stat_changes.append([target, stat, stat_index])
if stat_index < 0:
stat_index = 0
stat_changes.append([target, stat, stat_index])
else:
if move_data[move_data.index(move) + 1][-5] == 'Stats':
for stat in move_data[move_data.index(move) + 1][-3].split(', '):
if move_data[move_data.index(move) + 1][-1] == 'Target':
stat_index = stat_boost_stages.index(enemy_info[enemy_info.index(target) + 1][stat_organization.index(stat) + 3]) + move_data[move_data.index(move) + 1][-2]
if stat_index > len(stat_boost_stages) - 1:
stat_index = len(stat_boost_stages)
stat_changes.append([target, stat, stat_index])
if stat_index < 0:
stat_index = 0
stat_changes.append([target, stat, stat_index])
else:
if stat == 'Critical':
stat_changes.append([user, stat, move_data[move_data.index(move) + 1][-2]])
else:
stat_index = stat_boost_stages.index(party_info[party_info.index(user) + 1][stat_organization.index(stat) + 4]) + move_data[move_data.index(move) + 1][-2]
if stat_index > len(stat_boost_stages) - 1:
stat_index = len(stat_boost_stages)
stat_changes.append([target, stat, stat_index])
if stat_index < 0:
stat_index = 0
stat_changes.append([target, stat, stat_index])
# Determining status effects
count = 0
if len(enemy_summons) > 0 and move_data[move_data.index(move) + 1][-1] == 'Target':
for lst in enemy_summons:
if target in lst:
break
else:
count += 1
if count == len(enemy_summons):
if move_data[move_data.index(move) + 1][-5] == 'Status' and enemy_info[enemy_info.index(target) + 1][1] == 'Healthy':
if random.randint(1, 100) <= move_data[move_data.index(move) + 1][-4]:
status_effects.append([target, move_data[move_data.index(move) + 1][-3].split(', ')[random.randint(0, len(move_data[move_data.index(move) + 1][-3].split(', ')) - 1)]])
else:
if move_data[move_data.index(move) + 1][-5] == 'Status' and enemy_info[enemy_info.index(target) + 1][1] == 'Healthy':
if random.randint(1, 100) <= move_data[move_data.index(move) + 1][-4]:
status_effects.append([target, move_data[move_data.index(move) + 1][-3].split(', ')[random.randint(0, len(move_data[move_data.index(move) + 1][-3].split(', ')) - 1)]])
return print(damage, critical, stat_changes, status_effects)```