Implement Spell send to chat
This commit is contained in:
parent
b30aa18a27
commit
efc9316c31
3 changed files with 24 additions and 1 deletions
|
|
@ -57,6 +57,25 @@ export class ActorHandler extends Actor {
|
|||
this.fn?.[`createCustom${data.embeddedCreate}`].bind(this)($event);
|
||||
};
|
||||
|
||||
async genericSendToChat($event) {
|
||||
const data = $event.currentTarget.dataset;
|
||||
const type = data.messageType;
|
||||
console.log(data)
|
||||
if (this.fn?.[`send${type}ToChat`]) {
|
||||
return await this.fn?.[`send${type}ToChat`].bind(this)($event);
|
||||
};
|
||||
if (!data.messageContent) {
|
||||
console.warn(`.dungeon | Tried to send a chat message with no content`);
|
||||
return;
|
||||
};
|
||||
let message = await ChatMessage.create({
|
||||
content: data.messageContent,
|
||||
flavor: data.messageFlavor,
|
||||
speaker: { actor: this.actor }
|
||||
});
|
||||
message.render();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ItemHandler} item
|
||||
* @returns {boolean} true to allow the document to be embedded
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ export class GenericActorSheet extends ActorSheet {
|
|||
.on(`click`, this.actor.genericEmbeddedDelete.bind(this.actor));
|
||||
html.find(`[data-embedded-create]`)
|
||||
.on(`click`, this.actor.genericEmbeddedCreate.bind(this.actor));
|
||||
html.find(`[data-message-type]`)
|
||||
.on(`click`, this.actor.genericSendToChat.bind(this.actor));
|
||||
html.find(`[data-embedded-edit]`)
|
||||
.on(`click`, this.actor.openEmbeddedSheet.bind(this.actor));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@
|
|||
<button
|
||||
class="neutral equal-padding"
|
||||
aria-label="{{localize "dotdungeon.actor.pc.spells.aria.chat"}}"
|
||||
data-embedded-chat
|
||||
data-message-type="Spell"
|
||||
data-message-flavor="{{spell.name}} {{localize "dotdungeon.actor.pc.spells.title.cost" cost=spell.system.usage_cost}}"
|
||||
data-message-content="{{spell.system.description}}"
|
||||
data-embedded-id="{{spell.uuid}}"
|
||||
>
|
||||
<div aria-hidden="true" class="icon icon--20">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue