import { Component, OnInit } from '@angular/core';
import { getClassColor } from '../../../../../../backend/Types/PlayerSpecs';
import { IApiService } from '../../services/ApiService/ApiService';

@Component({
  selector: 'rules',
  templateUrl: './rules.component.html',
})
export class FrontcraftRulesComponent implements OnInit{

    managePriorities
    rules = {}

    constructor(
      private api: IApiService,
    ){
    }

    async ngOnInit(){
      this.api.get('ItemManager').getAllPriorities().then(prios => prios.forEach(prio => {
        if(!this.rules[prio.itemname]){
          this.rules[prio.itemname] = []
        }
        prio['color'] = getClassColor(prio.class) || '#FFFFFF'
        this.rules[prio.itemname].push(prio)
      }))
      
      const managePriorities = this.api.get('managePriorities')
      this.managePriorities = managePriorities
    }
}