Last active
September 21, 2020 17:05
-
-
Save James-Firth/472394df96da011c34ebfbf5731b4788 to your computer and use it in GitHub Desktop.
13th Age stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flesh Warp Targeter Macro | |
// for The Occultist | |
// Whispers player and GM which Defense should be used for each targeted enemy for quicker play when you've taken the Flesh Warp Talent. | |
// Set up some vars | |
const gmID = game.users.entities.filter(u => u.isGM).map(u => u._id)[0]; | |
const mdLower = []; | |
const pdLower = []; | |
// Figure out what each target should be | |
game.user.targets.forEach(tar => { | |
// find the attributes | |
const name = tar.actor.data.name; | |
const attrs = tar.actor.data.data.attributes; | |
// grab stats for comparison | |
const pd = attrs.pd && attrs.pd.value; | |
const md = attrs.md && attrs.md.value; | |
// Just do a bit of error checking | |
if (!(Number.isNumeric(pd) && Number.isNumeric(md))) { | |
throw new Error('PD or MD not found'); | |
} | |
if (pd < md) { | |
// flesh warping begin. | |
pdLower.push(name); | |
} else { | |
// no warp | |
mdLower.push(name); | |
} | |
}); | |
// this is what we'll post | |
let content = ''; | |
if (pdLower.length > 1 ) { | |
content = '<h3>Their Flesh is Weak!</h3>Target PD for:<ul>'; | |
pdLower.forEach(name => { | |
content += `<li>${name}</li>`; | |
}); | |
content += '</ul><br />'; | |
} else if (pdLower.length == 1) { | |
content = `<h3><i>${pdLower[0]}'s flesh is weak</i><br /><b>Target PD</b></h3>` | |
} | |
if (mdLower.length > 1) { | |
content += '<h3>Their Minds shall be Mush...</h3>Target MD for:<ul>'; | |
mdLower.forEach(name => { | |
content += `<li>${name}</li>`; | |
}); | |
content += '</ul><br />'; | |
} else if (mdLower.length == 1) { | |
content = `<h3><i>${mdLower[0]}'s mind still suits me best</i><br /><b>Target MD</b></h3>`; | |
} | |
if (content === '') { | |
console.log(content, pdLower, mdLower); | |
content = 'error, help!'; | |
} | |
// Put it in chat | |
let chatData = { | |
user: gmID, | |
speaker: { alias: "A Voice from Beyond the Veil" }, | |
content: content, | |
whisper: ChatMessage.getWhisperRecipients(game.user.name), | |
}; | |
ChatMessage.create(chatData, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment