Hello Nick!
First off, thanks so much for the awesome tutorial vids! As an ex-employee of Square Enix for 8 years, I really enjoyed seeing all the FF desktop wallpapers on your computer (especially FFXIV) and the homage to the games in your code.
I had a quick question about something I discovered that seems to be breaking the code for me.
# Enemy attack phase
for enemy in enemies:
enemy_choice = random.randrange(0, 2)
if enemy_choice == 0:
# Chose attack
target = random.randrange(0, 3)
enemy_dmg = enemy.generate_damage()
players[target].take_damage(enemy_dmg)
print("\n" + enemy.name.replace(" ", "") + " attacks " + players[target].name.replace(" ", "") + " for", enemy_dmg)
elif enemy_choice == 1:
spell, magic_dmg = enemy.choose_enemy_spell()
enemy.reduce_mp(spell.cost)
if spell.type == "white":
enemy.heal(magic_dmg)
print("\n" + bcolors.OKBLUE + spell.name + " heals " + enemy.name + " for", str(magic_dmg),
"HP." + bcolors.ENDC)
elif spell.type == "black":
target = random.randrange(0, 3)
players[target].take_damage(magic_dmg)
print(bcolors.OKBLUE + "\n" + enemy.name.replace(" ", "") + "'s " + spell.name + " deals",
str(magic_dmg), "points of damage to " + players[target].name.replace(" ", "") + bcolors.ENDC)
if players[target].get_hp() == 0:
print("\n" + players[target].name.replace(" ", "") + " has died.")
del players[target]
With the above portion, it seems like if someone in your party dies and is removed from the battle, the enemies are still able to target them with the current random.randrange parameters, which results in a crash.
Is there a way to make it so instead of a static range (ex: (0, 3), that you use the "len" function to create the range from the amount of players you have left in the party? Any advice to modify this would be much appreciated!
Hello Nick!
First off, thanks so much for the awesome tutorial vids! As an ex-employee of Square Enix for 8 years, I really enjoyed seeing all the FF desktop wallpapers on your computer (especially FFXIV) and the homage to the games in your code.
I had a quick question about something I discovered that seems to be breaking the code for me.
With the above portion, it seems like if someone in your party dies and is removed from the battle, the enemies are still able to target them with the current random.randrange parameters, which results in a crash.
Is there a way to make it so instead of a static range (ex: (0, 3), that you use the "len" function to create the range from the amount of players you have left in the party? Any advice to modify this would be much appreciated!