Skip to content

Commit

Permalink
v11 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
krbz999 committed Jun 8, 2023
1 parent f1a961e commit 747cdd2
Show file tree
Hide file tree
Showing 51 changed files with 360 additions and 594 deletions.
10 changes: 4 additions & 6 deletions classes/bard/eloquence.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Eloquence
// required modules: none

const a = token?.actor ?? game.user.character;
if(a) return ui.notifications.warn("You must have a selected token or assigned actor.");

if (!actor) return ui.notifications.warn("You must have a selected token or assigned actor.");
return Dialog.prompt({
title: "Eloquence",
content: `
Expand All @@ -12,8 +10,8 @@ return Dialog.prompt({
<label>Select Skill</label>
<div class="form-fields">
<select>
<option value="per">Persuasion</option>
<option value="dec">Deception</option>
<option value="per">${CONFIG.DND5E.skills.per.label}</option>
<option value="dec">${CONFIG.DND5E.skills.dec.label}</option>
</select>
</div>
</div>
Expand All @@ -22,6 +20,6 @@ return Dialog.prompt({
label: "Roll",
callback: async (html) => {
const skill = html[0].querySelector("select").value;
return a.rollSkill(skill, {reliableTalent: true, event});
return actor.rollSkill(skill, {reliableTalent: true, event});
}
});
2 changes: 1 addition & 1 deletion classes/cleric/eyes_of_night.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ const options = {
const use = await item.use();
if (!use) return;

for(const target of targets) {
for (const target of targets) {
await warpgate.mutate(target.document, updates, {}, options);
}
14 changes: 7 additions & 7 deletions classes/cleric/harness_divine_power.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
// required modules: itemacro

const data = actor.getRollData();
const maxLevel = Math.ceil(data.attributes.prof/2);
const maxLevel = Math.ceil(data.attributes.prof / 2);
const validLevels = [];
for(let i = 1; i <= maxLevel; i++){
for (let i = 1; i <= maxLevel; i++) {
const key = `spell${i}`;
if( (data.spells[key].value < data.spells[key].max) && (data.spells[key].max > 0) ){
if ((data.spells[key].value < data.spells[key].max) && (data.spells[key].max > 0)) {
validLevels.push(key);
}
}
const pact = data.spells.pact;
if( (pact.max > 0) && (pact.level <= maxLevel) && (pact.value < pact.max) ) validLevels.push("pact");
if ((pact.max > 0) && (pact.level <= maxLevel) && (pact.value < pact.max)) validLevels.push("pact");

// bail out if you are not missing any spell slots or if the item has no remaining uses (limited uses and resources).
if(!validLevels.length) return ui.notifications.warn("You are not missing any valid spell slots.");
if(!item.system.uses.value) return ui.notifications.warn("You have no uses left of Harness Divine Power.");
if (!validLevels.length) return ui.notifications.warn("You are not missing any valid spell slots.");
if (!item.system.uses.value) return ui.notifications.warn("You have no uses left of Harness Divine Power.");

const resourceItem = actor.items.get(item.system.consume.target);
const uses = resourceItem.system.uses;
if(!uses.value) return ui.notifications.warn("You have no uses of Channel Divinity left.");
if (!uses.value) return ui.notifications.warn("You have no uses of Channel Divinity left.");

// define dialog contents
const options = validLevels.reduce((acc, e) => {
Expand Down
12 changes: 5 additions & 7 deletions classes/cleric/steps_of_night.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
// required modules: itemacro

const id = item.name.slugify({strict: true});
const effect = actor.effects.find(e => e.flags.core?.statusId === id);
const effect = actor.effects.find(e => e.statuses.has(id));
if (effect) return effect.delete();
const use = await item.use();
if (!use) return;

return actor.createEmbeddedDocuments("ActiveEffect", [{
label: item.name,
name: item.name,
changes: [{
key: "system.attributes.movement.fly",
mode: CONST.ACTIVE_EFFECT_MODES.UPGRADE,
value: actor.system.attributes.movement.walk
}],
duration: {seconds: 60},
icon: item.img,
"flags.core.statusId": id,
"flags.visual-active-effects.data": {
intro: "<p>You have a flying speed equal to your walking speed.</p>",
content: item.system.description.value
}
statuses: [id],
description: "<p>You have a flying speed equal to your walking speed.</p>",
"flags.visual-active-effects.data.content": item.system.description.value
}]);
22 changes: 11 additions & 11 deletions classes/cleric/twilight_sanctuary.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const target = game.user.targets.first();
// find Sequencer effect
const [effect] = Sequencer.EffectManager.getEffects({name: item.name});

if(!effect){
if (!effect) {
const use = await item.use();
if (!use) return;
return new Sequence()
.effect()
.attachTo(token)
.persist()
.name(item.name)
.file(file)
.size(canvas.grid.size * 8)
.scaleIn(0, 800, {ease: "easeOutCubic"})
.rotateIn(180, 1200, {ease: "easeOutCubic"})
.scaleOut(0, 500, {ease: "easeOutCubic"})
.fadeOut(500, {ease: "easeOutCubic"});
.attachTo(token)
.persist()
.name(item.name)
.file(file)
.size(canvas.grid.size * 8)
.scaleIn(0, 800, {ease: "easeOutCubic"})
.rotateIn(180, 1200, {ease: "easeOutCubic"})
.scaleOut(0, 500, {ease: "easeOutCubic"})
.fadeOut(500, {ease: "easeOutCubic"})
.play();
}

Expand All @@ -40,7 +40,7 @@ new Dialog({
const temp = target.actor.system.attributes.hp.temp ?? 0;
const updates = {actor: {"system.attributes.hp.temp": total}};
const config = {permanent: true, name: item.name, description: `You are being granted ${total} temporary hit points.`};
if(total > temp) return warpgate.mutate(target.document, updates, {}, config);
if (total > temp) return warpgate.mutate(target.document, updates, {}, config);
}
},
effect: {
Expand Down
86 changes: 43 additions & 43 deletions classes/paladin/channel_divinity_burning_weapon.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,50 @@

const name = "Burning Weapon";
const hasMutation = warpgate.mutationStack(token.document).getName(name);
if ( hasMutation ) return warpgate.revert(token.document, name);
if (hasMutation) return warpgate.revert(token.document, name);

const weapons = actor.itemTypes.weapon.filter(i => i.system.equipped);
if ( !weapons.length ) return ui.notifications.warn("You have no equipped weapons.");
if (!weapons.length) return ui.notifications.warn("You have no equipped weapons.");

const use = await item.use();
if ( !use ) return;
if (!use) return;

// mutation function:
async function mutate(weaponId){
const weapon = actor.items.get(weaponId);
if ( !weapon ) return;
const mod = Math.max(1, actor.system.abilities.cha.mod);
const damageParts = weapon.system.damage.parts;
damageParts[0][0] = `${damageParts[0][0]} + ${mod}[fire]`;

await warpgate.mutate(token.document, {
token: {
light: {
bright: 20,
dim: 40,
color: "#e05d06",
"animation.type": "torch"
}
},
embedded: {
Item: {
[weaponId]: {
system: {
"properties.mgc": true,
"damage.parts": damageParts
}
}
}
async function mutate(weaponId) {
const weapon = actor.items.get(weaponId);
if (!weapon) return;
const mod = Math.max(1, actor.system.abilities.cha.mod);
const damageParts = weapon.system.damage.parts;
damageParts[0][0] = `${damageParts[0][0]} + ${mod}[fire]`;

await warpgate.mutate(token.document, {
token: {
light: {
bright: 20,
dim: 40,
color: "#e05d06",
"animation.type": "torch"
}
},
embedded: {
Item: {
[weaponId]: {
system: {
"properties.mgc": true,
"damage.parts": damageParts
}
}
}, {}, { name, comparisonKeys: { Item: "_id" } });
}
}
}, {}, {name, comparisonKeys: {Item: "_id"}});
}

/* exactly one weapon */
if ( weapons.length === 1 ) return mutate(weapons[0].id);
if (weapons.length === 1) return mutate(weapons[0].id);

/* multiple weapons */
const weaponSelect = weapons.reduce((acc, { id, name }) => {
return acc + `<option value="${id}">${name}</option>`;
const weaponSelect = weapons.reduce((acc, {id, name}) => {
return acc + `<option value="${id}">${name}</option>`;
}, "");
const content = `
<p>Pick your weapon for ${name}.</p>
Expand All @@ -68,16 +68,16 @@ const content = `
</form>`;

new Dialog({
title: name,
content,
buttons: {
go: {
icon: "<i class='fas fa-fire'></i>",
label: "Flame On!",
callback: (html) => {
const id = html[0].querySelector("#wpn").value;
return mutate(id);
}
}
title: name,
content,
buttons: {
go: {
icon: "<i class='fas fa-fire'></i>",
label: "Flame On!",
callback: (html) => {
const id = html[0].querySelector("#wpn").value;
return mutate(id);
}
}
}
}).render(true);
4 changes: 2 additions & 2 deletions classes/paladin/channel_divinity_harness_divine_power.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// HARNESS DIVINE POWER
// required modules: itemacro
// setup:
// setup:
// (1) Place macro in Item Macro on the Harness Divine Power feature.
// (2) Have Harness Divine Power set up with Limited Uses.
// (3) Have Harness Divine Power consume Limited Uses of a Channel Divinity item.

const {spells, attributes: {prof}} = foundry.utils.duplicate(actor.system);
const maxLevel = Math.ceil(prof/2);
const maxLevel = Math.ceil(prof / 2);
const validLevels = [];
for (let i = 1; i <= maxLevel; i++) {
const key = `spell${i}`;
Expand Down
20 changes: 10 additions & 10 deletions classes/paladin/channel_divinity_warming_respite.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// required modules: itemacro, warpgate

const use = await item.use();
if ( !use ) return;
if (!use) return;

const { levels } = actor.getRollData().classes.paladin;
const updates = { actor: { "system.attributes.hp.temp": levels } }
const levels = actor.classes.paladin.system.levels;
const updates = {actor: {"system.attributes.hp.temp": levels}};
const options = {
permanent: true,
description: `${actor.name} is granting you ${levels} temporary hit points.`
permanent: true,
description: `${actor.name} is granting you ${levels} temporary hit points.`
};
for (const target of game.user.targets) {
if (target.actor.system.attributes.hp.temp < levels) {
await warpgate.mutate(target.document, updates, {}, options);
}
}
Array.from(game.user.targets).filter(target => {
return target.actor.system.attributes.hp.temp < levels;
}).map(target => {
return warpgate.mutate(target.document, updates, {}, options);
});
6 changes: 3 additions & 3 deletions classes/paladin/divine_smite.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const inputs = Object.entries(data.spells).filter(([key, values]) => {
const crd = key === "pact" ? "Pact Slot" : CONFIG.DND5E.spellLevels[key.at(-1)];
return [key, crd, values];
});
if(!inputs.length) return ui.notifications.warn("You have no spell slots remaining.");
if (!inputs.length) return ui.notifications.warn("You have no spell slots remaining.");

const options = inputs.reduce((acc, [key, crd, values]) => {
return acc + `<option value="${key}">${crd} (${values.value}/${values.max})</option>`;
Expand Down Expand Up @@ -38,7 +38,7 @@ return new Dialog({
}
}).render(true);

async function rollDamage(html){
async function rollDamage(html) {
const slot = html[0].querySelector("select").value;
const extra = html[0].querySelector("#smite-extra-die").checked;
const level = slot === "pact" ? data.spells["pact"].level : Number(slot.at(-1));
Expand All @@ -52,7 +52,7 @@ async function rollDamage(html){
}
}, {parent: actor});
const roll = await feature.rollDamage({event});
if(!roll) return;
if (!roll) return;
const value = data.spells[slot].value - 1;
return actor.update({[`system.spells.${slot}.value`]: value});
}
6 changes: 3 additions & 3 deletions classes/paladin/lay_on_hands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// required modules: itemacro

const uses = item.system.uses;
if(!uses.value) return ui.notifications.warn(`${item.name} has no uses left.`);
if (!uses.value) return ui.notifications.warn(`${item.name} has no uses left.`);

const content = `
<p>Lay on Hands has ${uses.value} uses left.</p>
Expand All @@ -21,13 +21,13 @@ const buttons = {
label: "Heal!",
callback: async (html) => {
const number = Number(html[0].querySelector("#num").value);
if(!number.between(1, uses.value)) return ui.notifications.warn("Invalid number.");
if (!number.between(1, uses.value)) return ui.notifications.warn("Invalid number.");
await new Roll(`${number}`).toMessage({speaker, flavor: item.name});
return item.update({"system.uses.value": uses.value - number});
}
}
};
if(uses.value >= 5){
if (uses.value >= 5) {
buttons.cure = {
icon: "<i class='fa-solid fa-virus'></i>",
label: "Cure!",
Expand Down
19 changes: 0 additions & 19 deletions classes/rogue/sneak_attack.js

This file was deleted.

Loading

0 comments on commit 747cdd2

Please sign in to comment.