import { SettingsService } from "@services/settings.service" ; import { TranslateService } from "@ngx-translate/core" ; export abstract class Mod { private events : any [ ] = [ ] ; private onReset : any [ ] = [ ] ; public wGame : any | Window ; protected settings : SettingsService ; protected translate : TranslateService ; protected params : any ; constructor ( wGame , settings , translate ) { this . wGame = wGame ; this . settings = settings ; this . translate = translate ; this . startMod ?. ( ) ; } protected startMod ( ) { return ; } protected addOnResetListener ( fct ) { this . onReset . push ( fct ) ; } protected getRandomTime ( min , max ) { return ( Math . random ( ) * ( max * 1000 - min * 1000 ) + min * 1000 ) ; } protected on ( manager , eventHandler , fct ) { manager . on ( eventHandler , fct ) ; this . events . push ( { manager : manager , eventHandler : eventHandler , fct : fct } ) ; } protected once ( manager , eventHandler , fct ) { manager . once ( eventHandler , fct ) ; this . events . push ( { manager : manager , eventHandler : eventHandler , fct : fct } ) ; } protected removeListener ( manager , eventHandler , fct ) { manager . removeListener ( eventHandler , fct ) ; } public reset ( ) { this . onReset . forEach ( ( fct ) => { fct ( ) ; } ) ; this . onReset = [ ] ; this . events . forEach ( ( event ) => { this . removeListener ( event . manager , event . eventHandler , event . fct ) ; } ) ; this . events = [ ] ; } }