@@ -136,8 +136,6 @@ export class Room {
136136 private emptyRoomCallback : ( emptyRoom : Room , channel : Channel ) => void
137137 private parentChannel : Channel
138138
139- private status : RoomStatus
140-
141139 private countingDown : boolean
142140 private countdown : number
143141
@@ -154,8 +152,6 @@ export class Room {
154152
155153 this . settings = new RoomSettings ( options )
156154
157- this . status = RoomStatus . Waiting
158-
159155 this . countingDown = false
160156 this . countdown = defaultCountdownNum
161157
@@ -375,6 +371,26 @@ export class Room {
375371 return userInfo . ready === RoomReadyStatus . Yes
376372 }
377373
374+ /**
375+ * is the user ingame?
376+ * @param user the target user
377+ */
378+ public isUserIngame ( user : User ) : boolean {
379+ if ( this . hasUser ( user ) === false ) {
380+ console . warn ( 'isUserIngame: user "%s" not found!' , user . userName )
381+ return false
382+ }
383+
384+ const userInfo : RoomUser = this . usersInfo . get ( user )
385+
386+ if ( userInfo == null ) {
387+ console . warn ( 'isUserIngame: couldnt get "%s"\'s userinfo' , user . userName )
388+ return false
389+ }
390+
391+ return userInfo . isIngame
392+ }
393+
378394 /**
379395 * checks if the room's users are ready
380396 * @returns true if everyone is ready, false if not
@@ -409,6 +425,27 @@ export class Room {
409425 userInfo . team = newTeam
410426 }
411427
428+ /**
429+ * set's an user's ingame status
430+ * @param user the target user
431+ * @param ingame the new ingame status
432+ */
433+ public setUserIngame ( user : User , ingame : boolean ) : void {
434+ if ( this . hasUser ( user ) === false ) {
435+ console . warn ( 'setUserIngame: user "%s" not found!' , user . userName )
436+ return
437+ }
438+
439+ const userInfo : RoomUser = this . usersInfo . get ( user )
440+
441+ if ( userInfo == null ) {
442+ console . warn ( 'setUserIngame: couldnt get "%s"\'s userinfo' , user . userName )
443+ return null
444+ }
445+
446+ userInfo . isIngame = ingame
447+ }
448+
412449 /**
413450 * toggles the user's room ready status
414451 * @param user the user's object
@@ -465,23 +502,16 @@ export class Room {
465502 * @returns the room's status
466503 */
467504 public getStatus ( ) : RoomStatus {
468- return this . status
505+ return this . settings . status
469506 }
470507
471508 /**
472509 * set a room's status
473510 * @param newStatus the new room's status
474511 */
475512 public setStatus ( newStatus : RoomStatus ) : void {
476- this . status = newStatus
477- }
478-
479- /**
480- * is the countdown request user a host and can it start a global countdown?
481- * @param user the user that requested the countdown
482- */
483- public canCountdown ( user : User ) : boolean {
484- return user === this . host && this . status === RoomStatus . Waiting
513+ this . settings . status = newStatus
514+ this . settings . isIngame = newStatus === RoomStatus . Ingame
485515 }
486516
487517 /**
@@ -743,9 +773,9 @@ export class Room {
743773 this . settings . unk18 = newSettings . unk18
744774 updatedSet . unk18 = newSettings . unk18
745775 }
746- if ( newSettings . unk20 != null ) {
747- this . settings . unk20 = newSettings . unk20
748- updatedSet . unk20 = newSettings . unk20
776+ if ( newSettings . status != null ) {
777+ this . settings . status = newSettings . status
778+ updatedSet . status = newSettings . status
749779 }
750780 if ( newSettings . unk21 != null ) {
751781 this . settings . unk21 = newSettings . unk21
@@ -803,9 +833,9 @@ export class Room {
803833 this . settings . unk39 = newSettings . unk39
804834 updatedSet . unk39 = newSettings . unk39
805835 }
806- if ( newSettings . unk40 != null ) {
807- this . settings . unk40 = newSettings . unk40
808- updatedSet . unk40 = newSettings . unk40
836+ if ( newSettings . isIngame != null ) {
837+ this . settings . isIngame = newSettings . isIngame
838+ updatedSet . isIngame = newSettings . isIngame
809839 }
810840 if ( newSettings . unk43 != null ) {
811841 this . settings . unk43 = newSettings . unk43
@@ -961,6 +991,20 @@ export class Room {
961991 user . socket . send ( resultReply )
962992 }
963993
994+ /**
995+ * send an user its current room's status
996+ * @param user the target user
997+ */
998+ public sendRoomStatusTo ( user : User ) : void {
999+ const settings : RoomSettings = new RoomSettings ( )
1000+ settings . status = this . settings . status
1001+ settings . isIngame = this . settings . isIngame
1002+
1003+ const statusReply : Buffer =
1004+ new OutRoomPacket ( user . socket ) . updateSettings ( settings )
1005+ user . socket . send ( statusReply )
1006+ }
1007+
9641008 /**
9651009 * handle max players setting's update event
9661010 * @param newMaxPlayers the requested new max players number
0 commit comments