public void PlayerCannotJoinAGameThatHasAlreadyStarted() { CreateRoomRequest createRequest = new CreateRoomRequest() { Anonymous = false, Goal = Goal.Domination, MaxPlayers = 2, IsRanked = false, RoomName = "My Room!", AllowedSpecialists = { "a", "b", "c" }, }; CreateRoomResponse roomResponse = client.CreateNewRoom(createRequest); Assert.AreEqual(roomResponse.Status.IsSuccess, true); Assert.IsTrue(roomResponse.CreatedRoom.RoomId != null); var roomId = roomResponse.CreatedRoom.RoomId; authHelper.loginToAccount("userTwo"); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); authHelper.loginToAccount("userThree"); var exception = client.JoinRoom(joinRequest); Assert.AreEqual(exception.Status.IsSuccess, false); Assert.AreEqual(exception.Status.Detail, ResponseType.ROOM_IS_FULL.ToString()); }
public HttpResponseMessage Join([ModelBinder(typeof(JsonNetModelBinder))] JoinRoomRequest request) { var room = Data.FindRoom(request.GameName); if (room == null) { var joinRoomFailedResponse = new JoinRoomResponse() { Result = false }; return(new JsonNetResponseMessage(joinRoomFailedResponse)); } var player = Data.FindPlayer(request.PlayerId); if (player == null) { player = new Player() { Name = request.PlayerId, RoomName = request.GameName }; Data.Players.Add(player.Name, player); } room.Players.Add(player); var response = new JoinRoomResponse() { Result = true, Room = room }; return(new JsonNetResponseMessage(response)); }
void JoinRoom() { var joinReq = new { roomNo = roomNo, userId = Player.Me.userId, clientInfo = Utils.GetClientInfo(), userInfo = Utils.GetUserInfo() }; Debug.Log("try to join room"); gameSocket.Emit(Messages.JoinRoom, (socket, packet, args) => { string msg = packet.ToString(); Debug.Log("Join Room Response: " + msg); JoinRoomResponse resp = JsonConvert.DeserializeObject <JoinRoomResponse[]>(msg)[0]; if (resp.status != 0) { Debug.LogError("ErrorMessage: " + resp.errorMessage); Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters[Utils.Message_Key] = "该房间不存在"; Scenes.Load("MainPage", parameters); return; } gamePlayController.HandleResponse(resp); timeLeft = retryTimeInterval; DateTime endConnTime = DateTime.Now; double totalMilliSecs = (endConnTime - startConnTime).TotalMilliseconds; Debug.Log("连接和加入房间,使用了" + totalMilliSecs + "ms"); //Debug.Log("Connect"); }, JsonConvert.SerializeObject(joinReq)); }
private void SetRounds(JoinRoomResponse resp, Game game) { for (int i = 0; i < game.currentRoundNo - 1; i++) { game.rounds [i] = resp.rounds [i]; } }
public void Parse_Returns_Expected_Data_When_1_User(string roomName) { var builder = new MessageBuilder() .WriteCode(MessageCode.Server.JoinRoom) .WriteString(roomName) .WriteInteger(1) // user count .WriteString("1") .WriteInteger(1) // status count .WriteInteger((int)UserPresence.Online) .WriteInteger(1) // data count .WriteInteger(10) // average speed .WriteLong(11) // download count .WriteInteger(12) // file count .WriteInteger(13) // directory count .WriteInteger(1) // slots free count .WriteInteger(14) // slots free .WriteInteger(1) // country count .WriteString("US"); var res = JoinRoomResponse.FromByteArray(builder.Build()); var users = res.Users.ToList(); Assert.Equal(roomName, res.Name); Assert.Equal(1, res.UserCount); Assert.Equal("1", users[0].Username); Assert.Equal(UserPresence.Online, users[0].Status); Assert.Equal(10, users[0].AverageSpeed); Assert.Equal(11, users[0].DownloadCount); Assert.Equal(12, users[0].FileCount); Assert.Equal(13, users[0].DirectoryCount); Assert.Equal(14, users[0].SlotsFree); Assert.Equal("US", users[0].CountryCode); }
public void BeingTheLastPlayerToJoinAGameWillStartTheGame() { CreateRoomResponse roomResponse = client.CreateNewRoom(createRoomRequest("My room!", maxPlayers: 2)); Assert.AreEqual(roomResponse.Status.IsSuccess, true); Assert.IsTrue(roomResponse.CreatedRoom.Id != null); var roomId = roomResponse.CreatedRoom.Id; authHelper.loginToAccount("userTwo"); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); // Check to see the room is not visible. OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true); Assert.AreEqual(0, openLobbiesResponseAfterJoin.Rooms.Count); // Check to see the player can see the game because they are a member. PlayerCurrentGamesResponse playerGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest()); Assert.AreEqual(playerGamesResponse.Status.IsSuccess, true); Assert.AreEqual(1, playerGamesResponse.Games.Count); }
public void PlayerCanStartAGameEarlyIfTwoPlayersAreInTheLobby() { CreateRoomResponse roomResponse = authHelper.CreateGameRoom("room1"); var roomId = roomResponse.CreatedRoom.RoomId; authHelper.loginToAccount("userTwo"); JoinRoomResponse joinResponse = client.JoinRoom(new JoinRoomRequest() { RoomId = roomId, }); Assert.AreEqual(joinResponse.Status.IsSuccess, true); authHelper.loginToAccount("userOne"); StartGameEarlyResponse startGameEarlyResponse = client.StartGameEarly(new StartGameEarlyRequest() { RoomId = roomId, }); Assert.AreEqual(startGameEarlyResponse.Status.IsSuccess, true); // Ensure game cannot be seen in open lobbies. // View open rooms. OpenLobbiesResponse openLobbiesResponse = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponse.Status.IsSuccess, true); Assert.AreEqual(0, openLobbiesResponse.Rooms.Count); }
void JoinRes(JoinRoomResponse joinRoomResponse) { int roomId = joinRoomResponse.RoomId; Debug.Log("进入房间:" + roomId.ToString()); GoRoomScene(roomId); }
//TODO 需要在寻转座位之后进行,进行重构 private void SetShowcardPlayers(JoinRoomResponse resp, Game game) { Dictionary <string, string[]> cardsDict = resp.playerCards; Dictionary <string, ShowCardResult> showcardPlayersDict = resp.showcardPlayers; foreach (KeyValuePair <string, ShowCardResult> pair in showcardPlayersDict) { string userId = pair.Key; ShowCardResult showcardResult = pair.Value; //这是的位置不是用户最终的位置。 int index = game.GetSeatIndex(userId); game.currentRound.cardSequenceArray [userId] = showcardResult.cardSequences; game.currentRound.niuArray [userId] = showcardResult.niu; game.currentRound.multipleArray [userId] = showcardResult.multiple; foreach (KeyValuePair <string, string[]> kv in cardsDict) { string uid = kv.Key; string[] cards = kv.Value; if (userId == uid) { game.currentRound.playerCardsDict[uid] = cards; break; } } } }
private async void btnJoin_Click(object sender, RoutedEventArgs e) { try { if (_chatRoomServiceProxy != null) { _chatRoomServiceProxy.Leave(); } JoinRoomResponse response = await _chatServiceProxy.JoinOrCreateRoom(cbChatRooms.Text); if (_chatChannelDisconnectionSubscription != null) { _chatChannelDisconnectionSubscription.Dispose(); } _chatChannel = await _node.ConnectToServer(response.ServerEndpoint); _chatRoomServiceProxy = await _chatChannel.GetProxy <IChatRoomService>(response.RoomActorId); _chatChannel.SetHandler <IChatRoomServiceCallback>(this); _chatChannelDisconnectionSubscription = _chatChannel.DisconnectedEvent.Subscribe((_) => MessageBox.Show("Disconnected from chat room, try connect again")); var content = await _chatRoomServiceProxy.Join(response.Ticket); txtChat.Clear(); foreach (var msg in content) { txtChat.AppendText(msg + "\n"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public void PlayerCanJoinAGameRoom() { var roomId = createRoom(); authHelper.loginToAccount("userTwo"); // View open rooms. OpenLobbiesResponse openLobbiesResponse = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponse.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponse.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponse.Rooms[0].Id); // Ensure the creator is a member of the game Assert.AreEqual(1, openLobbiesResponse.Rooms[0].Players.Count); Assert.AreEqual("userOne", openLobbiesResponse.Rooms[0].Players[0].Username); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponseAfterJoin.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponseAfterJoin.Rooms[0].Id); Assert.AreEqual(2, openLobbiesResponseAfterJoin.Rooms[0].Players.Count); Assert.IsTrue(openLobbiesResponseAfterJoin.Rooms[0].Players.Any(it => it.Id == authHelper.getAccountId("userTwo"))); }
public void PlayerCanLeaveAGameRoom() { CreateRoomResponse roomResponse = client.CreateNewRoom(createRoomRequest("My room!")); Assert.AreEqual(roomResponse.Status.IsSuccess, true); Assert.IsTrue(roomResponse.CreatedRoom.Id != null); var roomId = roomResponse.CreatedRoom.Id; authHelper.loginToAccount("userTwo"); // View open rooms. OpenLobbiesResponse openLobbiesResponse = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponse.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponse.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponse.Rooms[0].Id); // Ensure the creator is a member of the game Assert.AreEqual(1, openLobbiesResponse.Rooms[0].Players.Count); Assert.AreEqual("userOne", openLobbiesResponse.Rooms[0].Players[0].Username); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); // View open rooms. OpenLobbiesResponse openLobbiesResponsAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponsAfterJoin.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponsAfterJoin.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponsAfterJoin.Rooms[0].Id); Assert.AreEqual(2, openLobbiesResponsAfterJoin.Rooms[0].Players.Count); LeaveRoomRequest leaveRequest = new LeaveRoomRequest() { RoomId = roomId }; LeaveRoomResponse leaveResponse = client.LeaveRoom(leaveRequest); Assert.AreEqual(leaveResponse.Status.IsSuccess, true); // Ensure that the player has left the game. // View open rooms. OpenLobbiesResponse openLobbiesResponsAfterLeave = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponsAfterLeave.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponsAfterLeave.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponsAfterLeave.Rooms[0].Id); Assert.AreEqual(1, openLobbiesResponsAfterLeave.Rooms[0].Players.Count); }
public void Parse_Throws_MessageException_On_Code_Mismatch() { var msg = new MessageBuilder() .WriteCode(MessageCode.Server.LeaveRoom) .Build(); var ex = Record.Exception(() => JoinRoomResponse.FromByteArray(msg)); Assert.NotNull(ex); Assert.IsType <MessageException>(ex); }
public void AdminsCanViewAnyOngoingGameTheyAreNotIn() { CreateRoomRequest createRequest = new CreateRoomRequest() { Anonymous = false, Goal = Goal.Domination, MaxPlayers = 2, IsRanked = false, RoomName = "My Room!", AllowedSpecialists = { "a", "b", "c" }, }; CreateRoomResponse roomResponse = client.CreateNewRoom(createRequest); Assert.AreEqual(roomResponse.Status.IsSuccess, true); Assert.IsTrue(roomResponse.CreatedRoom.RoomId != null); var roomId = roomResponse.CreatedRoom.RoomId; authHelper.loginToAccount("userTwo"); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); // Check to see the room is not visible. OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true); Assert.AreEqual(0, openLobbiesResponseAfterJoin.Rooms.Count); // Check to see the player can see the game because they are a member. PlayerCurrentGamesResponse playerGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest()); Assert.AreEqual(playerGamesResponse.Status.IsSuccess, true); Assert.AreEqual(1, playerGamesResponse.Games.Count); SuperUser superUser = authHelper.CreateSuperUser(); client.Login(new AuthorizationRequest() { Password = superUser.password, Username = superUser.userModel.UserModel.Username, }); PlayerCurrentGamesResponse adminGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest()); Assert.AreEqual(adminGamesResponse.Status.IsSuccess, true); Assert.AreEqual(1, adminGamesResponse.Games.Count); }
async static Task Run(INetNode node) { node.Start(); Console.WriteLine("Input server endpoint in form of ipaddress:port"); string[] addressAndPort = Console.ReadLine().Split(':'); var endpoint = new IPEndPoint(IPAddress.Parse(addressAndPort[0]), int.Parse(addressAndPort[1])); //before doing any network comms we should connect to some server node using (INetChannel channel = await node.Connect(endpoint)) { await Task.Yield(); Console.WriteLine("Enter your name"); string name = Console.ReadLine(); Console.WriteLine("Enter chat room name"); string roomName = Console.ReadLine(); //using connected channel we can send in request/reply pattern JoinRoomResponse response = await channel.SendRequestAsync <JoinRoomResponse>( new JoinRoom { ClientName = name, RoomName = roomName }); if (response.RetCode == JoinRoomRetCode.NameIsTaken) { Console.WriteLine("Name is taken"); return; } Console.WriteLine("You are connected, say something or enter exit"); bool exit = false; while (!exit) { await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline string text = Console.ReadLine(); if (text == "exit") { exit = true; } else { //or we can send just one way messages channel.Send(new Say { Text = text }); } } } }
private void SetReadyPlayers(JoinRoomResponse resp, Game game) { Dictionary <string, bool> readyPlayerDict = resp.readyPlayers; foreach (KeyValuePair <string, bool> pair in readyPlayerDict) { string userId = pair.Key; int index = game.GetSeatIndex(userId); game.seats [index].player.isReady = true; } }
public void Parse_Throws_MessageReadException_On_Missing_Data() { var msg = new MessageBuilder() .WriteCode(MessageCode.Server.JoinRoom) .WriteInteger(1) .Build(); var ex = Record.Exception(() => JoinRoomResponse.FromByteArray(msg)); Assert.NotNull(ex); Assert.IsType <MessageReadException>(ex); }
private void JoinRoomCallback(Socket socket, Packet packet, params object[] args) { string msg = packet.ToString(); JoinRoomResponse resp = JsonConvert.DeserializeObject <JoinRoomResponse[]> (msg) [0]; Debug.Log("msg: " + resp.status); DateTime end = DateTime.Now; double millisecs = (end - startTime).TotalMilliseconds; Debug.Log("TotalMilliseconds = " + millisecs); }
//TODO 需要在寻转座位之后进行,进行重构 private void SetBetPlayers(JoinRoomResponse resp, Game game) { Dictionary <string, int> betPlayerDict = resp.betPlayers; foreach (KeyValuePair <string, int> pair in betPlayerDict) { string userId = pair.Key; int bet = pair.Value; //有问题,因为现在的位置不是最终的位置。 game.currentRound.playerBets [userId] = bet; //Debug.Log ("Set " + userId + " index = " + game.GetSeatIndex(userId) + " bet = " + bet); } }
/** * Join a room with it's identifier. * If the room does not exist create it * otherwise join. */ public async Task <JoinRoomResponse> JoinRoom(JoinRoomRequest payload) { try { var response = new JoinRoomResponse(); User user = await _userRepository.FindRoomOfUserById((Guid)payload.userIdentifier); if (user == null) { throw new ApplicationError("[RoomService.JoinRoom]", 1); } var room = await _roomRepository.FindByIdentifier((Guid)payload.roomIdentifier); if (room == null) { room = new Room(); room.id = Guid.NewGuid(); room.identifier = (Guid)payload.roomIdentifier; room.users = new List <User> { user }; bool result = await _roomRepository.Save(room); if (!result) { throw new ApplicationError("[RoomService.JoinRoom]", 3); } } else { room.users = await _userRepository.FindAllByRoomId(room.id); room.users.Add(user); } response.roomIdentifier = room.identifier; response.users = room.users; response.messages = await _messageRepository.FindAllByRoomId(room.id); await _unitOfWork.Save(); return(response); } catch (Exception e) { throw e; } }
private void SetMyBets(JoinRoomResponse resp, Game game) { Dictionary <string, int[]> playerBetsDict = resp.playerBets; foreach (KeyValuePair <string, int[]> pair in playerBetsDict) { string userId = pair.Key; int[] bets = pair.Value; if (userId == Player.Me.userId) { game.currentRound.myBets = bets; } } }
private void SetDelegatePlayers(JoinRoomResponse resp, Game game) { foreach (string userId in resp.delegatePlayers) { var seatIndex = game.GetSeatIndex(userId); if (seatIndex != -1) { if (game.seats [seatIndex].player.userId != Player.Me.userId) { game.seats [seatIndex].player.isDelegate = true; } } } }
private void SetMyCards(JoinRoomResponse resp, Game game) { var cards = resp.playerCards; //Debug.Log ("cards.keys: " + cards.Keys); //Debug.Log ("Me.userId: " + Player.Me.userId); //Debug.Log ("cards.ContainsKey (Player.Me.userId): " + cards.ContainsKey (Player.Me.userId)); if (cards.ContainsKey(Player.Me.userId)) { game.currentRound.playerCardsDict [Player.Me.userId] = new string[5]; for (int i = 0; i < cards[Player.Me.userId].Length; i++) { game.currentRound.playerCardsDict[Player.Me.userId][i] = cards[Player.Me.userId][i]; } } }
public void Parse_Returns_Expected_Data_When_0_Users(string roomName) { var builder = new MessageBuilder() .WriteCode(MessageCode.Server.JoinRoom) .WriteString(roomName) .WriteInteger(0) // user count .WriteInteger(0) // status count .WriteInteger(0) // data count .WriteInteger(0) // slots free count .WriteInteger(0); // country count var response = JoinRoomResponse.FromByteArray(builder.Build()); Assert.Equal(roomName, response.Name); Assert.Equal(0, response.UserCount); }
public void PlayerCanJoinAGameRoom() { CreateRoomRequest createRequest = new CreateRoomRequest() { Anonymous = false, Goal = Goal.Domination, MaxPlayers = 5, IsRanked = false, RoomName = "My Room!", AllowedSpecialists = { "a", "b", "c" }, }; CreateRoomResponse roomResponse = client.CreateNewRoom(createRequest); Assert.AreEqual(roomResponse.Status.IsSuccess, true); Assert.IsTrue(roomResponse.CreatedRoom.RoomId != null); var roomId = roomResponse.CreatedRoom.RoomId; authHelper.loginToAccount("userTwo"); // View open rooms. OpenLobbiesResponse openLobbiesResponse = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponse.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponse.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponse.Rooms[0].RoomId); // Ensure the creator is a member of the game Assert.AreEqual(1, openLobbiesResponse.Rooms[0].Players.Count); Assert.AreEqual("userOne", openLobbiesResponse.Rooms[0].Players[0].Username); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true); Assert.AreEqual(1, openLobbiesResponseAfterJoin.Rooms.Count); Assert.AreEqual(roomId, openLobbiesResponseAfterJoin.Rooms[0].RoomId); Assert.AreEqual(2, openLobbiesResponseAfterJoin.Rooms[0].Players.Count); Assert.IsTrue(openLobbiesResponseAfterJoin.Rooms[0].Players.Any(it => it.Id == authHelper.getAccountId("userTwo"))); }
public void PlayerJoinRoom(JoinRoomResponse resp) { if (GameGlobalData.fd == resp.roomOwnerFd) { gameStartButton.gameObject.SetActive(true); } else { gameStartButton.gameObject.SetActive(false); } ResetChild(resp.manCount); int index = 0; foreach (SinglePlayerInfo info in resp.playerInfo) { addPlayer(info.userName, info.fd, index); ++index; } }
public void BeingTheLastPlayerToJoinAGameWillStartTheGame() { CreateRoomRequest createRequest = new CreateRoomRequest() { Anonymous = false, Goal = Goal.Domination, MaxPlayers = 2, IsRanked = false, RoomName = "My Room!", AllowedSpecialists = { "a", "b", "c" }, }; CreateRoomResponse roomResponse = client.CreateNewRoom(createRequest); Assert.AreEqual(roomResponse.Status.IsSuccess, true); Assert.IsTrue(roomResponse.CreatedRoom.RoomId != null); var roomId = roomResponse.CreatedRoom.RoomId; authHelper.loginToAccount("userTwo"); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); // Check to see the room is not visible. OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true); Assert.AreEqual(0, openLobbiesResponseAfterJoin.Rooms.Count); // Check to see the player can see the game because they are a member. PlayerCurrentGamesResponse playerGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest()); Assert.AreEqual(playerGamesResponse.Status.IsSuccess, true); Assert.AreEqual(1, playerGamesResponse.Games.Count); }
public void AdminsCanViewAnyOngoingGameTheyAreNotIn() { var roomId = createRoom(maxPlayers: 2); authHelper.loginToAccount("userTwo"); JoinRoomRequest joinRequest = new JoinRoomRequest() { RoomId = roomId, }; JoinRoomResponse joinResponse = client.JoinRoom(joinRequest); Assert.AreEqual(joinResponse.Status.IsSuccess, true); // Check to see the room is not visible. OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest()); Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true); Assert.AreEqual(0, openLobbiesResponseAfterJoin.Rooms.Count); // Check to see the player can see the game because they are a member. PlayerCurrentGamesResponse playerGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest()); Assert.AreEqual(playerGamesResponse.Status.IsSuccess, true); Assert.AreEqual(1, playerGamesResponse.Games.Count); SuperUser superUser = authHelper.CreateSuperUser(); client.Login(new AuthorizationRequest() { Password = superUser.password, Username = superUser.DbUserModel.UserModel.Username, }); PlayerCurrentGamesResponse adminGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest()); Assert.AreEqual(adminGamesResponse.Status.IsSuccess, true); Assert.AreEqual(1, adminGamesResponse.Games.Count); }
async static Task ExecuteChatUserFlow(this ClientNode node, string roomName) { string name = Guid.NewGuid().ToString(); JoinRoomResponse response = await node.SendRequestAsync <JoinRoomResponse>( new JoinRoom { UserName = name, RoomName = roomName }); if (response.RetCode == JoinRoomRetCode.NameIsTaken) { Console.WriteLine("Name is taken"); return; } Console.WriteLine("You are connected, say something or write 'exit' to quit"); bool exit = false; while (!exit) { await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline string text = Console.ReadLine(); if (text == "exit") { exit = true; } else { node.SendOneWay(new Say { Text = text }); } } }
private void SetPlayingPlayers(JoinRoomResponse resp, Game game) { if (game.state != GameState.BeforeStart && game.state != GameState.WaitForNextRound) { Dictionary <string, string[]> cardsDict = resp.playerCards; foreach (KeyValuePair <string, string[]> pair in cardsDict) { string userId = pair.Key; int seatIndex = game.GetSeatIndex(userId); game.seats [seatIndex].player.isPlaying = true; } } else { for (int i = 0; i < Game.SeatCount; i++) { if (game.seats [i].player != null) { game.seats [i].player.isPlaying = true; } } } }