import { Component } from '@angular/core';
import { DataService } from 'src/services/data/data.service';

@Component({
  selector: 'app-exhaustion',
  templateUrl: './exhaustion.component.html',
  styleUrls: ['./exhaustion.component.scss'],
})
export class ExhaustionComponent {
  public constructor(public dataAccessor: DataService) {}

  public exhaustion: number = 0;

  ngOnInit(): void {
    this.initAttributeSubscription();
  }

  private initAttributeSubscription(): void {
    this.dataAccessor.exhaustion$.subscribe((newValue: any) => {
      this.exhaustion = newValue.value;
    });
  }

  public updateValue(): void {
    this.dataAccessor.updateCharacterData({
      name: 'exhaustion',
      value: this.exhaustion,
    });
  }
}
