import { Battle , BattleType , IPosition } from './types' ; import { Tank } from '../tanks' ; export class BattleService { private static _battles : Battle [ ] = [ ] ; public static async clearCache ( ) { try { this . _battles = [ ] ; } catch ( ex ) { throw ex ; } } description static param { string } id returns memberof public static getBattleById ( id ) { let battle = undefined ; if ( this . _battles && this . _battles . length ) { battle = this . _battles . find ( b => b . id === id ) ; } return battle ; } description todo static param { BattleType } type param { Tank [ ] } opponents param { IPosition } size returns memberof public static startBattle ( type , opponents , size ) { const battle = new Battle ( { type , opponents , size } ) ; this . _battles . push ( battle ) ; return battle ; } description static returns { Battle [ ] } memberof public static getBattles ( ) { if ( this . _battles && this . _battles . length ) { return this . _battles ; } return this . _battles ; } }