Skip to content

Commit

Permalink
v2.5.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Mar 31, 2021
1 parent ca02e17 commit 83ff16e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog
## 2.5.0.1
- Added a generic system support. The module should now work with any system whose actors have HP set up as either `token.actor.data.data.attributes.hp` or `token.actor.data.data.hp`.
- Fixed an issue where the module would fail to work because of a refactoring issue.

## 2.5.0.0
- New release under a new repo.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "healthEstimate",
"title": "Health Estimate 2",
"description": "Gives players ability to see approximate health status of a token",
"version": "2.5.0.0",
"version": "2.5.0.1",
"author": "MClemente, Shylight",
"scripts": [
"./lib/chroma.min.js",
Expand Down
5 changes: 2 additions & 3 deletions module/logic.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {breakOverlayRender, descriptionToShow, fractionFormula, updateBreakSettings} from './systemSpecifics.js'
import {sGet} from './utils.js'

let descriptions, deathStateName, showDead, useColor, smooth, isDead, NPCsJustDie, deathMarker,
colors, outline, deadColor, deadOutline, perfectionism, outputChat, npcName
let descriptions, deathStateName, showDead, useColor, smooth, isDead, NPCsJustDie, deathMarker, colors, outline, deadColor, deadOutline, perfectionism

export function updateSettings () {
useColor = sGet('core.menuSettings.useColor')
Expand All @@ -29,7 +28,7 @@ export function updateSettings () {
`return (
${NPCsJustDie ? '(!token.actor.hasPlayerOwner && stage === 0) ||' : ''}
${showDead ? `token.actor.effects.entries.some(x => x.data.icon === '${deathMarker}') ||` : ''}
token.getFlag('healthestimate', 'dead')
token.getFlag('healthEstimate', 'dead')
)`
)
}
Expand Down
7 changes: 6 additions & 1 deletion module/systemSpecifics.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export function updateBreakSettings () {

export function prepareSystemSpecifics () {
return new Promise((resolve, reject) => {
import(`./systems/${game.system.id}.js`)
const 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"];
let importString = `./systems/${game.system.id}.js`;
if (!systems.includes(game.system.id)) {
importString = `./systems/generic.js`;
}
import(importString)
.then(currentSystem => {
fractionFormula = currentSystem.fraction
if (currentSystem.settings !== undefined) {
Expand Down
6 changes: 6 additions & 0 deletions module/systems/generic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const fraction = function (token) {
const hp = token.actor.data.data.attributes?.hp || token.actor.data.data.hp;
return Math.min(hp.value / hp.max, 1)
}

export {fraction}
2 changes: 1 addition & 1 deletion packs/macros.db
Original file line number Diff line number Diff line change
@@ -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(\"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":[]}
{"_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":[]}

0 comments on commit 83ff16e

Please sign in to comment.