def calculate_damage(attacker, defender):
    """Calculate and return effective power of attacker against defender.

        args:
            attacker: [side, units, hit_points, weaknesses, immunities,
                       damage, damage_type, initiative]

            defender: [side, units, hit_points, weaknesses, immunities,
                       damage, damage_type, initiative]

        Return:
            group_damage: effective power modified by weaknesses/immunities
    """
    group_damage = attacker[1] * attacker[5]
    damage_type = attacker[6]
    if damage_type in defender[3]:
        group_damage *= 2
    elif damage_type in defender[4]:
        group_damage = 0
    return group_damage