lipefl / swade-tools

A Fondry VTT module with automations for Savage Worlds (SWADE)
15 stars 13 forks source link

Fixed combat start/end automation bug #296

Closed EternalRider closed 2 months ago

EternalRider commented 3 months ago

1.补上了战斗开始时的第一个回合的Hook; 2.令endTurn函数使用正确的combatant; 3.使用combatant自身的combat对象,以支持同时存在多遭遇的情况,以及修复在战斗过程中掉线重连时CombatControl对象重建导致丢失id的问题; 4.使用更准确的Boolean进行逻辑判断; 5.使用hasStarted和hasEnded标记以避免同一轮内调整combatant顺序时重复触发; ——————

  1. made up the Hook for the first turn at the start of the battle;
  2. made the endTurn function use the correct combatant;
  3. using the combatant's own combat object to support the simultaneous existence of multiple encounters, as well as fixing a problem with CombatControl objects rebuilding when disconnecting and reconnecting during combat that resulted in lost ids;
  4. use more accurate Boolean for logical judgement;
  5. using hasStarted and hasEnded flags to avoid repeated triggers when adjusting combatant order within the same round;

Translated with DeepL.com (free version)

EternalRider commented 3 months ago

oh no, I forget the waitfor function; (it's copyed from warpgate) this is warpgate.wait(iterWaitTime) function:

  /**
   * Helper function. Waits for a specified amount of time in milliseconds (be sure to await!).
   * Useful for timings with animations in the pre/post callbacks.
   *
   * @param {Number} ms Time to delay, in milliseconds
   * @returns Promise
   */
  static async wait(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }
lipefl commented 3 months ago

Thanks for the work! I'll add these changes in the next version.

lipefl commented 2 months ago

Added to v1.16 (only compatible with Foundry v12 and SWADE system v4)