mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2026-11-09 17:57:06 +01:00
Merge branch 'adrien' of github.com:AudebertAdrien/ft_transcendence into trash
This commit is contained in:
@@ -40,7 +40,7 @@ class MatchMaker:
|
||||
await asyncio.sleep(1)
|
||||
self.timer += 1
|
||||
# Waiting for more than 30s -> BOT game
|
||||
if self.timer >= 30 and self.waiting_players:
|
||||
if self.timer >= 15 and self.waiting_players:
|
||||
player1 = self.waiting_players.pop(0)
|
||||
print(f"*** MATCH FOUND: {player1.user.username} vs BOT")
|
||||
self.botgame = True
|
||||
@@ -112,4 +112,4 @@ class MatchMaker:
|
||||
match_maker = MatchMaker()
|
||||
|
||||
# to get what you want use get_player_p_win(player_name) !! (voir utils.py)
|
||||
#
|
||||
#
|
||||
|
||||
@@ -6,8 +6,9 @@ Django settings for pong project.
|
||||
Generated by 'django-admin startproject' using Django 3.2.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
import logging.config
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@@ -136,18 +137,36 @@ CHANNEL_LAYERS = {
|
||||
}
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'version': 1, # The version of the logging configuration schema
|
||||
'disable_existing_loggers': False, # Allows existing loggers to keep logging
|
||||
'formatters': { # Defines how log messages will be formatted
|
||||
'json': {
|
||||
'()': 'pythonjsonlogger.jsonlogger.JsonFormatter',
|
||||
# Formatter that outputs logs in JSON format, which is ideal for ingestion by Logstash.
|
||||
},
|
||||
'default': {
|
||||
'format': '[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s',
|
||||
# This is a basic text formatter with timestamp, log level, logger name, line number, and the actual message.
|
||||
},
|
||||
},
|
||||
'handlers': { # Handlers determine where the log messages are sent
|
||||
'file': {
|
||||
'level': 'INFO', # Minimum log level to be handled (INFO and above)
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_DIR, 'logs/django.log'), # The file where logs will be saved
|
||||
'formatter': 'json', # Uses the JSON formatter defined above
|
||||
},
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'level': 'DEBUG', # Minimum log level to be handled (DEBUG and above)
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'default', # Uses the default text formatter
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['console'],
|
||||
'level': 'DEBUG',
|
||||
'loggers': { # Loggers are the actual log streams that get configured
|
||||
'django': { # The Django logger catches all messages sent by the Django framework
|
||||
'handlers': ['file', 'console'], # Sends logs to both the file and the console
|
||||
'level': 'DEBUG', # Minimum log level to be logged
|
||||
'propagate': True, # If True, messages will be passed to the parent loggers as well
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,28 +557,31 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const matchListBody = document.querySelector('#match-list tbody');
|
||||
matchListBody.innerHTML = '';
|
||||
|
||||
if (matches.length === 0) {
|
||||
console.log('No matches to display');
|
||||
}
|
||||
|
||||
matches.forEach(match => {
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td>${match.id}</td>
|
||||
<td>${match.player1__name}</td>
|
||||
<td>${match.player2__name}</td>
|
||||
<td>${match.score_player1}</td>
|
||||
<td>${match.score_player2}</td>
|
||||
<td>${match.winner__name}</td>
|
||||
<td>${match.nbr_ball_touch_p1}</td>
|
||||
<td>${match.nbr_ball_touch_p2}</td>
|
||||
<td>${match.duration}</td>
|
||||
<td>${match.date}</td>
|
||||
<td>${match.is_tournoi}</td>
|
||||
<td>${match.tournoi__name}</td>
|
||||
`;
|
||||
matchListBody.appendChild(row);
|
||||
});
|
||||
const row = document.createElement('tr');
|
||||
if (matches.length != 0) {
|
||||
matches.forEach(match => {
|
||||
row.innerHTML = `
|
||||
<td>${match.id}</td>
|
||||
<td>${match.player1__name}</td>
|
||||
<td>${match.player2__name}</td>
|
||||
<td>${match.score_player1}</td>
|
||||
<td>${match.score_player2}</td>
|
||||
<td>${match.winner__name}</td>
|
||||
<td>${match.nbr_ball_touch_p1}</td>
|
||||
<td>${match.nbr_ball_touch_p2}</td>
|
||||
<td>${match.duration}</td>
|
||||
<td>${match.date}</td>
|
||||
<td>${match.is_tournoi}</td>
|
||||
<td>${match.tournoi__name}</td>
|
||||
`;
|
||||
matchListBody.appendChild(row);
|
||||
});
|
||||
} else {
|
||||
row.innerHTML = `
|
||||
<td colspan="12">No matches found.</td>
|
||||
`;
|
||||
matchListBody.appendChild(row);
|
||||
}
|
||||
}
|
||||
|
||||
function displayPlayers(players) {
|
||||
@@ -586,51 +589,58 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const playersListBody = document.querySelector('#player-list tbody');
|
||||
playersListBody.innerHTML = '';
|
||||
|
||||
if (players.length === 0) {
|
||||
console.log('No players to display');
|
||||
}
|
||||
const row = document.createElement('tr');
|
||||
if (players.length != 0) {
|
||||
players.forEach(player => {
|
||||
row.innerHTML = `
|
||||
<td>${player.id}</td>
|
||||
<td>${player.name}</td>
|
||||
<td>${player.total_match}</td>
|
||||
<td>${player.total_win}</td>
|
||||
<td>${player.p_win}</td>
|
||||
<td>${player.m_score_match}</td>
|
||||
<td>${player.m_score_adv_match}</td>
|
||||
<td>${player.best_score}</td>
|
||||
<td>${player.m_nbr_ball_touch}</td>
|
||||
<td>${player.total_duration}</td>
|
||||
<td>${player.m_duration}</td>
|
||||
<td>${player.num_participated_tournaments}</td>
|
||||
<td>${player.num_won_tournaments}</td>
|
||||
`;
|
||||
playersListBody.appendChild(row);
|
||||
});
|
||||
} else {
|
||||
row.innerHTML = `
|
||||
<td colspan="12">No matches found.</td>
|
||||
`
|
||||
playersListBody.appendChild(row);
|
||||
}
|
||||
}
|
||||
|
||||
players.forEach(player => {
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td>${player.id}</td>
|
||||
<td>${player.name}</td>
|
||||
<td>${player.total_match}</td>
|
||||
<td>${player.total_win}</td>
|
||||
<td>${player.p_win}</td>
|
||||
<td>${player.m_score_match}</td>
|
||||
<td>${player.m_score_adv_match}</td>
|
||||
<td>${player.best_score}</td>
|
||||
<td>${player.m_nbr_ball_touch}</td>
|
||||
<td>${player.total_duration}</td>
|
||||
<td>${player.m_duration}</td>
|
||||
<td>${player.num_participated_tournaments}</td>
|
||||
<td>${player.num_won_tournaments}</td>
|
||||
`;
|
||||
playersListBody.appendChild(row);
|
||||
});
|
||||
}
|
||||
function displayTournois(tournois) {
|
||||
console.log('Displaying tournois:');
|
||||
const tournoisListBody = document.querySelector('#tournoi-list tbody');
|
||||
tournoisListBody.innerHTML = '';
|
||||
|
||||
function displayTournois(tournois) {
|
||||
console.log('Displaying tournois:');
|
||||
const tournoisListBody = document.querySelector('#tournoi-list tbody');
|
||||
tournoisListBody.innerHTML = '';
|
||||
|
||||
if (tournois.length === 0) {
|
||||
console.log('No tournois to display');
|
||||
}
|
||||
|
||||
tournois.forEach(tournoi => {
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td>${tournoi.id}</td>
|
||||
<td>${tournoi.name}</td>
|
||||
<td>${tournoi.nbr_player}</td>
|
||||
<td>${tournoi.date}</td>
|
||||
<td>${tournoi.winner.name}</td>
|
||||
`;
|
||||
tournoisListBody.appendChild(row);
|
||||
});
|
||||
const row = document.createElement('tr');
|
||||
if (tournois.length != 0) {
|
||||
tournois.forEach(tournoi => {
|
||||
row.innerHTML = `
|
||||
<td>${tournoi.id}</td>
|
||||
<td>${tournoi.name}</td>
|
||||
<td>${tournoi.nbr_player}</td>
|
||||
<td>${tournoi.date}</td>
|
||||
<td>${tournoi.winner.name}</td>
|
||||
`;
|
||||
tournoisListBody.appendChild(row);
|
||||
});
|
||||
} else {
|
||||
row.innerHTML = `
|
||||
<td colspan="12">No matches found.</td>
|
||||
`
|
||||
tournoisListBody.appendChild(row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////// END BURGER BUTTON ////////////////////////////////
|
||||
|
||||
@@ -144,27 +144,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for match in matches %}
|
||||
<tr>
|
||||
<td>{{ match.id }}</td>
|
||||
<td>{{ match.player1.name }}</td>
|
||||
<td>{{ match.player2.name }}</td>
|
||||
<td>{{ match.score_player1 }}</td>
|
||||
<td>{{ match.score_player2 }}</td>
|
||||
<td>{{ match.winner.name }}</td>
|
||||
<td>{{ match.nbr_ball_touch_p1 }}</td>
|
||||
<td>{{ match.nbr_ball_touch_p2 }}</td>
|
||||
<td>{{ match.duration }}</td>
|
||||
<td>{{ match.date }}</td>
|
||||
<td>{{ match.is_tournoi }}</td>
|
||||
<td>{{ match.tournoi.name }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="12">No matches found.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -189,28 +169,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for player in players %}
|
||||
<tr>
|
||||
<td>{{ player.id }}</td>
|
||||
<td>{{ player.name }}</td>
|
||||
<td>{{ player.total_match }}</td>
|
||||
<td>{{ player.total_win }}</td>
|
||||
<td>{{ player.p_win }}</td>
|
||||
<td>{{ player.m_score_match }}</td>
|
||||
<td>{{ player.m_score_adv_match }}</td>
|
||||
<td>{{ player.best_score }}</td>
|
||||
<td>{{ player.m_nbr_ball_touch }}</td>
|
||||
<td>{{ player.total_duration }}</td>
|
||||
<td>{{ player.m_duration }}</td>
|
||||
<td>{{ player.num_participated_tournaments }}</td>
|
||||
<td>{{ player.num_won_tournaments }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="13">No players found.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -226,21 +185,8 @@
|
||||
<th>Winner</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for tournoi in tournois %}
|
||||
<tr>
|
||||
<td>{{ tournoi.id }}</td>
|
||||
<td>{{ tournoi.name }}</td>
|
||||
<td>{{ tournoi.nbr_player }}</td>
|
||||
<td>{{ tournoi.date }}</td>
|
||||
<td>{{ tournoi.winner.name }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="14">No tournois found.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user