<commit_before>(function() {

var app = angular.module('optc');

var BOX_COLORS = { STR: 'salmon', QCK: 'lightskyblue', DEX: 'lightgreen', PSY: 'gold', INT: 'orchid' };
var ORB_COLORS = { STR: 'orangered', QCK: 'dodgerblue', DEX: 'lightgreen', PSY: 'gold', INT: 'orchid' };

app.controller('ImageGeneratorCtrl', function($scope, $filter, $timeout) {

    var canvas = $('#canvas')[0];
    var context = canvas.getContext('2d');
    
    context.fillStyle = 'white';
    context.fillRect(0, 0, canvas.width, canvas.height);

    // damage numbers
    $scope.$watch('numbers',function(numbers) {
        [ 'STR', 'QCK', 'DEX', 'PSY', 'INT' ].forEach(function(which, n) {
            if (!numbers[which]) return;
            // rectangles
            context.fillStyle = BOX_COLORS[which];
            context.fillRect(440, 10 + n * 70, 150, 60);
            // text
            var overall = $filter('number')(numbers[which].overall);
            type(context, { text: 'Damage against ' + which, style: '10.5px "Open Sans"', x: 465, y: 30 + n * 70 });
            type(context, { text: overall, style: 'bold 21px "Open Sans"', x: 515, y: 58 + n * 70, align: 'center' });
        });
        // indicators
        if ($scope.numbers.cost) {
            var baseX = 10, baseY = 30;
            fill(context, 'white', baseX, baseY - 15, 160, 66);
            var currentHP = $filter('number')(Math.round($scope.numbers.hp * $scope.data.percHP / 100));
            var percHP = $filter('number')(Math.round($scope.data.percHP * 100) / 100);
            var rcv = $filter('number')($scope.numbers.rcv);
            var cost = $filter('number')($scope.numbers.cost.cost);
            awesome(context, { text: 'f21e', x: baseX + 8, y: baseY, align: 'center' });
            type(context, { text: currentHP + ' HP (' + percHP + '%)', x: baseX + 25, y: baseY });
            awesome(context, { text: 'f0f5', x: baseX + 8, y: baseY + 25, align: 'center' });
            type(context, { text: rcv + ' RCV', x: baseX + 25, y: baseY + 25 });
            awesome(context, { text: 'f039', x: baseX + 8, y: baseY + 50, align: 'center' });
            type(context, { text: cost + ' cost', x: baseX + 25, y: baseY + 50 });
        }
    },true);

    // team
    $scope.$watch('data.team',function(team) {
        team.forEach(function(data, n) {
            var unit = data.unit;
            if (!unit) return;
            var image = new Image();
            image.onload = function() {
                var baseX = 203 + (n%2 * 115), baseY = 9 + Math.floor(n/2) * 115;
                context.drawImage(image, baseX, baseY, 112, 112);
                // orbs
                var orb = $scope.tdata.team[n].orb;
                if (orb != 1.0) {
                    var gradient = context.createRadialGradient(baseX + 20, baseY + 21, 13, baseX + 22, baseY + 22, 35);
                    if (orb < 1) gradient.addColorStop(0.1, ORB_COLORS[Utils.getOppositeType(unit.type)]);
                    else gradient.addColorStop(0.1, ORB_COLORS[unit.type]);
                    if (orb < 1) gradient.addColorStop(0.2, 'black');
                    else {
                        gradient.addColorStop(0.2, 'white');
                        gradient.addColorStop(0.3, ORB_COLORS[unit.type]);
                    }
                    gradient.addColorStop(1.0, 'transparent');
                    context.fillStyle = gradient;
                    context.fillRect(0, 0, canvas.width, canvas.height);
                    var temp = (orb < 1 ? [ 'f0d7', baseX + 13, baseY + 31 ] : [ 'f0d8', baseX + 13, baseY + 28 ]);
                    awesome(context, { text: temp[0], style: '28px', color: 'white',
                        x: temp[1], y: temp[2], stroke: 'gray' });
                }
                // level label
                fill(context, 'black', baseX + 80, baseY + 95, 31, 16);
                fill(context, 'white', baseX + 81, baseY + 96, 30, 15);
                type(context, { text: 'Lv.' + data.level, style: 'bold 10px "Open Sans"',
                    x: baseX + (data.level < 10 ? 87 : 84), y: baseY + 107 });
                // candy labels
                var total = data.candies.hp + data.candies.atk + data.candies.rcv;
                if (total > 0) {
                    type(context, { text: '+' + total, style: 'bold 14px "Open Sans"',
                        x: baseX + 7, y: baseY + 103, color: 'gold', stroke: 'black', strokeWidth: 3 });
                }
            };
            image.src = Utils.getThumbnailUrl(unit.number + 1);
        });
    },true);

    baseX = 10; baseY = 85;

    if ($scope.data.effect) {
        awesome(context, { text: 'f02d', x: baseX + 8, y: baseY + 20, align: 'center' });<commit_msg>minor fixes<commit_after>(function() {

var app = angular.module('optc');

var BOX_COLORS = { STR: 'salmon', QCK: 'lightskyblue', DEX: 'lightgreen', PSY: 'gold', INT: 'orchid' };
var ORB_COLORS = { STR: 'orangered', QCK: 'dodgerblue', DEX: 'lightgreen', PSY: 'gold', INT: 'orchid' };

app.controller('ImageGeneratorCtrl', function($scope, $filter, $timeout) {

    var canvas = $('#canvas')[0];
    var context = canvas.getContext('2d');
    
    context.fillStyle = 'white';
    context.fillRect(0, 0, canvas.width, canvas.height);

    // damage numbers
    $scope.$watch('numbers',function(numbers) {
        [ 'STR', 'QCK', 'DEX', 'PSY', 'INT' ].forEach(function(which, n) {
            if (!numbers[which]) return;
            // rectangles
            context.fillStyle = BOX_COLORS[which];
            context.fillRect(440, 10 + n * 70, 150, 60);
            // text
            var overall = $filter('number')(numbers[which].overall);
            type(context, { text: 'Damage against ' + which, style: '10.5px "Open Sans"', x: 465, y: 30 + n * 70 });
            type(context, { text: overall, style: 'bold 21px "Open Sans"', x: 515, y: 58 + n * 70, align: 'center' });
        });
        // indicators
        if ($scope.numbers.cost) {
            var baseX = 10, baseY = 30;
            fill(context, 'white', baseX, baseY - 15, 160, 66);
            var currentHP = $filter('number')(Math.round($scope.numbers.hp * $scope.data.percHP / 100));
            var percHP = $filter('number')(Math.round($scope.data.percHP * 100) / 100);
            var rcv = $filter('number')($scope.numbers.rcv);
            var cost = $filter('number')($scope.numbers.cost.cost);
            awesome(context, { text: 'f21e', x: baseX + 8, y: baseY, align: 'center' });
            type(context, { text: currentHP + ' HP (' + percHP + '%)', x: baseX + 25, y: baseY });
            awesome(context, { text: 'f0f5', x: baseX + 8, y: baseY + 25, align: 'center' });
            type(context, { text: rcv + ' RCV', x: baseX + 25, y: baseY + 25 });
            awesome(context, { text: 'f039', x: baseX + 8, y: baseY + 50, align: 'center' });
            type(context, { text: cost + ' cost', x: baseX + 25, y: baseY + 50 });
        }
    },true);

    // team
    $scope.$watch('data.team',function(team) {
        team.forEach(function(data, n) {
            var unit = data.unit;
            if (!unit) return;
            var image = new Image();
            image.onload = function() {
                var baseX = 203 + (n%2 * 115), baseY = 9 + Math.floor(n/2) * 115;
                context.drawImage(image, baseX, baseY, 112, 112);
                // orbs
                var orb = $scope.tdata.team[n].orb;
                if (orb != 1.0) {
                    var gradient = context.createRadialGradient(baseX + 20, baseY + 21, 13, baseX + 22, baseY + 22, 35);
                    if (orb < 1) gradient.addColorStop(0.1, ORB_COLORS[Utils.getOppositeType(unit.type)]);
                    else gradient.addColorStop(0.1, ORB_COLORS[unit.type]);
                    if (orb < 1) gradient.addColorStop(0.2, 'black');
                    else {
                        gradient.addColorStop(0.2, 'white');
                        gradient.addColorStop(0.3, ORB_COLORS[unit.type]);
                    }
                    gradient.addColorStop(1.0, 'transparent');
                    context.fillStyle = gradient;
                    context.fillRect(0, 0, canvas.width, canvas.height);
                    var temp = (orb < 1 ? [ 'f0d7', baseX + 13, baseY + 31 ] : [ 'f0d8', baseX + 13, baseY + 28 ]);
                    awesome(context, { text: temp[0], style: '28px', color: 'white',
                        x: temp[1], y: temp[2], stroke: 'gray' });
                }
                // level label
                fill(context, 'black', baseX + 80, baseY + 95, 31, 16);
                fill(context, 'white', baseX + 81, baseY + 96, 30, 15);
                type(context, { text: 'Lv.' + data.level, style: 'bold 10px "Open Sans"', align: 'center',
                    x: baseX + 96, y: baseY + 107 });
                // candy labels
                var total = data.candies.hp + data.candies.atk + data.candies.rcv;
                if (total > 0) {
                    type(context, { text: '+' + total, style: 'bold 14px "Open Sans"',
                        x: baseX + 7, y: baseY + 103, color: 'gold', stroke: 'black', strokeWidth: 3 });
                }
            };
            image.src = Utils.getThumbnailUrl(unit.number + 1);
        });
    },true);

    baseX = 10; baseY = 85;

    if ($scope.data.effect) {
        awesome(context, { text: 'f02d', x: baseX + 8, y: baseY + 20, align: 'center' });
{'fraction_non_alphanumeric': 0.16712560898114806, 'fraction_numerical': 0.039822071595001056, 'mean_word_length': 1.8606482883974553, 'pattern_counts': {'":': 0, '<': 10, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1504853', 'n_tokens_mistral': 3392, 'n_tokens_neox': 2985, 'n_words': 768}