public void Setup() { client = ClientHelper.GetClient(); // Clear the database every test. RedisConnector.Server.FlushDatabase(); // Create two new user accounts. authHelper = new AuthTestHelper(client); authHelper.createAccount(playerOneInGame); authHelper.createAccount(playerTwoInGame); authHelper.createAccount(playerThreeInGame); authHelper.createAccount(playerOutOfGame); authHelper.loginToAccount(playerOneInGame); gameId = client.CreateNewRoom(new CreateRoomRequest() { MaxPlayers = 3, RoomName = "TestRoom", MinutesPerTick = (1.0 / 60.0), // One second per tick }).CreatedRoom.RoomId; authHelper.loginToAccount(playerTwoInGame); client.JoinRoom(new JoinRoomRequest() { RoomId = gameId }); authHelper.loginToAccount(playerThreeInGame); client.JoinRoom(new JoinRoomRequest() { RoomId = gameId }); // Game has begun. authHelper.loginToAccount(playerOneInGame); }
public void Setup() { client = ClientHelper.GetClient(); // Clear the database every test. MongoConnector.FlushCollections(); // Create two new user accounts. authHelper = new AuthTestHelper(client); authHelper.createAccount(playerOneInGame); authHelper.createAccount(playerTwoInGame); authHelper.createAccount(playerThreeInGame); authHelper.createAccount(playerOutOfGame); authHelper.loginToAccount(playerOneInGame); gameId = client.CreateNewRoom(new CreateRoomRequest() { GameSettings = new GameSettings() { Anonymous = false, Goal = Goal.Domination, IsRanked = false, MaxPlayers = 3, MinutesPerTick = (1.0 / 60.0), // One second per tick }, RoomName = "TestRoom", MapConfiguration = new MapConfiguration() { Seed = 123123, OutpostsPerPlayer = 3, MinimumOutpostDistance = 100, MaximumOutpostDistance = 1200, DormantsPerPlayer = 3, OutpostDistribution = new OutpostWeighting() { FactoryWeight = 0.33f, GeneratorWeight = 0.33f, WatchtowerWeight = 0.33f, } }, }).CreatedRoom.Id; authHelper.loginToAccount(playerTwoInGame); client.JoinRoom(new JoinRoomRequest() { RoomId = gameId }); authHelper.loginToAccount(playerThreeInGame); client.JoinRoom(new JoinRoomRequest() { RoomId = gameId }); // Game has begun. authHelper.loginToAccount(playerOneInGame); }
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 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"))); }