kopparhavet/module/items/item.js

66 lines
2.2 KiB
JavaScript

/**
* 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";
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";
itemData.isShipWeapon = itemData.type === "shipweapon";
itemData.isShipTalent = itemData.type === "shiptalent";
return itemData
}
}