パッケージ simulation

クラス CombatSimulator

java.lang.Object
simulation.CombatSimulator

public class CombatSimulator extends Object
God-class that drives the entire time-based combat simulation.

Responsibilities:

  • Time progressionadvanceTime(double) ticks the event queue forward, firing registered TimerEvents in chronological order.
  • Action executionperformAction(String, AttackAction) resolves damage, applies elemental gauges, handles ICD, triggers reactions, and advances simulation time by the action's animation duration.
  • Buff lifecycle — team-wide and field-only Buffs are collected and merged in getApplicableBuffs(model.entity.Character) before each damage calculation.
  • Reaction hooks — elemental reactions are computed per hit; amplifying reactions modify the damage multiplier in-line while transformative reactions (Overload, Superconduct, Electro-Charged) produce independent damage instances.
  • Moonsign system — custom Lunar mechanic tracked via the CombatSimulator.Moonsign enum; when CombatSimulator.Moonsign.ASCENDANT_GLEAM is active, non-Lunar characters trigger applyAscendantBlessing(model.entity.Character) on Skill / Burst use.

Entry points create a CombatSimulator, call addCharacter(model.entity.Character) and setEnemy(model.entity.Enemy), then drive a rotation by calling performAction(java.lang.String, java.lang.String) and switchCharacter(java.lang.String) in sequence. After the rotation, getDPS() and printReport() summarise results.

  • コンストラクタの詳細

    • CombatSimulator

      public CombatSimulator()
      Constructs a new simulator with an empty party and zeroed time.
  • メソッドの詳細

    • setLoggingEnabled

      public void setLoggingEnabled(boolean enable)
      Enables or disables per-action console logging ([T=x.x] lines). Disable before optimisation runs to reduce output noise.
      パラメータ:
      enable - true to enable logging
    • isLoggingEnabled

      public boolean isLoggingEnabled()
      Returns whether console logging is currently enabled.
      戻り値:
      true if logging is on
    • setECTimerRunning

      public void setECTimerRunning(boolean running)
      Sets the EC timer running flag directly. Used by the EC tick event to signal that the Electro-Charged DoT sequence has ended.
      パラメータ:
      running - true if an EC tick timer is active
    • isThundercloudActive

      public boolean isThundercloudActive()
      Returns whether the Thundercloud state (Lunar-Charged extension) is currently active. The Thundercloud persists for 6 seconds after the last Lunar-Charged trigger.
      戻り値:
      true if the current time is within the Thundercloud window
    • setEnemy

      public void setEnemy(Enemy enemy)
      Sets the enemy that characters will attack during the simulation.
      パラメータ:
      enemy - the Enemy instance
    • getEnemy

      public Enemy getEnemy()
      Returns the enemy currently set on the simulator.
      戻り値:
      the Enemy, or null if not yet assigned
    • addCharacter

      public void addCharacter(Character character)
      Adds a character to the party and initialises their energy to full. The first character added automatically becomes the active character.
      パラメータ:
      character - the Character to add
    • getCharacter

      public Character getCharacter(String name)
      Returns the party member with the given name, or null if not found.
      パラメータ:
      name - the character's registered name
      戻り値:
      the matching Character
    • getPartyMembers

      public Collection<Character> getPartyMembers()
      Returns all characters in the party.
      戻り値:
      collection of all Character objects
    • getActiveCharacter

      public Character getActiveCharacter()
      Returns the character currently on-field.
      戻り値:
      the active Character
    • switchCharacter

      public void switchCharacter(String name)
      Switches the active character to the named party member, enforcing a 1.0-second swap cooldown between consecutive swaps.

      Sequence of events:

      1. If the swap cooldown has not elapsed, advanceTime(double) is called to reach it.
      2. onSwitchOut and artifact onSwitchOut callbacks fire for the outgoing character.
      3. The new character becomes active and artifact onSwitchIn callbacks fire.
      4. A 0.1-second swap delay is applied via advanceTime(double).
      5. The swap is logged to the VisualLogger timeline.
      パラメータ:
      name - the name of the character to switch to
    • setActiveCharacter

      public void setActiveCharacter(String name)
      Immediately sets the active character without triggering swap callbacks, cooldowns, or time advancement. Intended for RL optimisation initialisation only.
      パラメータ:
      name - the name of the character to set as active
    • getCurrentTime

      public double getCurrentTime()
      Returns the current simulation time in seconds.
      戻り値:
      current time
    • applyTeamBuff

      public void applyTeamBuff(Buff buff)
      Adds a buff to the team buff list. The buff is considered for all party members during getApplicableBuffs(model.entity.Character).
      パラメータ:
      buff - the Buff to add
    • applyTeamBuffNoStack

      public void applyTeamBuffNoStack(Buff buff)
      Adds a buff to the team buff list, first removing any existing buff with the same name. Prevents stacking of effects that should not accumulate (e.g. refreshable buffs).
      パラメータ:
      buff - the Buff to apply without stacking
    • applyFieldBuff

      public void applyFieldBuff(Buff buff)
      Adds a buff to the field buff list. Field buffs are only applied to the currently active (on-field) character during getApplicableBuffs(model.entity.Character).
      パラメータ:
      buff - the Buff to restrict to the on-field character
    • getApplicableBuffs

      public List<Buff> getApplicableBuffs(Character c)
      Collects all buffs that apply to the given character at the current simulation time.

      Sources aggregated (in order):

      1. Team buffs whose appliesToCharacter predicate matches.
      2. Weapon team buffs from every party member's weapon.
      3. Character passive team buffs from every party member.
      4. Field buffs, only if c is the active character.
      パラメータ:
      c - the character to collect buffs for
      戻り値:
      list of applicable Buff objects (may include expired buffs; callers should filter with Buff#isExpired)
    • setMoonsign

      public void setMoonsign(CombatSimulator.Moonsign sign)
      Directly sets the Moonsign state. Prefer updateMoonsign() to derive the correct state from the current party composition.
      パラメータ:
      sign - the new CombatSimulator.Moonsign state
    • getMoonsign

      public CombatSimulator.Moonsign getMoonsign()
      Returns the current Moonsign state.
      戻り値:
      the active CombatSimulator.Moonsign
    • getTeamBuffs

      public List<Buff> getTeamBuffs()
      Convenience method returning all buffs applicable to the currently active character. Delegates to getApplicableBuffs(Character).
      戻り値:
      list of buffs for the active character
    • performAction

      public void performAction(String charName, String actionKey)
      Triggers a named ability action (e.g. "skill" or "burst") for a character, waiting out any remaining cooldown before executing.

      For "skill"/"E" actions the skill cooldown is enforced; for "burst"/"Q" actions the burst cooldown is enforced and an energy warning is printed if the character lacks sufficient energy. After cooldown resolution, the character's onAction callback and weapon onAction passive are invoked.

      パラメータ:
      charName - the name of the character performing the action
      actionKey - the action key string (e.g. "skill", "burst", "E", "Q")
      例外:
      RuntimeException - if no character with charName exists in the party
    • recordDamage

      public void recordDamage(String charName, double dmg)
      Accumulates damage into the per-character damage report and overall total. Called internally after each damage calculation and reaction damage instance.
      パラメータ:
      charName - the name to attribute the damage to
      dmg - the damage amount to record
    • getRotationTime

      public double getRotationTime()
      Returns the simulation time at the end of the last recorded action, used as the rotation duration denominator when computing DPS.
      戻り値:
      rotation end time in seconds
    • printReport

      public void printReport()
      Prints a formatted DPS breakdown table to standard output, showing each character's total damage, share percentage, and individual DPS over the rotation time.
    • getDPS

      public double getDPS()
      Returns total DPS over the rotation (totalDamage / rotationTime). Returns 0.0 if no time has elapsed.
      戻り値:
      DPS value
    • getTotalDamage

      public double getTotalDamage()
      Returns the cumulative damage dealt across all characters and reactions.
      戻り値:
      total damage
    • registerEvent

      public void registerEvent(TimerEvent e)
      Registers a TimerEvent in the priority queue. The event will fire when advanceTime(double) advances past its TimerEvent.getNextTickTime().
      パラメータ:
      e - the event to register
    • advanceTime

      public void advanceTime(double duration)
      Advances simulation time by duration seconds, firing any registered TimerEvents whose tick time falls within the interval.

      Events are processed in chronological order; after each tick the event is re-queued unless TimerEvent.isFinished(double) returns true. After all events in the window have fired, currentTime is set to currentTime + duration and rotationTime is updated.

      パラメータ:
      duration - the number of seconds to advance
    • addListener

      public void addListener(ActionListener l)
      Registers an ActionListener to be notified after each performAction(String, AttackAction) call.
      パラメータ:
      l - the listener to add
    • addParticleListener

      public void addParticleListener(ParticleListener l)
      Registers a ParticleListener to be notified when particles are generated.
      パラメータ:
      l - the listener to add
    • notifyParticle

      public void notifyParticle(Element e, double count)
      Notifies all registered ParticleListeners that particles have been generated. Called by character skill/burst implementations after emitting particles.
      パラメータ:
      e - the element of the particles
      count - the number of particles generated
    • addReactionListener

      public void addReactionListener(CombatSimulator.ReactionListener l)
      Registers a CombatSimulator.ReactionListener to be notified when any elemental reaction fires.
      パラメータ:
      l - the listener to add
    • notifyReaction

      public void notifyReaction(ReactionResult result, Character trigger)
      Notifies all registered CombatSimulator.ReactionListeners and all artifact onReaction callbacks for every party member when a reaction has been triggered.
      パラメータ:
      result - the reaction result
      trigger - the character whose element triggered the reaction
    • updateGleamingMoonSynergy

      public void updateGleamingMoonSynergy()
      Recalculates and reapplies the Gleaming Moon Synergy buff based on the current presence of "Gleaming Moon: Intent" and "Gleaming Moon: Devotion" buffs on any party member. Each unique effect present contributes +10% to Lunar Charged, Bloom, and Crystallize DMG Bonus. The resulting synergy buff is applied to all party members for 8 seconds.

      This method should be called after a damage or reaction event that might have changed the count of active Gleaming Moon effects.

    • updateMoonsign

      public void updateMoonsign()
      Recomputes the CombatSimulator.Moonsign state from the current party composition and updates it accordingly. Should be called after the full party is assembled via addCharacter(model.entity.Character).
    • performAction

      public void performAction(String charName, AttackAction action)
      Executes an AttackAction for the named character, then advances simulation time by the action's (ATK-SPD-adjusted) animation duration.

      In addition to the steps in performActionWithoutTimeAdvance(java.lang.String, simulation.action.AttackAction):

      • If CombatSimulator.Moonsign.ASCENDANT_GLEAM is active and the acting character is non-Lunar and uses a SKILL or BURST, applyAscendantBlessing(model.entity.Character) fires.
      • All registered ActionListeners are notified.
      • For NORMAL and CHARGE actions, ATK SPD from buffs shortens the animation.
      パラメータ:
      charName - the name of the character performing the action
      action - the AttackAction to execute
      例外:
      RuntimeException - if no character with charName exists in the party
    • performActionWithoutTimeAdvance

      public void performActionWithoutTimeAdvance(String charName, AttackAction action)
      Resolves all damage and elemental effects of an AttackAction without advancing simulation time. Used for periodic events (e.g. DoT ticks via PeriodicDamageEvent) where time is already managed by the event queue.

      Steps executed:

      1. ICD check via ICDManager; element application proceeds only if ICD permits.
      2. If AttackAction.isLunarConsidered(), a synthetic Lunar reaction event is fired.
      3. Elemental gauge is checked against active auras; reactions are computed and transformative damage instances (Overload, EC, Superconduct, Swirl) are dealt.
      4. Amplifying reactions set a multiplier applied in DamageCalculator.
      5. Standard action damage is calculated via DamageCalculator.calculateDamage.
      6. Weapon onDamage and artifact onDamage hooks are invoked.
      7. The hit is logged to VisualLogger.
      パラメータ:
      charName - the name of the character performing the action
      action - the AttackAction to resolve
      例外:
      RuntimeException - if no character with charName exists in the party