Skip to content

Commit

Permalink
10.9 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 committed Apr 2, 2023
1 parent 0adac47 commit 159fc7c
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 24 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## Version 10.9

Added the option to set the attribute icon to blank

Fixed lootables so that currencies that didn't exist aren't added to.

Added the option to use the currencies specified in Monk's Enhanced Journal if using that module for your loot.

Added the option to select tokens from either the players or the token on the token bar when requesting a roll.

Added the option of specifying a roll code when creating an inline roll for a journal entry. This way tokenbar can distinguish between a Strength saving throw and a regular Strength roll.

Fixed issue when requesting a contested roll from an inline link in a Journal Entry.

Fixed issue where inline links would open a roll request twice.

Fixed issues with SFRPG, xp will show again, and calculating xp won't throw an error.

Fixed issue with SW5e, calculating xp won't throw an error.

## Version 10.8

Removing debug code so that the tokenbar can be repositioned properly.
Expand Down
11 changes: 8 additions & 3 deletions apps/lootables.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class LootablesApp extends Application {
}

this.currency = Object.keys(CONFIG[game.system.id.toUpperCase()]?.currencies || {}).reduce((a, v) => ({ ...a, [v]: 0 }), {});
if (lootsheet == "monks-enhanced-journal" && game.modules.get("monks-enhanced-journal")?.active) {
this.currency = game.MonksEnhancedJournal.currencies.filter(c => c.convert != null).reduce((a, v) => ({ ...a, [v.id]: 0 }), {});
}

this.entries = [];
this.noitems = [];
Expand Down Expand Up @@ -108,9 +111,11 @@ export class LootablesApp extends Application {
let actorCurrency = (document.actorData.currency || document.actor.system.currency);
if (actorCurrency) {
for (let [key, value] of Object.entries(actorCurrency)) {
let val = (value.value ?? value);
if (isNaN(val)) val = 0;
this.currency[key] = (this.currency[key] ?? 0) + val;
if (this.currency[key] != undefined) {
let val = (value.value ?? value);
if (isNaN(val)) val = 0;
this.currency[key] = (this.currency[key] ?? 0) + val;
}
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion apps/pick-icon.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion apps/savingthrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,20 @@ export class SavingThrowApp extends Application {
changeTokens(e) {
let type = e.target.dataset.type;
switch (type) {
case 'player':
case 'tokenbar':
this.entries = MonksTokenBar.getTokenEntries(canvas.tokens.placeables.filter(t => {
let include = t.document.getFlag('monks-tokenbar', 'include');
include = (include === true ? 'include' : (include === false ? 'exclude' : include || 'default'));
return (t.actor != undefined && ((t.actor?.hasPlayerOwner && t.document.disposition == 1 && include != 'exclude') || include === 'include'));
}));
this.render(true);
break;
case 'player':
this.entries = MonksTokenBar.getTokenEntries(canvas.tokens.placeables.filter(t => {
return (t.actor != undefined && (t.actor?.hasPlayerOwner && t.document.disposition == 1));
}));
this.render(true);
break;
case 'last':
if (SavingThrow.lastTokens) {
this.entries = duplicate(SavingThrow.lastTokens);
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
"MonksTokenBar.Save": "Save",
"MonksTokenBar.IncreaseLevel": "Increase Level",
"MonksTokenBar.Creatures": "Creatures",
"MonksTokenBar.Tokenbar": "Tokenbar",

"MonksTokenBar.None": "No one",
"MonksTokenBar.GMOnly": "GM Only",
Expand Down
11 changes: 7 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"title": "Monk's TokenBar",
"description": "Add a bar with all the current player tokens. Limit movement, roll saving throws, assign XP.",
"version": "10.8",
"version": "10.9",
"authors": [
{
"name": "IronMonk",
"discord": "ironmonk88#4075",
"patreon": "https://www.patreon.com/ironmonk",
"ko-fi": "https://ko-fi.com/ironmonk88"
"flags": {
"github": "https://github.com/ironmonk88",
"patreon": "https://www.patreon.com/ironmonk",
"ko-fi": "https://ko-fi.com/ironmonk88"
}
}
],
"socket": true,
Expand Down Expand Up @@ -64,7 +67,7 @@
"css/tokenbar.css"
],
"url": "https://github.com/ironmonk88/monks-tokenbar",
"download": "https://github.com/ironmonk88/monks-tokenbar/archive/10.8.zip",
"download": "https://github.com/ironmonk88/monks-tokenbar/archive/10.9.zip",
"manifest": "https://github.com/ironmonk88/monks-tokenbar/releases/latest/download/module.json",
"bugs": "https://github.com/ironmonk88/monks-tokenbar/issues",
"allowBugReporter": true,
Expand Down
17 changes: 13 additions & 4 deletions monks-tokenbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,11 +977,20 @@ export class MonksTokenBar {
if (options.fastForward) options.fastForward = true;
if (options.silent) options.silent = true;

if (options.request.indexOf(":") > -1) {
let [type, key] = options.request.split(":");
options.request = { type, key };
}
if (options.request1 && options.request1.indexOf(":") > -1) {
let [type, key] = options.request1.split(":");
options.request1 = { type, key };
}

let requesttype = a.dataset.requesttype.toLowerCase();
if (requesttype == 'request')
MonksTokenBarAPI.requestRoll(canvas.tokens.controlled, options);
else if (requesttype == 'contested')
MonksTokenBarAPI.requestContestedRoll({ request: a.dataset.request }, { request: a.dataset.request1 }, options);
else if (requesttype == 'contested')
MonksTokenBarAPI.requestContestedRoll({ request: options.request }, { request: options.request1 }, options);
}
}

Expand Down Expand Up @@ -1671,11 +1680,11 @@ Hooks.on("setupTileActions", (app) => {
});

Hooks.on("renderJournalSheet", (sheet, html, data) => {
$("a.inline-request-roll", html).click(MonksTokenBar._onClickInlineRequestRoll.bind(sheet));
$("a.inline-request-roll", html).off("click").click(MonksTokenBar._onClickInlineRequestRoll.bind(sheet));
});

Hooks.on("renderJournalPageSheet", (sheet, html, data) => {
$("a.inline-request-roll", html).click(MonksTokenBar._onClickInlineRequestRoll.bind(sheet));
$("a.inline-request-roll", html).off("click").click(MonksTokenBar._onClickInlineRequestRoll.bind(sheet));
});

Hooks.on("preUpdateChatMessage", (message, data, dif, userId) => {
Expand Down
2 changes: 1 addition & 1 deletion systems/coc7-rolls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseRolls } from "./base-rolls.js"
import { i18n, log, setting } from "../monks-tokenbar.js"
import { i18n, MonksTokenBar, log, setting } from "../monks-tokenbar.js"

export class CoC7Rolls extends BaseRolls {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion systems/d35e-rolls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseRolls } from "./base-rolls.js"
import { i18n, log, setting } from "../monks-tokenbar.js"
import { i18n, MonksTokenBar, log, setting } from "../monks-tokenbar.js"

export class D35eRolls extends BaseRolls {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion systems/dnd4e-rolls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseRolls } from "./base-rolls.js"
import { i18n, log, setting } from "../monks-tokenbar.js"
import { i18n, MonksTokenBar, log, setting } from "../monks-tokenbar.js"

export class DnD4eRolls extends BaseRolls {
constructor() {
Expand Down
16 changes: 15 additions & 1 deletion systems/sfrpg-rolls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseRolls } from "./base-rolls.js"
import { i18n, log, setting } from "../monks-tokenbar.js"
import { i18n, log, MonksTokenBar, setting } from "../monks-tokenbar.js"

export class SFRPGRolls extends BaseRolls {
constructor() {
Expand Down Expand Up @@ -51,10 +51,24 @@ export class SFRPGRolls extends BaseRolls {
return 'abilities:str';
}

get showXP() {
return !game.settings.get('sfrpg', 'disableExperienceTracking');
}

getXP(actor) {
return actor?.system.details.xp;
}

calcXP(actors, monsters) {
//get the monster xp
let combatxp = 0;
for (let monster of monsters) {
combatxp += (MonksTokenBar.system.getXP(monster.actor)?.value || 0);
};

return combatxp;
}

roll({ id, actor, request, rollMode, fastForward = false }, callback, e) {
/*
let rollfn = null;
Expand Down
3 changes: 2 additions & 1 deletion systems/sw5e-rolls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseRolls } from "./base-rolls.js"
import { i18n, log, setting } from "../monks-tokenbar.js"
import { i18n, MonksTokenBar, log, setting } from "../monks-tokenbar.js"

export class SW5eRolls extends BaseRolls {
constructor() {
Expand Down Expand Up @@ -41,6 +41,7 @@ export class SW5eRolls extends BaseRolls {

calcXP(actors, monsters) {
//get the monster xp
let combatxp = 0;
for (let monster of monsters) {
combatxp += (MonksTokenBar.system.getXP(monster.actor)?.value || 0);
};
Expand Down
2 changes: 1 addition & 1 deletion systems/swade-rolls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseRolls } from "./base-rolls.js"
import { i18n, log, setting } from "../monks-tokenbar.js"
import { i18n, MonksTokenBar, log, setting } from "../monks-tokenbar.js"

export class SwadeRolls extends BaseRolls {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion templates/contestedroll.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h4>
</form>
</div>
<div class="dialog-buttons flexrow">
<button class="dialog-button save-macro" data-button="save-macro" title="{{localize 'MonksTokenBar.SaveToMacro'}}" style="width:30px;flex:0 0 30px;"><i class="fas fa-save"></i></button>
<button class="dialog-button save-macro" data-button="save-macro" title="{{localize 'MonksTokenBar.SaveToMacro'}}" style="width: 30px; flex: 0 0 30px; padding-top: 2px; padding-bottom: 0px; padding-left: 8px;"><i class="fas fa-save"></i></button>
<button class="dialog-button request-roll" data-button="request-roll"><i class="fas fa-dice"></i> {{localize 'MonksTokenBar.RequestWithRoll'}}</button>
<button class="dialog-button request" data-button="request"><i class="fas fa-receipt"></i> {{localize 'MonksTokenBar.Request'}}</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/lootables.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<div class="flexrow" style="margin: 4px 0px;">
{{#each currency}}
<div class="flexrow" style="flex-direction:row-reverse;">
<input type="text" class="currency-value" name="{{@key}}" style="text-align: right;" value="{{this}}" />
<span style="text-align: center; line-height: 24px;">{{@key}}</span>
<input type="text" class="currency-value" name="{{@key}}" style="text-align: right; max-width: 70px;" value="{{this}}" />
<span style="text-align: right; line-height: 24px; margin-right: 8px;">{{@key}}</span>
</div>
{{/each}}
<button type="button" class="add-gold" title="Calculate gold based on CR" style="flex: 0 0 28px; text-align: center; line-height: 24px; margin-left: 5px; padding: 0px 2px 0px 4px;">
Expand Down
7 changes: 5 additions & 2 deletions templates/savingthrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ <h3 class="item-name noborder flexrow">{{localize 'MonksTokenBar.Actors'}}</h3>

<div class="item-controls flexrow">
<a class="item-control" title="{{localize 'MonksTokenBar.AddPlayers'}}" data-type="player">
<i class="fas fa-child"></i>{{localize 'MonksTokenBar.Players'}}
<i class="fas fa-users"></i>{{localize 'MonksTokenBar.Players'}}
</a>
<a class="item-control" title="{{localize 'MonksTokenBar.AddTokenbar'}}" data-type="tokenbar">
<i class="fas fa-child"></i>{{localize 'MonksTokenBar.Tokenbar'}}
</a>
<a class="item-control" title="{{localize 'MonksTokenBar.AddLastTokens'}}" data-type="last">
<i class="fas fa-bolt"></i>{{localize 'MonksTokenBar.LastTokens'}}
Expand Down Expand Up @@ -82,7 +85,7 @@ <h4>
</form>
</div>
<div class="dialog-buttons flexrow">
<button class="dialog-button save-macro" data-button="save-macro" title="{{localize 'MonksTokenBar.SaveToMacro'}}" style="width:30px;flex:0 0 30px;"><i class="fas fa-save"></i></button>
<button class="dialog-button save-macro" data-button="save-macro" title="{{localize 'MonksTokenBar.SaveToMacro'}}" style="width: 30px; flex: 0 0 30px; padding-top: 2px; padding-bottom: 0px; padding-left: 8px;"><i class="fas fa-save"></i></button>
<button class="dialog-button request-roll" data-button="request-roll"><i class="fas fa-dice"></i> {{localize 'MonksTokenBar.RequestWithRoll'}}</button>
<button class="dialog-button request" data-button="request"><i class="fas fa-receipt"></i> {{localize 'MonksTokenBar.Request'}}</button>
</div>
Expand Down

0 comments on commit 159fc7c

Please sign in to comment.