mirror of
https://github.com/wolfswolke/DeathGarden_API_Rebirth.git
synced 2026-07-18 17:03:48 -05:00
Hopefully fixed all of the bugs in the Matchmaking...
This commit is contained in:
parent
bbb4b9f5e4
commit
7e16a033bc
|
|
@ -164,6 +164,9 @@ def match(matchid_unsanitized):
|
|||
try:
|
||||
response_data = matchmaking_queue.createMatchResponse(matchid)
|
||||
logger.graylog_logger(level="debug", handler="match", message=response_data)
|
||||
if response_data == "null":
|
||||
response_data = matchmaking_queue.getKilledLobbyById(matchid)
|
||||
logger.graylog_logger(level="debug", handler="match", message=response_data)
|
||||
return jsonify(response_data)
|
||||
except Exception as e:
|
||||
logger.graylog_logger(level="error", handler="match", message=e)
|
||||
|
|
@ -182,6 +185,8 @@ def match_kill(matchid_unsanitized):
|
|||
if lobby and matchmaking_queue.isOwner(matchid, userid):
|
||||
response_data = matchmaking_queue.createMatchResponse(matchid, killed=True)
|
||||
matchmaking_queue.deleteMatch(matchid)
|
||||
logger.graylog_logger(level="info", handler="match_kill", message=f"Killed Match: {matchid}"
|
||||
f"by User: {userid}")
|
||||
return jsonify(response_data)
|
||||
|
||||
else:
|
||||
|
|
@ -249,6 +254,31 @@ def match_quit(match_id_unsanitized):
|
|||
return jsonify({"status": "ERROR"}), 500
|
||||
|
||||
|
||||
@app.route("/api/v1/match/<match_id_unsanitized>/Close", methods=["PUT"])
|
||||
def close_lobby(match_id_unsanitized):
|
||||
check_for_game_client("strict")
|
||||
session_cookie = sanitize_input(request.cookies.get("bhvrSession"))
|
||||
userid = session_manager.get_user_id(session_cookie)
|
||||
match_id = sanitize_input(match_id_unsanitized)
|
||||
|
||||
try:
|
||||
lobby, _ = matchmaking_queue.getLobbyById(match_id)
|
||||
|
||||
if lobby:
|
||||
if matchmaking_queue.isOwner(match_id, userid):
|
||||
matchmaking_queue.deleteMatch(match_id)
|
||||
return "", 204
|
||||
else:
|
||||
return jsonify({"message": "Unauthorized"}), 401
|
||||
|
||||
else:
|
||||
return jsonify({"message": "Match not found"}), 404
|
||||
|
||||
except Exception as e:
|
||||
logger.graylog_logger(level="error", handler="close_lobby", message=e)
|
||||
return jsonify({"message": "Internal Server Error"}), 500
|
||||
|
||||
|
||||
@app.route("/api/v1/match/create", methods=["POST"])
|
||||
def match_create():
|
||||
# {'category': 'Steam-te-18f25613-36778-ue4-374f864b', 'region': 'US', 'playersA': [],
|
||||
|
|
@ -316,7 +346,11 @@ def progression_end_of_match():
|
|||
try:
|
||||
players = []
|
||||
for player in request.get_json()["data"]["players"]:
|
||||
players.append({"PlayerId": player["playerId"]})
|
||||
player = player["playerId"]
|
||||
response = {
|
||||
"playerId": player,
|
||||
# What could this struct be????
|
||||
}
|
||||
logger.graylog_logger(level="info", handler="matchmaking_endOfMatch", message=request.get_json())
|
||||
return jsonify({"Players": [
|
||||
{},
|
||||
|
|
@ -387,4 +421,4 @@ def remove_player_from_match(match_id_unsanitized, user_id):
|
|||
return jsonify({"message": "Internal Server Error"}), 500
|
||||
except Exception as e:
|
||||
logger.graylog_logger(level="error", handler="remove_player_from_match", message=e)
|
||||
return jsonify({"message": "Internal Server Error"}), 500
|
||||
return jsonify({"message": "Internal Server Error"}), 500
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ class QueuedPlayer:
|
|||
self.side = side
|
||||
self.lastCheckedForMatch = lastCheckedForMatch
|
||||
|
||||
def __repr__(self):
|
||||
return f"QueuedPlayer(userId={self.userId}, side={self.side}, lastCheckedForMatch={self.lastCheckedForMatch})"
|
||||
|
||||
|
||||
class Lobby:
|
||||
def __init__(self, isReady, host, nonHosts, id, isPrepared, hasStarted):
|
||||
|
|
@ -29,6 +32,7 @@ class Lobby:
|
|||
self.id = id
|
||||
self.isPrepared = isPrepared
|
||||
self.hasStarted = hasStarted
|
||||
self.status = "OPENED"
|
||||
|
||||
|
||||
class KilledLobby:
|
||||
|
|
@ -122,8 +126,15 @@ class MatchmakingQueue:
|
|||
lobby.sessionSettings = sessionSettings
|
||||
return self.createMatchResponse(matchId)
|
||||
|
||||
def closeMatch(self, matchId):
|
||||
lobby, _ = self.getLobbyById(matchId)
|
||||
if lobby:
|
||||
lobby.status = "CLOSED"
|
||||
return self.createMatchResponse(matchId)
|
||||
|
||||
def deleteMatch(self, matchId):
|
||||
lobby, index = self.getLobbyById(matchId)
|
||||
logger.graylog_logger(level="info", handler="deleteMatch", message=f"Deleting Match: {matchId}")
|
||||
if lobby:
|
||||
self.openLobbies.pop(index)
|
||||
current_timestamp, expiration_timestamp = get_time()
|
||||
|
|
@ -146,6 +157,8 @@ class MatchmakingQueue:
|
|||
if not lobby:
|
||||
return {}
|
||||
host = lobby.host
|
||||
if killed:
|
||||
lobby.status = "KILLED"
|
||||
current_timestamp, expiration_timestamp = get_time()
|
||||
try:
|
||||
sessionSettings = lobby.sessionSettings
|
||||
|
|
@ -168,10 +181,10 @@ class MatchmakingQueue:
|
|||
},
|
||||
"rank": 1,
|
||||
"Schema": 3,
|
||||
"sideA": host,
|
||||
"sideA": [host],
|
||||
"sideB": [player.userId for player in lobby.nonHosts],
|
||||
"Players": [host] + [player.userId for player in lobby.nonHosts],
|
||||
"status": "KILLED" if killed else "OPENED"
|
||||
"status": lobby.status
|
||||
}
|
||||
except Exception as e:
|
||||
logger.graylog_logger(level="error", handler="matchmaking_createMatchResponse", message=e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user