Black Trigram (흑괘) - Korean Martial Arts Combat Simulator API - v0.6.9
    Preparing search index...

    Class BalanceSystem

    Balance System managing stability and vulnerability.

    Balance represents physical stability and center of gravity control. Low balance creates vulnerability windows where opponents can capitalize with increased damage and reduced defensive options.

    const balanceSystem = new BalanceSystem();

    // Apply balance disruption from leg strike
    const newPlayer = balanceSystem.disruptBalance(
    player,
    15,
    BodyRegion.LEFT_LEG
    );

    // Check if vulnerable
    const isVulnerable = balanceSystem.isVulnerable(newPlayer);

    // Apply recovery
    const recovered = balanceSystem.applyRecovery(newPlayer, 1000);

    균형시스템

    Index

    Constructors

    Methods

    • Applies balance recovery over time.

      Balance recovers quickly when not being disrupted, allowing fighters to regain stable footing between exchanges.

      Parameters

      • player: PlayerState

        Current player state

      • deltaTime: number

        Time elapsed in milliseconds

      Returns PlayerState

      Updated player state with recovered balance

      // In game loop
      player = system.applyRecovery(player, 16); // ~60fps

      균형회복

    • Apply stamina cost for recovery animation.

      Deducts stamina cost from player state for recovery animations that require stamina (like roll recovery).

      Parameters

      • player: PlayerState

        Current player state

      • recoveryType: RecoveryAnimationType

        Type of recovery animation

      Returns PlayerState

      Updated player state with stamina deducted

      // Roll recovery costs 20 stamina
      const recovered = balanceSystem.applyRecoveryCost(player, "roll_recovery");
      // recovered.stamina = player.stamina - 20

      회복비용적용

    • Check if player can execute recovery based on stamina.

      Some recovery animations (like roll recovery) require stamina. This checks if player has sufficient stamina for the recovery type.

      Parameters

      • player: PlayerState

        Current player state

      • recoveryType: RecoveryAnimationType

        Type of recovery animation

      Returns boolean

      True if player has enough stamina

      // Roll recovery costs 20 stamina
      const canRoll = balanceSystem.canRecoverWithType(player, "roll_recovery");
      // Returns: true if player.stamina >= 20

      // Normal recoveries have no cost
      const canStand = balanceSystem.canRecoverWithType(player, "prone_standup");
      // Returns: true (no stamina requirement)

      회복가능확인

    • Determines which fall animation to play based on attack and stance.

      Calculates fall direction using:

      • Attack angle relative to player
      • Attack height (high/mid/low)
      • Player's current stance bias

      Korean falling techniques (낙법):

      • 전방낙법 (Jeonbang Nakbeop): Forward fall
      • 후방낙법 (Hubang Nakbeop): Backward fall
      • 측방낙법 (Cheukbang Nakbeop): Side fall

      Parameters

      • _player: PlayerState
      • attackAngle: number

        Angle of attack in radians (0 = from front)

      • attackHeight: "low" | "high" | "mid" = "mid"

        Attack height: 'high', 'mid', or 'low'

      Returns FallType

      Fall type to use for animation

      // Player facing forward (0°), attacked from behind (π)
      const fallType = balanceSystem.determineFallType(
      player,
      Math.PI,
      'mid'
      );
      // Returns: 'forward' (pushed forward by rear attack)

      // Low sweep from right side
      const fallType = balanceSystem.determineFallType(
      player,
      Math.PI/2,
      'low'
      );
      // Returns: 'side_right' (swept to the side)

      낙법유형결정

    • Determines fall type based on player stance when no attack direction available.

      Uses stance bias to determine likely fall direction when balance is lost without a specific attack (e.g., from fatigue, leg damage accumulation).

      Parameters

      Returns FallType

      Fall type based on stance characteristics

      // Player in Heaven stance (aggressive forward)
      const fallType = balanceSystem.determineFallTypeFromStance(
      TrigramStance.GEON
      );
      // Returns: 'forward' (Heaven stance has forward bias)

      자세낙법결정

    • Disrupts balance from combat impact.

      Calculates balance loss based on damage amount and body region hit. Leg strikes cause maximum balance disruption.

      Parameters

      • player: PlayerState

        Current player state

      • impact: number

        Impact force amount

      • Optionalregion: BodyRegion

        Body region affected

      Returns PlayerState

      Updated player state with reduced balance

      // Leg sweep causes major balance disruption
      player = system.disruptBalance(
      player,
      20,
      BodyRegion.RIGHT_LEG
      );

      균형파괴

    • Get ground state from animation state.

      Extracts the ground position type from animation state name. Returns null if not in a ground state.

      Parameters

      • animationState: string

        Current animation state from AnimationStateMachine

      Returns GroundState | null

      Ground state or null if not grounded

      const state = balanceSystem.getGroundState("ground_prone");
      // Returns: "prone"

      const none = balanceSystem.getGroundState("idle");
      // Returns: null

      지면자세가져오기

    • Get damage multiplier during recovery animation.

      Some recovery animations (like defensive getup) provide damage reduction. This returns the multiplier to apply to incoming damage.

      Parameters

      • recoveryType: RecoveryAnimationType

        Type of recovery animation

      • currentFrame: number

        Current frame in the animation

      Returns number

      Damage multiplier (1.0 = normal, 0.5 = 50% reduction)

      // Defensive getup has 50% damage reduction
      const multiplier = balanceSystem.getRecoveryDamageMultiplier("defensive_getup", 20);
      // Returns: 0.5 (50% damage reduction)

      // Normal recoveries have no reduction
      const normal = balanceSystem.getRecoveryDamageMultiplier("prone_standup", 15);
      // Returns: 1.0 (full damage)

      회복피해배율

    • Calculates damage multiplier for vulnerable balance state.

      Parameters

      Returns number

      Damage multiplier (1.0 = normal, >1.0 = increased damage)

      취약성배율

    • Check if player is in a grounded state based on animation state.

      Player is considered grounded when in any ground_* animation state (ground_prone, ground_supine, ground_side_left, ground_side_right).

      Parameters

      • animationState: string

        Current animation state from AnimationStateMachine

      Returns boolean

      True if player is on the ground

      const isGrounded = balanceSystem.isGrounded("ground_prone");
      // Returns: true

      const notGrounded = balanceSystem.isGrounded("idle");
      // Returns: false

      지면상태확인

    • Checks if knockdown should occur, using a provided random function for determinism.

      Parameters

      • player: PlayerState

        Current player state

      • randomFn: () => number = Math.random

        Optional random number generator (returns number in [0,1)), defaults to Math.random

      Returns boolean

      True if knockdown should occur

      넘어짐확인

    • Checks if balance is low enough to trigger fall animation.

      Falls occur when balance drops below 20% (FALLING state). This creates realistic knockdown conditions from balance loss.

      Parameters

      Returns boolean

      True if fall animation should trigger

      if (balanceSystem.shouldTriggerFall(player)) {
      const fallType = balanceSystem.determineFallType(
      player,
      attackAngle,
      attackHeight
      );
      animationMachine.transitionTo(FALL_TYPE_TO_ANIMATION[fallType]);
      }

      낙법발동확인

    Properties

    balanceEffects: Record<BalanceLevel, BalanceEffects> = ...

    Balance level effects and thresholds.

    baseRecoveryRate: 8 = 8.0

    Base balance recovery rate per second.

    maxBalance: 100

    Maximum balance value.

    regionMultipliers: Record<string, number> = ...

    Balance disruption multipliers by body region.