<commit_before>define(['angular', 'class-mod/module-def'], function (angular, classModModule) {

    'use strict';

    classModModule.controller('ClassModCreateCtrl', [
        '$scope', '$log', 'rarities', 'manufacturers', 'characters', 'ClassModService', 'CharacterService',
        function ($scope, $log, rarities, manufacturers, characters, ClassModService, CharacterService) {

            $scope.loadSkillTree = function () {
                CharacterService.getSkills($scope.classMod.characterClass).then(function (skills) {
                    $scope.skills = skills;

                    // init point property for each skill within the skill tree

                    // iterate sub trees
                    angular.forEach($scope.skills, function (subTree) {
                        // iterate skillTiers
                        angular.forEach(subTree.skillTiers, function (tier) {
                            if (tier.leftSkill) {
                                tier.leftSkill.points = 0;
                            }
                            if (tier.middleSkill) {
                                tier.middleSkill.points = 0;
                            }
                            if (tier.rightSkill) {
                                tier.rightSkill.points = 0;
                            }
                        });
                    });
                });
            };

            $scope.addPoint = function (skill) {
                // first skill point added?
                if (!$scope.classMod.skills[skill.name]) {
                    $scope.classMod.skills[skill.name] = skill;
                }

                if (skill.points < skill.levels) {
                    skill.points++;
                }
            };

            $scope.removePoint = function (skill) {
                if (skill.points > 0) {
                    skill.points--;
                }

                // last skill point removed?
                if (skill.points === 0) {
                    delete $scope.classMod.skills[skill.name];
                }
            };

            $scope.save = function () {
                ClassModService.create($scope.classMod)
                    .then(function () {
                        ClassModService.showList();
                    }, function (response) {
                        if (response.status === 422) {
                            $scope.errors = response.data;
                        }
                        else {
                            // TODO show error message
                            $log.error('error creating class mod');
                        }
                    });
            };

            // constructor
            // assign ui router resolves
            $scope.rarities = rarities;
            $scope.manufacturers = manufacturers;
            $scope.characters = characters;

            // init default classMod
            $scope.classMod = {
                itemtype: 'classMod',
                level: 50,
                rarity: $scope.rarities[0],
                manufacturer: $scope.manufacturers[0],
                characterClass: $scope.characters[2], // TODO use index 0
                damage: null,
                accuracy: null,
                fireRate: null,
                reloadSpeed: null,
                magazineSize: null,
                uniqueText: null,
                elementalText: null,
                additionalText: null,
                skills: {}
            };

            $scope.loadSkillTree();

        }]);

});<commit_msg>correct class initialization when creating new class mods<commit_after>define(['angular', 'class-mod/module-def'], function (angular, classModModule) {

    'use strict';

    classModModule.controller('ClassModCreateCtrl', [
        '$scope', '$log', 'rarities', 'manufacturers', 'characters', 'ClassModService', 'CharacterService',
        function ($scope, $log, rarities, manufacturers, characters, ClassModService, CharacterService) {

            $scope.loadSkillTree = function () {
                CharacterService.getSkills($scope.classMod.characterClass).then(function (skills) {
                    $scope.skills = skills;

                    // init point property for each skill within the skill tree

                    // iterate sub trees
                    angular.forEach($scope.skills, function (subTree) {
                        // iterate skillTiers
                        angular.forEach(subTree.skillTiers, function (tier) {
                            if (tier.leftSkill) {
                                tier.leftSkill.points = 0;
                            }
                            if (tier.middleSkill) {
                                tier.middleSkill.points = 0;
                            }
                            if (tier.rightSkill) {
                                tier.rightSkill.points = 0;
                            }
                        });
                    });
                });
            };

            $scope.addPoint = function (skill) {
                // first skill point added?
                if (!$scope.classMod.skills[skill.name]) {
                    $scope.classMod.skills[skill.name] = skill;
                }

                if (skill.points < skill.levels) {
                    skill.points++;
                }
            };

            $scope.removePoint = function (skill) {
                if (skill.points > 0) {
                    skill.points--;
                }

                // last skill point removed?
                if (skill.points === 0) {
                    delete $scope.classMod.skills[skill.name];
                }
            };

            $scope.save = function () {
                ClassModService.create($scope.classMod)
                    .then(function () {
                        ClassModService.showList();
                    }, function (response) {
                        if (response.status === 422) {
                            $scope.errors = response.data;
                        }
                        else {
                            // TODO show error message
                            $log.error('error creating class mod');
                        }
                    });
            };

            // constructor
            // assign ui router resolves
            $scope.rarities = rarities;
            $scope.manufacturers = manufacturers;
            $scope.characters = characters;

            // init default classMod
            $scope.classMod = {
                itemtype: 'classMod',
                level: 50,
                rarity: $scope.rarities[0],
                manufacturer: $scope.manufacturers[0],
                characterClass: $scope.characters[0],
                damage: null,
                accuracy: null,
                fireRate: null,
                reloadSpeed: null,
                magazineSize: null,
                uniqueText: null,
                elementalText: null,
                additionalText: null,
                skills: {}
            };

            $scope.loadSkillTree();

        }]);

});
{'fraction_non_alphanumeric': 0.09824659059281937, 'fraction_numerical': 0.0037573058725299193, 'mean_word_length': 1.021659634317862, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '830049', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1589, 'n_words': 325}