|
| 1 | +import {successChatMessage} from "../helpers/chat.mjs"; |
| 2 | + |
1 | 3 | /** |
2 | 4 | * Extend the basic Item with some very simple modifications. |
3 | 5 | * @extends {Item} |
@@ -34,26 +36,28 @@ export class BasicFantasyRPGItem extends Item { |
34 | 36 | const item = this; |
35 | 37 |
|
36 | 38 | // Initialize chat data. |
37 | | - const speaker = ChatMessage.getSpeaker({ actor: this.actor }); |
| 39 | + const speaker = ChatMessage.getSpeaker({ actor: item.actor }); |
38 | 40 | const rollMode = game.settings.get('core', 'rollMode'); |
39 | | - const label = `Roll: ${game.i18n.localize('ITEM.Type' + item.type.capitalize())} - ${item.name}`; |
40 | 41 |
|
41 | | - // If there's no roll data, or the formula is empty, send a chat message. |
42 | | - if (!this.system.formula || !this.system.formula.value) { |
| 42 | + // If there's no roll data, or the formula is empty, just send a chat message. |
| 43 | + if (!item.system.formula || !item.system.formula.value) { |
43 | 44 | ChatMessage.create({ |
44 | 45 | speaker: speaker, |
45 | 46 | rollMode: rollMode, |
46 | | - flavor: label, |
47 | | - content: item.description ?? '' |
| 47 | + flavor: `<span class="chat-item-name">${game.i18n.localize('ITEM.Type' + item.type.capitalize())} - ${item.name}</span>`, |
| 48 | + content: item.system.description ? `<span class="chat-item-description">${item.system.description}</span>` : '' |
48 | 49 | }); |
49 | 50 | } else { // Otherwise, create a roll and send a chat message from it. |
50 | | - // Retrieve roll data. |
51 | | - const rollData = this.getRollData(); |
| 51 | + let label = `<span class="chat-item-name">${game.i18n.localize('BASICFANTASYRPG.Roll')}: ${game.i18n.localize('ITEM.Type' + item.type.capitalize())} - ${item.name}</span>`; |
| 52 | + if (item.type == 'feature' && item.system.description) { |
| 53 | + label += `<span class="chat-item-description">${item.system.description}</span>`; |
| 54 | + } |
52 | 55 |
|
53 | | - // Invoke the roll and submit it to chat. |
| 56 | + // Retrieve roll data and invoke the roll |
| 57 | + const rollData = item.getRollData(); |
54 | 58 | const roll = new Roll(rollData.item.formula.value, rollData); |
55 | | - // If you need to store the value first, uncomment the next line. |
56 | | - // let result = await roll.roll({async: true}); |
| 59 | + await roll.roll(); |
| 60 | + label += successChatMessage(roll.total, rollData.item.targetNumber.value, true); |
57 | 61 | roll.toMessage({ |
58 | 62 | speaker: speaker, |
59 | 63 | rollMode: rollMode, |
|
0 commit comments