/**
 * In a game, a character has the ability to perform critical hits, which can cause more damage than a regular attack.
 * The damage calculation depends on whether the attack is critical or not, and the enemy's armor.
 *
 * @param isCritical Indicates whether the attack is critical or not.
 * @param attackPower The power of the attack.
 * @param enemyArmor The armor of the enemy.
 * @return The calculated damage based on the given conditions.
 */
fun calculateDamage(isCritical: Boolean, attackPower: Int, enemyArmor: Int): Int {

    return if (isCritical) {
        when {
            attackPower < 50 -> {
                // Critical hits with low attack power penetrate through half of the enemy's armor
                attackPower * 5 - enemyArmor / 2
            }
            attackPower in 50 until 100 -> {
                // Critical hits with medium attack power penetrate through one-fourth of the enemy's armor
                attackPower * 4 - enemyArmor / 4
            }
            else -> {
                // Critical hits with high attack power ignore the enemy's armor completely
                attackPower
            }
        }
    } else {
        if (attackPower < 50) {
            // Regular hits with low attack power are weakened by the enemy's armor
            attackPower - enemyArmor
        } else {
            // Regular hits with medium or high attack power are not affected by the enemy's armor
            attackPower
        }
    }
}
/**
 * In a game, a character has the ability to perform critical hits, which can cause more damage than a regular attack.
 * The damage calculation depends on whether the attack is critical or not, and the enemy's armor.
 *
 * @param isCritical Indicates whether the attack is critical or not.
 * @param attackPower The power of the attack.
 * @param enemyArmor The armor of the enemy.
 * @return The calculated damage based on the given conditions.
 */
fun calculateDamage(isCritical: Boolean, attackPower: Int, enemyArmor: Int): Int {
/**
 * In a game, a character has the ability to perform critical hits, which can cause more damage than a regular attack.
 * The damage calculation depends on whether the attack is critical or not, and the enemy's armor.
 *
 * @param isCritical Indicates whether the attack is critical or not.
 * @param attackPower The power of the attack.
 * @param enemyArmor The armor of the enemy.
 * @return The calculated damage based on the given conditions.
 */
fun calculateDamage(isCritical: Boolean, attackPower: Int, enemyArmor: Int): Int {

    return if (isCritical) {
        when {
            attackPower < 50 -> {
                // Critical hits with low attack power penetrate through half of the enemy's armor
                attackPower * 5 - enemyArmor / 2
            }
            attackPower in 50 until 100 -> {
                // Critical hits with medium attack power penetrate through one-fourth of the enemy's armor
                attackPower * 4 - enemyArmor / 4
            }
            else -> {
                // Critical hits with high attack power ignore the enemy's armor completely
                attackPower
            }
        }
    } else {
        if (attackPower < 50) {
            // Regular hits with low attack power are weakened by the enemy's armor
            attackPower - enemyArmor
        } else {
            // Regular hits with medium or high attack power are not affected by the enemy's armor
            attackPower
        }
    }
}