@@ -24,7 +24,7 @@ import TankBody from "../Entity/Tank/TankBody";
2424import GameServer from "../Game" ;
2525import ArenaEntity , { ArenaState } from "../Native/Arena" ;
2626import { Entity } from "../Native/Entity" ;
27- import { PI2 } from "../util" ;
27+ import { PI2 , randomFrom } from "../util" ;
2828
2929const arenaSize = 11150 ;
3030const TEAM_COLORS = [ Color . TeamBlue , Color . TeamRed ] ;
@@ -70,7 +70,7 @@ export default class MothershipArena extends ArenaEntity {
7070
7171 public spawnPlayer ( tank : TankBody , client : Client ) {
7272 if ( ! this . motherships . length && ! this . playerTeamMotMap . has ( client ) ) {
73- const team = this . teams [ ~ ~ ( Math . random ( ) * this . teams . length ) ] ;
73+ const team = randomFrom ( this . teams ) ;
7474 const { x, y } = this . findPlayerSpawnLocation ( ) ;
7575
7676 tank . positionData . values . x = x ;
@@ -80,22 +80,17 @@ export default class MothershipArena extends ArenaEntity {
8080 return ;
8181 }
8282
83- const mothership = this . playerTeamMotMap . get ( client ) || this . motherships [ ~ ~ ( Math . random ( ) * this . motherships . length ) ] ;
83+ const mothership = this . playerTeamMotMap . get ( client ) || randomFrom ( this . motherships ) ;
8484 this . playerTeamMotMap . set ( client , mothership ) ;
8585
8686 tank . relationsData . values . team = mothership . relationsData . values . team ;
8787 tank . styleData . values . color = mothership . styleData . values . color ;
8888
8989 // TODO: Possess mothership if its unpossessed
90- if ( Entity . exists ( mothership ) ) {
91- tank . positionData . values . x = mothership . positionData . values . x ;
92- tank . positionData . values . y = mothership . positionData . values . y ;
93- } else {
94- const { x, y } = this . findPlayerSpawnLocation ( ) ;
90+ const { x, y } = this . findPlayerSpawnLocation ( ) ;
9591
96- tank . positionData . values . x = x ;
97- tank . positionData . values . y = y ;
98- }
92+ tank . positionData . values . x = x ;
93+ tank . positionData . values . y = y ;
9994
10095 if ( client . camera ) client . camera . relationsData . team = tank . relationsData . values . team ;
10196 }
0 commit comments