Char - WIP

This commit is contained in:
2022-01-06 18:22:05 +01:00
parent 7a06989d87
commit a8a27d1924
34 changed files with 693 additions and 144 deletions

View File

@ -1,3 +1,7 @@
/* -------------------------------------------- */
import { PegasusCommands } from "./pegasus-commands.js";
import { PegasusActorCreate } from "./pegasus-create-char.js";
/* -------------------------------------------- */
const __level2Dice = [ "d0", "d4", "d6", "d8", "d10", "d12" ];
@ -14,7 +18,9 @@ export class PegasusUtility {
this.diceFoundryList = [];
this.optionsDiceList = "";
this.buildDiceLists();
PegasusCommands.init();
}
/* -------------------------------------------- */
static getSpecs( ) {
return this.specs;
@ -26,6 +32,18 @@ export class PegasusUtility {
this.specs = specs.map(i => i.toObject());
}
/* -------------------------------------------- */
static async loadCompendiumData(compendium) {
const pack = game.packs.get(compendium);
return await pack?.getDocuments() ?? [];
}
/* -------------------------------------------- */
static async loadCompendium(compendium, filter = item => true) {
let compendiumData = await PegasusUtility.loadCompendiumData(compendium);
return compendiumData.filter(filter);
}
/* -------------------------------------------- */
static buildDiceLists() {
let maxLevel = game.settings.get("fvtt-pegasus-rpg", "dice-max-level");
@ -98,29 +116,11 @@ export class PegasusUtility {
/* -------------------------------------------- */
static async chatListeners(html) {
html.on("click", '.apply-technique-cost', event => {
const rollId = $(event.currentTarget).data("roll-id");
const actorId = $(event.currentTarget).data("actor-id");
const techId = $(event.currentTarget).data("technique-id");
let actor = game.actors.get( actorId);
actor.applyTechniqueCost(techId);
});
html.on("click", '.chat-create-actor', event => {
console.log("Event !")
game.system.pegasus.creator.processChatEvent(event);
} );
html.on("click", '.apply-defense-roll', event => {
const defenseRollId = $(event.currentTarget).data("roll-id");
this.computeAttackDefense(defenseRollId);
});
html.on("click", '.apply-nodefense', event => {
const actorId = $(event.currentTarget).data("actor-id");
const rollId = $(event.currentTarget).data("roll-id");
this.applyNoDefense(actorId, rollId);
});
html.on("click", '.apply-damage', event => {
const rollId = $(event.currentTarget).data("roll-id");
this.applyDamage(rollId);
});
}
/* -------------------------------------------- */