import React, { useEffect, useState } from 'react'; import type { BattleResult } from '../types'; interface BattleModalProps { battle: BattleResult | null; onClose: () => void; } export const BattleModal: React.FC = ({ battle, onClose }) => { const [countdown, setCountdown] = useState(5); useEffect(() => { if (!battle) return; // Reset countdown to 5 whenever a new battle modal is opened setCountdown(5); const timer = window.setInterval(() => { setCountdown((prev) => { if (prev <= 1) { window.clearInterval(timer); onClose(); return 0; } return prev - 1; }); }, 1000); return () => { window.clearInterval(timer); }; }, [battle, onClose]); if (!battle) return null; return (
{/* Glowing cyber header banner */}
{/* 5-second automatic progress bar */}
⚔️

PARTY ENGAGEMENT: 3-BOUT D20 CLASH

{battle.party1_name} vs {battle.party2_name}

{/* 3 Bouts Breakdown */}
{battle.bouts.map((bout) => (
BOUT #{bout.bout_number} Winner: {bout.winner_name || 'Tied'}
{/* Party 1 */}
{battle.party1_name}
Str: {bout.party1_strength} × 🎲 {bout.party1_roll} = {bout.party1_score}
{/* Party 2 */}
{battle.party2_name}
Str: {bout.party2_strength} × 🎲 {bout.party2_roll} = {bout.party2_score}
))}
{/* Battle Resolution Summary */}
🏆 VICTORY: {battle.winner_party_name} Bouts: {battle.party1_bouts_won} - {battle.party2_bouts_won}
• Winning Leader {battle.winner_leader_name} receives{' '} +2 points, and all other winning squad members receive{' '} +1 point!
• Defeated Leader {battle.killed_leader_name} receives{' '} -1 point. {battle.absorbed_members.includes(battle.killed_leader_id) ? ( Resistance broken! Surrendered and joined {battle.winner_party_name}. ) : ( Respawned at ({battle.killed_leader_respawn_position.x}, {battle.killed_leader_respawn_position.y}). )}
{battle.absorbed_members.length > 0 && !battle.absorbed_members.includes(battle.killed_leader_id) && (
{battle.absorbed_members.length} surviving bot(s) from the defeated party surrendered and joined {battle.winner_party_name}!
)}
New Squad Size: {battle.new_party_size} bots • Total Strength:{' '} {battle.new_party_strength}
{/* Continue Button with 5s Auto-close Countdown */}
); };