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

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

  public proficiency: number = 0;

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

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

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