"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tools = void 0;
class Tools {
    static calculateDamageRange(attacker, defender) {
        function damage_multiplier(a) {
            return Math.min(1.32, Math.max(.05, 1 - (.001 * Math.max(0, Math.min(100, a)) + .001 * Math.max(0, Math.min(100, a - 100)) + .00095 * Math.max(0, Math.min(100, a - 200)) + .0009 * Math.max(0, Math.min(100, a - 300)) + .00082 * Math.max(0, Math.min(100, a - 400)) + .0007 * Math.max(0, Math.min(100, a - 500)) + .0006 * Math.max(0, Math.min(100, a - 600)) + .0005 * Math.max(0, Math.min(100, a - 700)) + .0004 * Math.max(0, a - 800)) + .001 * Math.max(0, Math.min(50, 0 - a)) + .00075 * Math.max(0, Math.min(50, -50 - a)) + .0005 * Math.max(0, Math.min(50, -100 - a)) + .00025 * Math.max(0, -150 - a)));
        }
        if (defender["1hp"]) {
            return [1, 1];
        }
        let baseDamage = attacker.attack;
        if (defender.s.cursed) {
            baseDamage *= 1.2;
        }
        if (defender.s.marked) {
            baseDamage *= 1.1;
        }
        if (attacker.ctype == "priest")
            baseDamage *= 0.4;
        if (attacker.damage_type == "physical")
            baseDamage *= damage_multiplier(defender.armor - attacker.apiercing);
        else if (attacker.damage_type == "magical")
            baseDamage *= damage_multiplier(defender.resistance - attacker.rpiercing);
        return [baseDamage * 0.9, baseDamage * 1.1];
    }
    static distance(a, b) {
        if (!a || !b)
            return Number.MAX_VALUE;
        if ((a.map && b.map) && (a.map !== b.map))
            return Number.MAX_VALUE;
        return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
    }
}
exports.Tools = Tools;
//# sourceMappingURL=Tools.js.map