Skip to content

Commit

Permalink
Refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChasarooniZ committed Aug 7, 2023
1 parent b9535d4 commit 6283150
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
3 changes: 2 additions & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
]
},
"esmodules": [
"scripts/module.js"
"scripts/module.js",
"scripts/hook.js"
],
"languages": [
{
Expand Down
23 changes: 23 additions & 0 deletions scripts/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* A single Damage Number in damage number list.
* @typedef {Object} DamageNumber
* @property {string} type - Type of damage
* @property {number} value - How much damage it was
*/
Hooks.on("init", function () {
console.log("PF2e RPG Numbers is initiated"); if (!game.user.isGM) return;
game.RPGNumbers = new RPGNumbers();
});

Hooks.on("ready", function () {
console.log("PF2e RPG Numbers is ready");
game.ui.notify("PF2e RPG Numbers is ready")
});

Hooks.on("createChatMessage", async function (msg, status, id) {
console.log({ msg })
if (msg?.flags?.pf2e?.context?.type !== 'damage-roll') return;
const dmg_list = game.RPGNumbers.extractDamageInfoCombined(msg.rolls);
const targets = game.RPGNumbers.getTargetList(msg);
game.RPGNumbers.generateDamageScroll(dmg_list, targets);
});
27 changes: 3 additions & 24 deletions scripts/module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class RPGNumbers {
constructor() {
}
static fontSize = 20;
static fontMod = 1;
static colors = {
Expand Down Expand Up @@ -143,27 +145,4 @@ class RPGNumbers {
return [(await fromUuid(msg.flags.pf2e.target.token)).id];
}
}
}

/**
* A single Damage Number in damage number list.
* @typedef {Object} DamageNumber
* @property {string} type - Type of damage
* @property {number} value - How much damage it was
*/

Hooks.on("init", function () {
console.log("PF2e RPG Numbers is initiated");if(!game.user.isGM) return;
game.RPGNumbers = new RPGNumbers();
});
Hooks.on("ready", function () {
console.log("PF2e RPG Numbers is ready");
});

Hooks.on("createChatMessage", async function (msg, status, id) {
console.log({ msg })
if (msg?.flags?.pf2e?.context?.type !== 'damage-roll') return;
const dmg_list = game.RPGNumbers.extractDamageInfoCombined(msg.rolls);
const targets = game.RPGNumbers.getTargetList(msg);
game.RPGNumbers.generateDamageScroll(dmg_list, targets);
});
}

0 comments on commit 6283150

Please sign in to comment.