Skip to content

Commit

Permalink
min 3 player
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatbostanci committed Jun 10, 2021
1 parent 25a44b9 commit 42c889c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions handler/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ func (h *MultiplayerHandler) RoomStream(stream pb.MultiplayerService_RoomStreamS
h.rooms[request.GetRoomId()][request.GetPlayer().GetId()] = request.GetPlayer()

currentPlayers := make([]*pb.Player, 0, len(h.rooms[request.GetRoomId()]))
for _, player := range h.rooms[request.GetRoomId()] {
currentPlayers = append(currentPlayers, player)
if len(h.rooms[request.GetRoomId()]) > 2 {
for _, player := range h.rooms[request.GetRoomId()] {
currentPlayers = append(currentPlayers, player)
}
}

err = stream.Send(&pb.RoomStreamResponse{Players: currentPlayers})
Expand Down

0 comments on commit 42c889c

Please sign in to comment.