<commit_before>﻿
var checkRating = function () { };

$(document).ready(function () {
    var $form = $('#form-rating');

    if ($form.length == 0) return;

    var timeStep = 0.05;

    var shieldWeapon = function (shield, aggregate) {
        if (shield.HitPoints > 0) {
            var hp = shield.HitPoints;
            shield.HitPoints -= aggregate.Physical / shield.Physical_DamageAbsorbDirect;
            shield.HitPoints -= aggregate.Energy / shield.Energy_DamageAbsorbDirect;
            shield.HitPoints -= aggregate.Distortion / shield.Distortion_DamageAbsorbDirect;

            if (shield.HitPoints < 0) {
                var ratio = shield.HitPoints / (shield.HitPoints - hp);
                
                aggregate.Physical   = aggregate.Physical * ratio * shield.Physical_DamageAbsorbDirect;
                aggregate.Energy     = aggregate.Energy * ratio * shield.Energy_DamageAbsorbDirect;
                aggregate.Distortion = aggregate.Distortion * ratio * shield.Distortion_DamageAbsorbDirect;

                shield.HitPoints = 0;
            } else {
                aggregate.Physical = 0;
                aggregate.Energy = 0;
                aggregate.Distortion = 0;
            }
        }

        return aggregate;
    }

    var fireWeapon = function (weapon, aggregate) {
        if (weapon.Heat + weapon.HeatingRate < weapon.MaxHeat) {
            weapon.ShotsFired++;
            weapon.TotalDamage += weapon.Physical;
            weapon.TotalDamage += weapon.Energy;
            weapon.TotalDamage += weapon.Distortion;
            weapon.Heat += weapon.HeatingRate;

            aggregate.Physical += weapon.Physical;
            aggregate.Energy += weapon.Energy;
            aggregate.Distortion += weapon.Distortion;
        }

        return aggregate;
    }

    var attack = function (source, target, time, min_max) {
        if (target.Health <= 0)
            return;

        var aggregate = {
            Physical: 0,
            Energy: 0,
            Distortion: 0,
        };

        if (time > 0) {
            aggregate = {
                Physical: 0,
                Energy: 0,
                Distortion: 0,
            };

            for (var i = 0, j = source.Damage.length; i < j; i++) {
                if (source.Damage[i].ShotsFired == null)
                    source.Damage[i].ShotsFired = 0;

                if (source.Damage[i].TotalDamage == null)
                    source.Damage[i].TotalDamage = 0;

                if (source.Damage[i].ShotsChecked == null)
                    source.Damage[i].ShotsChecked = 0;

                if (source.Damage[i].Heat == null)
                    source.Damage[i].Heat = 0;

                source.Damage[i].Heat = Math.max(0, source.Damage[i].Heat - source.Damage[i].CoolingRate * timeStep);

                while (source.Damage[i].ShotsChecked < (time * source.Damage[i].Rate / 60)) {
                    source.Damage[i].ShotsChecked++;
                    fireWeapon(source.Damage[i], aggregate);
                }
            }
        }

        target.Shield = 0;

        if (target.Shields != null && target.Shields.length > 0) {
            for (var i = 0, j = target.Shields.length; i < j; i++) {
                if (target.Shields[i].HitPoints == null) {
                    if (min_max == "min") {
                        switch (target.Shields[i].FaceType) {
                            case "Quadrant":
                                target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints / 4;
                                break;
                            case "FrontBack":
                                target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints / 2;
                                break;
                            default:
                                target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints;
                                break;
                        }
                    } else {
                        target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints;
                    }
                }

                if (target.Shields[i].FaceType == "Quadrant" || target.Shields[i].FaceType == "FrontBack") {
                    if (min_max != "min" &&
                        target.Shields[i].HitPoints < target.Shields[i].MaxHitPoints &&
                        time >= target.Shields[i].RegenDelay)
                        target.Shields[i].HitPoints = Math.min(target.Shields[i].MaxHitPoints, target.Shields[i].HitPoints + target.Shields[i].MaxRegenRate * timeStep);
                }

                shieldWeapon(target.Shields[i], aggregate);

                target.Shield += target.Shields[i].HitPoints;
            }
        }

        if (target.Shield == 0 && target.TTDS == null) {
            target.TTDS = time;
        }

        if (target.Armor != null) {
            aggregate.Physical = aggregate.Physical * target.Armor.Physical;
            aggregate.Energy = aggregate.Energy * target.Armor.Energy;
            aggregate.Distortion = aggregate.Distortion * target.Armor.Distortion;
        }

        if (time > 0) {
            target.Health -= aggregate.Physical;
            target.Health -= aggregate.Energy;
            target.Health -= aggregate.Distortion;

            if (target.Health <= 0 && target.TTK == null) {
                target.TTK = time;
                target.Health = 0;
            }
        }
    }
<commit_msg>Disable Shield Regen again - but leave it commented for future reference<commit_after>﻿
var checkRating = function () { };

$(document).ready(function () {
    var $form = $('#form-rating');

    if ($form.length == 0) return;

    var timeStep = 0.05;

    var shieldWeapon = function (shield, aggregate) {
        if (shield.HitPoints > 0) {
            var hp = shield.HitPoints;
            shield.HitPoints -= aggregate.Physical / shield.Physical_DamageAbsorbDirect;
            shield.HitPoints -= aggregate.Energy / shield.Energy_DamageAbsorbDirect;
            shield.HitPoints -= aggregate.Distortion / shield.Distortion_DamageAbsorbDirect;

            if (shield.HitPoints < 0) {
                var ratio = shield.HitPoints / (shield.HitPoints - hp);
                
                aggregate.Physical   = aggregate.Physical * ratio * shield.Physical_DamageAbsorbDirect;
                aggregate.Energy     = aggregate.Energy * ratio * shield.Energy_DamageAbsorbDirect;
                aggregate.Distortion = aggregate.Distortion * ratio * shield.Distortion_DamageAbsorbDirect;

                shield.HitPoints = 0;
            } else {
                aggregate.Physical = 0;
                aggregate.Energy = 0;
                aggregate.Distortion = 0;
            }
        }

        return aggregate;
    }

    var fireWeapon = function (weapon, aggregate) {
        if (weapon.Heat + weapon.HeatingRate < weapon.MaxHeat) {
            weapon.ShotsFired++;
            weapon.TotalDamage += weapon.Physical;
            weapon.TotalDamage += weapon.Energy;
            weapon.TotalDamage += weapon.Distortion;
            weapon.Heat += weapon.HeatingRate;

            aggregate.Physical += weapon.Physical;
            aggregate.Energy += weapon.Energy;
            aggregate.Distortion += weapon.Distortion;
        }

        return aggregate;
    }

    var attack = function (source, target, time, min_max) {
        if (target.Health <= 0)
            return;

        var aggregate = {
            Physical: 0,
            Energy: 0,
            Distortion: 0,
        };

        if (time > 0) {
            aggregate = {
                Physical: 0,
                Energy: 0,
                Distortion: 0,
            };

            for (var i = 0, j = source.Damage.length; i < j; i++) {
                if (source.Damage[i].ShotsFired == null)
                    source.Damage[i].ShotsFired = 0;

                if (source.Damage[i].TotalDamage == null)
                    source.Damage[i].TotalDamage = 0;

                if (source.Damage[i].ShotsChecked == null)
                    source.Damage[i].ShotsChecked = 0;

                if (source.Damage[i].Heat == null)
                    source.Damage[i].Heat = 0;

                source.Damage[i].Heat = Math.max(0, source.Damage[i].Heat - source.Damage[i].CoolingRate * timeStep);

                while (source.Damage[i].ShotsChecked < (time * source.Damage[i].Rate / 60)) {
                    source.Damage[i].ShotsChecked++;
                    fireWeapon(source.Damage[i], aggregate);
                }
            }
        }

        target.Shield = 0;

        if (target.Shields != null && target.Shields.length > 0) {
            for (var i = 0, j = target.Shields.length; i < j; i++) {
                if (target.Shields[i].HitPoints == null) {
                    if (min_max == "min") {
                        switch (target.Shields[i].FaceType) {
                            case "Quadrant":
                                target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints / 4;
                                break;
                            case "FrontBack":
                                target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints / 2;
                                break;
                            default:
                                target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints;
                                break;
                        }
                    } else {
                        target.Shields[i].HitPoints = target.Shields[i].MaxHitPoints;
                    }
                }

                // TODO: Need to only apply this if we can actually hold an opponent off one shield face completely
                // if (target.Shields[i].FaceType == "Quadrant" || target.Shields[i].FaceType == "FrontBack") {
                //     if (min_max != "min" &&
                //         target.Shields[i].HitPoints < target.Shields[i].MaxHitPoints &&
                //         time >= target.Shields[i].RegenDelay)
                //         target.Shields[i].HitPoints = Math.min(target.Shields[i].MaxHitPoints, target.Shields[i].HitPoints + target.Shields[i].MaxRegenRate * timeStep);
                // }

                shieldWeapon(target.Shields[i], aggregate);

                target.Shield += target.Shields[i].HitPoints;
            }
        }

        if (target.Shield == 0 && target.TTDS == null) {
            target.TTDS = time;
        }

        if (target.Armor != null) {
            aggregate.Physical = aggregate.Physical * target.Armor.Physical;
            aggregate.Energy = aggregate.Energy * target.Armor.Energy;
            aggregate.Distortion = aggregate.Distortion * target.Armor.Distortion;
        }

        if (time > 0) {
            target.Health -= aggregate.Physical;
            target.Health -= aggregate.Energy;
            target.Health -= aggregate.Distortion;

            if (target.Health <= 0 && target.TTK == null) {
                target.TTK = time;
                target.Health = 0;
            }
        }
    }

{'fraction_non_alphanumeric': 0.11193962806576228, 'fraction_numerical': 0.006288743149761926, 'mean_word_length': 1.3981042654028435, 'pattern_counts': {'":': 4, '<': 19, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7374799', 'n_tokens_mistral': 3235, 'n_tokens_neox': 2974, 'n_words': 556}