generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored some code fixed some bugs added stuff for Aoen st one
- Loading branch information
1 parent
b42fb55
commit 90e3766
Showing
5 changed files
with
117 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"eslint.format.enable": true, | ||
"compile-hero.disable-compile-files-on-did-save-code": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { MODULE_ID } from "./helper/const.js"; | ||
import { checkActionSupport, getCoolDownTime, updateFrequencyOfActors } from "./module.js"; | ||
|
||
export async function updateItem(item, changes, _diff, _userID) { | ||
//Use this to set item flags | ||
//Ignore day (as that is handled by the system) | ||
const usesChange = changes?.system?.frequency?.value; | ||
const maxUses = item?.system?.frequency?.max; | ||
if (usesChange < maxUses) { | ||
// change is a frequency change, and it's lower than max | ||
const flag = item.getFlag(MODULE_ID, "cooldown"); | ||
if (!flag || flag.per !== item?.system?.frequency?.per) { | ||
const cooldown = getCoolDownTime(item?.system?.frequency); | ||
if (cooldown) { | ||
item.setFlag(MODULE_ID, "cooldown", { | ||
cooldown, | ||
per: item?.system?.frequency?.per, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export async function preCreateChatMessage(msg, _data, _info, _userID) { | ||
if (checkActionSupport()) { | ||
const item = msg.item; | ||
if (item?.system?.frequency?.value) { | ||
await item.update({ | ||
system: { frequency: { value: item.system.frequency.value - 1 } }, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
export async function updateWorldTime(total, diff) { | ||
const actors = game.actors.party.members; | ||
if (game.settings.get(MODULE_ID, "include-canvas.enabled")) { | ||
actors.push(...(canvas?.tokens?.placeables?.map((t) => t?.actor) ?? [])); | ||
} | ||
await updateFrequencyOfActors( | ||
actors, | ||
total, | ||
diff, | ||
!game.combat ? "updateTime" : "default" | ||
); | ||
} | ||
|
||
export async function pf2eEndTurn(combatant, _encounter, _userID) { | ||
await updateFrequency(combatant.token.actor, 0, "endTurn"); | ||
} | ||
|
||
export async function pf2eStartTurn(combatant, _encounter, _userID) { | ||
await updateFrequency(combatant.token.actor, 0, "startTurn"); | ||
} | ||
|
||
export async function combatRound(encounter, _changes, _diff, _userID) { | ||
const actors = encounter.combatants.contents.map( | ||
(combatant) => combatant.token.actor | ||
); | ||
await updateFrequencyOfActors(actors, 0, "endRound"); | ||
} | ||
|
||
|
||
export async function combatStart(encounter, _current) { | ||
const actors = encounter.combatants.contents.map( | ||
(combatant) => combatant.token.actor | ||
); | ||
await updateFrequencyOfActors(actors, 0, "startCombat"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters