New items and cleanup
This commit is contained in:
@ -1,52 +0,0 @@
|
||||
/* -------------------------------------------- */
|
||||
|
||||
import { HeritiersUtility } from "./heritiers-utility.js";
|
||||
import "./xregexp-all.js";
|
||||
|
||||
const __level1Expr = '(?<effectType>[a-z]+):(?<objectType>[a-zA-Z]+)\\((?<objectName>[a-zA-Z0-9\\.]+)\\)\\s+(?<modifierValue>[\\d]+)\\s*{*(?<modifierLabel>[a-zA-Zàéè\\s]*)}*'
|
||||
const __effectTypes = {modifier: 1, cost: 1, provide: 1}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class HeritiersAutomation {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static init() {
|
||||
this.__objectTypes = { }
|
||||
|
||||
Object.entries(game.data.model.Actor).forEach(kv => {
|
||||
this.__objectTypes[kv[0]] = duplicate(kv[1])
|
||||
})
|
||||
Object.entries(game.data.model.Item).forEach(kv => {
|
||||
this.__objectTypes[kv[0]] = duplicate(kv[1])
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static processAutomations(event, item, actor) {
|
||||
//console.log("We have", event, item, actor)
|
||||
if ( !item.system.isautomated || item.system.automations.length == 0 ) {
|
||||
return {isValid: true}
|
||||
}
|
||||
let relevantAutomations = item.system.automations.filter( auto => auto.eventtype == event)
|
||||
if ( !relevantAutomations || relevantAutomations.length == 0) {
|
||||
return {isValid: true}
|
||||
}
|
||||
|
||||
let validTab = []
|
||||
for(let auto of relevantAutomations) {
|
||||
if ( event == "on-drop") {
|
||||
validTab.push( actor.checkAttributOrCompetenceLevel( auto.competence, auto.minLevel) )
|
||||
}
|
||||
}
|
||||
|
||||
// Post process validation array
|
||||
for (let ret of validTab) {
|
||||
if ( !ret.isValid) {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
return {isValid: true}
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,11 @@ export const HERITIERS_CONFIG = {
|
||||
"erudit": "Erudit",
|
||||
"savant": "Savant",
|
||||
"gentleman": "Gentleman"
|
||||
},
|
||||
|
||||
typePouvoir: {
|
||||
"actif": "Actif",
|
||||
"passif": "Passif"
|
||||
}
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class HeritiersTokenHud {
|
||||
|
||||
static init() {
|
||||
// Integration du TokenHUD
|
||||
Hooks.on('renderTokenHUD', (app, html, data) => { HeritiersTokenHud.addTokenHudExtensions(app, html, data._id) });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async removeExtensionHud(app, html, tokenId) {
|
||||
html.find('.control-icon.heritiers-adversite').remove()
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async addExtensionHud(app, html, tokenId) {
|
||||
|
||||
let token = canvas.tokens.get(tokenId)
|
||||
let actor = token.actor
|
||||
app.hasExtension = true
|
||||
|
||||
const hudData = { actor: actor }
|
||||
|
||||
const controlIconActions = html.find('.control-icon[data-action=combat]');
|
||||
// initiative
|
||||
await HeritiersTokenHud._configureSubMenu(controlIconActions, 'systems/fvtt-les-heritiers/templates/hud-adversites.html', hudData,
|
||||
(event) => {
|
||||
let adversite = event.currentTarget.attributes['data-action-index'].value
|
||||
let value = Number(event.currentTarget.attributes['data-action-value'].value)
|
||||
hudData.actor.incDecAdversite( adversite, value)
|
||||
} )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async addTokenHudExtensions(app, html, tokenId) {
|
||||
const controlIconCombat = html.find('.control-icon[data-action=combat]')
|
||||
if (controlIconCombat.length>0 ) {
|
||||
HeritiersTokenHud.addExtensionHud(app, html, tokenId);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
|
||||
const hud = $(await renderTemplate(template, hudData))
|
||||
const list = hud.find('div.heritiers-hud-list')
|
||||
|
||||
HeritiersTokenHud._toggleHudListActive(hud, list);
|
||||
|
||||
hud.find('img.heritiers-hud-togglebutton').click(event => HeritiersTokenHud._toggleHudListActive(hud, list));
|
||||
list.find('.heritiers-hud-adversite').click(onMenuItem);
|
||||
|
||||
insertionPoint.after(hud);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _showControlWhen(control, condition) {
|
||||
if (condition) {
|
||||
control.show()
|
||||
}
|
||||
else {
|
||||
control.hide()
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _toggleHudListActive(hud, list) {
|
||||
hud.toggleClass('active')
|
||||
HeritiersTokenHud._showControlWhen(list, hud.hasClass('active'))
|
||||
}
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
import { HeritiersUtility } from "./heritiers-utility.js";
|
||||
|
||||
export const defaultItemImg = {
|
||||
competence: "systems/fvtt-les-heritiers/assets/icons/skill.webp",
|
||||
competence: "systems/fvtt-les-heritiers/assets/icons/skill.webp",
|
||||
avantage: "systems/fvtt-les-heritiers/assets/icons/advantage.webp",
|
||||
desavantage: "systems/fvtt-les-heritiers/assets/icons/disadvantage.webp",
|
||||
contact: "systems/fvtt-les-heritiers/assets/icons/contact.webp",
|
||||
pouvoir: "systems/fvtt-les-heritiers/assets/icons/power.webp",
|
||||
equipement: "systems/fvtt-les-heritiers/assets/icons/equipement.webp",
|
||||
accessoire: "systems/fvtt-les-heritiers/assets/icons/accessoire.webp",
|
||||
arme: "systems/fvtt-les-heritiers/assets/icons/melee.webp",
|
||||
monnaie: "systems/fvtt-les-heritiers/assets/icons/monnaie.webp",
|
||||
protection: "systems/fvtt-les-heritiers/assets/icons/protection.webp",
|
||||
talent: "systems/fvtt-les-heritiers/assets/icons/talent.webp"
|
||||
atoutfeerique: "systems/fvtt-les-heritiers/assets/icons/fairy_atout.webp",
|
||||
capacitenaturelle: "systems/fvtt-les-heritiers/assets/icons/natural_capacity.webp",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,8 +15,6 @@ import { HeritiersCreatureSheet } from "./heritiers-creature-sheet.js";
|
||||
import { HeritiersUtility } from "./heritiers-utility.js";
|
||||
import { HeritiersCombat } from "./heritiers-combat.js";
|
||||
import { HeritiersItem } from "./heritiers-item.js";
|
||||
import { HeritiersAutomation } from "./heritiers-automation.js";
|
||||
import { HeritiersTokenHud } from "./heritiers-hud.js";
|
||||
import { HERITIERS_CONFIG } from "./heritiers-config.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -50,7 +48,6 @@ Hooks.once("init", async function () {
|
||||
CONFIG.Item.documentClass = HeritiersItem
|
||||
game.system.lesheritiers = {
|
||||
HeritiersUtility,
|
||||
HeritiersAutomation,
|
||||
config: HERITIERS_CONFIG
|
||||
}
|
||||
|
||||
@ -64,8 +61,6 @@ Hooks.once("init", async function () {
|
||||
Items.registerSheet("fvtt-les-heritiers", HeritiersItemSheet, { makeDefault: true })
|
||||
|
||||
HeritiersUtility.init()
|
||||
HeritiersAutomation.init()
|
||||
HeritiersTokenHud.init()
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user