Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | import { HitEffect, PlayerState } from "@/systems"; import { CombatSystem } from "@/systems/CombatSystem"; import { GameMode, PlayerArchetype, Position } from "@/types"; import "@pixi/layout"; import { LayoutContainer } from "@pixi/layout/components"; import "@pixi/layout/react"; import { extend } from "@pixi/react"; import { Container } from "pixi.js"; import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react"; import { HitEffectType } from "../../systems/effects"; import { usePlayerMovement } from "../../utils/inputSystem"; import { extendPixiComponents } from "../../utils/pixiExtensions"; import { createPlayerFromArchetype } from "../../utils/playerUtils"; import { DojangBackground } from "../game/DojangBackground"; import { HitEffectsLayer } from "../ui/HitEffectsLayer"; import { PlayerVisuals } from "../ui/PlayerVisuals"; import { CombatControls } from "./components/CombatControls"; import { CombatFooter } from "./components/CombatFooter"; import { CombatHUD } from "./components/CombatHUD"; import { CombatStatsPanel } from "./components/CombatStatsPanel"; import { PauseOverlay } from "./components/PauseOverlay"; import { RoundStatusDisplay } from "./components/RoundStatusDisplay"; // Register custom components for use as JSX tags in @pixi/react extend({ Container, LayoutContainer, }); // Ensure PixiJS components are extended extendPixiComponents(); export interface CombatScreenProps { readonly players: readonly PlayerState[]; readonly onPlayerUpdate: ( playerIndex: number, updates: Partial<PlayerState> ) => void; readonly currentRound: number; readonly timeRemaining: number; readonly isPaused: boolean; readonly onReturnToMenu: () => void; readonly onGameEnd: (winner: number) => void; readonly gameMode?: GameMode; readonly width?: number; readonly height?: number; readonly x?: number; readonly y?: number; } export const CombatScreen: React.FC<CombatScreenProps> = ({ players, onPlayerUpdate, currentRound, timeRemaining, isPaused, onReturnToMenu, onGameEnd, width = 1200, height = 800, x = 0, y = 0, }) => { // Combat state const [hitEffects, setHitEffects] = useState<HitEffect[]>([]); const [isExecutingTechnique, setIsExecutingTechnique] = useState(false); const [combatMessages, setCombatMessages] = useState<string[]>([]); const [roundStarted, setRoundStarted] = useState(false); const [roundEnded, setRoundEnded] = useState(false); const [roundDisplayStatus, setRoundDisplayStatus] = useState< "start" | "fight" | "ko" | "end" | null >(null); // Match timing const matchStartTimeRef = useRef(Date.now()); // Combat system const combatSystem = useMemo(() => new CombatSystem(), []); // Fixed player positions for 2-player combat with proper bounds const arenaBounds = useMemo( () => ({ x: width * 0.1, y: height * 0.2, width: width * 0.8, height: height * 0.6, }), [width, height] ); const [playerPositions, setPlayerPositions] = useState<Position[]>([ { x: arenaBounds.x + arenaBounds.width * 0.3, y: arenaBounds.y + arenaBounds.height * 0.6, }, { x: arenaBounds.x + arenaBounds.width * 0.7, y: arenaBounds.y + arenaBounds.height * 0.6, }, ]); const [aiState, setAiState] = useState({ nextAction: Date.now() + 1000, actionCooldown: 500, isMoving: false, targetPosition: { x: width * 0.75, y: height * 0.7 }, aggressionLevel: 0.5, // Increased from 0.3 }); const { playerPosition, isMoving } = usePlayerMovement({ enabled: !isPaused && roundStarted && !roundEnded, bounds: arenaBounds, onPositionChange: (newPosition: Position) => { setPlayerPositions((prev) => [newPosition, prev[1]]); onPlayerUpdate(0, { position: newPosition }); }, initialPosition: playerPositions[0], moveSpeed: 300, }); // Responsive layout detection const isMobile = useMemo(() => width < 768, [width]); // Ensure exactly 2 players with complete PlayerState objects const validPlayers = useMemo((): [PlayerState, PlayerState] => { if (players.length === 0) { // Create default players using the utility function const player1 = createPlayerFromArchetype(PlayerArchetype.MUSA, 0); const player2 = createPlayerFromArchetype(PlayerArchetype.AMSALJA, 1); return [ { ...player1, position: playerPositions[0], }, { ...player2, position: playerPositions[1], }, ]; } // Use existing players but ensure complete PlayerState const player1 = players[0]; const player2 = players[1] || createPlayerFromArchetype(PlayerArchetype.AMSALJA, 1); return [ { ...player1, position: playerPositions[0], }, { ...player2, position: playerPositions[1], }, ]; }, [players, playerPositions]); // Enhanced bilingual combat messages const addCombatMessage = useCallback((korean: string, english: string) => { const message = `${korean} | ${english}`; setCombatMessages((prev) => [message, ...prev.slice(0, 4)]); }, []); // ✅ FIXED: Properly handle hit effect completion const handleEffectComplete = useCallback((effectId: string) => { setHitEffects((prev) => prev.filter((effect) => effect.id !== effectId)); }, []); // ✅ FIXED: Create hit effect with proper integration const createHitEffect = useCallback( ( id: string, type: HitEffectType, position: Position, intensity: number ): HitEffect => ({ id, type, attackerId: "player1", defenderId: "player2", timestamp: Date.now(), duration: 1000, position, intensity, startTime: Date.now(), }), [] ); // ✅ FIXED: Add hit effect helper with proper usage const addHitEffect = useCallback( (type: HitEffectType, position: Position, intensity: number = 1) => { const effect = createHitEffect( `effect_${Date.now()}`, type, position, intensity ); setHitEffects((prev) => [...prev, effect]); // Auto-remove effect after duration setTimeout(() => { handleEffectComplete(effect.id); }, effect.duration); }, [createHitEffect, handleEffectComplete] ); // Update player 1 position based on movement useEffect(() => { setPlayerPositions((prev) => [playerPosition, prev[1]]); onPlayerUpdate(0, { position: playerPosition }); }, [playerPosition, onPlayerUpdate]); // Round Management useEffect(() => { if (isPaused) return; if (timeRemaining <= 0 && !roundEnded) { setRoundEnded(true); setRoundStarted(false); setRoundDisplayStatus("end"); // Determine winner by health const winner = validPlayers[0].health > validPlayers[1].health ? 0 : 1; addCombatMessage("라운드 종료!", "Round Over!"); setTimeout(() => { onGameEnd(winner); }, 2500); } else if ( timeRemaining > 0 && !roundStarted && !roundEnded && currentRound > 0 ) { setRoundStarted(true); addCombatMessage("라운드 시작!", "Round Start!"); setRoundDisplayStatus("start"); const fightTimer = setTimeout(() => setRoundDisplayStatus("fight"), 1500); return () => clearTimeout(fightTimer); } }, [ timeRemaining, roundEnded, roundStarted, validPlayers, onGameEnd, addCombatMessage, currentRound, isPaused, ]); // ✅ FIXED: Enhanced combat system integration with proper hit effects const handleAttack = useCallback(() => { if (isExecutingTechnique || !roundStarted || roundEnded) return; setIsExecutingTechnique(true); // Create basic attack technique const basicAttack = { id: "basic_attack", name: { korean: "기본공격", english: "Basic Attack", romanized: "gibon_gonggyeok", }, koreanName: "기본공격", englishName: "Basic Attack", romanized: "gibon_gonggyeok", description: { korean: "기본 공격", english: "Basic attack" }, stance: validPlayers[0].currentStance, type: "attack" as const, damageType: "physical" as const, damage: 15, kiCost: 5, staminaCost: 8, accuracy: 0.8, range: 1.0, executionTime: 400, recoveryTime: 300, critChance: 0.1, critMultiplier: 1.5, effects: [], }; // Use combat system for proper calculation const result = combatSystem.resolveAttack( validPlayers[0], validPlayers[1], basicAttack ); // ✅ FIXED: Use addHitEffect instead of creating manually const effectType = result.hit ? result.isCritical ? HitEffectType.CRITICAL_HIT : HitEffectType.HIT : HitEffectType.MISS; addHitEffect(effectType, playerPosition, result.hit ? 1 : 0.5); if (result.hit) { // Apply damage through combat system const { updatedAttacker, updatedDefender } = combatSystem.applyCombatResult( result, validPlayers[0], validPlayers[1] ); onPlayerUpdate(0, updatedAttacker); onPlayerUpdate(1, updatedDefender); if (result.isCritical) { addCombatMessage("치명타 공격!", "Critical Hit!"); } else { addCombatMessage("공격 성공!", "Attack Hit!"); } } else { addCombatMessage("공격 빗나감", "Attack Missed"); } setTimeout(() => setIsExecutingTechnique(false), 500); }, [ playerPosition, onPlayerUpdate, validPlayers, isExecutingTechnique, addCombatMessage, combatSystem, roundStarted, roundEnded, addHitEffect, ]); // Handle defend with Korean feedback const handleDefend = useCallback(() => { if (!roundStarted || roundEnded) return; onPlayerUpdate(0, { isBlocking: true }); addCombatMessage("방어 자세", "Defensive Stance"); // Add defensive effect addHitEffect(HitEffectType.BLOCK, playerPosition, 0.8); setTimeout(() => { onPlayerUpdate(0, { isBlocking: false }); }, 1000); }, [ onPlayerUpdate, addCombatMessage, roundStarted, roundEnded, addHitEffect, playerPosition, ]); // ✅ FIXED: Handle technique execution with proper effects const handleTechniqueExecute = useCallback(() => { if (isExecutingTechnique || !roundStarted || roundEnded) return; if (validPlayers[0].ki < 10 || validPlayers[0].stamina < 15) { addCombatMessage("기력/체력 부족", "Insufficient Ki/Stamina"); return; } setIsExecutingTechnique(true); // Add technique effect addHitEffect(HitEffectType.CRITICAL_HIT, playerPosition, 1.5); const distance = Math.sqrt( Math.pow(playerPositions[0].x - playerPositions[1].x, 2) + Math.pow(playerPositions[0].y - playerPositions[1].y, 2) ); if (distance < 150) { onPlayerUpdate(1, { health: Math.max(0, validPlayers[1].health - 25), hitsTaken: validPlayers[1].hitsTaken + 1, }); addCombatMessage("특수 기술 성공!", "Special Technique Hit!"); } else { addCombatMessage("기술 실패", "Technique Failed"); } // Consume resources onPlayerUpdate(0, { ki: Math.max(0, validPlayers[0].ki - 10), stamina: Math.max(0, validPlayers[0].stamina - 15), }); setTimeout(() => setIsExecutingTechnique(false), 800); }, [ playerPosition, playerPositions, onPlayerUpdate, validPlayers, isExecutingTechnique, addCombatMessage, roundStarted, roundEnded, addHitEffect, ]); // Handle stance switch with Korean feedback const handleStanceSwitch = useCallback( (stance: any) => { if (!roundStarted || roundEnded) return; onPlayerUpdate(0, { currentStance: stance }); addCombatMessage(`자세 변경: ${stance}`, `Stance Change: ${stance}`); // Add stance change effect addHitEffect(HitEffectType.STATUS_EFFECT, playerPosition, 0.6); }, [ onPlayerUpdate, addCombatMessage, roundStarted, roundEnded, addHitEffect, playerPosition, ] ); // ✅ FIXED: AI combat handlers with proper effect integration const handleAIAttack = useCallback(() => { addHitEffect(HitEffectType.HIT, playerPositions[1], 1); const distance = Math.sqrt( Math.pow(playerPositions[0].x - playerPositions[1].x, 2) + Math.pow(playerPositions[0].y - playerPositions[1].y, 2) ); if (distance < 120) { // AI attack hits const damage = 10 + Math.random() * 15; onPlayerUpdate(0, { health: Math.max(0, validPlayers[0].health - damage), hitsTaken: validPlayers[0].hitsTaken + 1, }); addCombatMessage("AI 공격 성공!", "AI Attack Hit!"); } else { addCombatMessage("AI 공격 빗나감", "AI Attack Missed"); } }, [ playerPositions, validPlayers, onPlayerUpdate, addCombatMessage, addHitEffect, ]); const handleAIDefend = useCallback(() => { onPlayerUpdate(1, { isBlocking: true }); addCombatMessage("AI 방어 자세", "AI Defensive Stance"); // Add AI defensive effect addHitEffect(HitEffectType.BLOCK, playerPositions[1], 0.8); setTimeout(() => { onPlayerUpdate(1, { isBlocking: false }); }, 1000); }, [onPlayerUpdate, addCombatMessage, addHitEffect, playerPositions]); const handleAITechnique = useCallback(() => { if (validPlayers[1].ki < 10 || validPlayers[1].stamina < 15) { handleAIAttack(); // Fallback to basic attack return; } addHitEffect(HitEffectType.CRITICAL_HIT, playerPositions[1], 1.5); const distance = Math.sqrt( Math.pow(playerPositions[0].x - playerPositions[1].x, 2) + Math.pow(playerPositions[0].y - playerPositions[1].y, 2) ); if (distance < 150) { const damage = 20 + Math.random() * 20; onPlayerUpdate(0, { health: Math.max(0, validPlayers[0].health - damage), hitsTaken: validPlayers[0].hitsTaken + 1, }); addCombatMessage("AI 특수 기술!", "AI Special Technique!"); } // Consume AI resources onPlayerUpdate(1, { ki: Math.max(0, validPlayers[1].ki - 10), stamina: Math.max(0, validPlayers[1].stamina - 15), }); }, [ playerPositions, validPlayers, onPlayerUpdate, addCombatMessage, handleAIAttack, addHitEffect, ]); const moveAIPlayer = useCallback( (targetPos: Position) => { const currentPos = playerPositions[1]; const speed = 4; // Increased from 2 const dx = targetPos.x - currentPos.x; const dy = targetPos.y - currentPos.y; const distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { const newPos = { x: currentPos.x + (dx / distance) * speed, y: currentPos.y + (dy / distance) * speed, }; // Keep AI within bounds newPos.x = Math.max( arenaBounds.x, Math.min(arenaBounds.x + arenaBounds.width - 60, newPos.x) ); newPos.y = Math.max( arenaBounds.y, Math.min(arenaBounds.y + arenaBounds.height - 180, newPos.y) ); setPlayerPositions((prev) => [prev[0], newPos]); onPlayerUpdate(1, { position: newPos }); } }, [playerPositions, arenaBounds, onPlayerUpdate] ); // Execute AI Actions const executeAIAction = useCallback( (action: string, targetPos: Position) => { switch (action) { case "attack": handleAIAttack(); break; case "defend": handleAIDefend(); break; case "technique": handleAITechnique(); break; case "approach": case "retreat": case "circle": moveAIPlayer(targetPos); break; } }, [handleAIAttack, handleAIDefend, handleAITechnique, moveAIPlayer] ); // AI System - Enhanced for Korean martial arts useEffect(() => { if (isPaused || !roundStarted || roundEnded) return; const aiInterval = setInterval(() => { const now = Date.now(); if (now < aiState.nextAction) return; const player1Pos = playerPositions[0]; const player2Pos = playerPositions[1]; const distanceToPlayer = Math.sqrt( Math.pow(player1Pos.x - player2Pos.x, 2) + Math.pow(player1Pos.y - player2Pos.y, 2) ); // AI Decision Making - more aggressive let aiAction = "idle"; let newTargetPosition = aiState.targetPosition; if (validPlayers[1].health < validPlayers[1].maxHealth * 0.3) { // Defensive when low health aiAction = "retreat"; newTargetPosition = { x: Math.max( arenaBounds.x, player2Pos.x + (player2Pos.x > player1Pos.x ? 80 : -80) // Increased retreat distance ), y: player2Pos.y, }; } else if (distanceToPlayer < 120) { // Increased close combat range // Close combat const random = Math.random(); if (random < 0.5) { // Increased attack chance aiAction = "attack"; } else if (random < 0.75) { aiAction = "defend"; } else { aiAction = "technique"; } } else if (distanceToPlayer > 250) { // Increased approach range // Move closer aiAction = "approach"; newTargetPosition = { x: player1Pos.x + (Math.random() - 0.5) * 120, // Increased variation y: player1Pos.y + (Math.random() - 0.5) * 80, }; } else { // Medium distance - tactical movement aiAction = "circle"; const angle = Math.atan2( player1Pos.y - player2Pos.y, player1Pos.x - player2Pos.x ); newTargetPosition = { x: player1Pos.x + Math.cos(angle + Math.PI / 2) * 180, // Increased circle radius y: player1Pos.y + Math.sin(angle + Math.PI / 2) * 180, }; } // Execute AI action executeAIAction(aiAction, newTargetPosition); // Set next action time - reduced delay setAiState((prev) => ({ ...prev, nextAction: now + prev.actionCooldown + Math.random() * 300, // Reduced random delay targetPosition: newTargetPosition, })); }, 50); // Reduced from 100ms to 50ms for more responsive AI return () => clearInterval(aiInterval); }, [ isPaused, roundStarted, roundEnded, playerPositions, validPlayers, aiState.nextAction, aiState.actionCooldown, aiState.targetPosition, arenaBounds, executeAIAction, ]); // Force position updates to sync properly useEffect(() => { setPlayerPositions((prev) => [playerPosition, prev[1]]); onPlayerUpdate(0, { position: playerPosition }); }, [playerPosition, onPlayerUpdate]); // Check game end conditions const checkGameEnd = useCallback(() => { if (roundEnded) return; const p1Defeated = validPlayers[0].health <= 0; const p2Defeated = validPlayers[1].health <= 0; if (p1Defeated || p2Defeated) { setRoundEnded(true); setRoundStarted(false); setRoundDisplayStatus("ko"); const winner = p1Defeated ? 1 : 0; addCombatMessage( p1Defeated ? "플레이어 1 패배" : "플레이어 1 승리!", p1Defeated ? "Player 1 Defeated" : "Player 1 Victory!" ); setTimeout(() => onGameEnd(winner), 2500); } }, [validPlayers, onGameEnd, addCombatMessage, roundEnded]); // Check game end on health changes useEffect(() => { checkGameEnd(); }, [validPlayers[0].health, validPlayers[1].health, checkGameEnd]); // Calculate match duration const matchDuration = useMemo( () => Math.floor((Date.now() - matchStartTimeRef.current) / 1000), [] ); // Get player animation state const getPlayerAnimationState = useCallback( (playerIndex: number) => { const player = validPlayers[playerIndex]; if (player.health <= 0) return "defeat"; if (player.isBlocking) return "defend"; if (isExecutingTechnique && playerIndex === 0) return "technique_execute"; if (playerIndex === 0 && isMoving) return "walk"; return "idle"; }, [validPlayers, isExecutingTechnique, isMoving] ); // Centralized layout constants for easier tweaking const layoutConstants = { padding: 10, hudHeight: 120, controlsHeight: 100, footerHeight: 40, }; return ( <pixiContainer data-testid="combat-screen" layout={{ width, height, position: "absolute", top: y, left: x, }} > {/* Dojang Background Layer - Stays in the back */} <DojangBackground width={width} height={height} lighting="cyberpunk" animate={true} /> {/* Main Combat Layout: A vertical flex container for all UI */} <pixiContainer layout={{ width, height, flexDirection: "column", alignItems: "center", justifyContent: "space-between", // Pushes content to top and bottom padding: layoutConstants.padding, }} > {/* Top HUD Area: Fixed height */} <pixiContainer layout={{ width: "100%", height: layoutConstants.hudHeight, alignItems: "flex-start", // Align items to the top of the container justifyContent: "center", flexShrink: 0, // Prevents this container from shrinking }} > <CombatHUD player1={validPlayers[0]} player2={validPlayers[1]} timeRemaining={timeRemaining} currentRound={currentRound} maxRounds={3} gameScore={{ player1: validPlayers[0].wins || 0, player2: validPlayers[1].wins || 0, }} roundsWon={{ player1: validPlayers[0].wins || 0, player2: validPlayers[1].wins || 0, }} isPaused={isPaused} onPauseToggle={() => console.log("Pause toggled")} width={width - layoutConstants.padding * 2} height={layoutConstants.hudHeight} /> </pixiContainer> {/* Combat Arena Area: Flexible height, fills remaining space */} <pixiContainer data-testid="combat-arena" layout={{ width: "100%", flexGrow: 1, // Allows this container to take up available vertical space position: "relative", // For absolute positioning of players and effects alignItems: "center", justifyContent: "center", }} > {/* Player 1 Visuals - Use absolute positioning */} <PlayerVisuals playerState={validPlayers[0]} x={playerPositions[0].x} y={playerPositions[0].y} scale={isMobile ? 0.8 : 1.0} renderMode="combat" facing="right" showDetails={true} showVitalPoints={false} showKiAura={true} showKoreanLabels={true} interactive={true} onPlayerClick={() => console.log("Player 1 clicked")} animationState={getPlayerAnimationState(0)} data-testid="combat-player-1" /> {/* Player 2 Visuals - Use absolute positioning */} <PlayerVisuals playerState={validPlayers[1]} x={playerPositions[1].x} y={playerPositions[1].y} scale={isMobile ? 0.8 : 1.0} renderMode="combat" facing="left" showDetails={true} showVitalPoints={false} showKiAura={true} showKoreanLabels={true} interactive={true} onPlayerClick={() => console.log("Player 2 clicked")} animationState={getPlayerAnimationState(1)} data-testid="combat-player-2" /> {/* Hit Effects Layer */} <HitEffectsLayer effects={hitEffects} onEffectComplete={handleEffectComplete} /> {/* Round Status Display */} {roundDisplayStatus && ( <RoundStatusDisplay status={roundDisplayStatus} round={currentRound} width={width} height={height} onAnimationComplete={() => setRoundDisplayStatus(null)} /> )} </pixiContainer> {/* Bottom UI Area: Contains controls and stats */} <pixiContainer layout={{ width: "100%", height: layoutConstants.controlsHeight, flexDirection: "row", alignItems: "flex-end", // Align to the bottom of the container justifyContent: "space-between", gap: 20, flexShrink: 0, paddingBottom: layoutConstants.footerHeight + 10, // Add padding to not overlap with footer }} > <CombatControls onAttack={handleAttack} onDefend={handleDefend} onSwitchStance={handleStanceSwitch} onTechniqueExecute={handleTechniqueExecute} player={validPlayers[0]} isExecutingTechnique={isExecutingTechnique} width={isMobile ? width * 0.45 : 400} height={isMobile ? 90 : 120} /> <CombatStatsPanel players={validPlayers} combatLog={combatMessages.map((msg, index) => ({ id: `msg-${index}`, timestamp: Date.now() - index * 1000, korean: msg.split(" | ")[0] || msg, english: msg.split(" | ")[1] || msg, type: msg.includes("공격") ? "attack" : msg.includes("방어") ? "defend" : msg.includes("기술") ? "technique" : "info", }))} matchDuration={matchDuration} totalDamageDealt={{ player1: validPlayers[0].totalDamageDealt || 0, player2: validPlayers[1].totalDamageDealt || 0, }} criticalHits={{ player1: Math.floor((validPlayers[0].totalDamageDealt || 0) / 50), player2: Math.floor((validPlayers[1].totalDamageDealt || 0) / 50), }} perfectStrikes={{ player1: validPlayers[0].perfectStrikes || 0, player2: validPlayers[1].perfectStrikes || 0, }} width={isMobile ? width * 0.45 : 400} height={isMobile ? 90 : 120} /> </pixiContainer> {/* Footer Area: Fixed height for instructions and menu button */} <pixiContainer layout={{ position: "absolute", bottom: 0, left: 0, width: "100%", height: layoutConstants.footerHeight, }} > <CombatFooter onReturnToMenu={onReturnToMenu} isMobile={isMobile} width={width} height={layoutConstants.footerHeight} /> </pixiContainer> </pixiContainer> {/* Pause Overlay - Centered on the whole screen */} {isPaused && <PauseOverlay isMobile={isMobile} />} </pixiContainer> ); }; export default CombatScreen; |