diff --git a/module.json b/module.json index 2731501..f379920 100644 --- a/module.json +++ b/module.json @@ -1,8 +1,8 @@ { - "name": "healthEstimate2", + "name": "healthEstimate", "title": "Health Estimate 2", "description": "Gives players ability to see approximate health status of a token", - "version": "1.0.0.3", + "version": "2.5.0.0", "author": "MClemente, Shylight", "scripts": [ "./lib/chroma.min.js", @@ -58,32 +58,6 @@ "path": "./lang/pt-BR.json" } ], - "systems": [ - "archmage", - "D35E", - "dungeonworld", - "fate", - "lancer", - "numenera", - "ose", - "pf1", - "pf2e", - "ryuutama", - "shadowrun5e", - "swade", - "symbaroum", - "tormenta20", - "twodsix", - "wfrp4e", - "worldbuilding", - "starfinder", - "dnd5e", - "sw5e", - "blades-in-the-dark", - "foundryvtt-reve-de-dragon", - "tormenta20", - "uesrpg-d100" - ], "minimumCoreVersion": "0.5.0", "compatibleCoreVersion": "0.7.9", "url": "https://github.com/mclemente/healthEstimate", diff --git a/module/logic.js b/module/logic.js index 34e7e6b..c0a631b 100644 --- a/module/logic.js +++ b/module/logic.js @@ -2,23 +2,23 @@ import {breakOverlayRender, descriptionToShow, fractionFormula, updateBreakSetti import {sGet} from './utils.js' let descriptions, deathStateName, showDead, useColor, smooth, isDead, NPCsJustDie, deathMarker, - colors, outline, deadColor, deadOutline, perfectionism + colors, outline, deadColor, deadOutline, perfectionism, outputChat, npcName export function updateSettings () { - useColor = sGet('core.menuSettings.useColor') - descriptions = sGet('core.stateNames').split(/[,;]\s*/) - smooth = sGet('core.menuSettings.smoothGradient') + useColor = sGet('core.menuSettings.useColor') + descriptions = sGet('core.stateNames').split(/[,;]\s*/) + smooth = sGet('core.menuSettings.smoothGradient') deathStateName = sGet('core.deathStateName') - showDead = sGet('core.deathState') - NPCsJustDie = sGet('core.NPCsJustDie') - deathMarker = sGet('core.deathMarker') - colors = sGet('core.variables.colors')[0] - outline = sGet('core.variables.outline')[0] - deadColor = sGet('core.variables.deadColor') - deadOutline = sGet('core.variables.deadOutline') - perfectionism = sGet('core.perfectionism') + showDead = sGet('core.deathState') + NPCsJustDie = sGet('core.NPCsJustDie') + deathMarker = sGet('core.deathMarker') + colors = sGet('core.variables.colors')[0] + outline = sGet('core.variables.outline')[0] + deadColor = sGet('core.variables.deadColor') + deadOutline = sGet('core.variables.deadOutline') + perfectionism = sGet('core.perfectionism') - const margin = `${sGet('core.menuSettings.positionAdjustment')}em` + const margin = `${sGet('core.menuSettings.positionAdjustment')}em` const alignment = sGet('core.menuSettings.position') document.documentElement.style.setProperty('--healthEstimate-margin', margin) document.documentElement.style.setProperty('--healthEstimate-alignment', alignment) @@ -29,22 +29,22 @@ export function updateSettings () { `return ( ${NPCsJustDie ? '(!token.actor.hasPlayerOwner && stage === 0) ||' : ''} ${showDead ? `token.actor.effects.entries.some(x => x.data.icon === '${deathMarker}') ||` : ''} - token.getFlag('healthEstimate2', 'dead') + token.getFlag('healthestimate', 'dead') )` ) } class HealthEstimateOverlay extends BasePlaceableHUD { static get defaultOptions () { - const options = super.defaultOptions - options.classes = options.classes.concat(['healthEstimate', 'healthEstimateColor']) - options.template = 'modules/healthEstimate2/templates/healthEstimate.hbs' - options.id = 'healthEstimate' + const options = super.defaultOptions + options.classes = options.classes.concat(['healthEstimate', 'healthEstimateColor']) + options.template = 'modules/healthestimate/templates/healthEstimate.hbs' + options.id = 'healthEstimate' return options } getData () { - const data = super.getData() + const data = super.getData() data.status = this.estimation return data } @@ -58,7 +58,6 @@ export class HealthEstimate { this.initHooks() } - initHooks () { Hooks.on('hoverToken', (token, hovered) => { this._handleOverlay(token, hovered) @@ -67,6 +66,7 @@ export class HealthEstimate { Hooks.on('deleteToken', (...args) => { canvas.hud.HealthEstimate.clear() }) + Hooks.on('updateToken', (scene, token, ...args) => { if (canvas.hud.HealthEstimate !== undefined && canvas.hud.HealthEstimate.object !== null) { if (token._id === canvas.hud.HealthEstimate.object.id) { @@ -86,14 +86,15 @@ export class HealthEstimate { if (hovered) { this._getEstimation(token) canvas.hud.HealthEstimate.bind(token) - } else { + } + else { canvas.hud.HealthEstimate.clear() } } _getEstimation (token) { - const fraction = Math.min(fractionFormula(token), 1) - const stage = Math.max(0, + const fraction = Math.min(fractionFormula(token), 1) + const stage = Math.max(0, perfectionism ? Math.ceil((descriptions.length - 2 + Math.floor(fraction)) * fraction) : Math.ceil((descriptions.length - 1) * fraction), @@ -101,18 +102,18 @@ export class HealthEstimate { const colorIndex = Math.max(0, Math.ceil((colors.length - 1) * fraction)) let desc, color, stroke - desc = descriptionToShow(descriptions, stage, token, { + desc = descriptionToShow(descriptions, stage, token, { isDead: isDead(token, stage), - desc : deathStateName, + desc : deathStateName, }, fraction) - color = colors[colorIndex] + color = colors[colorIndex] stroke = outline[colorIndex] if (isDead(token, stage)) { - color = deadColor + color = deadColor stroke = deadOutline } document.documentElement.style.setProperty('--healthEstimate-stroke-color', stroke) document.documentElement.style.setProperty('--healthEstimate-text-color', color) canvas.hud.HealthEstimate.estimation = {desc} } -} +} \ No newline at end of file diff --git a/module/preloadTemplates.js b/module/preloadTemplates.js index 031de83..bb50b22 100644 --- a/module/preloadTemplates.js +++ b/module/preloadTemplates.js @@ -1,7 +1,7 @@ export const preloadTemplates = async function () { const templatePaths = [ - // Add paths to "modules/healthEstimate2/templates" - 'modules/healthEstimate2/templates/healthEstimate.hbs' + // Add paths to "modules/healthestimate/templates" + 'modules/healthestimate/templates/healthEstimate.hbs' ] return loadTemplates(templatePaths) diff --git a/module/styleSettings.js b/module/styleSettings.js index b6e6bf3..3630761 100644 --- a/module/styleSettings.js +++ b/module/styleSettings.js @@ -20,7 +20,7 @@ export class HealthEstimateStyleSettings extends FormApplication { return mergeObject(super.defaultOptions, { id : 'healthestimate-style-form', title : 'Health Estimate Style Settings', - template : './modules/healthEstimate2/templates/settings.hbs', + template : './modules/healthestimate/templates/settings.hbs', classes : ['sheet'], width : 640, height : 480, diff --git a/packs/macros.db b/packs/macros.db index 1cd5ae7..a36726d 100644 --- a/packs/macros.db +++ b/packs/macros.db @@ -1 +1 @@ -{"_id":"FUnpsmyP2zPf79JL","name":"Mark Dead","permission":{"default":0,"Y2U0NDkzODdlOTk1":3},"type":"script","flags":{"combat-utility-belt":{"macroTrigger":""}},"scope":"global","command":"/**\r\n* This macro will mark the selected tokens as dead.\r\n* If all the selected tokens are dead, they will be marked\r\n as alive instead.\r\n*/\r\n\r\nlet hasAlive = false;\r\nfor (let e of canvas.tokens.controlled) {\r\n\tif (!e.getFlag(\"healthEstimate2\", \"dead\")) {\r\n\t\thasAlive = true;\r\n\t\tbreak\r\n\t}\r\n}\r\nfor (let e of canvas.tokens.controlled) {\r\n\te.setFlag(\"healthEstimate2\", \"dead\", hasAlive)\r\n}","author":"Y2U0NDkzODdlOTk1","img":"icons/svg/bones.svg","actorIds":[]} +{"_id":"FUnpsmyP2zPf79JL","name":"Mark Dead","permission":{"default":0,"Y2U0NDkzODdlOTk1":3},"type":"script","flags":{"combat-utility-belt":{"macroTrigger":""}},"scope":"global","command":"/**\r\n* This macro will mark the selected tokens as dead.\r\n* If all the selected tokens are dead, they will be marked\r\n as alive instead.\r\n*/\r\n\r\nlet hasAlive = false;\r\nfor (let e of canvas.tokens.controlled) {\r\n\tif (!e.getFlag(\"healthestimate\", \"dead\")) {\r\n\t\thasAlive = true;\r\n\t\tbreak\r\n\t}\r\n}\r\nfor (let e of canvas.tokens.controlled) {\r\n\te.setFlag(\"healthestimate\", \"dead\", hasAlive)\r\n}","author":"Y2U0NDkzODdlOTk1","img":"icons/svg/bones.svg","actorIds":[]} diff --git a/templates/healthEstimate.hbs b/templates/healthEstimate.hbs index 157ee01..17b06d7 100644 --- a/templates/healthEstimate.hbs +++ b/templates/healthEstimate.hbs @@ -1,5 +1,5 @@