diff --git a/icons/faune/cerf.webp b/icons/faune/cerf.webp new file mode 100644 index 00000000..c18c8505 Binary files /dev/null and b/icons/faune/cerf.webp differ diff --git a/icons/faune/chevre.webp b/icons/faune/chevre.webp new file mode 100644 index 00000000..f604aa6c Binary files /dev/null and b/icons/faune/chevre.webp differ diff --git a/icons/faune/crabe.webp b/icons/faune/crabe.webp new file mode 100644 index 00000000..6e797ec4 Binary files /dev/null and b/icons/faune/crabe.webp differ diff --git a/icons/faune/lapin.webp b/icons/faune/lapin.webp new file mode 100644 index 00000000..dc37f4a4 Binary files /dev/null and b/icons/faune/lapin.webp differ diff --git a/icons/faune/oie.webp b/icons/faune/oie.webp new file mode 100644 index 00000000..58687f01 Binary files /dev/null and b/icons/faune/oie.webp differ diff --git a/icons/faune/oiseau.webp b/icons/faune/oiseau.webp new file mode 100644 index 00000000..f5ef4a2d Binary files /dev/null and b/icons/faune/oiseau.webp differ diff --git a/icons/faune/poisson.webp b/icons/faune/poisson.webp new file mode 100644 index 00000000..b4e68d2a Binary files /dev/null and b/icons/faune/poisson.webp differ diff --git a/icons/faune/raton-laveur.webp b/icons/faune/raton-laveur.webp new file mode 100644 index 00000000..9022c695 Binary files /dev/null and b/icons/faune/raton-laveur.webp differ diff --git a/icons/faune/rongeur.webp b/icons/faune/rongeur.webp new file mode 100644 index 00000000..9fb51a92 Binary files /dev/null and b/icons/faune/rongeur.webp differ diff --git a/icons/faune/saumon.webp b/icons/faune/saumon.webp new file mode 100644 index 00000000..5b8faf39 Binary files /dev/null and b/icons/faune/saumon.webp differ diff --git a/icons/faune/singe-vert.webp b/icons/faune/singe-vert.webp new file mode 100644 index 00000000..36cecb0a Binary files /dev/null and b/icons/faune/singe-vert.webp differ diff --git a/lang/fr.json b/lang/fr.json index 76a10929..3cc1bf86 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -20,6 +20,7 @@ "TypeMonnaie": "Monnaie", "TypeHerbe": "Herbe ou plante", "TypeIngredient": "Ingrédient", + "TypeFaune": "Faune", "TypeLivre": "Livre", "TypePotion": "Potion", "TypeArme": "Arme", diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 075c6d22..8dc97a16 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -132,10 +132,12 @@ export class RdDActorSheet extends ActorSheet { /* -------------------------------------------- */ async _onDropItem(event, dragData) { const destItemId = $(event.target)?.closest('.item').attr('data-item-id') - const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor.id, dragData, this.objetVersConteneur) - const callSuper = await this.actor.processDropItem(dropParams) - if (callSuper) { - await super._onDropItem(event, dragData) + const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur) + if (dropParams){ + const callSuper = await this.actor.processDropItem(dropParams) + if (callSuper) { + await super._onDropItem(event, dragData) + } } } diff --git a/module/actor.js b/module/actor.js index edf43b10..1e7c51bc 100644 --- a/module/actor.js +++ b/module/actor.js @@ -145,7 +145,7 @@ export class RdDActor extends Actor { // Make separate methods for each Actor type (character, npc, etc.) to keep // things organized. if (this.isPersonnage()) this._prepareCharacterData(this) - if (this.isCreature()) this._prepareCreatureData(this) + if (this.isCreatureEntite()) this._prepareCreatureData(this) if (this.isVehicule()) this._prepareVehiculeData(this) this.computeEtatGeneral(); } @@ -193,10 +193,36 @@ export class RdDActor extends Actor { } } + canReceive(item) { + if (this.isCreature()) { + return item.type == 'competencecreature' || RdDItem.isItemInventaire(item); + } + if (this.isEntite()) { + return item.type == 'competencecreature'; + } + if (this.isVehicule()) { + return RdDItem.isItemInventaire(item); + } + if (this.isPersonnage()) { + switch (item.type) { + case 'competencecreature': case 'tarot': + return false; + } + return true; + } + return false; + } + /* -------------------------------------------- */ - isCreature() { + isCreatureEntite() { return this.type == 'creature' || this.type == 'entite'; } + isCreature() { + return this.type == 'creature'; + } + isEntite() { + return this.type == 'entite'; + } /* -------------------------------------------- */ isPersonnage() { return this.type == 'personnage'; @@ -1175,13 +1201,13 @@ export class RdDActor extends Actor { } let result = true; const item = this.getObjet(itemId); - if (item?.isEquipement() && sourceActorId == targetActorId) { + if (item?.isInventaire() && sourceActorId == targetActorId) { // rangement if (srcId != destId && itemId != destId) { // déplacement de l'objet const src = this.getObjet(srcId); const dest = this.getObjet(destId); const cible = this.getContenantOrParent(dest); - const [empilable, message] = item.isEquipementEmpilable(dest); + const [empilable, message] = item.isInventaireEmpilable(dest); if (empilable) { await this.regrouperEquipementsSimilaires(item, dest); result = false; @@ -1359,7 +1385,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ computePrixTotalEquipement() { - const valeur = this.items.filter(it => it.isEquipement()) + const valeur = this.items.filter(it => it.isInventaire()) .map(it => it.valeurTotale()) .reduce(Misc.sum(), 0); return valeur; @@ -2995,7 +3021,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ getHeureNaissance() { - if (this.isCreature()) { + if (this.isCreatureEntite()) { return 0; } return this.system.heure; @@ -3003,7 +3029,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ ajustementAstrologique() { - if (this.isCreature()) { + if (this.isCreatureEntite()) { return 0; } // selon l'heure de naissance... diff --git a/module/environnement.js b/module/environnement.js index 508f4da7..eebc6834 100644 --- a/module/environnement.js +++ b/module/environnement.js @@ -23,7 +23,7 @@ const MILIEUX = [ "Sous-sols" ] const ITEM_ENVIRONNEMENT_TYPES = [ - 'herbe', 'ingredient' + 'herbe', 'ingredient', 'faune' ] export class Environnement { @@ -126,22 +126,12 @@ export class Environnement { export class EnvironmentSheetHelper { - static defaultOptions(defaultOptions, type) { + static defaultOptions(defaultOptions) { return mergeObject(defaultOptions, { - classes: ["rdd", "sheet", "item"], - template: `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`, - width: 500, - height: 600, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "informations" }] }); } - /* -------------------------------------------- */ - static getHeaderButtons(sheet, buttons) { - buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => sheet.item.postItem() }); - return buttons; - } - static setPosition(sheet, superPosition) { const position = superPosition; const sheetHeader = sheet.element.find(".sheet-header"); @@ -152,22 +142,14 @@ export class EnvironmentSheetHelper { /* -------------------------------------------- */ static async getData(sheet, formData) { - const autresMilieux = await game.system.rdd.environnement.autresMilieux(sheet.item); - mergeObject(formData, { - title: formData.name, - isGM: game.user.isGM, - owner: sheet.actor?.isOwner, - isOwned: sheet.actor ? true : false, - actorId: sheet.actor?.id, - editable: sheet.isEditable, - cssClass: sheet.isEditable ? "editable" : "locked", - milieux: autresMilieux + return mergeObject(formData, { + milieux: await game.system.rdd.environnement.autresMilieux(sheet.item) }); - return formData; } static activateListeners(sheet, html) { if (!sheet.options.editable) return; + html.find("input.input-selection-milieu").keypress(event => { if (event.keyCode == '13') { EnvironmentSheetHelper.onAddMilieu(html, sheet, event); @@ -238,13 +220,4 @@ export class EnvironmentSheetHelper { return $(event.currentTarget)?.parents("div.environnement-milieu").data("milieu"); } - static template(itemType) { - /* -------------------------------------------- */ - return `systems/foundryvtt-reve-de-dragon/templates/item-${itemType}-sheet.html`; - } - - static title(item) { - return Misc.typeName('Item', item.type) + ': ' + item.name; - } - } \ No newline at end of file diff --git a/module/item-conteneur-sheet.js b/module/item-conteneur-sheet.js new file mode 100644 index 00000000..6ab5205d --- /dev/null +++ b/module/item-conteneur-sheet.js @@ -0,0 +1,58 @@ +import { RdDItemSheet } from "./item-sheet.js"; +import { RdDSheetUtility } from "./rdd-sheet-utility.js"; +import { RdDUtility } from "./rdd-utility.js"; + +export class RdDConteneurItemSheet extends RdDItemSheet { + + static get ITEM_TYPE() { return "conteneur" }; + + async getData() { + const formData = await super.getData(); + if (this.actor) { + this.prepareConteneurData(formData); + } + } + + activateListeners(html) { + super.activateListeners(html); + if (!this.options.editable) return; + + html.find('.conteneur-name a').click(async event => { + RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event)); + this.render(true); + }); + } + + /* -------------------------------------------- */ + prepareConteneurData(formData) { + RdDUtility.filterEquipementParType(formData, this.actor.itemTypes); + + this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets); + formData.subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems; + } + + async _onDragStart(event) { + console.log("_onDragStart", event); + if (event.target.classList.contains("entity-link")) return; + + const itemId = event.srcElement?.attributes["data-item-id"].value; + const item = this.actor.items.get(itemId); + // Create drag data + const dragData = { + actorId: this.actor.id, + type: "Item", + data: item.system + }; + + event.dataTransfer.setData("text/plain", JSON.stringify(dragData)); + } + + async _onDropItem(event, dragData) { + if (this.actor) { + const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor, dragData, this.objetVersConteneur); + await this.actor.processDropItem(dropParams); + await this.render(true); + } + } + +} diff --git a/module/item-faune-sheet.js b/module/item-faune-sheet.js new file mode 100644 index 00000000..274142b2 --- /dev/null +++ b/module/item-faune-sheet.js @@ -0,0 +1,54 @@ +import { EnvironmentSheetHelper } from "./environnement.js"; +import { RdDItemSheet } from "./item-sheet.js"; +import { RdDUtility } from "./rdd-utility.js"; + +export class RdDFauneItemSheet extends RdDItemSheet { + + static get ITEM_TYPE() { return "faune" }; + + static get defaultOptions() { + return EnvironmentSheetHelper.defaultOptions(super.defaultOptions); + } + + setPosition(options = {}) { + return EnvironmentSheetHelper.setPosition(this, super.setPosition(options)); + } + + async getData() { + const formData = await super.getData(); + return await EnvironmentSheetHelper.getData(this, formData); + } + + activateListeners(html) { + super.activateListeners(html); + if (!this.options.editable) return; + + EnvironmentSheetHelper.activateListeners(this, html); + + html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor()); + + } + + async _onDropActor(event, dragData) { + console.log('faune:dropActor', event, dragData) + const actor = fromUuidSync(dragData.uuid); + if (actor?.pack) { + this.item.update({ + 'system.actor.pack': actor.pack, + 'system.actor.id': actor._id, + 'system.actor.name': actor.name + }); + } + else { + ui.notifications.warn(`${actor.name} ne provient pas d'eun compendium. + Choisissez une créature du compendium pour représenter un élément de faune générique`) + } + } + async onDeleteLinkedActor() { + this.item.update({ + 'system.actor.pack': '', + 'system.actor.id': '', + 'system.actor.name': '' + }); + } +} diff --git a/module/item-herbe-sheet.js b/module/item-herbe-sheet.js index 616025a9..940eec58 100644 --- a/module/item-herbe-sheet.js +++ b/module/item-herbe-sheet.js @@ -1,26 +1,12 @@ -import { SYSTEM_RDD } from "./constants.js"; import { EnvironmentSheetHelper } from "./environnement.js"; import { RdDItemSheet } from "./item-sheet.js"; -import { Misc } from "./misc.js"; - -const ITEM_TYPE = 'herbe'; export class RdDHerbeItemSheet extends RdDItemSheet { - static register() { - Items.registerSheet(SYSTEM_RDD, RdDHerbeItemSheet, { - label: Misc.typeName('Item', ITEM_TYPE), - types: [ITEM_TYPE], - makeDefault: true - }); - } + static get ITEM_TYPE() { return "herbe" }; static get defaultOptions() { - return EnvironmentSheetHelper.defaultOptions(super.defaultOptions, ITEM_TYPE); - } - - _getHeaderButtons() { - return EnvironmentSheetHelper.getHeaderButtons(this, super._getHeaderButtons()); + return EnvironmentSheetHelper.defaultOptions(super.defaultOptions); } setPosition(options = {}) { @@ -36,12 +22,4 @@ export class RdDHerbeItemSheet extends RdDItemSheet { super.activateListeners(html); EnvironmentSheetHelper.activateListeners(this, html); } - - get template() { - return EnvironmentSheetHelper.template(this.item.type); - } - - get title() { - return EnvironmentSheetHelper.title(this.item); - } } diff --git a/module/item-ingredient-sheet.js b/module/item-ingredient-sheet.js index 6f5cd5f6..fe78bc68 100644 --- a/module/item-ingredient-sheet.js +++ b/module/item-ingredient-sheet.js @@ -1,25 +1,12 @@ -import { SYSTEM_RDD } from "./constants.js"; import { EnvironmentSheetHelper } from "./environnement.js"; import { RdDItemSheet } from "./item-sheet.js"; -import { Misc } from "./misc.js"; -const ITEM_TYPE = 'ingredient'; export class RdDIngredientItemSheet extends RdDItemSheet { - static register() { - Items.registerSheet(SYSTEM_RDD, RdDIngredientItemSheet, { - label: Misc.typeName('Item', ITEM_TYPE), - types: [ITEM_TYPE], - makeDefault: true - }); - } + static get ITEM_TYPE() { return "ingredient" }; static get defaultOptions() { - return EnvironmentSheetHelper.defaultOptions(super.defaultOptions, ITEM_TYPE); - } - - _getHeaderButtons() { - return EnvironmentSheetHelper.getHeaderButtons(this, super._getHeaderButtons()); + return EnvironmentSheetHelper.defaultOptions(super.defaultOptions); } setPosition(options = {}) { @@ -35,12 +22,4 @@ export class RdDIngredientItemSheet extends RdDItemSheet { super.activateListeners(html); EnvironmentSheetHelper.activateListeners(this, html); } - - get template() { - return EnvironmentSheetHelper.template(this.item.type); - } - - get title() { - return EnvironmentSheetHelper.title(this.item); - } } diff --git a/module/item-rencontre-sheet.js b/module/item-rencontre-sheet.js index baaf5d8d..d4b74a98 100644 --- a/module/item-rencontre-sheet.js +++ b/module/item-rencontre-sheet.js @@ -1,29 +1,16 @@ import { RdDRencontre } from "./item-rencontre.js"; +import { RdDItemSheet } from "./item-sheet.js"; -/** - * Item sheet pour configurer les rencontres - * @extends {ItemSheet} - */ -export class RdDRencontreItemSheet extends ItemSheet { +export class RdDRencontreItemSheet extends RdDItemSheet { + + static get ITEM_TYPE() { return "rencontre" }; - /** @override */ static get defaultOptions() { return mergeObject(super.defaultOptions, { - classes: ["rdd", "sheet", "item"], - template: "systems/foundryvtt-reve-de-dragon/templates/item-rencontre-sheet.html", - width: 500, - height: 500, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }] }); } - /* -------------------------------------------- */ - _getHeaderButtons() { - let buttons = super._getHeaderButtons(); - buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => this.item.postItem() }); - return buttons; - } - /* -------------------------------------------- */ /** @override */ setPosition(options = {}) { @@ -34,7 +21,6 @@ export class RdDRencontreItemSheet extends ItemSheet { return position; } - /* -------------------------------------------- */ async getData() { const formData = duplicate(this.item); @@ -96,13 +82,4 @@ export class RdDRencontreItemSheet extends ItemSheet { updates[key] = liste; this.item.update(updates); } - - get template() { - /* -------------------------------------------- */ - return `systems/foundryvtt-reve-de-dragon/templates/item-rencontre-sheet.html`; - } - - get title() { - return `Rencontre: ${this.object.name}`; - } } diff --git a/module/item-sheet.js b/module/item-sheet.js index 3ce65a19..2e6c91c2 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -9,30 +9,54 @@ import { ReglesOptionelles } from "./settings/regles-optionelles.js"; import { SYSTEM_RDD } from "./constants.js"; import { RdDSheetUtility } from "./rdd-sheet-utility.js"; import { SystemCompendiums } from "./settings/system-compendiums.js"; +import { Misc } from "./misc.js"; /** - * Extend the basic ItemSheet with some very simple modifications - * @extends {ItemSheet} + * Extend the basic ItemSheet for RdD specific items */ export class RdDItemSheet extends ItemSheet { + static get ITEM_TYPE() { + return undefined + } + + static defaultTemplate(type) { + return type ? + `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html` : + "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html"; + } + + static register(sheetClass) { + Items.registerSheet(SYSTEM_RDD, sheetClass, { + label: Misc.typeName('Item', sheetClass.ITEM_TYPE), + types: [sheetClass.ITEM_TYPE], + makeDefault: true + }) + } + /** @override */ static get defaultOptions() { return mergeObject(super.defaultOptions, { classes: [SYSTEM_RDD, "sheet", "item"], - template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html", + template: RdDItemSheet.defaultTemplate(RdDItemSheet.ITEM_TYPE), width: 550, height: 550 }); } + /* -------------------------------------------- */ + get template() { + return RdDItemSheet.defaultTemplate(this.item.type); + } + + get title() { + return `${Misc.typeName('Item', this.item.type)}: ${this.item.name}`; + } /* -------------------------------------------- */ _getHeaderButtons() { let buttons = super._getHeaderButtons(); - // Add "Post to chat" button - // We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry! - if ("cout" in this.item.system && this.item.isVideOuNonConteneur()) { + if (this.item.isInventaire() && this.item.isVideOuNonConteneur()) { buttons.unshift({ class: "vendre", icon: "fas fa-comments-dollar", @@ -69,18 +93,13 @@ export class RdDItemSheet extends ItemSheet { system: this.item.system, isGM: game.user.isGM, actorId: this.actor?.id, + isOwned: this.actor ? true : false, owner: this.item.isOwner, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", isSoins: false, - description: await TextEditor.enrichHTML(this.item.system.description, {async: true}), - descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, {async: true}) - } - if (this.actor) { - formData.isOwned = true; - if (this.item.type == 'conteneur') { - this.prepareConteneurData(formData); - } + description: await TextEditor.enrichHTML(this.item.system.description, { async: true }), + descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true }) } const competences = await SystemCompendiums.getCompetences(this.actor?.type); @@ -97,18 +116,18 @@ export class RdDItemSheet extends ItemSheet { formData.competences = competences.filter(it => RdDItemCompetence.isDraconic(it)); } if (this.item.type == 'recettecuisine') { - formData.ingredients = await TextEditor.enrichHTML(this.object.system.ingredients, {async: true}) + formData.ingredients = await TextEditor.enrichHTML(this.object.system.ingredients, { async: true }) } if (this.item.type == 'extraitpoetique') { - formData.extrait = await TextEditor.enrichHTML(this.object.system.extrait, {async: true}) - formData.texte = await TextEditor.enrichHTML(this.object.system.texte, {async: true}) + formData.extrait = await TextEditor.enrichHTML(this.object.system.extrait, { async: true }) + formData.texte = await TextEditor.enrichHTML(this.object.system.texte, { async: true }) } if (this.item.type == 'recettealchimique') { RdDAlchimie.processManipulation(this.item, this.actor && this.actor.id); - formData.manipulation_update = await TextEditor.enrichHTML(this.object.system.manipulation_update, {async: true}) - formData.utilisation = await TextEditor.enrichHTML(this.object.system.utilisation, {async: true}) - formData.enchantement = await TextEditor.enrichHTML(this.object.system.enchantement, {async: true}) - formData.sureffet = await TextEditor.enrichHTML(this.object.system.sureffet, {async: true}) + formData.manipulation_update = await TextEditor.enrichHTML(this.object.system.manipulation_update, { async: true }) + formData.utilisation = await TextEditor.enrichHTML(this.object.system.utilisation, { async: true }) + formData.enchantement = await TextEditor.enrichHTML(this.object.system.enchantement, { async: true }) + formData.sureffet = await TextEditor.enrichHTML(this.object.system.sureffet, { async: true }) } if (this.item.type == 'gemme') { formData.gemmeTypeList = RdDGemme.getGemmeTypeOptionList(); @@ -133,25 +152,10 @@ export class RdDItemSheet extends ItemSheet { return formData; } - /* -------------------------------------------- */ - prepareConteneurData(formData) { - RdDUtility.filterEquipementParType(formData, this.actor.itemTypes); - - this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets); - formData.subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems; - - } - /* -------------------------------------------- */ /** @override */ activateListeners(html) { super.activateListeners(html); - - if (this.item.type == 'conteneur') { - this.form.ondragstart = (event) => this._onDragStart(event); - this.form.ondrop = (event) => this._onDrop(event); - } - let itemSheetDialog = this; HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned); @@ -159,6 +163,9 @@ export class RdDItemSheet extends ItemSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; + this.form.ondragstart = (event) => this._onDragStart(event); + this.form.ondrop = (event) => this._onDrop(event); + // Select competence categorie html.find(".categorie").change(event => this._onSelectCategorie(event)); @@ -229,10 +236,6 @@ export class RdDItemSheet extends ItemSheet { const item = RdDSheetUtility.getItem(event, this.actor); this.actor.actionItem(item, async () => itemSheetDialog.render(true)); }); - html.find('.conteneur-name a').click(async event => { - RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event)); - this.render(true); - }); } /* -------------------------------------------- */ @@ -247,65 +250,51 @@ export class RdDItemSheet extends ItemSheet { } /* -------------------------------------------- */ - get template() { - let type = this.item.type - return `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`; - } - - /* -------------------------------------------- */ - /** @override */ _updateObject(event, formData) { - // Données de bonus de cases ? - formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue); + if (this.item.type == 'sort') { + // Données de bonus de cases ? + formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue); + } return this.item.update(formData); } + /* -------------------------------------------- */ async _onDragStart(event) { - console.log("_onDragStart", event); - if (event.target.classList.contains("entity-link")) return; - - const itemId = event.srcElement?.attributes["data-item-id"].value; - const item = this.actor.items.get(itemId); - // Create drag data - const dragData = { - actorId: this.actor.id, - type: "Item", - data: item.system - }; - - event.dataTransfer.setData("text/plain", JSON.stringify(dragData)); } async _onDrop(event) { // Try to extract the dragData - let dragData; - try { - dragData = JSON.parse(event.dataTransfer.getData('text/plain')); - } catch (err) { - return false; - } - + let dragData = RdDItemSheet.$extractDragData(event); + if (!dragData) return false; const allowed = Hooks.call("dropActorSheetData", this.actor, this, dragData); - if (allowed === false) return; + if (allowed === false) return false; // Handle different dragData types switch (dragData.type) { case "Item": return this._onDropItem(event, dragData); + case "Actor": + return this._onDropActor(event, dragData); } return super._onDrop(event); } - /* -------------------------------------------- */ - async _onDropItem(event, dragData) { - if (this.actor) { - const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor.id, dragData, this.objetVersConteneur); - await this.actor.processDropItem(dropParams); - await this.render(true); - } + static $extractDragData(event) { + try { + const eventData = event?.dataTransfer?.getData('text/plain'); + if (eventData) { + return JSON.parse(eventData); + } + } catch (err) { } + return undefined; } + async _onDropItem(event, dragData) { + } + + async _onDropActor(event, dragData) { + } } diff --git a/module/item-signedraconique-sheet.js b/module/item-signedraconique-sheet.js index f3c33fdd..823d459c 100644 --- a/module/item-signedraconique-sheet.js +++ b/module/item-signedraconique-sheet.js @@ -1,29 +1,14 @@ -import { SYSTEM_RDD } from "./constants.js"; +import { RdDItemSheet } from "./item-sheet.js"; import { RdDItemSigneDraconique } from "./item-signedraconique.js"; import { TMRUtility } from "./tmr-utility.js"; /** * Item sheet pour signes draconiques - * @extends {ItemSheet} + * @extends {RdDItemSheet} */ -export class RdDSigneDraconiqueItemSheet extends ItemSheet { +export class RdDSigneDraconiqueItemSheet extends RdDItemSheet { - /** @override */ - static get defaultOptions() { - return mergeObject(super.defaultOptions, { - classes: [SYSTEM_RDD, "sheet", "item"], - template: "systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html", - width: 550, - height: 550 - }); - } - - /* -------------------------------------------- */ - _getHeaderButtons() { - let buttons = super._getHeaderButtons(); - buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => this.item.postItem() }); - return buttons; - } + static get ITEM_TYPE() { return "signedraconique" } /* -------------------------------------------- */ /** @override */ @@ -61,12 +46,13 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet { if (!this.options.editable) return; html.find(".signe-aleatoire").click(event => this.setSigneAleatoire()); - html.find("input.select-tmr").change((event) => this.onSelectTmr(event)); - html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value))); + html.find("input.select-tmr").change(event => this.onSelectTmr(event)); + html.find(".signe-xp-sort").change(event => this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value))); } async setSigneAleatoire() { const newSigne = await RdDItemSigneDraconique.randomSigneDraconique(); + newSigne.name = this.item.name; this.item.update(newSigne); } @@ -88,12 +74,4 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet { await this.item.update({ 'system.valeur': newValeur }); } - /* -------------------------------------------- */ - get template() { - return `systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html`; - } - - get title() { - return `Signe draconique: ${this.object.name}`; - } } diff --git a/module/item.js b/module/item.js index fd41209b..6182bd0f 100644 --- a/module/item.js +++ b/module/item.js @@ -1,16 +1,16 @@ import { DialogItemVente } from "./dialog-item-vente.js"; import { Grammar } from "./grammar.js"; -import { Monnaie } from "./item-monnaie.js"; import { RdDHerbes } from "./rdd-herbes.js"; import { RdDUtility } from "./rdd-utility.js"; -const typesObjetsEquipement = [ +const typesObjetsInventaire = [ "arme", "armure", "conteneur", "gemme", "herbe", "ingredient", + "faune", "livre", "monnaie", "munition", @@ -36,6 +36,7 @@ export const defaultItemImg = { conteneur: "systems/foundryvtt-reve-de-dragon/icons/objets/sac_a_dos.webp", sort: "systems/foundryvtt-reve-de-dragon/icons/competence_oniros.webp", herbe: "systems/foundryvtt-reve-de-dragon/icons/botanique/Endorlotte.webp", + faune: "systems/foundryvtt-reve-de-dragon/icons/faune/rongeur.webp", ingredient: "systems/foundryvtt-reve-de-dragon/icons/objets/sable_poudre.webp", livre: "systems/foundryvtt-reve-de-dragon/icons/objets/livre.webp", potion: "systems/foundryvtt-reve-de-dragon/icons/objets/liqueur_de_bagdol.webp", @@ -70,7 +71,11 @@ export class RdDItem extends Item { return defaultItemImg[itemType]; } - static isEquipementFieldEditable(type, field) { + static isItemInventaire(newLocal) { + return typesObjetsInventaire.includes(newLocal.type); + } + + static isFieldInventaireModifiable(type, field) { switch (field) { case 'quantite': if (['conteneur'].includes(type)) { @@ -78,8 +83,8 @@ export class RdDItem extends Item { } break; case 'cout': - if(['monnaie'].includes(type)){ - return game.user.isGM; + if (['monnaie'].includes(type)) { + return game.user.isGM; } break; } @@ -98,12 +103,12 @@ export class RdDItem extends Item { constructor(itemData, context) { if (!itemData.img) { itemData.img = RdDItem.getDefaultImg(itemData.type); - } + } super(itemData, context); - } + } - static getTypesObjetsEquipement() { - return typesObjetsEquipement + static getItemTypesInventaire() { + return typesObjetsInventaire } static getTypesOeuvres() { @@ -113,11 +118,14 @@ export class RdDItem extends Item { isCompetencePersonnage() { return this.type == 'competence' } + isCompetenceCreature() { + return this.type == 'competencecreature' + } isCompetence() { return typesObjetsCompetence.includes(this.type) } - isEquipement() { - return typesObjetsEquipement.includes(this.type) + isInventaire() { + return RdDItem.isItemInventaire(this) } isOeuvre() { return typesObjetsOeuvres.includes(this.type) @@ -136,7 +144,7 @@ export class RdDItem extends Item { } getItemGroup() { - if (this.isEquipement()) return "equipement"; + if (this.isInventaire()) return "equipement"; if (this.isOeuvre()) return "oeuvre"; if (this.isDraconique()) return "draconique"; if (this.isConnaissance()) return "connaissance"; @@ -180,7 +188,7 @@ export class RdDItem extends Item { getEncTotal() { return this.getEnc() * this.getQuantite(); - } + } getEnc() { switch (this.type) { @@ -202,7 +210,7 @@ export class RdDItem extends Item { prepareDerivedData() { super.prepareDerivedData(); - if (this.isEquipement()) { + if (this.isInventaire()) { this.system.encTotal = this.getEncTotal(); if (this.isPotion()) { this.prepareDataPotion() @@ -229,13 +237,13 @@ export class RdDItem extends Item { case 'potion': return this._actionOrWarnQuantiteZero('Boire', warn); case 'livre': return this._actionOrWarnQuantiteZero('Lire', warn); case 'conteneur': return 'Ouvrir'; - case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined; - case 'queue': case 'ombre': return this.system.refoulement>0 ? 'Refouler' : undefined; + case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined; + case 'queue': case 'ombre': return this.system.refoulement > 0 ? 'Refouler' : undefined; } return undefined; } - _actionOrWarnQuantiteZero(actionName, warn){ + _actionOrWarnQuantiteZero(actionName, warn) { if ((this.system.quantite ?? 0) <= 0) { if (warn) { ui.notifications.warn(`Vous n'avez plus de ${this.name}.`); @@ -275,14 +283,14 @@ export class RdDItem extends Item { /* -------------------------------------------- */ // détermine si deux équipements sont similaires: de même type, et avec les même champs hormis la quantité - isEquipementEmpilable(other) { - if (!other || !this.isEquipement()) { + isInventaireEmpilable(other) { + if (!other || !this.isInventaire()) { return [false, undefined]; } if (this.system.quantite == undefined) { return [false, `Impossible de regrouper des ${this.type}, ils ne sont pas empilables`]; - } + } else if (this.type != other.type) { return [false, `Impossible de regrouper des ${this.type} avec des ${other.type}`]; } @@ -309,7 +317,7 @@ export class RdDItem extends Item { ui.notifications.warn(`Votre ${this.name} n'est pas vide, pas possible de le proposer`); return; } - await DialogItemVente.display(this, async (vente) => { + await DialogItemVente.display(this, async (vente) => { vente["properties"] = this.getProprietes(); if (vente.isOwned) { if (vente.quantiteNbLots * vente.tailleLot > vente.quantiteMax) { @@ -318,7 +326,7 @@ export class RdDItem extends Item { } } vente.jsondata = JSON.stringify(vente.item); - + console.log(vente); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente); ChatMessage.create(RdDUtility.chatDataSetup(html)); @@ -327,7 +335,7 @@ export class RdDItem extends Item { /* -------------------------------------------- */ getProprietes() { - return this[`_${this.type}ChatData`](); + return this[`_${this.type}ChatData`]().filter(it => it != undefined); } /* -------------------------------------------- */ @@ -351,29 +359,31 @@ export class RdDItem extends Item { }); } - static propertyIfDefined(name, val, condition = (it) => true) { - return condition ? [`${name}: ${val}`] : []; + static propertyIfDefined(name, val, condition = true) { + return condition ? `${name}: ${val}` : undefined; } + _inventaireTemplateChatData() { + return [ + RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite != 0), + RdDItem.propertyIfDefined('Encombrement', this.system.encombrement) + // cout et quantité masqués + ] + } /* -------------------------------------------- */ _objetChatData() { - return [].concat( - RdDItem.propertyIfDefined('Résistance', this.system.resistance, this.system.resistance), - RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite), - RdDItem.propertyIfDefined('Encombrement', this.system.encombrement), - ); + return this._inventaireTemplateChatData() } /* -------------------------------------------- */ _nourritureboissonChatData() { - return [].concat( + return [ RdDItem.propertyIfDefined('Sustentation', this.system.sust, this.system.sust > 0), RdDItem.propertyIfDefined('Désaltère', this.system.desaltere, this.system.boisson), RdDItem.propertyIfDefined('Force alcool', this.system.force, this.system.boisson && this.system.alcoolise), RdDItem.propertyIfDefined('Exotisme', this.system.exotisme, this.system.exotisme < 0), - RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite), - RdDItem.propertyIfDefined('Encombrement', this.system.encombrement), - ); + ...this._inventaireTemplateChatData() + ] } /* -------------------------------------------- */ _armeChatData() { @@ -382,21 +392,19 @@ export class RdDItem extends Item { `Dommages: ${this.system.dommages}`, `Force minimum: ${this.system.force}`, `Resistance: ${this.system.resistance}`, - `Encombrement: ${this.system.encombrement}` + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _conteneurChatData() { return [ `Capacité: ${this.system.capacite} Enc.`, - `Encombrement: ${this.system.encombrement}` + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _munitionChatData() { - return [ - `Encombrement: ${this.system.encombrement}` - ] + return this._inventaireTemplateChatData() } /* -------------------------------------------- */ _armureChatData() { @@ -404,7 +412,7 @@ export class RdDItem extends Item { `Protection: ${this.system.protection}`, `Détérioration: ${this.system.deterioration}`, `Malus armure: ${this.system.malus}`, - `Encombrement: ${this.system.encombrement}` + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ @@ -438,16 +446,24 @@ export class RdDItem extends Item { _herbeChatData() { return [ `Milieu: ${this.system.milieu}`, - `Rareté: ${this.system.rarete}`, `Catégorie: ${this.system.categorie}`, + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _ingredientChatData() { return [ `Milieu: ${this.system.milieu}`, - `Rareté: ${this.system.rarete}`, `Catégorie: ${this.system.categorie}`, + ...this._inventaireTemplateChatData() + ] + } + /* -------------------------------------------- */ + _fauneChatData() { + return [ + `Sustentation: ${this.system.sust}`, + `Milieu: ${this.system.milieu}`, + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ @@ -457,12 +473,9 @@ export class RdDItem extends Item { `Compétence: ${this.system.competence}`, `Périodicité: ${this.system.periodicite}`, `Fatigue: ${this.system.fatigue}`, - `Difficulté: ${this.system.difficulte}` - ].concat([ - this.system.cacher_points_de_tache ? [] :`Points de Tâche: ${this.system.points_de_tache}` - ]).concat([ + `Difficulté: ${this.system.difficulte}`, + RdDItem.propertyIfDefined('Points de Tâche', this.system.points_de_tache, this.system.cacher_points_de_tache), `Points de Tâche atteints: ${this.system.points_de_tache_courant}`] - ); } /* -------------------------------------------- */ _livreChatData() { @@ -470,8 +483,8 @@ export class RdDItem extends Item { `Compétence: ${this.system.competence}`, `Auteur: ${this.system.auteur}`, `Difficulté: ${this.system.difficulte}`, - `Points de Tâche: ${this.system.points_de_tache}`, - `Encombrement: ${this.system.encombrement}` + RdDItem.propertyIfDefined('Points de Tâche', this.system.points_de_tache, this.system.cacher_points_de_tache), + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ @@ -479,32 +492,44 @@ export class RdDItem extends Item { return [ `Rareté: ${this.system.rarete}`, `Catégorie: ${this.system.categorie}`, - `Encombrement: ${this.system.encombrement}`, + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _queueChatData() { + function label(categorie) { + switch (categorie) { + case 'ideefixe': return 'Idée fixe'; + case 'lancinant': return 'Désir lancinant'; + } + return '' + } return [ - `Refoulement: ${this.system.refoulement}` + `Refoulement: ${this.system.refoulement}`, + `Catégorie: ${label(this.system.categorie)}`, + `Affecte: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`, ] } /* -------------------------------------------- */ _ombreChatData() { - return [ - `Refoulement: ${this.system.refoulement}` - ] + return this._queueChatData() } /* -------------------------------------------- */ _souffleChatData() { - return []; + return [ + `Affecte: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`, + ]; } /* -------------------------------------------- */ _teteChatData() { - return []; + return [ + `Affecte: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`, + ]; } /* -------------------------------------------- */ _tarotChatData() { return [ + RdDItem.propertyIfDefined('Carte', RdDUtility.linkCompendium(this.pack, this.id, this.name), this.pack), `Concept: ${this.system.concept}`, `Aspect: ${this.system.aspect}`, ] @@ -518,10 +543,7 @@ export class RdDItem extends Item { } /* -------------------------------------------- */ _monnaieChatData() { - return [ - `Valeur en Sols: ${this.system.cout}`, - `Encombrement: ${this.system.encombrement}` - ] + return this._inventaireTemplateChatData() } /* -------------------------------------------- */ _meditationChatData() { @@ -545,9 +567,9 @@ export class RdDItem extends Item { ] } return [ - `Force: ${this.system.force}`, + `Force: ${this.system.formule}`, `Refoulement: ${this.system.refoulement}`, - `Présent de cités: ${this.system.presentCite}`, + RdDItem.propertyIfDefined('Présent de cités', '', this.system.presentCite), ] } /* -------------------------------------------- */ @@ -562,15 +584,12 @@ export class RdDItem extends Item { if (!this.system.identifie) { return [`Inconnue`] } - let properties = [ - `Malignité: ${this.system.malignite}`, - `Périodicité: ${this.system.periodicite}`, - `Dommages: ${this.system.dommages}` - ] - if (this.system.remedesconnus) { - properties.push(`Remedes: ${this.system.remedes}`) - } - return properties; + return [ + `Malignité: ${this.system.malignite}`, + `Périodicité: ${this.system.periodicite}`, + `Dommages: ${this.system.dommages}`, + RdDItem.propertyIfDefined('Remedes', this.system.remedes, this.system.remedesconnus), + ] } /* -------------------------------------------- */ @@ -585,7 +604,7 @@ export class RdDItem extends Item { `Taille: ${this.system.taille}`, `Inertie: ${this.system.inertie}`, `Enchantabilité: ${this.system.enchantabilite}`, - `Prix: ${this.system.cout}`, + ...this._inventaireTemplateChatData() ] } diff --git a/module/misc.js b/module/misc.js index 849c0d52..2aa30278 100644 --- a/module/misc.js +++ b/module/misc.js @@ -42,7 +42,8 @@ export class Misc { } static typeName(type, subType) { - return game.i18n.localize(`${type.toUpperCase()}.Type${Misc.upperFirst(subType)}`); + return subType ? game.i18n.localize(`${type.toUpperCase()}.Type${Misc.upperFirst(subType)}`) + : ''; } /** diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 74dbfb0e..c5579338 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -246,7 +246,7 @@ export class RdDCombatManager extends Combat { if (actions.length > 0) { return actions; } - if (actor.isCreature()) { + if (actor.isCreatureEntite()) { actions = actions.concat(RdDCombatManager.listActionsCreature(actor.itemTypes['competencecreature'])); } else { // Recupération des items 'arme' @@ -821,7 +821,7 @@ export class RdDCombat { essais: {} }; - if (this.attacker.isCreature()) { + if (this.attacker.isCreatureEntite()) { RdDItemCompetenceCreature.setRollDataCreature(rollData); } else if (arme) { @@ -1079,7 +1079,7 @@ export class RdDCombat { show: {} }; - if (this.defender.isCreature()) { + if (this.defender.isCreatureEntite()) { RdDItemCompetenceCreature.setRollDataCreature(defenderRoll); } @@ -1158,7 +1158,7 @@ export class RdDCombat { show: {} }; - if (this.defender.isCreature()) { + if (this.defender.isCreatureEntite()) { RdDItemCompetenceCreature.setRollDataCreature(rollData); } return rollData; diff --git a/module/rdd-main.js b/module/rdd-main.js index f4d5c361..912d6209 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -42,6 +42,8 @@ import { TMRRencontres } from "./tmr-rencontres.js"; import { RdDHerbeItemSheet } from "./item-herbe-sheet.js"; import { Environnement } from "./environnement.js"; import { RdDIngredientItemSheet } from "./item-ingredient-sheet.js"; +import { RdDFauneItemSheet } from "./item-faune-sheet.js"; +import { RdDConteneurItemSheet } from "./item-conteneur-sheet.js"; /* -------------------------------------------- */ /* Foundry VTT Initialization */ @@ -163,8 +165,8 @@ Hooks.once("init", async function () { RdDCombat.onSocketMessage(sockmsg); ChatUtility.onSocketMessage(sockmsg); RdDActor.onSocketMessage(sockmsg); - } catch(e) { - console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg,' => ', e) + } catch (e) { + console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg, ' => ', e) } }); @@ -187,28 +189,24 @@ Hooks.once("init", async function () { Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true }); Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true }); Items.unregisterSheet("core", ItemSheet); - Items.registerSheet(SYSTEM_RDD, RdDSigneDraconiqueItemSheet, { - label: "Signe draconique", - types: ["signedraconique"], - makeDefault: true - }); - Items.registerSheet(SYSTEM_RDD, RdDRencontreItemSheet, { - label: "Rencontre", - types: ["rencontre"], - makeDefault: true - }); - RdDHerbeItemSheet.register(); - RdDIngredientItemSheet.register(); + + RdDItemSheet.register(RdDSigneDraconiqueItemSheet); + RdDItemSheet.register(RdDRencontreItemSheet); + RdDItemSheet.register(RdDConteneurItemSheet); + RdDItemSheet.register(RdDHerbeItemSheet); + RdDItemSheet.register(RdDFauneItemSheet); + RdDItemSheet.register(RdDIngredientItemSheet); + Items.registerSheet(SYSTEM_RDD, RdDItemSheet, { types: [ "competence", "competencecreature", "recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre", - "objet", "arme", "armure", "conteneur", "livre", "potion", "munition", + "objet", "arme", "armure", "livre", "potion", "munition", "monnaie", "nourritureboisson", "gemme", "meditation", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve", "nombreastral", "tache", "maladie", "poison", "possession", "tarot", "extraitpoetique" - ], makeDefault: true + ], makeDefault: true }); CONFIG.Combat.documentClass = RdDCombatManager; @@ -247,8 +245,8 @@ function messageDeBienvenue() { /* -------------------------------------------- */ // Register world usage statistics -function registerUsageCount( registerKey ) { - if ( game.user.isGM ) { +function registerUsageCount(registerKey) { + if (game.user.isGM) { game.settings.register("world", "world-key", { name: "Unique world key", scope: "world", @@ -258,9 +256,9 @@ function registerUsageCount( registerKey ) { }); let worldKey = game.settings.get("world", "world-key") - if ( worldKey == undefined || worldKey == "" ) { + if (worldKey == undefined || worldKey == "") { worldKey = randomID(32) - game.settings.set("world", "world-key", worldKey ) + game.settings.set("world", "world-key", worldKey) } let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"` $.ajax(regURL) @@ -300,7 +298,7 @@ Hooks.once("ready", async function () { } if (Misc.isUniqueConnectedGM()) { messageDeBienvenue(); - registerUsageCount( SYSTEM_RDD ); + registerUsageCount(SYSTEM_RDD); } }); diff --git a/module/rdd-possession.js b/module/rdd-possession.js index 0de88bf0..a0e73204 100644 --- a/module/rdd-possession.js +++ b/module/rdd-possession.js @@ -45,7 +45,7 @@ export class RdDPossession { defender: defender, targetToken: Targets.extractTokenData(target) }; - if (attacker.isCreature()) { + if (attacker.isCreatureEntite()) { RdDItemCompetenceCreature.setRollDataCreature(rollData) } diff --git a/module/rdd-sheet-utility.js b/module/rdd-sheet-utility.js index 15dc98e0..faa6856d 100644 --- a/module/rdd-sheet-utility.js +++ b/module/rdd-sheet-utility.js @@ -19,17 +19,23 @@ export class RdDSheetUtility { return $(event.currentTarget)?.parents(".item"); } - static prepareItemDropParameters(destItemId, actorId, dragData, objetVersConteneur) { + static prepareItemDropParameters(destItemId, actor, dragData, objetVersConteneur) { const item = fromUuidSync(dragData.uuid) - return { - destId: destItemId, - targetActorId: actorId, - itemId: item.id, - sourceActorId: item.actor?.id, - srcId: objetVersConteneur[item.id], - onEnleverConteneur: () => { delete objetVersConteneur[item.id]; }, - onAjouterDansConteneur: (itemId, conteneurId) => { objetVersConteneur[itemId] = conteneurId; } + if (actor.canReceive(item)) { + return { + destId: destItemId, + targetActorId: actor.id, + itemId: item.id, + sourceActorId: item.actor?.id, + srcId: objetVersConteneur[item.id], + onEnleverConteneur: () => { delete objetVersConteneur[item.id]; }, + onAjouterDansConteneur: (itemId, conteneurId) => { objetVersConteneur[itemId] = conteneurId; } + } } + else { + ui.notifications.warn(`Impossible de donner ${item.name} à ${actor.name}: ${item.type} / ${actor.type}`); + } + return undefined; } static async splitItem(item, actor, onSplit = () => { }) { diff --git a/module/rdd-utility.js b/module/rdd-utility.js index c747e221..0b7f21d3 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -1,5 +1,4 @@ /* Common useful functions shared between objects */ - import { ChatUtility } from "./chat-utility.js"; import { RdDCombat } from "./rdd-combat.js"; import { Misc } from "./misc.js"; @@ -14,7 +13,6 @@ import { RdDPossession } from "./rdd-possession.js"; import { RdDNameGen } from "./rdd-namegen.js"; import { RdDConfirm } from "./rdd-confirm.js"; import { RdDCalendrier } from "./rdd-calendrier.js"; -import { RdDCarac } from "./rdd-carac.js"; import { Environnement } from "./environnement.js"; /* -------------------------------------------- */ @@ -185,6 +183,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/item-sort-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-herbe-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-ingredient-sheet.html', + 'systems/foundryvtt-reve-de-dragon/templates/item-faune-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-livre-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-tache-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-potion-sheet.html', @@ -220,6 +219,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-type.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-effet.html', // Partials + 'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs', 'systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-description-sort.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html', @@ -328,14 +328,18 @@ export class RdDUtility { return a.name.localeCompare(b.name); }) ); - Handlebars.registerHelper('linkCompendium', (compendium, id, name) => `@Compendium[${compendium}.${id}]{${name}}`); + Handlebars.registerHelper('linkCompendium', (pack, id, name)=> RdDUtility.linkCompendium(pack, id, name)); Handlebars.registerHelper('uniteQuantite', (type) => RdDItem.getUniteQuantite(type)); - Handlebars.registerHelper('isEquipementFieldEditable', (type, field) => RdDItem.isEquipementFieldEditable(type, field)); + Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field)); Handlebars.registerHelper('getFrequenceRarete', (rarete, field) => Environnement.getFrequenceRarete(rarete, field)); Handlebars.registerHelper('either', (a, b) => a ?? b); return loadTemplates(templatePaths); } + static linkCompendium(pack, id, name) { + return `@Compendium[${pack}.${id}]{${name}}`; + } + /* -------------------------------------------- */ static async creerObjet(actorSheet) { let itemType = $(".item-type").val(); @@ -344,7 +348,7 @@ export class RdDUtility { /* -------------------------------------------- */ static async selectObjetType(actorSheet) { - let typeObjets = RdDItem.getTypesObjetsEquipement(); + let typeObjets = RdDItem.getItemTypesInventaire(); let options = `Selectionnez le type d'équipement`; for (let typeName of typeObjets) { options += `${typeName}` @@ -466,9 +470,9 @@ export class RdDUtility { formData.livres = this.arrayOrEmpty(itemTypes['livre']); formData.potions = this.arrayOrEmpty(itemTypes['potion']); formData.ingredients = this.arrayOrEmpty(itemTypes['ingredient']); + formData.faunes = this.arrayOrEmpty(itemTypes['faune']); formData.herbes = this.arrayOrEmpty(itemTypes['herbe']); - formData.monnaie = this.arrayOrEmpty(itemTypes['monnaie']); - formData.monnaie.sort(Monnaie.triValeurEntiere()); + formData.monnaie = this.arrayOrEmpty(itemTypes['monnaie']).sort(Monnaie.triValeurEntiere()); formData.nourritureboissons = this.arrayOrEmpty(itemTypes['nourritureboisson']); formData.gemmes = this.arrayOrEmpty(itemTypes['gemme']); @@ -481,6 +485,7 @@ export class RdDUtility { .concat(formData.potions) .concat(formData.ingredients) .concat(formData.herbes) + .concat(formData.faunes) .concat(formData.monnaie) .concat(formData.nourritureboissons) .concat(formData.gemmes); diff --git a/styles/simple.css b/styles/simple.css index d20c17f8..052a4257 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -497,8 +497,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) { } .foundryvtt-reve-de-dragon .sheet-body, -.foundryvtt-reve-de-dragon .sheet-body .tab, -.foundryvtt-reve-de-dragon .sheet-body .tab .editor { +.foundryvtt-reve-de-dragon .sheet-body .tab { height: 100%; } @@ -543,7 +542,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) { .editor { border: 2; - height: 300px; + height: 10rem; padding: 0 3px; } diff --git a/system.json b/system.json index bbe0dc91..6f40a556 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.3.4", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.3.4.zip", + "version": "10.3.5", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.3.5.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10", diff --git a/template.json b/template.json index 27c37132..c9950acf 100644 --- a/template.json +++ b/template.json @@ -572,7 +572,7 @@ "types": [ "competence", "competencecreature", "recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre", - "objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", + "objet", "arme", "armure", "conteneur", "herbe", "ingredient", "faune", "livre", "potion", "munition", "monnaie", "nourritureboisson", "gemme", "meditation", "rencontre", "queue", "ombre", "souffle", "tete", "casetmr", "signedraconique", "sort", "sortreserve", "nombreastral", "tache", "maladie", "poison", "possession", @@ -700,11 +700,11 @@ }, "nourritureboisson": { "templates": [ "description", "inventaire" ], - "sust": 0, "boisson": false, "desaltere": 0, "alcoolise": false, "force": 0, + "sust": 0, "exotisme": 0 }, "herbe": { @@ -717,8 +717,20 @@ "templates": [ "description", "inventaire", "environnement" ], "niveau": 0, "base": 0, + "sust": 0, + "exotisme": 0, "categorie": "" }, + "faune": { + "templates": [ "description", "inventaire", "environnement"], + "sust": 0, + "exotisme": 0, + "actor": { + "id": "", + "pack": "", + "name": "" + } + }, "livre": { "templates": [ "description", "inventaire" ], "competence": "", diff --git a/templates/common/compendium-link.hbs b/templates/common/compendium-link.hbs new file mode 100644 index 00000000..3efebb63 --- /dev/null +++ b/templates/common/compendium-link.hbs @@ -0,0 +1 @@ +{{name}} \ No newline at end of file diff --git a/templates/item-faune-sheet.html b/templates/item-faune-sheet.html new file mode 100644 index 00000000..145b7a0c --- /dev/null +++ b/templates/item-faune-sheet.html @@ -0,0 +1,47 @@ + + + + + + + + + + Informations + {{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-tab-environnement.html"}} + + + + + + + Sustentation (si applicable) + + + {{#if (gt system.sust 0)}} + + Exotisme + + + {{/if}} + + Créature correspondante + + {{#if system.actor.id}} + + {{>'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs' + pack=system.actor.pack id=system.actor.id name=system.actor.name}} + + + {{else}} + Pas de fiche de créature + {{/if}} + + + {{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}} + + + {{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-environnement.html"}} + + \ No newline at end of file diff --git a/templates/item-herbe-sheet.html b/templates/item-herbe-sheet.html index da561fee..8221be6a 100644 --- a/templates/item-herbe-sheet.html +++ b/templates/item-herbe-sheet.html @@ -5,7 +5,7 @@ {{#if isIngredientPotionBase}} - Fabriquer une potion depuis cette plante + Fabriquer une potion depuis cette plante {{/if}} diff --git a/templates/item/partial-inventaire.html b/templates/item/partial-inventaire.html index 53ee6bfa..89c678ed 100644 --- a/templates/item/partial-inventaire.html +++ b/templates/item/partial-inventaire.html @@ -1,20 +1,20 @@ Qualité + {{#unless (isFieldInventaireModifiable type 'qualite')}}disabled{{/unless}}/> Encombrement + {{#unless (isFieldInventaireModifiable type 'encombrement')}}disabled{{/unless}}/> Quantité {{uniteQuantite type}} + {{#unless (isFieldInventaireModifiable type 'quantite')}}disabled{{/unless}}/> Prix (sols) + {{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/>