<commit_before>import { Component, Output  } from '@angular/core';
import { EwIcon } from '../../../services/ew-icon.service';
import { Socket } from '../../../services/socketio.service';
import { TranslateService } from '@ngx-translate/core';
import { User } from '../../../services/user.service';

import cloud from '@iconify/icons-fa-solid/cloud';
import questionCircle from '@iconify/icons-fa-regular/question-circle';

@Component({
  templateUrl: '../html/city.component.html',
  styleUrls: ['../css/city.component.css']
})

export class City {

  @Output() public armyInfo:any
            public buildingInfo:any
            public dailyCo:any
            public dailyCoCheck:number;
            public divinBonusSelected:any
            public divinBonusListSelected:any;
            public success:any;
            public templeSelected:any;
            public treasureInfo:any;
  
  public divineBonus:any;
  public divineBonusNb:number;
  
  //Icons
  cloud = cloud;
  EwIcon = EwIcon;
  questionCircle = questionCircle;
  
  constructor(private socket: Socket, public user: User, public translate: TranslateService) {
    //We set a default building to avoid errors
    this.buildingInfo = { code: 'mint' };
    this.armyInfo = { code: 'spartan' };
    this.dailyCo = {}
    this.dailyCoCheck = 1;
    this.divineBonusNb = 0;
    this.divineBonus = [];
    this.divinBonusSelected = {'error': 0 };
    this.divinBonusListSelected = {'error': 0 };
    this.success = {'selected': 0};
    this.templeSelected = {
      'id': 0,
      'power': 0,
      'error': 0
    };
    
  }
  
  ngOnInit() {
    this.selectTreasure();
    
    this.socket.on('divineBonus', (data:any) => {
      this.divineBonusNb = data.nb;
      if(this.divineBonusNb > 0) {
        this.divineBonus   = data.list;
      }
      else {
        this.divineBonus = [];
      }
    });
    
    this.socket.on('dailyCo', (result:any) => {
      this.dailyCo = result;
    });
    this.socket.on("dailyCoCheck", (r:number) => {
      this.dailyCoCheck = r;
      if(r == 1) {
        this.socket.emit('dailyCo');
        let element:HTMLElement = document.getElementById('DailyCoCheckOpen') as HTMLElement;
        element.click();
      }
    });
    
    setTimeout(() => {
      this.socket.emit('divineBonus');
      this.socket.emit('dailyCoCheck');
    }, 0);
  }
  
  ngOnDestroy() {
    this.socket.removeListener('divineBonus');
    this.socket.removeListener('dailyCo');
    this.socket.removeListener('dailyCoCheck');
  }
  
  dailCo() {
    return Object.keys(this.dailyCo).length;
  }
  
  divineBonusReset() {
    this.divinBonusListSelected.error = 0;
  }<commit_msg>Fix error on first connection<commit_after>import { Component, Output  } from '@angular/core';
import { EwIcon } from '../../../services/ew-icon.service';
import { Socket } from '../../../services/socketio.service';
import { TranslateService } from '@ngx-translate/core';
import { User } from '../../../services/user.service';

import cloud from '@iconify/icons-fa-solid/cloud';
import questionCircle from '@iconify/icons-fa-regular/question-circle';

@Component({
  templateUrl: '../html/city.component.html',
  styleUrls: ['../css/city.component.css']
})

export class City {

  @Output() public armyInfo:any
            public buildingInfo:any
            public dailyCo:any
            public dailyCoCheck:number;
            public divinBonusSelected:any
            public divinBonusListSelected:any;
            public success:any;
            public templeSelected:any;
            public treasureInfo:any;
  
  public divineBonus:any;
  public divineBonusNb:number;
  
  //Icons
  cloud = cloud;
  EwIcon = EwIcon;
  questionCircle = questionCircle;
  
  constructor(private socket: Socket, public user: User, public translate: TranslateService) {
    //We set a default building to avoid errors
    this.buildingInfo = { code: 'mint' };
    this.armyInfo = { code: 'spartan' };
    this.dailyCo = {}
    this.dailyCoCheck = 1;
    this.divineBonusNb = 0;
    this.divineBonus = [];
    this.divinBonusSelected = {'error': 0 };
    this.divinBonusListSelected = {'error': 0 };
    this.success = {'selected': 0};
    this.templeSelected = {
      'id': 0,
      'power': 0,
      'error': 0
    };
    
  }
  
  ngOnInit() {
    this.selectTreasure();
    
    this.socket.on('divineBonus', (data:any) => {
      this.divineBonusNb = data.nb;
      if(this.divineBonusNb > 0) {
        this.divineBonus   = data.list;
      }
      else {
        this.divineBonus = [];
      }
    });
    
    this.socket.on('dailyCo', (result:any) => {
      this.dailyCo = result;
      let element:HTMLElement = document.getElementById('DailyCoCheckOpen') as HTMLElement;
      element.click();
    });
    this.socket.on("dailyCoCheck", (r:number) => {
      this.dailyCoCheck = r;
      if(r == 1) {
        this.socket.emit('dailyCo');
      }
    });
    
    setTimeout(() => {
      this.socket.emit('divineBonus');
      this.socket.emit('dailyCoCheck');
    }, 0);
  }
  
  ngOnDestroy() {
    this.socket.removeListener('divineBonus');
    this.socket.removeListener('dailyCo');
    this.socket.removeListener('dailyCoCheck');
  }
  
  dailCo() {
    return Object.keys(this.dailyCo).length;
  }
  
  divineBonusReset() {
    this.divinBonusListSelected.error = 0;
  }
{'fraction_non_alphanumeric': 0.14805097451274363, 'fraction_numerical': 0.004497751124437781, 'mean_word_length': 2.589105581708137, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2348112', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1725, 'n_words': 314}