import React from "react"; import { motion, AnimatePresence } from "framer-motion"; interface BattleStatusProps { phase: string; myIndex: number; turn: number; players: any[]; lastHit: boolean | null; winner: string | null; gameOver: boolean | null; } export default function BattleStatus({ phase, myIndex, turn, players, lastHit, winner, gameOver, }: BattleStatusProps) { const isMyTurn = turn === myIndex; // ----------------------------- // STATUS TEXT // ----------------------------- let statusText = ""; if (gameOver) { statusText = winner === players[myIndex]?.user_id ? "🎉 Victory!" : "💥 Defeat"; } else if (phase === "placement") { statusText = "Place Your Fleet"; } else { statusText = isMyTurn ? "Your Turn — FIRE!" : "Opponent’s Turn"; } // ----------------------------- // Last hit/miss indicator // ----------------------------- let hitText = null; if (lastHit === true) hitText = "🔥 HIT!"; else if (lastHit === false) hitText = "💦 MISS"; return ( {/* MAIN STATUS */} {statusText} {/* HIT / MISS FEEDBACK */} {hitText && !gameOver && ( {hitText} )} {/* PHASE */}
Phase: {phase}
); }