import { Component, Input } from '@angular/core';
import { DetailsService } from 'src/services/details/details.service';
import { DataService } from 'src/services/data/data.service';
import { Attribute } from 'src/interfaces/interfaces';
import { TranslateService } from '@ngx-translate/core';
import { ListService } from 'src/services/list/list.service';

@Component({
  selector: 'app-attribute-details',
  templateUrl: './attribute-details.component.html',
  styleUrl: './attribute-details.component.scss',
})
export class AttributeDetailsComponent {
  @Input() public attribute!: Attribute;
  @Input() public modifier!: string;

  public resistances: string[] = [];
  public immunities: string[] = [];
  public vulnerabilities: string[] = [];
  public showButtonsContainer: boolean = false;
  public isEdit: boolean = false;

  public constructor(
    public detailsService: DetailsService,
    public translate: TranslateService,
    public list: ListService,
    public dataAccessor: DataService,
  ) {
    this.resistances = this.dataAccessor.resistances.resistances;
    this.immunities = this.dataAccessor.resistances.immunities;
    this.vulnerabilities = this.dataAccessor.resistances.vulnerabilities;
  }

  public skillsTable: any = {
    strength: ['athletics'],
    dexterity: ['acrobatics', 'sleightOfHand', 'stealth'],
    constitution: [],
    intelligence: ['arcana', 'history', 'investigation', 'nature', 'religion'],
    wisdom: ['animalHandling', 'insight', 'medicine', 'perception', 'survival'],
    charisma: ['deception', 'intimidation', 'performance', 'persuasion'],
  };

  public showButtons() {
    this.showButtonsContainer = true;
    console.log('show Buttons:', this.showButtonsContainer);
  }

  public toggleEdit() {
    this.isEdit = !this.isEdit;
  }

  public close(): void {
    this.dataAccessor.resistances = {
      resistances: this.resistances,
      immunities: this.immunities,
      vulnerabilities: this.vulnerabilities,
    };
    this.detailsService.closePanel('dismiss');
  }
}
