Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@
"AddInventory": "Loot",
"AddConsumable": "Consumable",

"Recharge": "Recharge",
"NCharged": "Not charged",
"Costs": "Costs",
"ResourceRefresh": "Day",

Expand Down
2 changes: 0 additions & 2 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@
"AddInventory": "Trésor",
"AddConsumable": "Consommable",

"Recharge": "Recharge",
"NCharged": "Pas chargé",
"Costs": "Coûts",
"ResourceRefresh": "Jour",

Expand Down
2 changes: 0 additions & 2 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@
"AddInventory": "戦利品",
"AddConsumable": "消耗品",

"Recharge": "再チャージ",
"NCharged": "チャージ失敗",
"Costs": "コスト",
"ResourceRefresh": "日",

Expand Down
2 changes: 0 additions & 2 deletions lang/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@
"AddInventory": "Inventário",
"AddConsumable": "Consumível",

"Recharge": "Recarga",
"NCharged": "Não carregada",
"Costs": "Custa",
"ResourceRefresh": "Dia",

Expand Down
7 changes: 5 additions & 2 deletions monsterblock.css
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@
}
.monsterblock .item-attackRoll:hover,
.monsterblock .item-damageRoll:hover,
.monsterblock .item-recharge:hover,
.monsterblock .ability:hover,
.monsterblock .saving-throw:hover,
.monsterblock .skill:hover,
.monsterblock .item-name:hover,
.monsterblock .spell:hover,
.monsterblock a.inline-roll:hover,
.monsterblock [data-roll-formula]:hover,
.monsterblock .window-content a:hover,
.monsterblock .tweak-menu ul label:hover,
.monsterblock .menu .menu-toggle:hover {
Expand Down Expand Up @@ -706,6 +706,9 @@ li:nth-last-of-type(2):after {
.monsterblock .spell .name-extension {
font-weight: initial;
}
.monsterblock .item-recharge {
color: var(--heading-color);
}
.monsterblock .legendary-actions .feature-description {
padding-left: 2ch;
text-indent: -2ch;
Expand Down Expand Up @@ -1120,4 +1123,4 @@ li:nth-last-of-type(2):after {
}
.monsterblock .flavor-text > p {
padding: 0 1ch;
}
}
59 changes: 7 additions & 52 deletions scripts/dnd5e/MonsterBlock5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,42 +703,6 @@ export default class MonsterBlock5e extends ActorSheet5eNPC {
}).render(true);
});

html.find("[data-roll-formula]").click(async (event) => { // Universal way to add an element that provides a roll, just add the data attribute "data-roll-formula" with a formula in it, and this applies.
event.preventDefault(); // This handler makes "quick rolls" possible, it just takes some data stored on the HTML element, and rolls dice directly.
event.stopPropagation();

const formula = event.currentTarget.dataset.rollFormula;
const target = event.currentTarget.dataset.rollTarget;
const success = event.currentTarget.dataset.rollSuccess;
const failure = event.currentTarget.dataset.rollFailure;
const handler = event.currentTarget.dataset.rollHandler;
let flavor = event.currentTarget.dataset.rollFlavor; // Optionally, you can include data-roll-flavor to add text to the message.

let roll;
try {
roll = new Roll(formula);
await roll.roll({ async: true });
}
catch (e) {
console.error(e);
ui.notifications.error(e);
roll = new Roll("0");
await roll.roll({ async: true });
}

if (target) {
let s = roll.total >= parseInt(target, 10);
if (handler) this[handler](s, event);

flavor += `<span style="font-weight: bold; color: ${s ? "green" : "red"};">${s ? success : failure}</span>`;
}

roll.toMessage({ // Creates a new Roll, rolls it, and sends the result as a message
flavor: flavor, // Including the text as defined
speaker: ChatMessage.getSpeaker({actor: this.actor})// And setting the speaker to the actor this sheet represents
});
});

// Special Roll Handlers
html.find(".ability").click(async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -774,6 +738,13 @@ export default class MonsterBlock5e extends ActorSheet5eNPC {
else return item.roll(); // Conveniently, items have all this logic built in already.
});

html.find(".item-recharge").click(async (event) => {
event.preventDefault();

const item = this.actor.items.get(event.currentTarget.dataset.itemId);
item.rollRecharge();
});

// uses the built in attack roll from the item
html.find(".item-attackRoll").click(async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -1141,22 +1112,6 @@ export default class MonsterBlock5e extends ActorSheet5eNPC {
await this.render(true);
}

/**
*
*
* @param {boolean} success - Whether or not the roll was a success.
* @param {Event} event - The event object associated with this roll.
* @memberof MonsterBlock5e
*/
async setCharged(success, event) {
await this.actor.updateEmbeddedDocuments("Item", [{
_id: event.currentTarget.dataset.itemId,
"data.recharge.charged": success
}])

super._onChangeInput(event);
}

static isMultiAttack(item) { // Checks if the item is the multiattack action.
let name = item.name.toLowerCase().replace(/\s+/g, ""); // Convert the name of the item to all lower case, and remove whitespace.
return getTranslationArray("MOBLOKS5E.MultiattackLocators").some(loc => name.includes(loc));
Expand Down
11 changes: 2 additions & 9 deletions templates/dnd5e/parts/featureBlock.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@
{{~item.name~}}
</span>
{{~#if item.data.recharge.value~}}
<span class="name-extension"
data-item-id="{{item._id}}"
data-roll-flavor="{{item.name}} ({{localize "MOBLOKS5E.Recharge"}} {{item.data.recharge.value}}-6): "
data-roll-formula="1d6"
data-roll-target="{{item.data.recharge.value}}"
data-roll-success="{{localize "DND5E.Charged"}}"
data-roll-failure="{{localize "MOBLOKS5E.NCharged"}}"
data-roll-handler="setCharged">
({{localize "MOBLOKS5E.Recharge"}} {{item.data.recharge.value}}-6){{~" "~}}
<span class="name-extension{{#unless item.data.recharge.charged}} item-recharge{{/unless}}" data-item-id="{{item._id}}">
({{localize "DND5E.Recharge"}} {{item.data.recharge.value}}-6){{~" "~}}
</span>
{{~/if~}}
{{~#if (and item.is.legendary (gt item.data.activation.cost 1))~}}
Expand Down