<commit_before>import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { Deck } from '../deck';
import Card from '../../card';
import { DustCalculationService } from '../../core/dust-calculation.service';
import { Http } from '@angular/http';
import { ActivatedRoute, Router } from '@angular/router';
import { BASE_URL } from '../../core/globals';
import { DOCUMENT } from '@angular/platform-browser';

@Component({
    selector: 'f2kNewDeckHub',
    templateUrl: './new-deck-hub.component.html',
    styleUrls: ['./new-deck-hub.component.css']
})
export class NewDeckHubComponent implements /*OnInit, */OnDestroy {

    public repoUrl = 'https://github.com/Epotignano/ng2-social-share';
    deck: Deck;
    decks: Deck[] = [];
    chartData: any;
    classCards: Card[] = [];
    neutralCards: Card[] = [];
    displayCard = false;
    displayedCard: Card;
    displayedCardUp: boolean;
    displayedCardLeft: boolean;
    displayCardTopPx: number;
    displayCardleftPx: number;
    CONTENT: any;
    routeSubscription: any;

    distribution: Array<Array<any>> = [ // TODO type
        ['0', 0],
        ['1', 0],
        ['2', 0],
        ['3', 0],
        ['4', 0],
        ['5', 0],
        ['6', 0],
        ['7', 0]
    ];

    static sortByManaCostAndName(a: Card, b: Card) {
        const sortValue = a.cost - b.cost;

        if (sortValue === 0) {
            if (a.name < b.name) {
                return -1;
            }
            if (a.name > b.name) {
                return 1;
            }
            return 0;
        }

        return sortValue;
    }

    constructor(@Inject(DOCUMENT) private docEl: Document, private http: Http, private router: Router, private route: ActivatedRoute) { // TODO remove when real data is there
        this.routeSubscription = this.route.params.subscribe(() => {
            this.deck = null;
            this.decks = [];
            this.chartData = null;
            this.classCards = [];
            this.neutralCards = [];
            this.displayCard = false;
            this.displayedCard = null;
            this.displayedCardUp = false;
            this.displayedCardLeft = false;
            this.displayCardTopPx = null;
            this.displayCardleftPx = null;
            this.CONTENT = '';

            this.getDeck(parseInt(this.router.url.slice(this.router.url.lastIndexOf('_') + 1), 10));
            this.getDecks();
        });

        // const card: Card = new Card('Gabe from <NAME>', 6, 'NEUTRAL', true, 5, 559, 'At least he has Angry Chicken.', 2, 'EX1_116', '<NAME>', 'expert1', 'LEGENDARY', 'MINION', false);
        // const card2: Card = new Card('Chippy', null, 'PALADIN', true, 1, 1373, 'Apparently with wisdom comes the knowledge that you should probably be attacking every turn.', 2, 'EX1_363', 'Blessing of Wisdom', 'expert1', 'COMMON', 'SPELL', false);
        // const cards: Card[] = [card, card2, card2];
        // const author: Author = new Author(2, 'Bob', '<EMAIL>', 'Hearthstone', null, 1501927168668);
        // this.deck = new Deck(1, author, 'This is a Tilte', 'Cipher.jpg', '<p>this is the content</p>', 'HEARTHSTONE', cards, true, 10, 'PALADIN', true, 'STANDARD', 1501927168668);
        // for (let i = 0; i < 6; i++) {
        //     this.decks.push(this.deck);
        // }
    }

    // ngOnInit() {
    //     this.getDeck(parseInt(this.router.url.slice(this.router.url.lastIndexOf('_') + 1), 10));
    //     this.getDecks();
    // }

    buildData() {
        const addedCardIDs: number[] = [];
        let deckMode: string;
        if (this.deck.mode === 'CON') {
            if (this.deck.isStandard) {
                deckMode = 'wild';
            } else {
                deckMode = 'standard';
            }
        }

        this.deck.cards.forEach((card: Card) => {
            this.distribution[(card.cost > 7 ? 7 : card.cost)][1] += 1;

            if (card.heroClass === 'NEUTRAL') {
                if (addedCardIDs.indexOf(card.dbId) >= 0) {
                    this.neutralCards.forEach(neutralCard => {
                        if (neutralCard.dbId === card.dbId) {
                            neutralCard.amount += 1;
                        }
                    });
                } else {
                    card.amount = 1;
                    this.neutralCards.push(card);
                }
            } else {
                if (addedCardIDs.indexOf(card.dbId) >= 0) {
                    this.classCards.forEach(classCard => {
                        if (classCard.dbId === card.dbId) {
                            classCard.amount += 1;
                        }<commit_msg>bug fix<commit_after>import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { Deck } from '../deck';
import Card from '../../card';
import { DustCalculationService } from '../../core/dust-calculation.service';
import { Http } from '@angular/http';
import { ActivatedRoute, Router } from '@angular/router';
import { BASE_URL } from '../../core/globals';
import { DOCUMENT } from '@angular/platform-browser';

@Component({
    selector: 'f2kNewDeckHub',
    templateUrl: './new-deck-hub.component.html',
    styleUrls: ['./new-deck-hub.component.css']
})
export class NewDeckHubComponent implements /*OnInit, */OnDestroy {

    public repoUrl = 'https://github.com/Epotignano/ng2-social-share';
    deck: Deck;
    decks: Deck[] = [];
    chartData: any;
    classCards: Card[] = [];
    neutralCards: Card[] = [];
    displayCard = false;
    displayedCard: Card;
    displayedCardUp: boolean;
    displayedCardLeft: boolean;
    displayCardTopPx: number;
    displayCardleftPx: number;
    CONTENT: any;
    routeSubscription: any;

    distribution: Array<Array<any>> = [ // TODO type
        ['0', 0],
        ['1', 0],
        ['2', 0],
        ['3', 0],
        ['4', 0],
        ['5', 0],
        ['6', 0],
        ['7', 0]
    ];

    static sortByManaCostAndName(a: Card, b: Card) {
        const sortValue = a.cost - b.cost;

        if (sortValue === 0) {
            if (a.name < b.name) {
                return -1;
            }
            if (a.name > b.name) {
                return 1;
            }
            return 0;
        }

        return sortValue;
    }

    constructor(@Inject(DOCUMENT) private docEl: Document, private http: Http, private router: Router, private route: ActivatedRoute) { // TODO remove when real data is there
        this.routeSubscription = this.route.params.subscribe(() => {
            this.deck = null;
            this.decks = [];
            this.chartData = null;
            this.classCards = [];
            this.neutralCards = [];
            this.displayCard = false;
            this.displayedCard = null;
            this.displayedCardUp = false;
            this.displayedCardLeft = false;
            this.displayCardTopPx = null;
            this.displayCardleftPx = null;
            this.CONTENT = '';

            this.getDeck(parseInt(this.router.url.slice(this.router.url.lastIndexOf('_') + 1), 10));
            this.getDecks();
        });

        // const card: Card = new Card('Gabe from <NAME>', 6, 'NEUTRAL', true, 5, 559, 'At least he has Angry Chicken.', 2, 'EX1_116', '<NAME>', 'expert1', 'LEGENDARY', 'MINION', false);
        // const card2: Card = new Card('Chippy', null, 'PALADIN', true, 1, 1373, 'Apparently with wisdom comes the knowledge that you should probably be attacking every turn.', 2, 'EX1_363', 'Blessing of Wisdom', 'expert1', 'COMMON', 'SPELL', false);
        // const cards: Card[] = [card, card2, card2];
        // const author: Author = new Author(2, 'Bob', '<EMAIL>', 'Hearthstone', null, 1501927168668);
        // this.deck = new Deck(1, author, 'This is a Tilte', 'Cipher.jpg', '<p>this is the content</p>', 'HEARTHSTONE', cards, true, 10, 'PALADIN', true, 'STANDARD', 1501927168668);
        // for (let i = 0; i < 6; i++) {
        //     this.decks.push(this.deck);
        // }
    }

    // ngOnInit() {
    //     this.getDeck(parseInt(this.router.url.slice(this.router.url.lastIndexOf('_') + 1), 10));
    //     this.getDecks();
    // }

    buildData() {
        const addedCardIDs: number[] = [];
        let deckMode: string;
        if (this.deck.mode === 'CON') {
            if (this.deck.isStandard) {
                deckMode = 'standard';
            } else {
                deckMode = 'wild';
            }
        }

        this.deck.cards.forEach((card: Card) => {
            this.distribution[(card.cost > 7 ? 7 : card.cost)][1] += 1;

            if (card.heroClass === 'NEUTRAL') {
                if (addedCardIDs.indexOf(card.dbId) >= 0) {
                    this.neutralCards.forEach(neutralCard => {
                        if (neutralCard.dbId === card.dbId) {
                            neutralCard.amount += 1;
                        }
                    });
                } else {
                    card.amount = 1;
                    this.neutralCards.push(card);
                }
            } else {
                if (addedCardIDs.indexOf(card.dbId) >= 0) {
                    this.classCards.forEach(classCard => {
                        if (classCard.dbId === card.dbId) {
                            classCard.amount += 1;
                        }
{'fraction_non_alphanumeric': 0.15336496980155306, 'fraction_numerical': 0.020276100086281276, 'mean_word_length': 1.8134101941747574, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 33, 'https://': 2, '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': '6124129', 'n_tokens_mistral': 2984, 'n_tokens_neox': 2792, 'n_words': 657}