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

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

    managePriorities
    rules = {}

    constructor(
      private api: ApiService,
    ){
    }

    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
    }
}