import { Injectable } from '@angular/core';
import { DrawingBag, MD2HeroInfo, MD2Icon, MobInfo, TreasureItem, TreasureType } from '../../games/massive-darkness2/massive-darkness2.model';
import { FileService } from '../file.service';
import { MD2GameInfo } from './md2.service';

@Injectable({
  providedIn: 'root'
})
export class MD2StateService {

  private _highestPlayerLevel: number = 1;
  private _playerAmount: number = 2;

  public info: MD2GameInfo;
  public playerHero: MD2HeroInfo;
  public mobDeck: DrawingBag<MobInfo>;
  public roamingMobDeck: DrawingBag<MobInfo>;
  public treasureBag: DrawingBag<TreasureItem> = new DrawingBag<TreasureItem>();

  constructor(
    public fileService: FileService,
  ) { }

  public iconHtml(icon: MD2Icon, cssClass = '') {


    if (icon == MD2Icon.Fire) {
      cssClass += ' g-color-google-plus ';
    }
    if (icon == MD2Icon.Frost || icon == MD2Icon.Mana) {
      cssClass += ' g-color-aqua ';
    }
    if (icon < MD2Icon.RedDice) {
      return `<span class='MD2Icon ${cssClass}'>${String.fromCharCode(65 + icon)}</span>`
    } else {
      return `<span class='MD2Icon dice ${MD2Icon[icon].replace('Dice', '')} ${cssClass}'></span>`;
    }
  }

  public imgHtml(imgPath: string, cssClass = 'g-height-25 mr-1') {
    return `<img src='${this.imgUrl(imgPath)}' class='${cssClass}'>`;
  }

  public imgUrl(imgPath: string) {
    return this.fileService.ImageUrl('MD2/' + imgPath);
  }
  public treasureImage(type: TreasureType) {
    return this.imgUrl(`TreasureToken/${TreasureType[type]}.png`);
  }
  public treasureImageHtml(type: TreasureType) {
    return this.imgHtml(`TreasureToken/${TreasureType[type]}.png`, 'g-height-40 mr-1');
  }
}
