Now let's customize the program!

Look in the calculate_damage() function and customize the amount of damage each spell does!
Add a loop of your choice in the MAIN CODE section to repeat the code for each wizard to cast a spell. If you use a while loop, make sure it is not infinite!
Three lines of code are needed for each wizard to cast a spell and update HP. Include all of this in your loop!
########################################################################
#        HELPER FUNCTIONS                                              #
########################################################################

# Calculate how much damage each spell does
def calculate_damage(caster, spell):
    # Get information about the caster sprite
    caster_x = caster.get_x()
    opponent_x = caster_x * -1
    
    # Generate random number for damage based on the spell
    if spell == "fireball":
        damage = random.randint(0, 60)
    elif spell == "rock_smash":
        damage = random.randint(25, 55)
    
    # Animate the damage dealt
    # sprite = codesters.Text("text", x, y, "color")
    damage_text = codesters.Text(-damage, opponent_x, 0, "red")
    stage.wait(1)
    damage_text.move_up(300)
    
    return damage
    

# Animate the fireball spell coming from the caster
def fireball(caster):
    # Get information about the caster sprite
    caster_image = caster.get_image_name()
    caster_x = caster.get_x()
    opponent_x = caster_x * -1
    
    if caster_image == "wizard":
        caster.say("Fireball of Veritas!", 2)
        fireball = codesters.Sprite("meteor1", caster_x, 0)
        fireball.flip_left_right()
        fireball.set_speed(10)
        fireball.turn_left(10)
    else:
        caster.say("Fireball of Evil!", 2)
        fireball = codesters.Sprite("meteor1", caster_x, 0)
        fireball.set_speed(10)
        fireball.turn_right(10)
    
    fireball.glide_to(opponent_x, -100)
    fireball.hide()
    
    # Calculate damage and then return it
    damage = calculate_damage(caster, "fireball")
    return damage

# Animate the rock smash spell coming from the caster
def rock_smash(caster):
    # Get information about the caster sprite
    caster_image = caster.get_image_name()
    caster_x = caster.get_x()
    opponent_x = caster_x * -1
    
    if caster_image == "wizard":
        caster.say("The power of the Earth!", 2)
    else:
        caster.say("Heavy rock incoming!", 2)
    
    rock = codesters.Sprite("rock", caster_x, 50)
    rock.glide_to(caster_x, 300)
    rock.go_to(opponent_x, 200)
    rock.set_speed(10)
    rock.glide_to(opponent_x, -100)
    rock.hide()
    
    # Calculate damage and then return it
    damage = calculate_damage(caster, "rock_smash")
    return damage

# Cast a spell based on which sprite is casting it
def cast_spell(caster):
    caster_image = caster.get_image_name()
    # If player, choose a spell. If computer, random choice.
    if caster_image == "wizard":
        choice = stage.ask("What spell would you like to cast? a) Fireball b) Rock Smash").lower()
    else:
        choice = random.choice(["a", "b"])
    
    # Cast a spell based on the choice
    if choice == "a":
        damage = fireball(caster)
    elif choice == "b":
        damage = rock_smash(caster)
    
    return damage
    

########################################################################
#        MAIN CODE                                                     #
########################################################################

stage.set_background("field")
player = codesters.Sprite("wizard", 150, -100)
computer = codesters.Sprite("evilwizard", -150, -100)

player_hp = 100

#my_display = codesters.Display(my_var, x, y)
player_display = codesters.Display(player_hp, 150, 200)

computer_hp = 100

#my_display = codesters.Display(my_var, x, y)
computer_display = codesters.Display(computer_hp, -150, 200)

damage = cast_spell(player)
computer_hp -= damage
computer_display.update(computer_hp)

damage = cast_spell(computer)
player_hp -= damage
player_display.update(player_hp)