All files / blacktrigram/src/systems types.ts

98.56% Statements 823/835
100% Branches 0/0
0% Functions 0/1
98.56% Lines 823/835

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 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520                          1x 1x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x       1x   1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x     1x 1x 1x     1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x   1x 1x 1x 1x   1x 1x 1x   1x 1x   1x 1x 1x 1x   1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x                         1x   1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x               1x                                                                                           1x             1x   1x 1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x     1x 1x     1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x     1x 1x     1x 1x 1x 1x   1x  
/**
 * Type definitions for systems types
 * Auto-generated by type migration script
 */
 
// System imports from shared types - avoid circular dependencies
import { AudioSystemInterface, SoundEffectId } from "@/audio";
import type {
  EffectIntensity,
  EnvironmentalEffectType,
  HitEffectType,
  ParticleType,
} from "@/systems/effects";
import { KOREAN_COLORS } from "@/types";
import {
  KoreanText,
  PlayerArchetype,
  Position,
  TrigramStance,
} from "@/types/common";
 
export interface AnimationConfig {
  readonly name: string;
  readonly frames: readonly AnimationFrame[];
  readonly loop?: boolean;
  readonly speed?: number;
}
 
export interface CombatSystemConfig {
  readonly damageMultiplier: number;
  readonly criticalChance: number;
}
 
export interface TrigramSystemConfig {
  readonly transitionSpeed: number;
  readonly energyCost: number;
}
 
export interface AISystemConfig {
  readonly difficulty: "easy" | "medium" | "hard" | "expert";
  readonly reactionTime: number;
}
 
export interface VitalPointSystemConfig {
  readonly precisionRequired: number;
  readonly damageMultipliers: Record<string, number>;
  readonly effectDurations: Record<string, number>;
}
 
// Direct PixiJS imports for core types
import type {
  Application as PixiApplication,
  DisplayObject as PixiDisplayObject,
  Texture,
} from "pixi.js";
 
// Vital point effect
// Player archetype data
export interface PlayerArchetypeData {
  readonly id: string;
  readonly name: KoreanText;
  readonly description: KoreanText;
  readonly baseHealth: number;
  readonly baseKi: number;
  readonly baseStamina: number;
  readonly coreStance: TrigramStance;
  readonly theme: {
    primary: number;
    secondary: number;
  };
  readonly colors: {
    primary: number;
    secondary: number;
  };
  readonly stats: {
    attackPower: number;
    defense: number;
    speed: number;
    technique: number;
  };
  readonly favoredStances: readonly TrigramStance[];
  readonly specialAbilities: readonly string[];
  readonly philosophy: KoreanText;
}
 
export interface AnimationState {
  readonly currentAnimationName?: string;
  readonly currentFrameIndex: number;
  readonly isPlaying: boolean;
  readonly elapsedTimeInFrame: number;
}
 
export interface CollisionData {
  readonly entityA: EntityId;
  readonly entityB: EntityId;
  readonly normal: Velocity;
  readonly penetration: number;
}
 
export interface PhysicsEntityConfig {
  readonly position: Position;
  readonly velocity?: Velocity;
  readonly mass?: number;
  readonly friction?: number;
  readonly restitution?: number;
  readonly shape:
    | { type: "circle"; radius: number }
    | { type: "rectangle"; width: number; height: number };
  readonly isStatic?: boolean;
}
 
export interface PhysicsEntityState {
  readonly position: Position;
  readonly velocity: Velocity;
  readonly acceleration?: Velocity;
  readonly angularVelocity?: number;
}
 
export interface RenderableConfig {
  readonly displayObject: PixiDisplayObject;
  readonly zOrder?: number;
  readonly visible?: boolean;
  readonly alpha?: number;
  readonly parent?: EntityId | "stage";
}
 
export interface StatusEffect {
  readonly id: string;
  readonly type: string;
  readonly intensity: EffectIntensity;
  readonly duration: number;
  readonly description: KoreanText;
  readonly stackable: boolean;
  readonly source: string;
  readonly startTime: number;
  readonly endTime: number;
}
 
export interface HitEffect {
  readonly id: string;
  readonly type: HitEffectType;
  readonly attackerId: string;
  readonly defenderId: string;
  readonly timestamp: number;
  readonly duration: number;
  readonly position?: Position;
  readonly velocity?: { x: number; y: number };
  readonly color?: number;
  readonly size?: number;
  readonly alpha?: number;
  readonly lifespan?: number;
  readonly text?: string | KoreanText;
  readonly damageAmount?: number;
  readonly vitalPointId?: string;
  readonly statusEffect?: StatusEffect;
  readonly yOffset?: number;
  readonly intensity: number;
  readonly startTime: number;
}
 
export interface ParticleEffect {
  readonly id: string;
  readonly type: ParticleType;
  readonly position: Position;
  readonly velocity: { x: number; y: number };
  readonly acceleration?: { x: number; y: number };
  readonly color: number;
  readonly size: number;
  readonly lifetime: number;
  readonly fadeOut?: boolean;
  readonly gravity?: number;
}
 
export interface EnvironmentalEffect {
  readonly id: string;
  readonly type: EnvironmentalEffectType;
  readonly affectedArea: {
    readonly x: number;
    readonly y: number;
    readonly width: number;
    readonly height: number;
  };
  readonly effects: {
    readonly visibilityModifier?: number;
    readonly accuracyModifier?: number;
    readonly movementModifier?: number;
    readonly damageModifier?: number;
  };
  readonly duration: number;
}
 
export interface VisualEffect {
  readonly id: string;
  readonly type: string;
  readonly duration: number;
  readonly intensity: number;
  readonly position?: Position;
  readonly color?: number;
}
 
export interface EffectSystem {
  readonly effects: readonly VisualEffect[];
  readonly addEffect: (effect: VisualEffect) => void;
  readonly removeEffect: (id: string) => void;
  readonly updateEffects: (deltaTime: number) => void;
}
 
export interface DisplayHitEffect extends HitEffect {
  readonly opacity: number;
  readonly scale: number;
  readonly startTime: number;
  readonly displayAlpha: number;
  readonly displayY: number;
  readonly displaySize: number;
}
 
export interface InputSystemInterface {
  registerAction: (action: string, callback: () => void) => void;
  unregisterAction: (action: string) => void;
  clearActions: () => void;
  isActionActive: (action: string) => boolean;
}
 
export interface AnimationSystemInterface {
  playAnimation: (entityId: EntityId, animationName: string) => void;
  stopAnimation: (entityId: EntityId, animationName?: string) => void;
  getCurrentFrame: (entityId: EntityId) => AnimationFrame | undefined;
  addAnimation: (config: AnimationConfig) => void;
  getAnimationState: (entityId: EntityId) => AnimationState | undefined;
}
 
export interface PhysicsSystemInterface {
  addEntity: (entityId: EntityId, config: PhysicsEntityConfig) => void;
  removeEntity: (entityId: EntityId) => void;
  update: (deltaTime: number) => void;
  getEntityState: (entityId: EntityId) => PhysicsEntityState | undefined;
  checkCollision: (
    entityIdA: EntityId,
    entityIdB: EntityId
  ) => CollisionData | null;
  applyForce: (entityId: EntityId, force: Velocity) => void;
}
 
export interface RenderingSystemInterface {
  readonly app: PixiApplication;
  addRenderable: (entityId: EntityId, config: RenderableConfig) => void;
  removeRenderable: (entityId: EntityId) => void;
  updateRenderable: (
    entityId: EntityId,
    updates: Partial<RenderableConfig>
  ) => void;
  getDisplayObject: (entityId: EntityId) => PixiDisplayObject | undefined;
  render: () => void;
}
 
export interface SystemEvent {
  readonly type: string;
  readonly timestamp: number;
  readonly source: string;
  readonly data: Record<string, any>;
}
 
export interface EventBusInterface {
  publish: (event: SystemEvent) => void;
  subscribe: (
    eventType: string,
    callback: (event: SystemEvent) => void
  ) => void;
  unsubscribe: (
    eventType: string,
    callback: (event: SystemEvent) => void
  ) => void;
}
 
// Define system interfaces without importing (to avoid circular deps)
export interface CombatSystemInterface {
  calculateDamage: (
    technique: any,
    attacker: any,
    defender: any,
    hitResult: any
  ) => {
    baseDamage: number;
    modifierDamage: number;
    totalDamage: number;
    effectsApplied: readonly StatusEffect[];
    finalDefenderState?: any;
  };
  resolveAttack: (
    attacker: any,
    defender: any,
    technique: any,
    targetedVitalPointId?: string
  ) => any;
  applyCombatResult: (
    result: any,
    attacker: any,
    defender: any
  ) => { updatedAttacker: any; updatedDefender: any };
  getAvailableTechniques: (player: any) => readonly any[];
}
 
export interface VitalPointSystemInterface {
  processHit: (
    targetPosition: Position,
    technique: any,
    baseDamage: number,
    attackerArchetype: any,
    targetDimensions: { width: number; height: number },
    targetedVitalPointId?: string | null
  ) => any;
  calculateHit: (
    technique: any,
    targetVitalPointId: string | null,
    accuracyRoll: number,
    attackerPosition: Position,
    defenderPosition: Position,
    defenderStance: any
  ) => any;
  applyVitalPointEffects: (
    player: any,
    vitalPoint: any,
    intensityMultiplier?: number
  ) => any;
}
 
export interface TrigramSystemInterface {
  getTechniqueForStance: (stance: any, archetype?: any) => any | undefined;
  calculateStanceEffectiveness: (
    attackerStance: any,
    defenderStance: any,
    technique?: any
  ) => number;
  isValidTransition: (from: any, to: any) => boolean;
  getTransitionCost: (
    from: any,
    to: any,
    player?: any
  ) => { ki: number; stamina: number; timeMs: number };
  recommendStance: (player: any, opponent?: any) => any;
}
 
export interface GameSystemManager {
  readonly combatSystem: CombatSystemInterface;
  readonly vitalPointSystem: VitalPointSystemInterface;
  readonly trigramSystem: TrigramSystemInterface;
  readonly inputSystem: InputSystemInterface;
  readonly audioSystem: AudioSystemInterface;
  readonly animationSystem?: AnimationSystemInterface;
  readonly physicsSystem?: PhysicsSystemInterface;
  readonly renderingSystem?: RenderingSystemInterface;
  readonly eventBus: EventBusInterface;
  initializeAll: () => Promise<void>;
  updateAll: (deltaTime: number) => void;
}
 
export interface SystemConfig {
  readonly debugMode?: boolean;
  readonly performanceMonitoring?: boolean;
}
 
export interface GameSystemState {
  readonly combat: CombatSystemConfig;
  readonly trigram: TrigramSystemConfig;
  readonly vitalPoint: VitalPointSystemConfig;
  readonly ai: AISystemConfig;
}
 
export interface SystemPerformance {
  readonly fps: number;
  readonly memoryUsage: number;
  readonly renderTime: number;
  readonly updateTime: number;
}
 
// Fix: Add missing type definitions
export type Timestamp = number;
export type EntityId = string;
export interface Velocity {
  readonly x: number;
  readonly y: number;
}
 
// Configuration for the VitalPointSystem
// Result from VitalPointSystem's hit calculation - unified with anatomy.ts version
// Combat system interface
// Vital point system interface
// Trigram system interface
// Input system interface
// Gamepad state
export interface GamepadState {
  readonly id: string;
  readonly axes: readonly number[];
  readonly buttons: readonly { pressed: boolean; value: number }[];
}
 
// Added AnimationFrame and AnimationState for AnimationSystemInterface
export interface AnimationFrame {
  readonly texture: Texture; // Texture from PIXI
  readonly duration: number;
}
 
export interface AnimationState {
  readonly currentAnimationName?: string;
  readonly currentFrameIndex: number;
  readonly isPlaying: boolean;
  readonly elapsedTimeInFrame: number;
}
 
// Physics system interface
// Physics entity configuration
export interface PhysicsEntityConfig {
  readonly position: Position;
  readonly velocity?: Velocity;
  readonly mass?: number;
  readonly friction?: number;
  readonly restitution?: number; // Bounciness
  readonly shape:
    | { type: "circle"; radius: number }
    | { type: "rectangle"; width: number; height: number };
  readonly isStatic?: boolean; // Cannot be moved by forces // Added
}
 
// Added PhysicsEntityState and CollisionData for PhysicsSystemInterface
export interface PhysicsEntityState {
  readonly position: Position;
  readonly velocity: Velocity;
  readonly acceleration?: Velocity;
  readonly angularVelocity?: number;
}
 
export interface CollisionData {
  readonly entityA: EntityId;
  readonly entityB: EntityId;
  readonly normal: Velocity; // Collision normal vector
  readonly penetration: number; // How much they are overlapping
}
 
// Rendering system interface
// Renderable configuration
export interface RenderableConfig {
  readonly displayObject: PixiDisplayObject; // The PIXI object to render - use aliased import
  readonly zOrder?: number; // For sorting
  readonly visible?: boolean;
  readonly alpha?: number; // Added
  readonly parent?: EntityId | "stage"; // ID of parent renderable or stage // Added
}
 
// Game system manager
// System event base type
// Event bus interface for system communication
// General system configuration
// System-specific types for Korean martial arts combat
 
// Combat system interfaces
export interface CombatSystemConfig {
  readonly damageMultiplier: number;
  readonly criticalChance: number;
  readonly blockEffectiveness: number;
  readonly staminaDrainRate: number;
}
 
// Trigram system interfaces
export interface TrigramSystemConfig {
  readonly transitionSpeed: number;
  readonly energyCost: number;
  readonly effectivenessMatrix: Record<
    TrigramStance,
    Record<TrigramStance, number>
  >;
}
 
// Vital point system interfaces
// AI system interfaces
export interface AISystemConfig {
  readonly difficulty: "easy" | "medium" | "hard" | "expert";
  readonly reactionTime: number;
  readonly aggressiveness: number;
  readonly adaptability: number;
}
 
// Re-export PixiJS types for convenience
export type { PixiApplication, PixiDisplayObject };
 
// Player archetype data
export const PLAYER_ARCHETYPES_DATA: Record<
  PlayerArchetype,
  PlayerArchetypeData
> = {
  [PlayerArchetype.MUSA]: {
    id: "musa",
    name: { korean: "무사 (Musa)", english: "Traditional Warrior" },
    description: {
      korean: "전통 무사의 길",
      english: "Path of the traditional warrior",
    },
    baseHealth: 120,
    baseKi: 100,
    baseStamina: 110,
    coreStance: TrigramStance.GEON,
    theme: {
      primary: KOREAN_COLORS.TRIGRAM_GEON_PRIMARY,
      secondary: KOREAN_COLORS.KOREAN_RED,
    },
    colors: {
      primary: KOREAN_COLORS.TRIGRAM_GEON_PRIMARY,
      secondary: KOREAN_COLORS.KOREAN_RED,
    },
    stats: {
      attackPower: 85,
      defense: 90,
      speed: 70,
      technique: 80,
    },
    favoredStances: [TrigramStance.GEON, TrigramStance.GAN],
    specialAbilities: ["Honor Strike", "Defensive Mastery"],
    philosophy: {
      korean: "명예와 정의의 길",
      english: "The way of honor and justice",
    },
  },
 
  [PlayerArchetype.AMSALJA]: {
    id: "amsalja",
    name: { korean: "암살자 (Amsalja)", english: "Shadow Assassin" },
    description: {
      korean: "그림자 속의 효율성",
      english: "Efficiency from the shadows",
    },
    baseHealth: 80,
    baseKi: 120,
    baseStamina: 100,
    coreStance: TrigramStance.SON,
    theme: {
      primary: KOREAN_COLORS.TRIGRAM_SON_PRIMARY,
      secondary: KOREAN_COLORS.UI_BACKGROUND_DARK,
    },
    colors: {
      primary: KOREAN_COLORS.TRIGRAM_SON_PRIMARY,
      secondary: KOREAN_COLORS.UI_BACKGROUND_DARK,
    },
    stats: {
      attackPower: 95,
      defense: 60,
      speed: 95,
      technique: 90,
    },
    favoredStances: [TrigramStance.SON, TrigramStance.GAM],
    specialAbilities: ["Shadow Strike", "Vital Point Mastery"],
    philosophy: {
      korean: "침묵과 정확성의 도",
      english: "The way of silence and precision",
    },
  },
 
  [PlayerArchetype.HACKER]: {
    id: "hacker",
    name: { korean: "해커 (Hacker)", english: "Cyber Warrior" },
    description: {
      korean: "정보를 통한 힘",
      english: "Power through information",
    },
    baseHealth: 90,
    baseKi: 130,
    baseStamina: 80,
    coreStance: TrigramStance.LI,
    theme: {
      primary: KOREAN_COLORS.PRIMARY_CYAN,
      secondary: KOREAN_COLORS.TRIGRAM_LI_PRIMARY,
    },
    colors: {
      primary: KOREAN_COLORS.PRIMARY_CYAN,
      secondary: KOREAN_COLORS.TRIGRAM_LI_PRIMARY,
    },
    stats: {
      attackPower: 75,
      defense: 70,
      speed: 85,
      technique: 95,
    },
    favoredStances: [TrigramStance.LI, TrigramStance.JIN],
    specialAbilities: ["System Override", "Digital Precision"],
    philosophy: {
      korean: "지식과 기술의 융합",
      english: "The fusion of knowledge and technology",
    },
  },
 
  [PlayerArchetype.JEONGBO_YOWON]: {
    id: "jeongbo_yowon",
    name: {
      korean: "정보요원 (Jeongbo Yowon)",
      english: "Intelligence Operative",
    },
    description: {
      korean: "관찰을 통한 지식",
      english: "Knowledge through observation",
    },
    baseHealth: 100,
    baseKi: 110,
    baseStamina: 100,
    coreStance: TrigramStance.TAE,
    theme: {
      primary: KOREAN_COLORS.TRIGRAM_TAE_PRIMARY,
      secondary: KOREAN_COLORS.UI_STEEL_GRAY,
    },
    colors: {
      primary: KOREAN_COLORS.TRIGRAM_TAE_PRIMARY,
      secondary: KOREAN_COLORS.UI_STEEL_GRAY,
    },
    stats: {
      attackPower: 80,
      defense: 85,
      speed: 80,
      technique: 85,
    },
    favoredStances: [TrigramStance.TAE, TrigramStance.GAN],
    specialAbilities: ["Intel Gathering", "Adaptive Combat"],
    philosophy: {
      korean: "적응과 전략의 예술",
      english: "The art of adaptation and strategy",
    },
  },
 
  [PlayerArchetype.JOJIK_POKRYEOKBAE]: {
    id: "jojik_pokryeokbae",
    name: {
      korean: "조직폭력배 (Jojik Pokryeokbae)",
      english: "Organized Crime",
    },
    description: {
      korean: "무자비함을 통한 생존",
      english: "Survival through ruthlessness",
    },
    baseHealth: 110,
    baseKi: 90,
    baseStamina: 120,
    coreStance: TrigramStance.JIN,
    theme: {
      primary: KOREAN_COLORS.TRIGRAM_JIN_PRIMARY,
      secondary: KOREAN_COLORS.NEGATIVE_RED,
    },
    colors: {
      primary: KOREAN_COLORS.TRIGRAM_JIN_PRIMARY,
      secondary: KOREAN_COLORS.NEGATIVE_RED,
    },
    stats: {
      attackPower: 90,
      defense: 75,
      speed: 75,
      technique: 70,
    },
    favoredStances: [TrigramStance.JIN, TrigramStance.GON],
    specialAbilities: ["Brutal Force", "Street Fighting"],
    philosophy: {
      korean: "강함과 의지의 길",
      english: "The way of strength and will",
    },
  },
} as const;
 
// Base player stats
export const BASE_PLAYER_STATS = {
  HEALTH: 100,
  KI: 100,
  STAMINA: 100,
  ATTACK_POWER: 75,
  DEFENSE: 75,
  SPEED: 75,
  TECHNIQUE: 75,
} as const;
 
// Combat configuration
export const COMBAT_CONFIG = {
  MAX_HEALTH: 100,
  MAX_KI: 100,
  MAX_STAMINA: 100,
  MAX_BALANCE: 100,
  MAX_CONSCIOUSNESS: 100,
 
  // Damage multipliers
  CRITICAL_HIT_MULTIPLIER: 2.0,
  VITAL_POINT_MULTIPLIER: 1.5,
  COUNTER_ATTACK_MULTIPLIER: 1.3,
 
  // Status thresholds
  LOW_HEALTH_THRESHOLD: 25,
  CRITICAL_HEALTH_THRESHOLD: 10,
  UNCONSCIOUS_THRESHOLD: 0,
  STAMINA_EXHAUSTED_THRESHOLD: 0,
 
  // Recovery rates (per second)
  STAMINA_RECOVERY_RATE: 10,
  KI_RECOVERY_RATE: 5,
  BALANCE_RECOVERY_RATE: 15,
  CONSCIOUSNESS_RECOVERY_RATE: 2,
 
  // Combat timing (milliseconds)
  TECHNIQUE_COOLDOWN: 500,
  STANCE_CHANGE_COOLDOWN: 200,
  BLOCK_DURATION: 300,
  RECOVERY_TIME: 400,
} as const;
 
// Enhanced damage calculation constants
export const ENHANCED_DAMAGE_CONSTANTS = {
  BASE_DAMAGE: 10,
  CRITICAL_MULTIPLIER: 2.0,
  VITAL_POINT_MULTIPLIER: 1.5,
  ARMOR_REDUCTION: 0.1,
  STANCE_DEFENSE_BONUS: 0.2,
  BALANCE_IMPACT_MULTIPLIER: 0.3,
  CONSCIOUSNESS_THRESHOLD: 30,
  PAIN_THRESHOLD: 80,
 
  // New damage factors
  TECHNIQUE_POWER_MODIFIER: 0.2,
  ARCHETYPE_BONUS: 0.15,
  COMBO_MULTIPLIER: 1.2,
  PERFECT_TIMING_BONUS: 0.3,
  BASE_CRIT_CHANCE: 0.1, // Added: Base critical hit chance (e.g., 10%)
} as const;
 
// Combat system constants for Korean martial arts
 
export const COMBAT_CONSTANTS = {
  // Damage calculation
  BASE_DAMAGE: 10,
  CRITICAL_MULTIPLIER: 2.0,
  VITAL_POINT_MULTIPLIER: 1.5,
 
  // Status thresholds
  LOW_HEALTH_THRESHOLD: 30,
  CRITICAL_HEALTH_THRESHOLD: 15,
  EXHAUSTED_STAMINA_THRESHOLD: 20,
 
  // Recovery rates (per second)
  STAMINA_RECOVERY_RATE: 5,
  KI_RECOVERY_RATE: 3,
  CONSCIOUSNESS_RECOVERY_RATE: 2,
 
  // Combat timing
  ATTACK_COOLDOWN: 500, // milliseconds
  STANCE_CHANGE_COOLDOWN: 300,
  BLOCK_WINDOW: 200,
 
  // Balance and momentum
  BALANCE_RECOVERY_RATE: 10,
  MOMENTUM_DECAY_RATE: 5,
 
  // Pain and status effects
  PAIN_DECAY_RATE: 3,
  STATUS_EFFECT_DURATION: 3000,
} as const;
 
// Combat controls mapping - Enhanced with realistic combat focus
export const COMBAT_CONTROLS = {
  // Trigram stance system (1-8 keys) with authentic Korean martial arts techniques
  stanceControls: {
    "1": {
      stance: "geon" as TrigramStance,
      korean: "건",
      english: "Heaven",
      symbol: "☰",
      technique: {
        korean: "천둥벽력",
        english: "Thunder Strike",
      },
      combatFocus: {
        korean: "골격타격",
        english: "Bone-striking force",
      },
      combatEffects: {
        korean: "골절, 구조적 손상",
        english: "Fractures, structural damage",
      },
      description: {
        korean: "하늘의 힘으로 적의 뼈를 부수는 강력한 타격",
        english:
          "Powerful strikes that shatter enemy bones with heaven's force",
      },
    },
    "2": {
      stance: "tae" as TrigramStance,
      korean: "태",
      english: "Lake",
      symbol: "☱",
      technique: {
        korean: "유수연타",
        english: "Flowing Strike",
      },
      combatFocus: {
        korean: "관절조작",
        english: "Joint manipulation",
      },
      combatEffects: {
        korean: "탈구, 이동력 상실",
        english: "Dislocations, mobility loss",
      },
      description: {
        korean: "호수처럼 부드럽게 흘러 관절을 조작하는 기법",
        english: "Techniques that flow like water to manipulate joints",
      },
    },
    "3": {
      stance: "li" as TrigramStance,
      korean: "리",
      english: "Fire",
      symbol: "☲",
      technique: {
        korean: "화염지창",
        english: "Fire Spear",
      },
      combatFocus: {
        korean: "정밀신경타격",
        english: "Precise nerve strikes",
      },
      combatEffects: {
        korean: "일시마비, 감각상실",
        english: "Temporary paralysis, numbness",
      },
      description: {
        korean: "불꽃같은 정확성으로 신경계를 공격하는 치명적 기법",
        english:
          "Deadly techniques targeting the nervous system with fire-like precision",
      },
    },
    "4": {
      stance: "jin" as TrigramStance,
      korean: "진",
      english: "Thunder",
      symbol: "☳",
      technique: {
        korean: "벽력일섬",
        english: "Lightning Strike",
      },
      combatFocus: {
        korean: "기절기법",
        english: "Stunning techniques",
      },
      combatEffects: {
        korean: "방향감각상실, 의식잃음",
        english: "Disorientation, knockouts",
      },
      description: {
        korean: "번개처럼 빠른 충격으로 적의 의식을 차단",
        english: "Lightning-fast shocks that disrupt enemy consciousness",
      },
    },
    "5": {
      stance: "son" as TrigramStance,
      korean: "손",
      english: "Wind",
      symbol: "☴",
      technique: {
        korean: "선풍연격",
        english: "Whirlwind Combo",
      },
      combatFocus: {
        korean: "지속압박",
        english: "Continuous pressure",
      },
      combatEffects: {
        korean: "점진적 무력화",
        english: "Gradual incapacitation",
      },
      description: {
        korean: "바람처럼 끊임없는 연타로 적을 서서히 무력화",
        english:
          "Relentless wind-like strikes that gradually overwhelm the enemy",
      },
    },
    "6": {
      stance: "gam" as TrigramStance,
      korean: "감",
      english: "Water",
      symbol: "☵",
      technique: {
        korean: "수류반격",
        english: "Water Counter",
      },
      combatFocus: {
        korean: "혈류차단",
        english: "Blood flow restriction",
      },
      combatEffects: {
        korean: "순환장애",
        english: "Circulation disruption",
      },
      description: {
        korean: "물의 흐름을 끊듯 혈액순환을 차단하는 위험한 기법",
        english:
          "Dangerous techniques that disrupt blood circulation like stopping water flow",
      },
    },
    "7": {
      stance: "gan" as TrigramStance,
      korean: "간",
      english: "Mountain",
      symbol: "☶",
      technique: {
        korean: "반석방어",
        english: "Mountain Defense",
      },
      combatFocus: {
        korean: "방어반격",
        english: "Defensive counters",
      },
      combatEffects: {
        korean: "반격, 차단",
        english: "Counter-attacks, blocks",
      },
      description: {
        korean: "산처럼 견고한 방어에서 나오는 강력한 반격",
        english: "Powerful counters emerging from mountain-solid defense",
      },
    },
    "8": {
      stance: "gon" as TrigramStance,
      korean: "곤",
      english: "Earth",
      symbol: "☷",
      technique: {
        korean: "대지포옹",
        english: "Earth's Embrace",
      },
      combatFocus: {
        korean: "지면기법",
        english: "Ground techniques",
      },
      combatEffects: {
        korean: "투척, 넘어뜨리기",
        english: "Throws, takedowns",
      },
      description: {
        korean: "대지의 힘으로 적을 땅에 내동댕이치는 투척술",
        english:
          "Throwing techniques that slam enemies to the ground with earth's power",
      },
    },
  },
 
  // Movement controls with combat context
  movement: {
    WASD: {
      korean: "전술적 이동과 발놀림",
      english: "Tactical positioning and footwork",
    },
    ArrowKeys: {
      korean: "대체 이동 시스템",
      english: "Alternative movement system",
    },
  },
 
  // Combat actions with realistic descriptions
  combat: {
    SPACE: {
      korean: "현재 자세의 기법 실행",
      english: "Execute current stance technique",
    },
    SHIFT: {
      korean: "방어 자세/차단 위치",
      english: "Defensive guard/block position",
    },
    CTRL: {
      korean: "정밀 급소 타격 모드",
      english: "Precision vital point targeting mode",
    },
    TAB: {
      korean: "무술 원형 순환",
      english: "Cycle through martial archetypes",
    },
  },
 
  // System controls
  system: {
    ESC: {
      korean: "일시정지 메뉴 / 인트로로 돌아가기",
      english: "Pause menu / Return to intro",
    },
    F1: {
      korean: "도움말 / 조작법 가이드",
      english: "Help / Controls guide",
    },
    M: {
      korean: "음소거 / 오디오 설정",
      english: "Mute / Audio settings",
    },
  },
} as const;
 
// Damage types
export const DAMAGE_TYPES = {
  PHYSICAL: "physical",
  ENERGY: "energy",
  VITAL_POINT: "vital_point",
  PSYCHOLOGICAL: "psychological",
} as const;
 
// Combat phases
export const COMBAT_PHASES = {
  PREPARATION: "preparation",
  ENGAGEMENT: "engagement",
  EXECUTION: "execution",
  RECOVERY: "recovery",
  RESOLUTION: "resolution",
} as const;
 
// Combat audio mapping
export const COMBAT_AUDIO_MAP: Record<string, SoundEffectId> = {
  light_attack: "attack_light",
  medium_attack: "attack_medium",
  heavy_attack: "attack_heavy",
  critical_attack: "attack_critical",
 
  light_hit: "hit_light",
  medium_hit: "hit_medium",
  heavy_hit: "hit_heavy",
  critical_hit: "critical_hit",
 
  block: "block_success",
  guard_break: "block_break",
  miss: "miss",
 
  stance_change: "stance_change",
  technique: "technique_execute",
 
  match_start: "match_start",
  combat_end: "combat_end",
  victory: "victory",
  defeat: "defeat",
 
  guard: "guard",
} as const;
 
// Combat state transitions
export const COMBAT_STATE_MACHINE = {
  idle: {
    canTransitionTo: ["attacking", "defending", "moving", "stunned"],
    duration: Infinity,
  },
  attacking: {
    canTransitionTo: ["idle", "recovering", "stunned"],
    duration: 500,
  },
  defending: {
    canTransitionTo: ["idle", "attacking", "stunned"],
    duration: 300,
  },
  moving: {
    canTransitionTo: ["idle", "attacking", "defending"],
    duration: 200,
  },
  stunned: {
    canTransitionTo: ["idle"],
    duration: 1000,
  },
  recovering: {
    canTransitionTo: ["idle"],
    duration: 400,
  },
  unconscious: {
    canTransitionTo: ["idle"],
    duration: 5000,
  },
} as const;
 
// Training-specific combat constants
export const TRAINING_COMBAT_SETTINGS = {
  techniqueCooldown: 500,
  perfectStrikeThreshold: 0.7,
  maxTrainingSession: 300000, // 5 minutes
  kiRegenerationRate: 2,
  staminaRegenerationRate: 1.5,
} as const;
 
// Combat state transitions for training mode
export const TRAINING_STATE_MACHINE = {
  practicing: {
    canTransitionTo: ["idle", "executing", "recovering"],
    duration: Infinity,
  },
  executing: {
    canTransitionTo: ["practicing", "idle"],
    duration: 800,
  },
  recovering: {
    canTransitionTo: ["practicing", "idle"],
    duration: 300,
  },
} as const;
 
// Technique execution results
export const TECHNIQUE_RESULTS = {
  SUCCESS: "success",
  BLOCKED: "blocked",
  MISSED: "missed",
  COUNTERED: "countered",
  INTERRUPTED: "interrupted",
} as const;
 
// Combat effectiveness modifiers
export const EFFECTIVENESS_MODIFIERS = {
  stance_advantage: 1.2,
  stance_disadvantage: 0.8,
  counter_attack: 1.5,
  perfect_timing: 1.3,
  off_balance: 0.7,
  fatigued: 0.6,
  focused: 1.1,
} as const;
 
// Combat resource costs
export const RESOURCE_COSTS = {
  KI: {
    BASIC_TECHNIQUE: 5,
    ADVANCED_TECHNIQUE: 10,
    SPECIAL_TECHNIQUE: 15,
    ULTIMATE_TECHNIQUE: 25,
  },
  STAMINA: {
    BASIC_ATTACK: 8,
    HEAVY_ATTACK: 15,
    BLOCK: 5,
    DODGE: 10,
    STANCE_CHANGE: 12,
  },
} as const;
 
// Hit detection constants
export const HIT_DETECTION = {
  PRECISION_THRESHOLD: 0.8,
  VITAL_POINT_THRESHOLD: 0.9,
  BASE_ACCURACY: 0.7,
  MAX_ACCURACY: 0.95,
 
  // Hit boxes
  PLAYER_HITBOX_WIDTH: 60,
  PLAYER_HITBOX_HEIGHT: 180,
  VITAL_POINT_RADIUS: 15,
} as const;
 
// Status effect durations
export const STATUS_DURATIONS = {
  STUN: 1500,
  POISON: 5000,
  BURN: 3000,
  BLEED: 4000,
  WEAKNESS: 6000,
  STRENGTH_BUFF: 8000,
} as const;
 
export interface CombatControlsConfig {
  readonly stanceControls: Record<
    string,
    { stance: string; korean: string; technique: string }
  >;
  readonly movement: Record<string, string>;
  readonly combat: Record<string, string>;
  readonly system: Record<string, string>;
}
 
// Key mapping for easier lookup
export const KEYBOARD_MAPPING = {
  // Stance keys
  STANCE_1: "1",
  STANCE_2: "2",
  STANCE_3: "3",
  STANCE_4: "4",
  STANCE_5: "5",
  STANCE_6: "6",
  STANCE_7: "7",
  STANCE_8: "8",
 
  // Combat actions
  EXECUTE_TECHNIQUE: " ", // Space
  BLOCK: "Shift",
  TARGET_MODE: "Control",
  ARCHETYPE_CYCLE: "Tab",
 
  // Movement
  MOVE_UP: "w",
  MOVE_DOWN: "s",
  MOVE_LEFT: "a",
  MOVE_RIGHT: "d",
 
  // System
  PAUSE: "Escape",
  HELP: "F1",
  MUTE: "m",
} as const;
 
/**
 * Get the stance associated with a given key.
 *
 * @param key - The key to lookup.
 * @returns The corresponding stance, or null if not found.
 */
export function getStanceFromKey(key: string): TrigramStance | null {
  const stanceMap: Record<string, TrigramStance> = {
    "1": TrigramStance.GEON,
    "2": TrigramStance.TAE,
    "3": TrigramStance.LI,
    "4": TrigramStance.JIN,
    "5": TrigramStance.SON,
    "6": TrigramStance.GAM,
    "7": TrigramStance.GAN,
    "8": TrigramStance.GON,
  };
  return stanceMap[key] || null;
}
 
export interface CombatControlsConfig {
  readonly stanceControls: Record<
    string,
    { stance: string; korean: string; technique: string }
  >;
  readonly movement: Record<string, string>;
  readonly combat: Record<string, string>;
  readonly system: Record<string, string>;
}
 
// Input handling types
export interface InputEvent {
  readonly type: "keydown" | "keyup" | "pointerdown" | "pointerup";
  readonly key?: string;
  readonly position?: { x: number; y: number };
  readonly timestamp: number;
}
 
export interface CombatInput {
  readonly player: number;
  readonly action: string;
  readonly data?: any;
}
 
// Gesture types
export interface Gesture {
  readonly type: "tap" | "hold" | "swipe" | "combo";
  readonly duration?: number;
  readonly direction?: "up" | "down" | "left" | "right";
  readonly sequence?: string[];
}
 
export const DEFAULT_GAME_SPEED = 1.0;
 
/**
 * Core game configuration constants for Black Trigram
 */
 
// Game configuration
export const GAME_CONFIG = {
  // Canvas dimensions
  CANVAS_WIDTH: 1200,
  CANVAS_HEIGHT: 800,
  TARGET_FPS: 60,
  MIN_FPS: 30,
 
  // Combat settings
  ROUND_DURATION: 180, // seconds
  MAX_ROUNDS: 3,
  KO_THRESHOLD: 0,
 
  // Player settings
  BASE_HEALTH: 100,
  BASE_KI: 100,
  BASE_STAMINA: 100,
 
  // Player positions
  PLAYER_START_POS_X_1: 300,
  PLAYER_START_POS_X_2: 900,
  PLAYER_START_POS_Y: 400,
 
  // Physics
  GRAVITY: 9.8,
  FRICTION: 0.85,
 
  // UI settings
  UI_PADDING: 20,
  BUTTON_HEIGHT: 50,
 
  // Audio settings
  MASTER_VOLUME: 1.0,
  MUSIC_VOLUME: 0.7,
  SFX_VOLUME: 0.8,
 
  // Debug settings
  DEBUG_MODE: false,
  SHOW_HITBOXES: false,
  SHOW_VITAL_POINTS: false,
} as const;
 
// Add missing player colors
export const PLAYER_COLORS = {
  PLAYER_1_COLOR: 0x0099ff, // Blue
  PLAYER_2_COLOR: 0xff9900, // Orange
} as const;
 
// Difficulty settings
export const DIFFICULTY_SETTINGS = {
  BEGINNER: {
    AI_REACTION_TIME: 800,
    DAMAGE_MULTIPLIER: 0.7,
    TECHNIQUE_SUCCESS_RATE: 0.6,
  },
  INTERMEDIATE: {
    AI_REACTION_TIME: 600,
    DAMAGE_MULTIPLIER: 1.0,
    TECHNIQUE_SUCCESS_RATE: 0.8,
  },
  EXPERT: {
    AI_REACTION_TIME: 400,
    DAMAGE_MULTIPLIER: 1.3,
    TECHNIQUE_SUCCESS_RATE: 0.9,
  },
  MASTER: {
    AI_REACTION_TIME: 200,
    DAMAGE_MULTIPLIER: 1.5,
    TECHNIQUE_SUCCESS_RATE: 0.95,
  },
} as const;
 
// Game phases
export const GAME_PHASES = {
  INTRO: "intro",
  TRAINING: "training",
  COMBAT: "combat",
  VICTORY: "victory",
  DEFEAT: "defeat",
} as const;
 
// Game version and metadata
export const GAME_METADATA = {
  VERSION: "1.0.0",
  BUILD: "2024.1",
  TITLE: "흑괘 (Black Trigram)",
  SUBTITLE: "Korean Martial Arts Combat Simulator",
  DEVELOPER: "Black Trigram Team",
  COPYRIGHT: "© 2024 Black Trigram",
} as const;
 
// Performance thresholds
export const PERFORMANCE_THRESHOLDS = {
  TARGET_FPS: 60,
  MIN_FPS: 30,
  FRAME_TIME_WARNING: 20, // ms
  MEMORY_WARNING: 100, // MB
  GARBAGE_COLLECTION_THRESHOLD: 50, // MB
} as const;
 
// Combat timing constants
export const COMBAT_TIMING = {
  ATTACK_WINDOW: 500, // ms
  DEFENSE_WINDOW: 300, // ms
  RECOVERY_TIME: 200, // ms
  COUNTER_WINDOW: 150, // ms
} as const;
 
// Damage calculation constants
export const DAMAGE_CONSTANTS = {
  BASE_DAMAGE: 10,
  CRITICAL_MULTIPLIER: 2.0,
  VITAL_POINT_MULTIPLIER: 1.5,
  ARMOR_REDUCTION: 0.1,
  STANCE_DEFENSE_BONUS: 0.2,
  BALANCE_IMPACT_MULTIPLIER: 0.3,
  CONSCIOUSNESS_THRESHOLD: 30,
  PAIN_THRESHOLD: 80,
  BASE_CRIT_CHANCE: 0.1, // Added: Base critical hit chance (e.g., 10%)
  TECHNIQUE_ACCURACY_MODIFIER: 1.0, // Added
  STANCE_EFFECTIVENESS_RANGE: { MIN: 0.5, MAX: 1.5 }, // Added
  PERFECT_TIMING_BONUS: 0.3, // Added
} as const;
 
// Animation timings
export const ANIMATION_TIMINGS = {
  STANCE_TRANSITION: 300,
  TECHNIQUE_STARTUP: 150,
  TECHNIQUE_ACTIVE: 100,
  TECHNIQUE_RECOVERY: 250,
  HIT_STUN: 200,
  BLOCK_STUN: 100,
  KNOCKDOWN_RECOVERY: 1000,
} as const;
 
// UI Layout constants
export const UI_LAYOUT = {
  HUD_HEIGHT: 80,
  CONTROLS_HEIGHT: 120,
  SIDEBAR_WIDTH: 200,
  MARGIN: 20,
  BUTTON_HEIGHT: 50,
  BUTTON_WIDTH: 150,
} as const;
 
// Audio volume defaults
export const AUDIO_DEFAULTS = {
  MASTER_VOLUME: 0.7,
  SFX_VOLUME: 0.8,
  MUSIC_VOLUME: 0.5,
  AMBIENT_VOLUME: 0.3,
} as const;
 
// Calculated constants based on GAME_CONFIG
export const HALF_CANVAS_WIDTH = GAME_CONFIG.CANVAS_WIDTH / 2;
export const HALF_CANVAS_HEIGHT = GAME_CONFIG.CANVAS_HEIGHT / 2;
export const CANVAS_ASPECT_RATIO =
  GAME_CONFIG.CANVAS_WIDTH / GAME_CONFIG.CANVAS_HEIGHT;
export const FRAME_TIME = 1000 / GAME_CONFIG.TARGET_FPS;
export const TICK_RATE = GAME_CONFIG.TARGET_FPS;
 
// Player distance calculations
export const PLAYER_DISTANCE =
  GAME_CONFIG.PLAYER_START_POS_X_2 - GAME_CONFIG.PLAYER_START_POS_X_1;
export const CENTER_POSITION_X =
  (GAME_CONFIG.PLAYER_START_POS_X_1 + GAME_CONFIG.PLAYER_START_POS_X_2) / 2;
 
// Combat ranges
export const COMBAT_RANGES = {
  MELEE_RANGE: 80,
  CLOSE_RANGE: 120,
  MEDIUM_RANGE: 200,
  LONG_RANGE: 300,
  MAX_RANGE: PLAYER_DISTANCE,
} as const;
 
// Game state constants
export const GAME_STATES = {
  LOADING: "loading",
  MENU: "menu",
  CHARACTER_SELECT: "character_select",
  TRAINING: "training",
  COMBAT: "combat",
  PAUSED: "paused",
  GAME_OVER: "game_over",
} as const;
 
// Input constants
export const INPUT_CONSTANTS = {
  DOUBLE_TAP_TIME: 300, // ms
  HOLD_THRESHOLD: 500, // ms
  GESTURE_TIMEOUT: 1000, // ms
  COMBO_TIMEOUT: 2000, // ms
} as const;
 
// Visual effect constants
export const VISUAL_EFFECTS = {
  HIT_FLASH_DURATION: 100,
  SCREEN_SHAKE_INTENSITY: 5,
  PARTICLE_LIFETIME: 1000,
  GLOW_PULSE_SPEED: 2,
  STANCE_GLOW_OPACITY: 0.3,
} as const;
 
// Training mode constants
export const TRAINING_CONFIG = {
  DUMMY_HEALTH: 1000,
  AUTO_RESET_TIME: 5000, // ms
  SHOW_FRAME_DATA: true,
  SHOW_HITBOXES: true,
  INFINITE_KI: true,
  INFINITE_STAMINA: true,
} as const;
 
// Game mode configurations
export const GAME_MODE_CONFIG = {
  VERSUS: {
    allowPause: true,
    timeLimit: 180,
    rounds: 3,
    enableAI: false,
  },
  TRAINING: {
    allowPause: true,
    timeLimit: null,
    rounds: 1,
    enableAI: true,
    infiniteResources: true,
  },
  PRACTICE: {
    allowPause: true,
    timeLimit: null,
    rounds: 1,
    enableAI: false,
    infiniteResources: true,
  },
} as const;
 
// Performance settings
export const PERFORMANCE_CONFIG = {
  MAX_PARTICLES: 100,
  MAX_SOUND_SOURCES: 16,
  TEXTURE_QUALITY: "high",
  ENABLE_SHADOWS: true,
  ENABLE_POST_PROCESSING: true,
} as const;
 
// Korean martial arts specific settings
export const MARTIAL_ARTS_CONFIG = {
  VITAL_POINTS_COUNT: 70,
  TRIGRAM_STANCES_COUNT: 8,
  PLAYER_ARCHETYPES_COUNT: 5,
 
  // Combat timing
  ATTACK_WINDOW: 500, // milliseconds
  COUNTER_WINDOW: 300,
  BLOCK_WINDOW: 200,
 
  // Stance transition
  MIN_STANCE_CHANGE_INTERVAL: 500,
  STANCE_CHANGE_COST_BASE: 10,
 
  // Damage calculations
  BASE_DAMAGE_MULTIPLIER: 1.0,
  CRITICAL_HIT_MULTIPLIER: 1.5,
  VITAL_POINT_MULTIPLIER: 2.0,
} as const;
 
export default GAME_CONFIG;