<commit_before>'use strict';

/* Directives */


angular.module('myApp.directives', ['ui.bootstrap'])

    .directive('appVersion', ['version', function (version) {
        return function (scope, elm, attrs) {
            elm.text(version);
        };
    }])

    .directive('characterCard', function () {
        return {
            restrict: 'E',
            scope: {
                character: '=character',
                selections: '=selections'
            },
            templateUrl: 'partials/character-card.html',
            controller: function ($scope) {
                $scope.isSelected = function() {
                    if ($scope.character == selections.activeActor || $scope.character == selections.activeTarget) {
                        return true;
                    }
                    return false;
                };

                $scope.healthBarType = function() { // Determines which color health bar to display
                    var health = $scope.character.health/$scope.character.maxHealth;

                    if (health >= .7) {
                        return "success";
                    }
                    else if (health < .7 && health > .3) {
                        return "warning";
                    }
                    else {
                        return "danger";
                    }
                }

                $scope.setCharacterDetail = function($event,character){

                    $event.stopPropagation();

                    $scope.$parent.$parent.characterDetail = character;

                }
            }
        }
    })

    .directive('calculator', function () {
        return {
            restrict: 'E',
            scope: {
                actor: '=actor',
                target: '=target',
                callback: '&callback'
            },
            templateUrl: 'partials/calculator.html',
            controller: function ($scope) {

                var init = function () {
                    $scope.attackData = {
                        'attackValue': 0,
                        'heal': 'Healing',
                        'crit': false,
                        'action': 'Attacking'
                    };
                };


                $scope.attack = function () {
                    $scope.soundPlay = !$scope.soundPlay;
                    $scope.sound = 'sounds/attack.ogg';
                    $scope.callback({'damage': parseInt($scope.attackData.attackValue), 'character': $scope.target});
                    init();
                };

                $scope.heal = function () {
                    $scope.soundPlay = !$scope.soundPlay;
                    $scope.sound = 'sounds/heal.ogg';
                    $scope.callback({'damage': parseInt($scope.attackData.attackValue) *-1, 'character': $scope.target});
                    init();
                };

                $scope.miss = function () {
                    $scope.actor = null;
                    $scope.target = null;
                    $scope.player = null;
                    $scope.enemy = null;
                    $scope.soundPlay = !$scope.soundPlay;
                    $scope.sound = 'sounds/miss.ogg';
                }

                $scope.crit = function () {
                    $scope.attackData.crit = !$scope.attackData.crit;

                    if ($scope.attackData.crit) {
                        $scope.attackData.attackValue *= 2;
                    }
                    else {
                        $scope.attackData.attackValue /= 2;
                    }
                };

                $scope.plus = function () {
                    $scope.plus({'damage': parseInt($scope.attackData.attackValue) + ($scope.attackData.attackValue),
                        'character': $scope.target});
                    init();
                };

                $scope.keystroke = function (keypressValue) {
                    $scope.attackData.attackValue += keypressValue;
                };

                $scope.cancel = function () {
                    $scope.actor = null;
                    $scope.target = null;
                    $scope.player = null;
                    $scope.enemy = null;
                    $scope.sound = 'sounds/heal.ogg';
                };

                $scope.clear = function () {
                    init();
                };

                $scope.$watch('soundPlay', function() {
                    var audio = new Audio($scope.sound);
                    // console.log(audio)
                    audio.play();
                });


                init();<commit_msg>Removed a line that used and old library for playing sounds<commit_after>'use strict';

/* Directives */


angular.module('myApp.directives', ['ui.bootstrap'])

    .directive('appVersion', ['version', function (version) {
        return function (scope, elm, attrs) {
            elm.text(version);
        };
    }])

    .directive('characterCard', function () {
        return {
            restrict: 'E',
            scope: {
                character: '=character',
                selections: '=selections'
            },
            templateUrl: 'partials/character-card.html',
            controller: function ($scope) {
                $scope.isSelected = function() {
                    if ($scope.character == selections.activeActor || $scope.character == selections.activeTarget) {
                        return true;
                    }
                    return false;
                };

                $scope.healthBarType = function() { // Determines which color health bar to display
                    var health = $scope.character.health/$scope.character.maxHealth;

                    if (health >= .7) {
                        return "success";
                    }
                    else if (health < .7 && health > .3) {
                        return "warning";
                    }
                    else {
                        return "danger";
                    }
                }

                $scope.setCharacterDetail = function($event,character){

                    $event.stopPropagation();

                    $scope.$parent.$parent.characterDetail = character;

                }
            }
        }
    })

    .directive('calculator', function () {
        return {
            restrict: 'E',
            scope: {
                actor: '=actor',
                target: '=target',
                callback: '&callback'
            },
            templateUrl: 'partials/calculator.html',
            controller: function ($scope) {

                var init = function () {
                    $scope.attackData = {
                        'attackValue': 0,
                        'heal': 'Healing',
                        'crit': false,
                        'action': 'Attacking'
                    };
                };


                $scope.attack = function () {
                    $scope.soundPlay = !$scope.soundPlay;
                    $scope.sound = 'sounds/attack.ogg';
                    $scope.callback({'damage': parseInt($scope.attackData.attackValue), 'character': $scope.target});
                    init();
                };

                $scope.heal = function () {
                    $scope.soundPlay = !$scope.soundPlay;
                    $scope.sound = 'sounds/heal.ogg';
                    $scope.callback({'damage': parseInt($scope.attackData.attackValue) *-1, 'character': $scope.target});
                    init();
                };

                $scope.miss = function () {
                    $scope.actor = null;
                    $scope.target = null;
                    $scope.player = null;
                    $scope.enemy = null;
                    $scope.soundPlay = !$scope.soundPlay;
                    $scope.sound = 'sounds/miss.ogg';
                }

                $scope.crit = function () {
                    $scope.attackData.crit = !$scope.attackData.crit;

                    if ($scope.attackData.crit) {
                        $scope.attackData.attackValue *= 2;
                    }
                    else {
                        $scope.attackData.attackValue /= 2;
                    }
                };

                $scope.plus = function () {
                    $scope.plus({'damage': parseInt($scope.attackData.attackValue) + ($scope.attackData.attackValue),
                        'character': $scope.target});
                    init();
                };

                $scope.keystroke = function (keypressValue) {
                    $scope.attackData.attackValue += keypressValue;
                };

                $scope.cancel = function () {
                    $scope.actor = null;
                    $scope.target = null;
                    $scope.player = null;
                    $scope.enemy = null;
                };

                $scope.clear = function () {
                    init();
                };

                $scope.$watch('soundPlay', function() {
                    var audio = new Audio($scope.sound);
                    // console.log(audio)
                    audio.play();
                });


                init();
{'fraction_non_alphanumeric': 0.11864771748492679, 'fraction_numerical': 0.0015073212747631353, 'mean_word_length': 1.0171552660152008, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2929847', 'n_tokens_mistral': 2339, 'n_tokens_neox': 2065, 'n_words': 383}