Added Matchmaking Website

This commit is contained in:
ZKWolf 2024-02-18 21:50:01 +01:00
parent 0a9e215a9b
commit f9c333cf81
2 changed files with 104 additions and 0 deletions

View File

@ -256,3 +256,53 @@ def updater_script():
return jsonify({"status": "error"})
except Exception as e:
logger.graylog_logger(level="error", handler="web-updater-script", message=e)
@app.route("/debug/MatchMaking", methods=["GET"])
def debug_matchmaking():
len_queue = matchmaking_queue.get_len_of_queue()
len_killed_lobbies = matchmaking_queue.get_len_of_killed_lobbies()
len_queued_runners = matchmaking_queue.get_len_of_queued_runners()
len_queued_hunters = matchmaking_queue.get_len_of_queued_hunters()
len_open_lobbies = matchmaking_queue.get_len_of_open_lobbies()
lobby_data = matchmaking_queue.get_lobby_data()
return render_template('debug/matchmaking.html',
len_queue=len_queue,
len_killed_lobbies=len_killed_lobbies,
len_queued_runners=len_queued_runners,
len_queued_hunters=len_queued_hunters,
len_open_lobbies=len_open_lobbies,
lobby_data=lobby_data)
@app.route("/api/debug/MatchMaking", methods=["GET"])
def api_debug_matchmaking():
len_queue = matchmaking_queue.get_len_of_queue()
len_killed_lobbies = matchmaking_queue.get_len_of_killed_lobbies()
len_queued_runners = matchmaking_queue.get_len_of_queued_runners()
len_queued_hunters = matchmaking_queue.get_len_of_queued_hunters()
len_open_lobbies = matchmaking_queue.get_len_of_open_lobbies()
lobby_data = matchmaking_queue.get_lobby_data()
lobby_return_data = []
for item in lobby_data:
# Hunters needs to be changed from STRING to LIST some day
lobby_info = {
"id": item.id,
"Hunters": 1,
"Runners": len(item.nonHosts),
"status": item.status
}
lobby_return_data.append(lobby_info)
return jsonify({
"len_queue": len_queue,
"len_killed_lobbies": len_killed_lobbies,
"len_queued_runners": len_queued_runners,
"len_queued_hunters": len_queued_hunters,
"len_open_lobbies": len_open_lobbies,
"lobby_data": lobby_return_data
})

View File

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Matchmaking Debug</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Matchmaking Debug Information</h1>
<p><strong>Length of Queue:</strong> {{ len_queue }}</p>
<p><strong>Killed Lobbies:</strong> {{ len_killed_lobbies }}</p>
<p><strong>Queued Runners:</strong> {{ len_queued_runners }}</p>
<p><strong>Queued Hunters:</strong> {{ len_queued_hunters }}</p>
<p><strong>Open Lobbies:</strong> {{ len_open_lobbies }}</p>
<h2>Lobby Data</h2>
<table>
<tr>
<th>Lobby ID</th>
<th>Hunters</th>
<th>Runners</th>
<th>Status</th>
</tr>
{% for lobby in lobby_data %}
<tr>
<td>{{ lobby.id }}</td>
<td>{{ lobby.host }}</td>
<td>
<ul>
{% for runner in lobby.nonHosts %}
<li>{{ runner.userId }}</li>
{% endfor %}
</ul>
</td>
<td>{{ lobby.status }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>