diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 3120da1..2a84bb7 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -5,16 +5,6 @@ RUN npm install -g pnpm@9 COPY . . RUN pnpm install --frozen-lockfile RUN pnpm --filter @rps-royale/shared build - -ARG NEXT_PUBLIC_API_URL -ARG NEXT_PUBLIC_CONTRACT_ADDRESS -ARG NEXT_PUBLIC_CHAIN_ID -ARG NEXT_PUBLIC_HARDHAT_RPC_URL -ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} -ENV NEXT_PUBLIC_CONTRACT_ADDRESS=${NEXT_PUBLIC_CONTRACT_ADDRESS} -ENV NEXT_PUBLIC_CHAIN_ID=${NEXT_PUBLIC_CHAIN_ID} -ENV NEXT_PUBLIC_HARDHAT_RPC_URL=${NEXT_PUBLIC_HARDHAT_RPC_URL} - RUN pnpm --filter @rps-royale/web build ENV NODE_ENV=production EXPOSE 3000 diff --git a/apps/web/src/app/play/PlayClient.tsx b/apps/web/src/app/play/PlayClient.tsx new file mode 100644 index 0000000..8593b42 --- /dev/null +++ b/apps/web/src/app/play/PlayClient.tsx @@ -0,0 +1,22 @@ +'use client'; + +import { useEffect, useRef } from 'react'; +import { initGame } from '@/phaser/Game'; + +export default function PlayClient() { + const containerRef = useRef(null); + + useEffect(() => { + if (!containerRef.current) return; + const game = initGame('phaser-container'); + return () => { + game.destroy(true); + }; + }, []); + + return ( +
+
+
+ ); +} diff --git a/apps/web/src/app/play/page.tsx b/apps/web/src/app/play/page.tsx index 89a2a01..60631a1 100644 --- a/apps/web/src/app/play/page.tsx +++ b/apps/web/src/app/play/page.tsx @@ -1,56 +1,9 @@ 'use client'; -import { useEffect, useRef, useState } from 'react'; +import dynamic from 'next/dynamic'; + +const PlayClient = dynamic(() => import('./PlayClient'), { ssr: false }); export default function PlayPage() { - const containerRef = useRef(null); - const [error, setError] = useState(null); - const gameRef = useRef(null); - - useEffect(() => { - let mounted = true; - const init = async () => { - try { - const { initGame } = await import('@/phaser/Game'); - if (!mounted || !containerRef.current) return; - // Delay slightly to ensure container has layout - await new Promise((r) => setTimeout(r, 100)); - if (!mounted || !containerRef.current) return; - const game = initGame('phaser-container'); - gameRef.current = game; - } catch (err: any) { - console.error('Failed to init Phaser game:', err); - setError(err?.message || 'Erreur de chargement du jeu'); - } - }; - init(); - return () => { - mounted = false; - if (gameRef.current) { - gameRef.current.destroy(true); - gameRef.current = null; - } - }; - }, []); - - if (error) { - return ( -
-

- Erreur de chargement -

-

{error}

-
- ); - } - - return ( -
-
-
- ); + return ; } diff --git a/apps/web/src/phaser/scenes/ArenaScene.ts b/apps/web/src/phaser/scenes/ArenaScene.ts index d5875f7..c62d423 100644 --- a/apps/web/src/phaser/scenes/ArenaScene.ts +++ b/apps/web/src/phaser/scenes/ArenaScene.ts @@ -208,10 +208,8 @@ export class ArenaScene extends Phaser.Scene { this.cameras.main.shake(3000, 0.005); // Intense particles - if (this.particles) { - this.particles.frequency = 30; - this.particles.lifespan = 2000; - } + this.particles.setFrequency(30); + this.particles.setLifespan(2000); // Flash effect const flash = this.add.rectangle(width / 2, height / 2, width, height, 0xffffff).setAlpha(0); diff --git a/apps/web/src/phaser/scenes/ResultScene.ts b/apps/web/src/phaser/scenes/ResultScene.ts index 772ba21..8f55682 100644 --- a/apps/web/src/phaser/scenes/ResultScene.ts +++ b/apps/web/src/phaser/scenes/ResultScene.ts @@ -71,13 +71,13 @@ export class ResultScene extends Phaser.Scene { } // Impact particles - const graphics = this.make.graphics({ x: 0, y: 0 }); + const graphics = this.make.graphics({ x: 0, y: 0, }); graphics.fillStyle(0xffffff, 1); graphics.fillCircle(4, 4, 4); graphics.generateTexture('resultSpark', 8, 8); graphics.destroy(); - const emitter = this.add.particles(width / 2, height / 2 - 60, 'resultSpark', { + this.add.particles(width / 2, height / 2 - 60, 'resultSpark', { speed: { min: 100, max: 300 }, angle: { min: 0, max: 360 }, quantity: 40, @@ -86,7 +86,6 @@ export class ResultScene extends Phaser.Scene { scale: { start: 0.8, end: 0 }, tint: isDraw ? 0x94a3b8 : isWinner ? 0x22c55e : 0xef4444, }); - emitter?.explode(40); new UIButton(this, width / 2, height / 2 + 140, 'Retour au Lobby', () => { this.cameras.main.fadeOut(400, 0, 0, 0); diff --git a/docker-compose.yml b/docker-compose.yml index 0cdc27a..b772cd3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,11 +74,6 @@ services: build: context: . dockerfile: apps/web/Dockerfile - args: - NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://api.jeu.cosmolan.fr} - NEXT_PUBLIC_CONTRACT_ADDRESS: ${NEXT_PUBLIC_CONTRACT_ADDRESS} - NEXT_PUBLIC_CHAIN_ID: ${NEXT_PUBLIC_CHAIN_ID:-31337} - NEXT_PUBLIC_HARDHAT_RPC_URL: ${NEXT_PUBLIC_HARDHAT_RPC_URL} container_name: rps-web restart: unless-stopped environment: