import { Component, Input, OnInit } from '@angular/core';
import { MD2Icon, MobDlgType, MobInfo, MobType } from '../../../massive-darkness2.model';
import { MobSkillType } from '../../../massive-darkness2.model.boss';

@Component({
  selector: 'md2-mob-combat-info',
  templateUrl: './mob-combat-info.component.html',
  styleUrls: ['./mob-combat-info.component.scss']
})
export class MobCombatInfoComponent implements OnInit {
  MobSkillType = MobSkillType;
  MD2Icon = MD2Icon;
  private _mob: MobInfo;
  public get mob(): MobInfo {
    return this._mob;
  }

  @Input() public set mob(v: MobInfo) {
    if (this._mob != v) {
      this._mob = v;

    }
  }
  @Input() mode: MobDlgType = MobDlgType.PreView;
  showAllSkill: boolean = false;
  showBlackDice: boolean
  skillTriggerHtml: string = '';
  constructor() { }

  ngOnInit(): void {
    this.showAllSkill = [MobDlgType.PreView, MobDlgType.Dashboard].includes(this.mode);
    if (this.mob.skills && this.mob.skills.length > 0) {
      this.mob.skills.forEach(element => {
        switch (this.mode) {
          case MobDlgType.Activating:
            element.uiDisplay = [MobSkillType.Combat, MobSkillType.Attack].includes(element.type);
            break;
          case MobDlgType.BeenAttacked:
            element.uiDisplay = [MobSkillType.Combat, MobSkillType.Defense].includes(element.type);
            break;
          case MobDlgType.PreView:
          case MobDlgType.Dashboard:
            element.uiDisplay = [MobSkillType.Combat, MobSkillType.Attack, MobSkillType.Defense].includes(element.type);
            break;
          case MobDlgType.Spawn:
            element.uiDisplay = false;
            break;
        }
      });
    }

    this.showBlackDice = this.mob.type == MobType.Mob && (this.mode == MobDlgType.Activating || this.mode == MobDlgType.BeenAttacked) && this.mob.minionAmount > 0;;
  }

}
