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 {

  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;
  showSkill: boolean = false;
  showBlackDice: boolean
  skillTriggerHtml: string = '';
  constructor() { }

  ngOnInit(): void {
    if (this.mob.combatSkill) {
      switch (this.mode) {
        case MobDlgType.Activating:
          this.showSkill = [MobSkillType.Combat, MobSkillType.Attack].includes(this.mob.combatSkill.type);
          break;
        case MobDlgType.BeenAttacked:
          this.showSkill = [MobSkillType.Combat, MobSkillType.Defense].includes(this.mob.combatSkill.type);
          break;
        case MobDlgType.PreView:
          this.showSkill = true;
          break;
        case MobDlgType.Spawn:
        default:
          this.showSkill = false;
          break;
      }
      this.skillTriggerHtml = `${MobSkillType[this.mob.combatSkill.type]} ${this.mob.combatSkill.skillRoll} `
    }

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

}
