Skip to content

Commit

Permalink
12.02 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 committed Jul 26, 2024
1 parent 19d0d5b commit 7d12081
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 35 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## Version 12.02

Fixed issues when using Dice So Nice and figuring out when to reveal the dice

Fixed double rolling of Dice So Nice in D&D 5e

Fixed some more v12 deprecation issues

Removing natural attacks and effects from the after combat Loot

Fixed how information for lootables is collected

Fixed initial Tokenbar positioning

Fixed issue when deleting a token when no panning is disabled

Fixed issue that the latest version of PF2e introduced when getting skills.

## Version 12.01

v12 compatibility
Expand Down
10 changes: 5 additions & 5 deletions apps/contestedroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class ContestedRoll {
* if (!game.user.isGM) {
MonksTokenBar.emit('rollability', { type: 'contestedroll', senderId: game.user.id, response: [{ actorid: actorid, roll: roll }], msgid: message.id });
} else {
const revealDice = game.dice3d ? game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages") : true;
const revealDice = MonksTokenBar.revealDice();
await ContestedRoll.updateContestedRoll([{ actorid: actorid, roll: roll }], message, revealDice && !fastForward);
}*/
static async rollDice(dice) {
Expand All @@ -268,7 +268,7 @@ export class ContestedRoll {
} else if (rollmode == 'blindroll')
cantSee = owners;

if (game.dice3d != undefined && roll instanceof Roll && roll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas")) {
if (game.dice3d != undefined && roll instanceof Roll && roll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas") && game.system.id != "dnd5e") {
let promises = [game.dice3d.showForRoll(roll, game.user, true, canSee, cantSee.includes(game.user.id), (rollmode == 'selfroll' ? msgId : null))];
if (cantSee.length) {
roll.ghost = true;
Expand Down Expand Up @@ -400,7 +400,7 @@ export class ContestedRoll {
});
}
} else {
const revealDice = game.dice3d ? game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages") : true;
const revealDice = MonksTokenBar.revealDice();
return await ContestedRoll.updateMessage(response, message, revealDice);
}
});
Expand All @@ -427,7 +427,7 @@ export class ContestedRoll {
if (msgtoken.roll.terms.length)
msgtoken.roll.terms = foundry.utils.duplicate(msgtoken.roll.terms);
for (let i = 0; i < msgtoken.roll.terms.length; i++) {
if (msgtoken.roll.terms[i] instanceof RollTerm)
if (msgtoken.roll.terms[i] instanceof foundry.dice.terms.RollTerm)
msgtoken.roll.terms[i] = msgtoken.roll.terms[i].toJSON();
}
msgtoken.total = update.roll.total;
Expand Down Expand Up @@ -699,7 +699,7 @@ export class ContestedRoll {
const newRoll = await new Roll(formula, newData, newOptions).evaluate({ async: !0 });
const rollmode = message.getFlag("monks-tokenbar", "rollmode");

if (game.dice3d != undefined && newRoll instanceof Roll && newRoll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas")) {
if (game.dice3d != undefined && newRoll instanceof Roll && newRoll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas") && game.system.id != "dnd5e") {
let canSee = (rollmode == 'roll' ? null : ChatMessage.getWhisperRecipients("GM").map(w => { return w.id }));
let cantSee = [];
let owners = actor.ownership.default == CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER ?
Expand Down
65 changes: 49 additions & 16 deletions apps/lootables.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ export class LootablesApp extends Application {
return false;

if (item.type == 'weapon') {
result = item.system.weaponType != 'natural';
result = getProperty(item, "system.weaponType") != 'natural' && getProperty(item, "system.type.value") != 'natural';
}
// Equipment's fine, unless it's natural armor
else if (item.type == 'equipment') {
if (!item.system.armor)
result = true;
else
result = item.system.armor.type != 'natural';
result = getProperty(item, "system.armor.type") != 'natural' && getProperty(item, "system.armor.type.value") != 'natural';
} else
result = !(['class', 'spell', 'feat', 'action', 'lore', 'melee', 'condition', 'spellcastingEntry'].includes(item.type));
result = !(['class', 'spell', 'feat', 'action', 'lore', 'melee', 'condition', 'spellcastingEntry', 'effect'].includes(item.type));

return result;
}).map(i => {
Expand Down Expand Up @@ -473,14 +473,14 @@ export class LootablesApp extends Application {
// Weapons are fine, unless they're natural
let result = false;
if (item.type == 'weapon') {
result = item.system.weaponType != 'natural';
result = getProperty(item, "system.weaponType")" != 'natural' && getProperty(item, "system.type.value") != 'natural';
}
// Equipment's fine, unless it's natural armor
else if (item.type == 'equipment') {
if (!item.system.armor)
result = true;
else
result = item.system.armor.type != 'natural';
result = getProperty(item, "system.armor.type")" != 'natural' && getProperty(item, "system.type.value") != 'natural';
} else
result = !(['class', 'spell', 'feat', 'action', 'lore'].includes(item.type));
Expand Down Expand Up @@ -577,9 +577,52 @@ export class LootablesApp extends Application {
let msg = "";
let created = false;

for (let e of this.entries) {
for (let loot of e.items) {
if (typeof loot.quantity == "string" && loot.quantity.indexOf("d") != -1) {
let r = new Roll(loot.quantity);
await r.evaluate({ async: true });
loot.quantity = r.total;
} else
loot.quantity = parseInt(loot.quantity);

if (isNaN(loot.quantity))
loot.quantity = 1;
}

e.items = e.items.filter(i => i && i.quantity > 0);
}

if (lootEntity == 'convert') {
if (lootSheet == "item-piles") {
let tokens = this.entries.flatMap(e => e.tokens).filter(t => !!t);
let tokens = this.entries.flatMap(e => {
return e.tokens.map(t => {
if (!t.actor)
return;
let actor = t.actor;
// remove any items that have been removed from the actor
for (let item of actor.items) {
let loot = e.items.find(i => i.id == item.id);
if (!loot || loot.quantity == 0) {
item.delete();
} else {
// update the quantity of the item
//let itemQty = foundry.utils.getProperty(item, "system.quantity") || 1;
//if (isNaN(itemQty))
// itemQty = 1;
foundry.utils.setProperty(item, "system.quantity", loot.quantity);

if (foundry.utils.getProperty(item, "system.equipped") != undefined) {
if (game.system.id == "pf2e")
foundry.utils.setProperty(item, "system.equipped.handsHeld", 0);
else
foundry.utils.setProperty(item, "system.equipped", false);
}
}
}
return t;
})
}).filter(t => !!t);
ItemPiles.API.turnTokensIntoItemPiles(tokens);
} else {
for (let entry of this.entries) {
Expand Down Expand Up @@ -771,16 +814,6 @@ export class LootablesApp extends Application {
for (let loot of loots) {
let item = loot.data;

if (typeof loot.quantity == "string" && loot.quantity.indexOf("d") != -1) {
let r = new Roll(loot.quantity);
await r.evaluate({ async: true });
loot.quantity = r.total;
} else
loot.quantity = parseInt(loot.quantity);

if (isNaN(loot.quantity))
loot.quantity = 1;

item._id = foundry.utils.randomID();
if (game.modules.get("monks-enhanced-journal")?.active) {
let sysPrice = game.MonksEnhancedJournal.getSystemPrice(item);
Expand Down
8 changes: 4 additions & 4 deletions apps/savingthrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ export class SavingThrow {
} else if (rollmode == 'blindroll')
cantSee = owners;

if (game.dice3d != undefined && roll instanceof Roll && roll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas")) {
if (game.dice3d != undefined && roll instanceof Roll && roll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas") && game.system.id != "dnd5e") {
let promises = [game.dice3d.showForRoll(roll, game.user, true, canSee, cantSee.includes(game.user.id), (rollmode == 'selfroll' ? msgId : null))];
if (cantSee.length) {
roll.ghost = true;
Expand Down Expand Up @@ -734,7 +734,7 @@ export class SavingThrow {
});
}
} else {
const revealDice = game.dice3d ? game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages") : true;
const revealDice = MonksTokenBar.revealDice();
return await SavingThrow.updateMessage(response, message, revealDice);
}
});
Expand Down Expand Up @@ -771,7 +771,7 @@ export class SavingThrow {
if (msgtoken.roll.terms.length)
msgtoken.roll.terms = foundry.utils.duplicate(msgtoken.roll.terms);
for (let i = 0; i < msgtoken.roll.terms.length; i++) {
if (msgtoken.roll.terms[i] instanceof RollTerm)
if (msgtoken.roll.terms[i] instanceof foundry.dice.terms.RollTerm)
msgtoken.roll.terms[i] = msgtoken.roll.terms[i].toJSON();
}
msgtoken.total = update.roll.total;
Expand Down Expand Up @@ -1049,7 +1049,7 @@ export class SavingThrow {
const newRoll = await new Roll(formula, newData, newOptions).evaluate({ async: !0 });
const rollmode = message.getFlag("monks-tokenbar", "rollmode");

if (game.dice3d != undefined && newRoll instanceof Roll && newRoll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas")) {
if (game.dice3d != undefined && newRoll instanceof Roll && newRoll.ignoreDice !== true && MonksTokenBar.system.showRoll && !game.settings.get("core", "noCanvas") && game.system.id != "dnd5e") {
let canSee = (rollmode == 'roll' ? null : ChatMessage.getWhisperRecipients("GM").map(w => { return w.id }));
let cantSee = [];
let owners = actor.ownership.default == CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER ?
Expand Down
6 changes: 3 additions & 3 deletions apps/tokenbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class TokenBar extends Application {
if (this.pos == undefined) {
let hbpos = $('#ui-bottom').offset();
let width = $('#hotbar').width();
this.pos = { left: hbpos.left + width + 4, right: '', top: '', bottom: 10 };
this.pos = { left: hbpos.left + width + 36, right: '', top: '', bottom: 10 };
game.user.setFlag("monks-tokenbar", "position", this.pos);
}

Expand Down Expand Up @@ -453,8 +453,8 @@ export class TokenBar extends Application {
diff.inspiration = (entry.actor.system?.attributes?.inspiration && setting('show-inspiration'));

if (setting("show-disable-panning-option")) {
if (entry.nopanning != entry.token.flags['monks-tokenbar']?.nopanning) {
diff.nopanning = entry.token.flags['monks-tokenbar']?.nopanning;
if (entry.nopanning != entry.token?.flags['monks-tokenbar']?.nopanning) {
diff.nopanning = entry.token?.flags['monks-tokenbar']?.nopanning;
}
} else {
diff.nopanning = false;
Expand Down
10 changes: 6 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Monk's TokenBar",
"description": "Add a bar with all the current player tokens. Limit movement, roll saving throws, assign XP.",
"version": "12.01",
"version": "12.02",
"authors": [
{
"name": "IronMonk",
Expand Down Expand Up @@ -82,16 +82,18 @@
"css/tokenbar.css"
],
"url": "https://github.com/ironmonk88/monks-tokenbar",
"download": "https://github.com/ironmonk88/monks-tokenbar/archive/12.01.zip",
"download": "https://github.com/ironmonk88/monks-tokenbar/archive/12.02.zip",
"manifest": "https://github.com/ironmonk88/monks-tokenbar/releases/latest/download/module.json",
"bugs": "https://github.com/ironmonk88/monks-tokenbar/issues",
"allowBugReporter": true,
"id": "monks-tokenbar",
"compatibility": {
"minimum": "12",
"verified": "12"
},
"name": "monks-tokenbar",
"minimumCoreVersion": "12",
"compatibleCoreVersion": "12"
"compatibleCoreVersion": "12",
"flags": {
"allowBugReporter": true
}
}
8 changes: 6 additions & 2 deletions monks-tokenbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ export class MonksTokenBar {
r.style.setProperty('--tokenbar-token-size', size + "px");
}

static revealDice() {
return game.dice3d ? game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages") || !game.dice3d.isEnabled() : true;
}

static ready() {
game.socket.on(MonksTokenBar.SOCKET, MonksTokenBar.onMessage);

Expand Down Expand Up @@ -469,7 +473,7 @@ export class MonksTokenBar {
case 'rollability': {
if (game.user.isGM) {
let message = game.messages.get(data.msgid);
const revealDice = game.dice3d ? game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages") : true;
const revealDice = MonksTokenBar.revealDice();
for (let response of data.response) {
if (response.roll) {
let r = Roll.fromData(response.roll);
Expand Down Expand Up @@ -547,7 +551,7 @@ export class MonksTokenBar {

let response = { id: data.tokenid, roll: Roll.fromData(data.roll), finish: null, reveal: true }

const revealDice = game.dice3d ? game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages") : true;
const revealDice = MonksTokenBar.revealDice();
await SavingThrow.updateMessage([response], msg, revealDice);
}
}
Expand Down
6 changes: 5 additions & 1 deletion systems/pf2e-rolls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export class PF2eRolls extends BaseRolls {
constructor() {
super();

const { lore, ...skills } = this.config.skillList
const configSkills = this.config.skills;
const skills = Object.keys(this.config.skills).reduce(function (result, key) {
result[key] = configSkills[key].label
return result
}, {})

this._requestoptions = [
{ id: "attribute", text: i18n("MonksTokenBar.Attribute"), groups: { perception: i18n("PF2E.PerceptionLabel") } },
Expand Down

0 comments on commit 7d12081

Please sign in to comment.