mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2026-11-09 18:17:07 +01:00
thrashfer
This commit is contained in:
@@ -169,11 +169,6 @@ class ChatConsumer(AsyncWebsocketConsumer):
|
||||
|
||||
logger.info(f"Message reçu: {data}")
|
||||
|
||||
if not username:
|
||||
logger.error(f"Username manquant dans le message: {data}")
|
||||
await self.chat_message('error', 'server', 'Username is missing', self.room_group_name)
|
||||
return
|
||||
|
||||
# Gestion des différents types de messages
|
||||
if message_type == 'authenticate':
|
||||
logger.info(f"Authentification demandée pour {username}")
|
||||
@@ -259,6 +254,43 @@ class ChatConsumer(AsyncWebsocketConsumer):
|
||||
'type': 'block_user',
|
||||
'message': f'Vous avez bloqué les messages de {target_user}'
|
||||
}))
|
||||
|
||||
async def handle_invite_user(self, data):
|
||||
# Récupération des informations de l'invitation
|
||||
inviter = data.get('username')
|
||||
target_user = data.get('target_user')
|
||||
room = data.get('room')
|
||||
|
||||
# Validation des paramètres
|
||||
if not inviter:
|
||||
logger.error("Invitant manquant dans le message d'invitation")
|
||||
await self.chat_message('error', 'server', 'Invitant manquant', self.room_group_name)
|
||||
return
|
||||
|
||||
if not target_user:
|
||||
logger.error("Utilisateur cible manquant dans le message d'invitation")
|
||||
await self.chat_message('error', 'server', 'Utilisateur cible manquant', self.room_group_name)
|
||||
return
|
||||
|
||||
if not room:
|
||||
logger.error("Room manquante dans le message d'invitation")
|
||||
await self.chat_message('error', 'server', 'Room manquante', self.room_group_name)
|
||||
return
|
||||
|
||||
logger.info(f"Invitation envoyée de {inviter} à {target_user} dans la room {room}")
|
||||
await self.chat_message('chat_message', 'server', f'{inviter} a invité {target_user} à rejoindre une partie {room}', room)
|
||||
|
||||
# Envoi de l'invitation
|
||||
await self.channel_layer.group_send(
|
||||
room,
|
||||
{
|
||||
'type': 'invite',
|
||||
'inviter': inviter,
|
||||
'target_user': target_user,
|
||||
'room': room,
|
||||
'message': f'{inviter} vous a invité à rejoindre la room {room}.'
|
||||
}
|
||||
)
|
||||
|
||||
# Méthode appelée pour envoyer l'invitation à l'utilisateur invité (target_user)
|
||||
async def invite(self, event):
|
||||
|
||||
@@ -185,7 +185,7 @@ class TournamentMatchMaker:
|
||||
asyncio.create_task(match.start_game())
|
||||
elif match.player1:
|
||||
# Gestion du BYE
|
||||
match_message = f"Prochain match: {match.player1.user.username} contre Bot"
|
||||
message = f"Prochain match: {match.player1.user.username} contre Bot"
|
||||
await self.send_to_player(match.player1, {'type': 'tournament_match', 'message': message})
|
||||
await match_maker.notify_players(match.player1, match.player2, match.game_id, False)
|
||||
match.game_state['player1_score'] = 3
|
||||
|
||||
@@ -614,6 +614,47 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
starsContainer.appendChild(star);
|
||||
}
|
||||
|
||||
const homeButton = document.getElementById('home');
|
||||
const replayButton = document.getElementById('retry');
|
||||
const gameControls = document.getElementById('game-controls');
|
||||
|
||||
homeButton.addEventListener('click', () => {
|
||||
gameContainer.style.display = 'none';
|
||||
gameControls.style.display = 'none';
|
||||
|
||||
logo.style.display = 'block'
|
||||
|
||||
formBlock.style.display = 'block';
|
||||
postFormButtons.style.display = 'flex';
|
||||
|
||||
setupFirstPlayer();
|
||||
});
|
||||
|
||||
function setupFirstPlayer() {
|
||||
const firstPlayerName = window.firstPlayerName;
|
||||
document.getElementById('player1-name').textContent = firstPlayerName;
|
||||
}
|
||||
|
||||
replayButton.addEventListener('click', () => {
|
||||
document.getElementById('player1-name').textContent = saveData.player1_name;
|
||||
document.getElementById('player2-name').textContent = saveData.player2_name;
|
||||
startLocalGame2();
|
||||
});
|
||||
|
||||
function checkForWinner() {
|
||||
if (gameState.player1_score === 3 || gameState.player2_score === 3) {
|
||||
if (saveData.type != "tournoi"){
|
||||
gameControls.style.display = 'flex';
|
||||
homeButton.style.display = 'block';
|
||||
replayButton.style.display = 'none';
|
||||
console.log(saveData.type);
|
||||
if (saveData.type === 'local'){
|
||||
replayButton.style.display = 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Détection de la commande /s username
|
||||
function sendStatsCommand(targetUser) {
|
||||
console.log(`Detected stats command for user: ${targetUser}`);
|
||||
|
||||
@@ -216,8 +216,6 @@
|
||||
</div>
|
||||
|
||||
<div id="chat-controls">
|
||||
<!-- Autres éléments du chat -->
|
||||
<button id="quit-room-btn">Quitter la room</button>
|
||||
<button id="show-chat">Afficher le Chat</button>
|
||||
<button id="hide-chat">Masquer le Chat</button>
|
||||
</div>
|
||||
@@ -320,20 +318,6 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const starsContainer = document.getElementById('stars');
|
||||
for (let i = 0; i < 500; i++) {
|
||||
const star = document.createElement('div');
|
||||
star.className = 'star';
|
||||
star.style.width = `${Math.random() * 3}px`;
|
||||
star.style.height = star.style.width;
|
||||
star.style.left = `${Math.random() * 100}%`;
|
||||
star.style.top = `${Math.random() * 100}%`;
|
||||
star.style.animationDuration = `${Math.random() * 2 + 1}s`;
|
||||
starsContainer.appendChild(star);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -702,20 +702,3 @@ canvas {
|
||||
transform: translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#quit-room-btn, #show-chat-btn {
|
||||
display: inline-block;
|
||||
padding: 5px 10px;
|
||||
margin: 5px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#quit-room-btn:hover, #show-chat-btn:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
Reference in New Issue
Block a user