@@ -441,6 +441,25 @@ export class Room {
441441 return newStatus
442442 }
443443
444+ /**
445+ * resets the ready status of ingame users
446+ * @returns true if reset successfully, false if not
447+ */
448+ public resetIngameUsersReadyStatus ( ) : boolean {
449+ for ( const user of this . users ) {
450+ const userInfo : RoomUser = this . usersInfo . get ( user )
451+
452+ if ( userInfo == null ) {
453+ console . warn ( 'resetIngameUsersReadyStatus: couldnt get userinfo' )
454+ return false
455+ }
456+
457+ userInfo . ready = RoomReadyStatus . No
458+ }
459+
460+ return true
461+ }
462+
444463 /**
445464 * get's a room's status
446465 * @returns the room's status
@@ -814,24 +833,6 @@ export class Room {
814833 user . socket . send ( reply )
815834 }
816835
817- /**
818- * send the room's data to the user that joined the room
819- * @param user the player to send the other player's ready status
820- * @param player the player whose ready status will be sent
821- */
822- public sendPlayerReadyStatusTo ( user : User , player : User ) : void {
823- const status : RoomReadyStatus = this . getUserReadyStatus ( player )
824-
825- if ( status == null ) {
826- console . warn ( 'sendPlayerReadyStatusTo: couldnt get user "%s"\'s status (room "%s" room id %i)' ,
827- user . userName , this . settings . roomName , this . id )
828- return null
829- }
830-
831- const reply : Buffer = new OutRoomPacket ( user . socket ) . setUserReadyStatus ( player , status )
832- user . socket . send ( reply )
833- }
834-
835836 /**
836837 * tell the user about a new user in the room
837838 * @param user the player to send the other player's ready status
@@ -851,7 +852,7 @@ export class Room {
851852 }
852853
853854 /**
854- * tell the user about a new user in the room
855+ * send an user's ready status to another user
855856 * @param user the player to send the other player's ready status
856857 * @param player the player whose ready status will be sent
857858 */
@@ -868,6 +869,16 @@ export class Room {
868869 user . socket . send ( reply )
869870 }
870871
872+ /**
873+ * send everyone's ready status to an user
874+ * @param targetUser the user to send the info to
875+ */
876+ public sendRoomUsersReadyStatusTo ( targetUser : User ) : void {
877+ this . recurseUsers ( ( u : User ) : void => {
878+ this . sendUserReadyStatusTo ( targetUser , u )
879+ } )
880+ }
881+
871882 /**
872883 * tell the user to connect to a host
873884 * @param user the user that will connect to the host
0 commit comments