kopparhavet/module/items/item.js

62 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-11-28 19:12:19 +01:00
/**
* Extend the basic Item.
* @extends {Item}
*/
export class ItemKH extends Item {
prepareData() {
super.prepareData();
}
async sendToChat() {
const itemData = duplicate(this.data);
if(itemData.img.includes("/mystery-man")) {
itemData.img = null;
}
itemData.isArmor = itemData.type === "armor";
itemData.isGear = itemData.type === "gear";
itemData.isAdversaryAttack = itemData.type === "adversaryAttack";
itemData.isSkill = itemData.type === "skill";
itemData.isSpell = itemData.type === "spell";
itemData.isTalent = itemData.type === "talent";
itemData.isWeapon = itemData.type === "weapon";
const html = await renderTemplate("systems/kopparhavet/templates/chat/item-card.html", itemData);
const chatData = {
user: game.user._id,
rollMode: game.settings.get("core", "rollMode"),
content: html,
};
if (["gmroll", "blindroll"].includes(chatData.rollMode)) {
chatData.whisper = ChatMessage.getWhisperRecipients("GM");
} else if (chatData.rollMode === "selfroll") {
chatData.whisper = [game.user];
}
ChatMessage.create(chatData);
}
/**
* Prepare and return details of the item for display in inventory or chat.
*/
getItemDetails() {
const itemData = duplicate(this.data);
if(itemData.img.includes("/mystery-man")) {
itemData.img = null;
}
itemData.isArmor = itemData.type === "armor";
itemData.isGear = itemData.type === "gear";
itemData.isAdversaryAttack = itemData.type === "adversaryAttack";
itemData.isSkill = itemData.type === "skill";
itemData.isSpell = itemData.type === "spell";
itemData.isTalent = itemData.type === "talent";
itemData.isWeapon = itemData.type === "weapon";
return itemData
}
}