<commit_before>import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { Socket } from '../../../services/socketio.service';
import { TranslateService } from '@ngx-translate/core';
import { User } from '../../../services/user.service';

import { environment } from './../../../environments/environment';

import animalDog20Filled from '@iconify-icons/fluent/animal-dog-20-filled';
import bowAndArrow from '@iconify-icons/emojione-monotone/bow-and-arrow';
import footPrint from '@iconify-icons/mdi/foot-print';
import horseIcon from '@iconify-icons/mdi/horse';
import manSharp from '@iconify-icons/ion/man-sharp';
import questionCircle from '@iconify/icons-fa-regular/question-circle';
import shieldShaded from '@iconify/icons-bi/shield-shaded';
import {default as sword}  from '@iconify-icons/whh/sword';
import swordIcon from '@iconify/icons-vaadin/sword';


@Component({
  selector: 'app-army-popup',
  templateUrl: '../html/army-popup.sub-component.html',
  styleUrls: ['../css/army-popup.sub-component.css']
})

export class ArmyPopupSubComponent implements OnInit, OnDestroy {
  @Input() info: any;
  
  Number = Number;
  Object = Object;
  
  animalDog20Filled = animalDog20Filled;
  footPrint = footPrint;
  bowAndArrow = bowAndArrow;
  horseIcon = horseIcon;
  manSharp = manSharp;
  questionCircle = questionCircle;
  shieldShaded = shieldShaded;
  sword = sword;
  swordIcon= swordIcon;
  
  constructor(private socket: Socket, public user: User, public translate: TranslateService) {
  }
  
  ngOnInit() {
    this.socket.on('engagePossible', (nb:number) => {
      this.info.rEngagePossible = nb;
    });
    this.socket.on('freeUnits', (nb:number) => {
      this.info.free = nb;
    });
    this.socket.on('build', () => {
      this.socket.emit('engagePossible', this.info.code);
    });
    this.socket.on('destruct', () => {
      this.socket.emit('engagePossible', this.info.code);
    });
    this.socket.on('engage', (nb:number) => {
      this.info.rEngageNb = nb;
      this.info.rLiberateNb = 0;
      this.socket.emit('engagePossible', this.info.code);
    });
    this.socket.on('liberate', (nb:number) => {
      this.info.rEngageNb = 0;
      this.info.rLiberateNb = nb;
      this.socket.emit('engagePossible', this.info.code);
    });
  }
  
  ngOnDestroy() {
    this.socket.removeListener('engagePossible');
    this.socket.removeListener('freeUnits');
    this.socket.removeListener('build');
    this.socket.removeListener('destruct');
    this.socket.removeListener('engage');
    this.socket.removeListener('liberate');
  }
  
  armyEngage() {
    let unit = this.info.code;
    let nb = this.info.engageNb;
    this.info.rEngageNb = 0;
    this.info.rLiberateNb = 0;
    this.info.error = 0;
    
    if(nb == '' || nb == null) {<commit_msg>Refresh free units after destruct/liberate<commit_after>import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { Socket } from '../../../services/socketio.service';
import { TranslateService } from '@ngx-translate/core';
import { User } from '../../../services/user.service';

import { environment } from './../../../environments/environment';

import animalDog20Filled from '@iconify-icons/fluent/animal-dog-20-filled';
import bowAndArrow from '@iconify-icons/emojione-monotone/bow-and-arrow';
import footPrint from '@iconify-icons/mdi/foot-print';
import horseIcon from '@iconify-icons/mdi/horse';
import manSharp from '@iconify-icons/ion/man-sharp';
import questionCircle from '@iconify/icons-fa-regular/question-circle';
import shieldShaded from '@iconify/icons-bi/shield-shaded';
import {default as sword}  from '@iconify-icons/whh/sword';
import swordIcon from '@iconify/icons-vaadin/sword';


@Component({
  selector: 'app-army-popup',
  templateUrl: '../html/army-popup.sub-component.html',
  styleUrls: ['../css/army-popup.sub-component.css']
})

export class ArmyPopupSubComponent implements OnInit, OnDestroy {
  @Input() info: any;
  
  Number = Number;
  Object = Object;
  
  animalDog20Filled = animalDog20Filled;
  footPrint = footPrint;
  bowAndArrow = bowAndArrow;
  horseIcon = horseIcon;
  manSharp = manSharp;
  questionCircle = questionCircle;
  shieldShaded = shieldShaded;
  sword = sword;
  swordIcon= swordIcon;
  
  constructor(private socket: Socket, public user: User, public translate: TranslateService) {
  }
  
  ngOnInit() {
    this.socket.on('engagePossible', (nb:number) => {
      this.info.rEngagePossible = nb;
    });
    this.socket.on('freeUnits', (nb:number) => {
      this.info.free = nb;
    });
    this.socket.on('build', () => {
      this.socket.emit('engagePossible', this.info.code);
    });
    this.socket.on('destruct', () => {
      this.socket.emit('engagePossible', this.info.code);
      this.socket.emit('freeUnits', this.info.code);
    });
    this.socket.on('engage', (nb:number) => {
      this.info.rEngageNb = nb;
      this.info.rLiberateNb = 0;
      this.socket.emit('engagePossible', this.info.code);
    });
    this.socket.on('liberate', (nb:number) => {
      this.info.rEngageNb = 0;
      this.info.rLiberateNb = nb;
      this.socket.emit('engagePossible', this.info.code);
      this.socket.emit('freeUnits', this.info.code);
    });
  }
  
  ngOnDestroy() {
    this.socket.removeListener('engagePossible');
    this.socket.removeListener('freeUnits');
    this.socket.removeListener('build');
    this.socket.removeListener('destruct');
    this.socket.removeListener('engage');
    this.socket.removeListener('liberate');
  }
  
  armyEngage() {
    let unit = this.info.code;
    let nb = this.info.engageNb;
    this.info.rEngageNb = 0;
    this.info.rLiberateNb = 0;
    this.info.error = 0;
    
    if(nb == '' || nb == null) {
{'fraction_non_alphanumeric': 0.1627988134705985, 'fraction_numerical': 0.004536730064561159, 'mean_word_length': 3.5856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5892167', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1954, 'n_words': 332}