import { AfterViewInit , ChangeDetectorRef , EventEmitter , Input , ViewRef } from '@angular/core' ; import { CardsFacadeService } from '@services/cards-facade.service' ; import { MainWindowStoreEvent } from '../../../services/mainwindow/store/events/main-window-store-event' ; import { OverwolfService } from '../../../services/overwolf.service' ; export class DuelsTreasureStatVignetteComponent implements AfterViewInit { @ Input ( ) set stat ( value ) { if ( ! value || value === this . _stat ) { return ; } this . _stat = value ; this . name = this . cards . getCard ( value . cardId ) ?. name ; this . cardId = value . cardId ; this . playerClass = this . cards . getCard ( value . cardId ) ?. playerClass ; this . icon = `https://static.zerotoheroes.com/hearthstone/cardart/256x/${ value . cardId }.jpg` ; this . playerPickRate = value . playerPickRate ; this . globalPickRate = value . globalPickRate ; this . globalWinrate = value . globalWinrate ; this . globalOfferingRate = value . globalOfferingRate ; this . numberOfGamesTooltip = `${ value . globalTotalMatches . toLocaleString ( ) } matches recorded` ; if ( ! ( this . cdr as ViewRef ) ?. destroyed ) { this . cdr . detectChanges ( ) ; } } _stat : any ; cardId : string ; name : string ; playerClass : string ; icon : string ; globalPickRate : number ; globalWinrate : number ; globalOfferingRate : number ; playerPickRate : number ; numberOfGamesTooltip : string ; private stateUpdater : EventEmitter < MainWindowStoreEvent > ; constructor ( private readonly ow , private readonly cards , private readonly cdr ) { } ngAfterViewInit ( ) { this . stateUpdater = this . ow . getMainWindow ( ) . mainWindowStoreUpdater ; } buildPercents ( value ) { return value == null || isNaN ( value ) ? '-' : value . toFixed ( 1 ) + '%' ; } buildValue ( value , decimal = 2 ) { return value == null ? '-' : value === 0 ? '0' : value . toFixed ( decimal ) ; } }