kopparhavet/module/items/item.js

66 lines
2.2 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";
itemData.isShipWeapon = itemData.type === "shipweapon";
itemData.isShipTalent = itemData.type === "shiptalent";
2020-11-28 19:12:19 +01:00
const html = await renderTemplate("systems/kopparhavet/templates/chat/item-card.html", itemData);
const chatData = {
2021-07-28 12:51:13 +02:00
user: game.user.id,
2020-11-28 19:12:19 +01:00
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";
itemData.isShipWeapon = itemData.type === "shipweapon";
itemData.isShipTalent = itemData.type === "shiptalent";
2020-11-28 19:12:19 +01:00
return itemData
}
}