Skip to content

Commit 6702868

Browse files
committed
a
1 parent a4559ab commit 6702868

File tree

3 files changed

+56
-11
lines changed

3 files changed

+56
-11
lines changed

index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/config.js

+54-9
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ export function initConfig() {
1919

2020
const getActivationType = (item) => {
2121
if (!item?.system?.activities) {
22-
return
22+
return;
2323
}
2424
return Array.from(item.system.activities)[0]?.activation?.type;
25-
}
25+
};
2626

2727
const getActionType = (item) => {
2828
if (!item?.system?.activities) {
29-
return
29+
return;
3030
}
3131
return Array.from(item.system.activities)[0]?.actionType;
32-
}
32+
};
3333

3434
const actionTypes = {
3535
action: ["action"],
@@ -714,8 +714,8 @@ export function initConfig() {
714714
}
715715

716716
get activity() {
717-
if(!this.item?.system?.activities) {
718-
return
717+
if (!this.item?.system?.activities) {
718+
return;
719719
}
720720
return Array.from(this.item.system.activities)[0];
721721
}
@@ -971,6 +971,7 @@ export function initConfig() {
971971
constructor(specialItem) {
972972
super();
973973
const actorItem = this.actor.items.getName(specialItem.name);
974+
this.actorItem = actorItem;
974975
this.item =
975976
actorItem ??
976977
new CONFIG.Item.documentClass(specialItem, {
@@ -990,25 +991,69 @@ export function initConfig() {
990991
return true;
991992
}
992993

994+
get activity() {
995+
if (!this.item?.system?.activities) {
996+
return;
997+
}
998+
return Array.from(this.item.system.activities)[0];
999+
}
1000+
9931001
async getTooltipData() {
9941002
const tooltipData = await getTooltipDetails(this.item);
9951003
tooltipData.propertiesLabel = "enhancedcombathud-dnd5e.tooltip.properties.name";
9961004
return tooltipData;
9971005
}
9981006

9991007
async _onLeftClick(event) {
1000-
const useCE = game.modules.get("dfreds-convenient-effects")?.active && game.dfreds.effectInterface.findEffect({effectName: this.label});
1008+
const useCE = game.modules.get("dfreds-convenient-effects")?.active && game.dfreds.effectInterface.findEffect({ effectName: this.label });
10011009
let success = false;
10021010
if (useCE) {
10031011
success = true;
1004-
await game.dfreds.effectInterface.toggleEffect({effectName: this.label, overlay: false, uuids: [this.actor.uuid] });
1012+
await game.dfreds.effectInterface.toggleEffect({ effectName: this.label, overlay: false, uuids: [this.actor.uuid] });
10051013
} else {
1006-
success = await this.item.use({ event }, { event });
1014+
success = this.actorItem ? await this.activity.use({ event }, { event }) : await this.createChatMessage();
10071015
}
10081016
if (success) {
10091017
DND5eItemButton.consumeActionEconomy(this.item);
10101018
}
10111019
}
1020+
1021+
async createChatMessage() {
1022+
return await ChatMessage.create({
1023+
user: game.user,
1024+
speaker: {
1025+
actor: this.actor,
1026+
token: this.actor.token,
1027+
alias: this.actor.name,
1028+
},
1029+
content: `
1030+
<div class="dnd5e2 chat-card item-card" data-display-challenge="">
1031+
1032+
<section class="card-header description collapsible">
1033+
1034+
<header class="summary">
1035+
<img class="gold-icon" src="${this.icon}">
1036+
<div class="name-stacked border">
1037+
<span class="title">${this.label}</span>
1038+
<span class="subtitle">
1039+
Feature
1040+
</span>
1041+
</div>
1042+
<i class="fas fa-chevron-down fa-fw"></i>
1043+
</header>
1044+
1045+
<section class="details collapsible-content card-content">
1046+
<div class="wrapper">
1047+
${this.item.system.description.value}
1048+
</div>
1049+
</section>
1050+
</section>
1051+
1052+
1053+
</div>
1054+
`,
1055+
});
1056+
}
10121057
}
10131058

10141059
class DND5eMovementHud extends ARGON.MovementHud {

0 commit comments

Comments
 (0)