import { Component , EventEmitter , OnInit , Output } from '@angular/core' ; import { AbstractWidget } from '../../abstract-widget' ; import { AttributeValue } from '../../../phaser/entities/cc-entity' ; @ Component ( { selector : 'app-enemy-type-overlay' , templateUrl : './enemy-type-overlay.component.html' , styleUrls : [ './enemy-type-overlay.component.scss' , '../../widget.scss' ] } ) export class EnemyTypeWidgetOverlayComponent extends AbstractWidget implements OnInit { @ Output ( ) exit = new EventEmitter < void > ( ) ; readonly partyOptions = [ 'PLAYER' , 'ENEMY' , 'OTHER' ] ; readonly partyAttributes : AttributeValue = { type : 'string' , description : '' , withNull : true , options : this . makeOptions ( this . partyOptions ) } ; readonly faceOptions = [ 'NORTH' , 'EAST' , 'SOUTH' , 'WEST' , 'NORTH_EAST' , 'SOUTH_EAST' , 'SOUTH_WEST' , 'NORTH_WEST' ] ; readonly faceAttributes : AttributeValue = { type : 'string' , description : '' , withNull : true , options : this . makeOptions ( this . faceOptions ) } ; private makeOptions ( options ) { const out = { } ; for ( const opt of options ) { out [ opt ] = 0 ; } return out ; } constructor ( ) { super ( ) ; } ngOnInit ( ) { super . ngOnInit ( ) ; } close ( ) { this . exit . emit ( ) ; } stringify ( arg ) { return JSON . stringify ( arg ) ; } parse ( arg ) { try { return JSON . parse ( arg ) ; } catch ( err ) { console . warn ( err ) ; return undefined ; } } }