Skip to content

Instantly share code, notes, and snippets.

@ThomasJClark
Last active September 22, 2024 18:01
Show Gist options
  • Select an option

  • Save ThomasJClark/80d6cf1f0a3110ba0c44c1214573d2c3 to your computer and use it in GitHub Desktop.

Select an option

Save ThomasJClark/80d6cf1f0a3110ba0c44c1214573d2c3 to your computer and use it in GitHub Desktop.
Macro for running MCDM's Draw Steel RPG in Foundry Virtual Tabletop
new Dialog({
title: "Power Roll",
content: `
<form id="form" class="flex-form" style="padding-bottom:8px">
<label>
Modifier <input type="number" name="mod" value="0"/>
</label>
<label>
<input type="radio" name="edge" value="edge2"/> <i class="fas fa-chevrons-up"></i> Double edge
</label>
<label>
<input type="radio" name="edge" value="edge"/> <i class="fas fa-chevron-up"></i> Edge
</label>
<label>
<input type="radio" name="edge" value="noedge" checked /> <i class="fas fa-minus"></i> No edge
</label>
<label>
<input type="radio" name="edge" value="bane"/> <i class="fas fa-chevron-down"></i> Bane
</label>
<label>
<input type="radio" name="edge" value="bane2"/> <i class="fas fa-chevrons-down"></i> Double bane
</label>
</form>
`,
default: "roll",
buttons: {
roll: {
icon: "<i class='fas fa-dice-d20'></i>",
label: "Roll",
async callback(html) {
const form = html.find("#form")[0];
const edge = form.edge.value;
let modifier = form.mod.valueAsNumber;
if (edge === "edge") {
modifier += 2;
} else if (edge === "bane") {
modifier -= 2;
}
const roll = await new Roll(`2d10+${modifier}`).roll();
let tier;
if (roll.total >= 17) {
tier = 3;
} else if (roll.total >= 12) {
tier = 2;
} else {
tier = 1;
}
if (edge === "edge2") {
tier++;
} else if (edge === "bane2") {
tier--;
}
let result;
if (tier >= 3) {
result = `<span style="color:blue">✸ Tier 3 (17+)</span>`;
} else if (tier == 2) {
result = `<span style="color:green">★ Tier 2 (12-16)</span>`;
} else {
result = `<span style="color:black">✦ Tier 1 (≤11)</span>`;
}
const naturalRoll = roll.total - modifier;
if (naturalRoll >= 19) {
result = `<span style="color:blue">✸ Tier 3 (<b>natural ${naturalRoll}!!</b>)</span>`;
}
if (edge === "edge2") {
result = `<i class="fas fa-chevrons-up"></i> Double edge<br>` + result;
} else if (edge === "edge") {
result = `<i class="fas fa-chevron-up"></i> Edge<br>` + result;
} else if (edge === "bane") {
result = `<i class="fas fa-chevron-down"></i> Bane<br>` + result;
} else if (edge === "bane2") {
result = `<i class="fas fa-chevrons-down"></i> Double bane<br>` + result;
}
await roll.toMessage({ flavor: result });
},
},
},
default: "yes",
}).render(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment