Skip to content

Commit bae3b3d

Browse files
committed
Revert "End Game Screen (#14)"
This reverts commit 6e4275c.
1 parent be7cd30 commit bae3b3d

File tree

7 files changed

+93
-239
lines changed

7 files changed

+93
-239
lines changed

EvoS.Framework/Misc/ServerGameMetrics.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

EvoS.Framework/Network/Static/LobbyPlayerInfo.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public LobbyPlayerInfo Clone()
1515

1616
public bool ReplacedWithBots { get; set; }
1717

18-
public static LobbyPlayerInfo FromServer(LobbyServerPlayerInfo serverInfo,
18+
public static LobbyPlayerInfo FromServer(LobbyServerPlayerInfo serverInfo, int maxPlayerLevel,
1919
MatchmakingQueueConfig queueConfig)
2020
{
2121
LobbyPlayerInfo lobbyPlayerInfo = null;
@@ -57,6 +57,22 @@ public static LobbyPlayerInfo FromServer(LobbyServerPlayerInfo serverInfo,
5757
((!serverInfo.IsRemoteControlled) ? 0 : serverInfo.ControllingPlayerInfo.PlayerId),
5858
EffectiveClientAccessLevel = serverInfo.EffectiveClientAccessLevel
5959
};
60+
if (serverInfo.AccountLevel >= maxPlayerLevel)
61+
{
62+
// lobbyPlayerInfo.DisplayedStat = LocalizationPayload.Create("TotalSeasonLevelStatNumber", "Global",
63+
// new LocalizationArg[]
64+
// {
65+
// LocalizationArg_Int32.Create(serverInfo.TotalLevel)
66+
// });
67+
}
68+
else
69+
{
70+
// lobbyPlayerInfo.DisplayedStat = LocalizationPayload.Create("LevelStatNumber", "Global",
71+
// new LocalizationArg[]
72+
// {
73+
// LocalizationArg_Int32.Create(serverInfo.AccountLevel)
74+
// });
75+
}
6076
}
6177

6278
return lobbyPlayerInfo;

EvoS.Framework/Network/Static/LobbyTeamInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public IEnumerable<LobbyPlayerInfo> TeamInfo(Team team)
3535
select p;
3636
}
3737

38-
public static LobbyTeamInfo FromServer(LobbyServerTeamInfo serverInfo,
38+
public static LobbyTeamInfo FromServer(LobbyServerTeamInfo serverInfo, int maxPlayerLevel,
3939
MatchmakingQueueConfig queueConfig)
4040
{
4141
LobbyTeamInfo lobbyTeamInfo = null;
@@ -47,7 +47,8 @@ public static LobbyTeamInfo FromServer(LobbyServerTeamInfo serverInfo,
4747
lobbyTeamInfo.TeamPlayerInfo = new List<LobbyPlayerInfo>();
4848
foreach (LobbyServerPlayerInfo serverInfo2 in serverInfo.TeamPlayerInfo)
4949
{
50-
lobbyTeamInfo.TeamPlayerInfo.Add(LobbyPlayerInfo.FromServer(serverInfo2, queueConfig));
50+
lobbyTeamInfo.TeamPlayerInfo.Add(LobbyPlayerInfo.FromServer(serverInfo2, maxPlayerLevel,
51+
queueConfig));
5152
}
5253
}
5354
}

LobbyServer2/BridgeServer/BridgeServerProtocol.cs

Lines changed: 21 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5-
using System.Threading;
6-
using System.Threading.Tasks;
75
using CentralServer.LobbyServer;
86
using CentralServer.LobbyServer.Session;
97
using EvoS.Framework.Constants.Enums;
10-
using EvoS.Framework.Logging;
118
using EvoS.Framework.Misc;
129
using EvoS.Framework.Network.NetworkMessages;
1310
using EvoS.Framework.Network.Static;
1411
using EvoS.Framework.Network.Unity;
1512
using log4net;
16-
using MongoDB.Bson;
17-
using Org.BouncyCastle.Asn1.Ocsp;
1813
using WebSocketSharp;
1914
using WebSocketSharp.Server;
20-
using ILog = log4net.ILog;
2115

2216
namespace CentralServer.BridgeServer
2317
{
@@ -62,7 +56,7 @@ public IEnumerable<long> GetPlayers()
6256
null, // typeof(MonitorHeartbeatResponse),
6357
typeof(ServerGameSummaryNotification),
6458
typeof(PlayerDisconnectedNotification),
65-
typeof(ServerGameMetricsNotification),
59+
null, // typeof(ServerGameMetricsNotification),
6660
typeof(ServerGameStatusNotification),
6761
null, // typeof(MonitorHeartbeatNotification),
6862
null, // typeof(LaunchGameResponse),
@@ -104,70 +98,51 @@ protected override void HandleMessage(MessageEventArgs e)
10498
ServerManager.AddServer(this);
10599

106100
Send(new RegisterGameServerResponse
107-
{
108-
Success = true
109-
},
101+
{
102+
Success = true
103+
},
110104
callbackId);
111105
}
112106
else if (type == typeof(ServerGameSummaryNotification))
113107
{
114108
ServerGameSummaryNotification request = Deserialize<ServerGameSummaryNotification>(networkReader);
115-
116109
log.Debug($"< {request.GetType().Name} {DefaultJsonSerializer.Serialize(request)}");
117-
log.Info($"Game {GameInfo.Name} finished ");
118-
119-
List<BadgeAndParticipantInfo> badges;
120-
if (request.GameSummary != null)
121-
{
122-
log.Info($"({request.GameSummary.NumOfTurns} turns), " +
123-
$"{request.GameSummary.GameResult} {request.GameSummary.TeamAPoints}-{request.GameSummary.TeamBPoints}");
124-
badges = request.GameSummary.BadgeAndParticipantsInfo;
125-
}
126-
else
127-
{
128-
log.Error("Received null GameSummary. stub");
129-
badges = new List<BadgeAndParticipantInfo>();
130-
}
131-
110+
log.Info($"Game {GameInfo.Name} at {request.GameSummary.GameServerAddress} finished " +
111+
$"({request.GameSummary.NumOfTurns} turns), " +
112+
$"{request.GameSummary.GameResult} {request.GameSummary.TeamAPoints}-{request.GameSummary.TeamBPoints}");
132113
foreach (LobbyServerProtocolBase client in clients)
133114
{
134115
MatchResultsNotification response = new MatchResultsNotification
135116
{
136-
BadgeAndParticipantsInfo = badges,
137-
BaseXpGained = 100,
138-
CurrencyRewards = new List<MatchResultsNotification.CurrencyReward>()
117+
// TODO
118+
BadgeAndParticipantsInfo = request.GameSummary.BadgeAndParticipantsInfo
139119
};
140120
client.Send(response);
141121
}
142-
if (request.GameSummary != null)
143-
{
144-
GameInfo.GameResult = request.GameSummary.GameResult;
145-
}
146-
else
147-
{
148-
// default value
149-
GameInfo.GameResult = GameResult.TieGame;
150-
}
151-
152-
UpdateGameInfoToPlayers();
122+
123+
Send(new ShutdownGameRequest());
153124
}
154125
else if (type == typeof(PlayerDisconnectedNotification))
155126
{
156127
PlayerDisconnectedNotification request = Deserialize<PlayerDisconnectedNotification>(networkReader);
157128
log.Debug($"< {request.GetType().Name} {DefaultJsonSerializer.Serialize(request)}");
158129
log.Info($"Player {request.PlayerInfo.AccountId} left game {GameInfo.GameServerProcessCode}");
159-
160-
OnPlayerDisconnected(request.PlayerInfo.AccountId);
161130

131+
foreach (LobbyServerProtocol client in clients)
132+
{
133+
if (client.AccountId == request.PlayerInfo.AccountId)
134+
{
135+
client.CurrentServer = null;
136+
break;
137+
}
138+
}
162139
}
163140
else if (type == typeof(ServerGameStatusNotification))
164141
{
165142
ServerGameStatusNotification request = Deserialize<ServerGameStatusNotification>(networkReader);
166143
log.Debug($"< {request.GetType().Name} {DefaultJsonSerializer.Serialize(request)}");
167144
log.Info($"Game {GameInfo.Name} {request.GameStatus}");
168-
169-
UpdateGameStatus(request.GameStatus, true);
170-
145+
GameStatus = request.GameStatus;
171146
if (GameStatus == GameStatus.Stopped)
172147
{
173148
foreach (LobbyServerProtocol client in clients)
@@ -176,14 +151,6 @@ protected override void HandleMessage(MessageEventArgs e)
176151
}
177152
}
178153
}
179-
else if (type == typeof(ServerGameMetricsNotification))
180-
{
181-
ServerGameMetricsNotification request = Deserialize<ServerGameMetricsNotification>(networkReader);
182-
if (request.GameMetrics != null)
183-
{
184-
log.Debug($"Game {GameInfo.Name} is on turn {request.GameMetrics.CurrentTurn} with score {request.GameMetrics.TeamAPoints}/{request.GameMetrics.TeamBPoints}");
185-
}
186-
}
187154
else
188155
{
189156
log.Warn($"Received unhandled bridge message type {(type != null ? type.Name : "id_" + messageType)}");
@@ -275,95 +242,5 @@ public short GetMessageType(AllianceMessageBase msg)
275242

276243
return num;
277244
}
278-
279-
public void UpdateGameStatus(GameStatus status, bool notify = false)
280-
{
281-
// Update GameInfo's GameStatus
282-
GameStatus = status;
283-
GameInfo.GameStatus = status;
284-
285-
// If status is not None, notify players of the change
286-
if (status == GameStatus.None || !notify) return;
287-
GameStatusNotification notification = new GameStatusNotification() { GameStatus = status};
288-
289-
foreach (long player in GetPlayers())
290-
{
291-
LobbyServerProtocol playerConnection = SessionManager.GetClientConnection(player);
292-
if (playerConnection != null)
293-
{
294-
playerConnection.Send(notification);
295-
}
296-
}
297-
}
298-
299-
public void UpdateGameInfoToPlayers()
300-
{
301-
foreach(long player in GetPlayers())
302-
{
303-
GameInfoNotification notification = new GameInfoNotification()
304-
{
305-
GameInfo = this.GameInfo,
306-
TeamInfo = LobbyTeamInfo.FromServer(this.TeamInfo, new MatchmakingQueueConfig()),
307-
PlayerInfo = LobbyPlayerInfo.FromServer(SessionManager.GetPlayerInfo(player), new MatchmakingQueueConfig())
308-
};
309-
LobbyServerProtocol playerConnection = SessionManager.GetClientConnection(player);
310-
if (playerConnection != null)
311-
{
312-
playerConnection.Send(notification);
313-
}
314-
}
315-
}
316-
317-
public void OnPlayerUsedGGPack(long accountId)
318-
{
319-
int ggPackUsedAccountIDs = 0;
320-
GameInfo.ggPackUsedAccountIDs.TryGetValue(accountId, out ggPackUsedAccountIDs);
321-
GameInfo.ggPackUsedAccountIDs[accountId] = ggPackUsedAccountIDs + 1;
322-
323-
UpdateGameInfoToPlayers();
324-
}
325-
326-
public void OnPlayerDisconnected(long accountId)
327-
{
328-
LobbyServerProtocol clientToRemove = null;
329-
330-
foreach (LobbyServerProtocol client in clients)
331-
{
332-
if (client.AccountId == accountId)
333-
{
334-
client.CurrentServer = null;
335-
clientToRemove = client;
336-
break;
337-
}
338-
}
339-
340-
if (clientToRemove != null)
341-
{
342-
clients.Remove(clientToRemove);
343-
clientToRemove.CurrentServer = null;
344-
345-
GameStatusNotification notify = new GameStatusNotification()
346-
{
347-
GameServerProcessCode = ProcessCode,
348-
GameStatus = GameStatus.Stopped // TODO check if there is a better way to make client leave mid-game
349-
};
350-
351-
/*
352-
* TODO: This seems to disconnect the player from the server
353-
2019-04-29 17:52:13.373+03:00 [INF] Received Game Assignment Notification (assigned=True assigning=False reassigning=False)
354-
2019-04-29 17:52:13.373+03:00 [INF] Unassigned from game 0a101c39-5cc7-077f (wss://208.94.25.140:6148) [RobotFactory_Deathmatch PvP GenericPvP]
355-
*/
356-
clientToRemove.Send(notify);
357-
}
358-
359-
360-
if (clients.Count == 0)
361-
{
362-
log.Info("No more players in game server. Sending shutdown request");
363-
Send(new ShutdownGameRequest());
364-
}
365-
}
366-
367-
368245
}
369246
}

LobbyServer2/BridgeServer/Messages/ServerGameMetricsNotification.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

LobbyServer2/LobbyServer/LobbyServerProtocol.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public void HandlePlayerInfoUpdateRequest(PlayerInfoUpdateRequest request)
331331

332332
PlayerInfoUpdateResponse response = new PlayerInfoUpdateResponse()
333333
{
334-
PlayerInfo = LobbyPlayerInfo.FromServer(playerInfo, new MatchmakingQueueConfig()),
334+
PlayerInfo = LobbyPlayerInfo.FromServer(playerInfo, 0, new MatchmakingQueueConfig()),
335335
CharacterInfo = playerInfo.CharacterInfo,
336336
OriginalPlayerInfoUpdate = update,
337337
ResponseId = request.RequestId
@@ -408,7 +408,14 @@ public void HandleLeaveGameRequest(LeaveGameRequest request)
408408

409409
if (CurrentServer != null)
410410
{
411-
CurrentServer.OnPlayerDisconnected(AccountId);
411+
CurrentServer.clients.Remove(this);
412+
GameStatusNotification notify = new GameStatusNotification()
413+
{
414+
GameServerProcessCode = CurrentServer.ProcessCode,
415+
GameStatus = GameStatus.Stopped // TODO check if there is a better way to make client leave mid-game
416+
};
417+
Send(notify);
418+
CurrentServer = null; // we will probably want to save it somewhere for reconnection
412419
}
413420
}
414421

@@ -772,8 +779,6 @@ public void HandleUseGGPackRequest(UseGGPackRequest request)
772779
client.Send(useGGPackNotification);
773780
}
774781
}
775-
776-
CurrentServer.OnPlayerUsedGGPack(AccountId);
777782
}
778783
}
779784

0 commit comments

Comments
 (0)