diff --git a/.env b/.env index 4ecdb09..41d604b 100644 --- a/.env +++ b/.env @@ -11,5 +11,5 @@ POSTGRES_PASSWORD=qwerty DB_HOST=db DB_PORT=5432 -PROJECT_PATH=${PWD}/pong -POSTGRES_DATA_PATH=${PWD}/data/db \ No newline at end of file +PROJECT_PATH=/home/mchiboub/42cursus/transcendence/pong +POSTGRES_DATA_PATH=/home/mchiboub/42cursus/transcendence/data/db \ No newline at end of file diff --git a/makefile b/makefile index b662bde..f84c03f 100644 --- a/makefile +++ b/makefile @@ -28,8 +28,6 @@ destroy: logs: $(COMPOSE) logs -f $(CONTAINER) -re: destroy up - ps: $(COMPOSE) ps diff --git a/pong/game/game.py b/pong/game/game.py index ea2a5a6..5ceecb8 100644 --- a/pong/game/game.py +++ b/pong/game/game.py @@ -126,9 +126,13 @@ class Game: # Check for scoring if self.game_state['ball_position']['x'] <= 10: self.game_state['player2_score'] += 1 + if self.game_state['player2_score'] >= 5: + self.end_game() self.reset_ball() elif self.game_state['ball_position']['x'] >= 790: self.game_state['player1_score'] += 1 + if self.game_state['player1_score'] >= 5: + self.end_game() self.reset_ball() def reset_ball(self): diff --git a/pong/game/matchmaking.py b/pong/game/matchmaking.py index fe6504c..28b8dda 100644 --- a/pong/game/matchmaking.py +++ b/pong/game/matchmaking.py @@ -40,7 +40,7 @@ class MatchMaker: await asyncio.sleep(1) self.timer += 1 # Waiting for more than 30s -> BOT game - if self.timer >= 3 and self.waiting_players: + if self.timer >= 30 and self.waiting_players: player1 = self.waiting_players.pop(0) print(f"*** MATCH FOUND: {player1.user.username} vs BOT") self.botgame = True diff --git a/pong/static/game.js b/pong/static/game.js index 60bc1d4..380d21b 100644 --- a/pong/static/game.js +++ b/pong/static/game.js @@ -20,6 +20,8 @@ document.addEventListener('DOMContentLoaded', () => { const matchList = document.getElementById('match-list'); const dropdownMenu = document.getElementById('dropdown-menu'); + const pongElements = document.getElementById('pong-elements'); + const logo = document.querySelector('.logo'); let socket; let token; @@ -103,6 +105,8 @@ document.addEventListener('DOMContentLoaded', () => { registerForm.style.display = 'none'; gameContainer.style.display = 'flex'; formBlock.style.display = 'none'; + logo.style.display = 'none'; + pongElements.style.display = 'none'; startWebSocketConnection(token); } else { alert('Registration failed. Please try again.'); @@ -139,6 +143,8 @@ document.addEventListener('DOMContentLoaded', () => { loginForm.style.display = 'none'; gameContainer.style.display = 'flex'; formBlock.style.display = 'none'; + logo.style.display = 'none'; + pongElements.style.display = 'none'; startWebSocketConnection(token); } else { alert('Authentication failed. Please try again.'); diff --git a/pong/static/index.html b/pong/static/index.html index 2d37bc3..9aae525 100644 --- a/pong/static/index.html +++ b/pong/static/index.html @@ -16,7 +16,7 @@