import { Event } from './Event' ; import { Player } from '../../../../shared/models/entity' ; import { AdventureLogEventType , EventMessageType } from '../../../../shared/interfaces' ; export class Switcheroo extends Event { public static readonly WEIGHT = 1 ; public operateOn ( player ) { const stat = this . pickStat ( ) ; const item = this . pickValidItem ( player ) ; if ( ! item || ! item . stats [ stat ] ) { player . increaseStatistic ( `Event/Switcheroo/Fail` , 1 ) ; return ; } const eventText = this . eventText ( EventMessageType . Switcheroo , player , { item : item . fullName ( ) , stat } ) ; const allText = `${ eventText } [${ stat . toUpperCase ( ) } ${ item . stats [ stat ] } → ${ - item . stats [ stat ] }]` ; item . stats [ stat ] = - item . stats [ stat ] ; item . recalculateScore ( ) ; player . recalculateStats ( ) ; this . emitMessage ( [ player ] , allText , AdventureLogEventType . Item ) ; } }