Faune et flore comestibles
- permettre de cuisiner les ingrédients (faune & flore) - permettre de manger des ingrédients "crus"
This commit is contained in:
parent
7b58407634
commit
5056c35038
@ -164,14 +164,11 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
RdDSheetUtility.splitItem(item, this.actor);
|
RdDSheetUtility.splitItem(item, this.actor);
|
||||||
});
|
});
|
||||||
html.find('.item-action').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor)
|
|
||||||
this.actor.actionItem(item);
|
|
||||||
});
|
|
||||||
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
|
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
|
||||||
html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
|
html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
|
||||||
html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
||||||
html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
||||||
|
html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor));
|
||||||
html.find('.subacteur-delete').click(async event => {
|
html.find('.subacteur-delete').click(async event => {
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
const actorId = li.data("actor-id");
|
const actorId = li.data("actor-id");
|
||||||
|
120
module/actor.js
120
module/actor.js
@ -1209,7 +1209,7 @@ export class RdDActor extends Actor {
|
|||||||
const cible = this.getContenantOrParent(dest);
|
const cible = this.getContenantOrParent(dest);
|
||||||
const [empilable, message] = item.isInventaireEmpilable(dest);
|
const [empilable, message] = item.isInventaireEmpilable(dest);
|
||||||
if (empilable) {
|
if (empilable) {
|
||||||
await this.regrouperEquipementsSimilaires(item, dest);
|
await dest.empiler(item)
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
// changer de conteneur
|
// changer de conteneur
|
||||||
@ -1309,11 +1309,6 @@ export class RdDActor extends Actor {
|
|||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
async regrouperEquipementsSimilaires(item, dest) {
|
|
||||||
await dest.quantiteIncDec(item.system.quantite);
|
|
||||||
await item.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
isSurenc() {
|
isSurenc() {
|
||||||
return this.isPersonnage() ? (this.computeMalusSurEncombrement() < 0) : false
|
return this.isPersonnage() ? (this.computeMalusSurEncombrement() < 0) : false
|
||||||
}
|
}
|
||||||
@ -1949,20 +1944,28 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async actionItem(item, onActionItem = async () => { }) {
|
async actionItem(item, onActionItem = async () => { }) {
|
||||||
if (!item.getActionPrincipale()) return;
|
item.actionPrincipale(this, onActionItem);
|
||||||
switch (item.type) {
|
|
||||||
case 'nourritureboisson': return await this.actionNourritureboisson(item, onActionItem);
|
|
||||||
case 'potion': return await this.consommerPotion(item, onActionItem);
|
|
||||||
case 'livre': return await this.actionLire(item);
|
|
||||||
case 'conteneur': return await item.sheet.render(true);
|
|
||||||
case 'herbe': {
|
|
||||||
if (item.isHerbeAPotion()) {
|
|
||||||
return this.dialogFabriquerPotion(item);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
async actionNourritureboisson(item, onActionItem) {
|
||||||
|
switch (item.isComestible()) {
|
||||||
|
case 'brut': {
|
||||||
|
let d = new Dialog({
|
||||||
|
title: "Nourriture brute",
|
||||||
|
content: `Que faire de votre ${item.name}`,
|
||||||
|
buttons: {
|
||||||
|
'cuisiner': { icon: '<i class="fas fa-check"></i>', label: 'Cuisiner', callback: async () => await this.preparerNourriture(item) },
|
||||||
|
'manger': { icon: '<i class="fas fa-check"></i>', label: 'Manger cru', callback: async () => await this.mangerNourriture(item, onActionItem) }
|
||||||
}
|
}
|
||||||
case 'queue': case 'ombre': return await this.actionRefoulement(item);
|
});
|
||||||
|
d.render(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
case 'pret':
|
||||||
|
await this.mangerNourriture(item, onActionItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1976,11 +1979,18 @@ export class RdDActor extends Actor {
|
|||||||
await this.rollTache(tache.id);
|
await this.rollTache(tache.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async actionHerbe(item) {
|
||||||
|
if (item.isHerbeAPotion()) {
|
||||||
|
return this.dialogFabriquerPotion(item);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async consommer(item, choix) {
|
async consommer(item, choix) {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case 'nourritureboisson':
|
case 'nourritureboisson':
|
||||||
|
case 'herbe': case 'faune':
|
||||||
return await this.consommerNourritureboisson(item.id, choix);
|
return await this.consommerNourritureboisson(item.id, choix);
|
||||||
case 'potion':
|
case 'potion':
|
||||||
return await this.consommerPotion(item)
|
return await this.consommerPotion(item)
|
||||||
@ -1999,7 +2009,7 @@ export class RdDActor extends Actor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const item = this.getObjet(itemId)
|
const item = this.getObjet(itemId)
|
||||||
if (item.type != 'nourritureboisson') {
|
if (!item.isComestible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (choix.doses > item.system.quantite) {
|
if (choix.doses > item.system.quantite) {
|
||||||
@ -2738,8 +2748,9 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _resultArt(artData) {
|
async _resultArt(artData) {
|
||||||
const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.system.niveau : artData.competence.system.niveau);
|
const niveau = artData.oeuvre.system.niveau ?? 0;
|
||||||
artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.system.niveau) + artData.rolled.ptQualite;
|
const baseQualite = (artData.rolled.isSuccess ? niveau : artData.competence.system.niveau);
|
||||||
|
artData.qualiteFinale = Math.min(baseQualite, niveau) + artData.rolled.ptQualite;
|
||||||
|
|
||||||
await RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
|
await RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
|
||||||
}
|
}
|
||||||
@ -2793,32 +2804,64 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _resultRecetteCuisine(artData) {
|
async _resultRecetteCuisine(cuisine) {
|
||||||
const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.system.niveau : artData.competence.system.niveau);
|
const niveauRecette = cuisine.oeuvre.system.niveau ?? 0;
|
||||||
const sust = artData.oeuvre.system.sust * artData.proportions;
|
const baseQualite = (cuisine.rolled.isSuccess ? niveauRecette : cuisine.competence.system.niveau);
|
||||||
artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.system.niveau) + artData.rolled.ptQualite;
|
cuisine.qualiteFinale = Math.min(baseQualite, niveauRecette) + cuisine.rolled.ptQualite;
|
||||||
artData.exotismeFinal = Math.min(Math.min(artData.qualiteFinale, artData.oeuvre.system.exotisme ?? 0), 0);
|
cuisine.exotismeFinal = Math.min(Math.min(cuisine.qualiteFinale, cuisine.oeuvre.system.exotisme ?? 0), 0);
|
||||||
//console.log("OEUVRE", artData.art, artData)
|
cuisine.sust = cuisine.oeuvre.system.sust * Math.min(cuisine.proportions, cuisine.proportionsMax ?? cuisine.proportions)
|
||||||
const platCuisine = {
|
const platCuisine = {
|
||||||
name: artData.oeuvre.name,
|
name: cuisine.oeuvre.name,
|
||||||
type: 'nourritureboisson',
|
type: 'nourritureboisson',
|
||||||
img: 'systems/foundryvtt-reve-de-dragon/icons/objets/provision_cuite.webp',
|
img: 'systems/foundryvtt-reve-de-dragon/icons/objets/provision_cuite.webp',
|
||||||
system: {
|
system: {
|
||||||
description: cuisine.oeuvre.system.description,
|
"description": cuisine.oeuvre.system.description,
|
||||||
sust: 1,
|
"sust": 1,
|
||||||
qualite: cuisine.qualiteFinale,
|
"qualite": cuisine.qualiteFinale,
|
||||||
exotisme: cuisine.exotismeFinal,
|
"exotisme": cuisine.exotismeFinal,
|
||||||
encombrement: 0.1,
|
"encombrement": 0.1,
|
||||||
quantite: Math.max(1, Math.floor(cuisine.sust)),
|
"quantite": Math.max(1, Math.floor(cuisine.sust)),
|
||||||
cout: Math.max(cuisine.qualiteFinale, 0) * 0.01
|
"cout": Math.max(cuisine.qualiteFinale) * 0.01
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
if (artData.ajouterEquipement) {
|
if (cuisine.ajouterEquipement) {
|
||||||
await this.createEmbeddedDocuments('Item', [platCuisine]);
|
await this.createEmbeddedDocuments('Item', [platCuisine]);
|
||||||
ui.notifications.info(`${platCuisine.system.quantite} rations de ${platCuisine.name} ont été ajoutés à votre équipement`);
|
ui.notifications.info(`${platCuisine.system.quantite} rations de ${platCuisine.name} ont été ajoutés à votre équipement`);
|
||||||
}
|
}
|
||||||
artData.platCuisine = platCuisine;
|
cuisine.platCuisine = platCuisine;
|
||||||
await RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
|
await RdDResolutionTable.displayRollData(cuisine, this.name, `chat-resultat-${cuisine.art}.html`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async preparerNourriture(item) {
|
||||||
|
if (item.isComestible() == 'brut') {
|
||||||
|
const nourriture = {
|
||||||
|
name: 'Plat de ' + item.name,
|
||||||
|
type: 'recettecuisine',
|
||||||
|
img: item.img,
|
||||||
|
system: {
|
||||||
|
sust: 1,
|
||||||
|
exotisme: item.system.exotisme,
|
||||||
|
ingredients: item.name
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const artData = {
|
||||||
|
verbe: 'Préparer',
|
||||||
|
compName: 'cuisine',
|
||||||
|
proportions: 1,
|
||||||
|
proportionsMax: Math.min(50, item.system.sust),
|
||||||
|
ajouterEquipement: true
|
||||||
|
};
|
||||||
|
await this._rollArt(artData, 'odoratgout', nourriture, async (cuisine) => {
|
||||||
|
await this._resultRecetteCuisine(cuisine);
|
||||||
|
const remaining = Math.max(item.system.quantite - cuisine.proportions, 0);
|
||||||
|
if (remaining > 0) {
|
||||||
|
await item.update({ 'system.quantite': remaining })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await this.deleteEmbeddedDocuments('Item', [item.id]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -4145,6 +4188,7 @@ export class RdDActor extends Actor {
|
|||||||
await this.onCreateOwnedDraconique(item, options, id);
|
await this.onCreateOwnedDraconique(item, options, id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
await item.onCreateDecoupeComestible(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDeleteItem(item, options, id) {
|
async onDeleteItem(item, options, id) {
|
||||||
|
@ -48,25 +48,47 @@ export class DialogConsommer extends Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
|
case 'herbe': case 'faune':
|
||||||
|
consommerData.title = 'Manger une portion crue: ';
|
||||||
|
consommerData.buttonName = "Manger";
|
||||||
|
break;
|
||||||
case 'nourritureboisson':
|
case 'nourritureboisson':
|
||||||
consommerData.title = item.system.boisson ? `${item.name}: boire une dose` : `${item.name}: manger une portion`;
|
consommerData.title = item.system.boisson ? 'Boire une dose: ' : 'Manger une portion: ';
|
||||||
consommerData.buttonName = item.system.boisson ? "Boire" : "Manger";
|
consommerData.buttonName = item.system.boisson ? "Boire" : "Manger";
|
||||||
break;
|
break;
|
||||||
case 'potion':
|
case 'potion':
|
||||||
consommerData.title = `${item.name}: boire la potion`;
|
consommerData.title = 'Boire la potion: ';
|
||||||
consommerData.buttonName = "Boire";
|
consommerData.buttonName = "Boire";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DialogConsommer.calculDoses(consommerData, consommerData.choix.doses)
|
consommerData.title += item.name;
|
||||||
|
DialogConsommer.calculDoses(consommerData, item)
|
||||||
return consommerData;
|
return consommerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static calculDoses(consommer) {
|
static calculDoses(consommer, item) {
|
||||||
const doses = consommer.choix.doses;
|
const doses = consommer.choix.doses;
|
||||||
|
switch (item.type) {
|
||||||
|
case 'herbe': case 'faune':
|
||||||
|
consommer.totalSust = doses;
|
||||||
|
consommer.totalDesaltere = 0;
|
||||||
|
consommer.choix.sust = 1;
|
||||||
|
consommer.choix.quantite = 0;
|
||||||
|
consommer.choix.encombrement = Misc.keepDecimals(consommer.item.system.encombrement / item.system.sust, 2);
|
||||||
|
return;
|
||||||
|
case 'nourritureboisson':
|
||||||
|
consommer.choix.sust = consommer.item.system.sust;
|
||||||
|
consommer.choix.quantite = doses;
|
||||||
|
consommer.choix.encombrement = 0
|
||||||
consommer.totalSust = Misc.keepDecimals(doses * (consommer.item.system.sust ?? 0), 2);
|
consommer.totalSust = Misc.keepDecimals(doses * (consommer.item.system.sust ?? 0), 2);
|
||||||
consommer.totalDesaltere = consommer.item.system.boisson
|
consommer.totalDesaltere = consommer.item.system.boisson
|
||||||
? Misc.keepDecimals(doses * (consommer.item.system.desaltere ?? 0), 2)
|
? Misc.keepDecimals(doses * (consommer.item.system.desaltere ?? 0), 2)
|
||||||
: 0;
|
: 0;
|
||||||
|
break;
|
||||||
|
case 'potion':
|
||||||
|
consommer.totalSust = 0
|
||||||
|
consommer.totalDesaltere = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +106,7 @@ export class DialogConsommer extends Dialog {
|
|||||||
|
|
||||||
selectDoses(event) {
|
selectDoses(event) {
|
||||||
this.consommerData.choix.doses = Number(event.currentTarget.value);
|
this.consommerData.choix.doses = Number(event.currentTarget.value);
|
||||||
DialogConsommer.calculDoses(this.consommerData);
|
DialogConsommer.calculDoses(this.consommerData, this.item);
|
||||||
$(".total-sust").text(this.consommerData.totalSust);
|
$(".total-sust").text(this.consommerData.totalSust);
|
||||||
$(".total-desaltere").text(this.consommerData.totalDesaltere);
|
$(".total-desaltere").text(this.consommerData.totalDesaltere);
|
||||||
}
|
}
|
||||||
|
@ -26,21 +26,22 @@ export class RdDFauneItemSheet extends RdDItemSheet {
|
|||||||
EnvironmentSheetHelper.activateListeners(this, html);
|
EnvironmentSheetHelper.activateListeners(this, html);
|
||||||
|
|
||||||
html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor());
|
html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor());
|
||||||
|
html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event));
|
||||||
|
html.find("a.manger-nourriture").click(event => this.mangerNourriture(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onDropActor(event, dragData) {
|
async _onDropActor(event, dragData) {
|
||||||
console.log('faune:dropActor', event, dragData)
|
console.log('faune:dropActor', event, dragData)
|
||||||
const actor = fromUuidSync(dragData.uuid);
|
const linkedActor = fromUuidSync(dragData.uuid);
|
||||||
if (actor?.pack) {
|
if (linkedActor?.pack) {
|
||||||
this.item.update({
|
this.item.update({
|
||||||
'system.actor.pack': actor.pack,
|
'system.actor.pack': linkedActor.pack,
|
||||||
'system.actor.id': actor._id,
|
'system.actor.id': linkedActor._id,
|
||||||
'system.actor.name': actor.name
|
'system.actor.name': linkedActor.name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui.notifications.warn(`${actor.name} ne provient pas d'eun compendium.
|
ui.notifications.warn(`${linkedActor.name} ne provient pas d'un compendium.
|
||||||
<br>Choisissez une créature du compendium pour représenter un élément de faune générique`)
|
<br>Choisissez une créature du compendium pour représenter un élément de faune générique`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,4 +52,16 @@ export class RdDFauneItemSheet extends RdDItemSheet {
|
|||||||
'system.actor.name': ''
|
'system.actor.name': ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async preparerNourriture(event) {
|
||||||
|
if (this.actor) {
|
||||||
|
await this.actor.preparerNourriture(this.item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async mangerNourriture(event) {
|
||||||
|
if (this.actor) {
|
||||||
|
await this.actor.mangerNourriture(this.item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,8 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
cssClass: this.isEditable ? "editable" : "locked",
|
cssClass: this.isEditable ? "editable" : "locked",
|
||||||
isSoins: false,
|
isSoins: false,
|
||||||
description: await TextEditor.enrichHTML(this.item.system.description, { async: true }),
|
description: await TextEditor.enrichHTML(this.item.system.description, { async: true }),
|
||||||
descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true })
|
descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true }),
|
||||||
|
isComestible: this.item.isComestible()
|
||||||
}
|
}
|
||||||
|
|
||||||
const competences = await SystemCompendiums.getCompetences(this.actor?.type);
|
const competences = await SystemCompendiums.getCompetences(this.actor?.type);
|
||||||
@ -197,15 +198,12 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('.item-action').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
|
|
||||||
});
|
|
||||||
html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, async () => itemSheetDialog.render(true)));
|
html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, async () => itemSheetDialog.render(true)));
|
||||||
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
|
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
|
||||||
html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
|
html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
|
||||||
html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
||||||
html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
||||||
|
html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => itemSheetDialog.render(true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_getEventActor(event) {
|
_getEventActor(event) {
|
||||||
|
115
module/item.js
115
module/item.js
@ -1,5 +1,6 @@
|
|||||||
import { DialogItemVente } from "./dialog-item-vente.js";
|
import { DialogItemVente } from "./dialog-item-vente.js";
|
||||||
import { Grammar } from "./grammar.js";
|
import { Grammar } from "./grammar.js";
|
||||||
|
import { Misc } from "./misc.js";
|
||||||
import { RdDHerbes } from "./rdd-herbes.js";
|
import { RdDHerbes } from "./rdd-herbes.js";
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
|
|
||||||
@ -91,10 +92,16 @@ export class RdDItem extends Item {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getUniteQuantite(type) {
|
getUniteQuantite() {
|
||||||
switch (type) {
|
switch (this.type) {
|
||||||
case "monnaie": return "(Pièces)"
|
case "monnaie": return "(Pièces)"
|
||||||
case "herbe": return "(Brins)"
|
case "herbe":
|
||||||
|
switch (this.system.categorie) {
|
||||||
|
case 'Alchimie': case 'Repos': case 'Soin':
|
||||||
|
return "(Brins)"
|
||||||
|
case 'Cuisine': return '';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
case "ingredient": return "(Pépins ou Brins)"
|
case "ingredient": return "(Pépins ou Brins)"
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@ -165,9 +172,25 @@ export class RdDItem extends Item {
|
|||||||
return !this.isConteneur() || (this.system.contenu?.length ?? 0) == 0;
|
return !this.isConteneur() || (this.system.contenu?.length ?? 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
isAlcool() {
|
isNourritureBoisson() {
|
||||||
return this.type == 'nourritureboisson' && this.system.boisson && this.system.alcoolise;
|
return this.type == 'nourritureboisson';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isComestible() {
|
||||||
|
switch (this.type) {
|
||||||
|
case 'nourritureboisson': return 'pret';
|
||||||
|
case 'herbe':
|
||||||
|
return this.system.categorie == 'Cuisine' && this.system.sust > 0 ? 'brut' : '';
|
||||||
|
case 'faune':
|
||||||
|
return this.system.sust > 0 ? 'brut' : '';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
isAlcool() {
|
||||||
|
return this.isNourritureBoisson() && this.system.boisson && this.system.alcoolise;
|
||||||
|
}
|
||||||
|
|
||||||
isHerbeAPotion() {
|
isHerbeAPotion() {
|
||||||
return this.type == 'herbe' && (this.system.categorie == 'Soin' || this.system.categorie == 'Repos');
|
return this.type == 'herbe' && (this.system.categorie == 'Soin' || this.system.categorie == 'Repos');
|
||||||
}
|
}
|
||||||
@ -193,13 +216,22 @@ export class RdDItem extends Item {
|
|||||||
getEnc() {
|
getEnc() {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case 'herbe':
|
case 'herbe':
|
||||||
return encBrin;
|
return this.getEncHerbe();
|
||||||
case 'gemme':
|
case 'gemme':
|
||||||
return encPepin * this.system.taille;
|
return encPepin * this.system.taille;
|
||||||
}
|
}
|
||||||
return Math.max(this.system.encombrement ?? 0, 0);
|
return Math.max(this.system.encombrement ?? 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEncHerbe() {
|
||||||
|
switch (this.system.categorie) {
|
||||||
|
case 'Repos': case 'Soin': case 'Alchimie':
|
||||||
|
return encBrin;
|
||||||
|
}
|
||||||
|
return this.system.encombrement;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
valeurTotale() {
|
valeurTotale() {
|
||||||
return this.getQuantite() * this.valeur()
|
return this.getQuantite() * this.valeur()
|
||||||
}
|
}
|
||||||
@ -231,18 +263,42 @@ export class RdDItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getActionPrincipale(options = { warnIfNot: true }) {
|
getActionPrincipale(options = { warnIfNot: true }) {
|
||||||
|
switch (this.type) {
|
||||||
|
case 'conteneur': return 'Ouvrir';
|
||||||
|
}
|
||||||
|
if (this.actor?.isPersonnage()) {
|
||||||
const warn = options.warnIfNot;
|
const warn = options.warnIfNot;
|
||||||
|
if (this.isComestible() == 'brut') {
|
||||||
|
return 'Utiliser';
|
||||||
|
}
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case 'nourritureboisson': return this._actionOrWarnQuantiteZero(this.system.boisson ? 'Boire' : 'Manger', warn);
|
case 'nourritureboisson': return this._actionOrWarnQuantiteZero(this.system.boisson ? 'Boire' : 'Manger', warn);
|
||||||
case 'potion': return this._actionOrWarnQuantiteZero('Boire', warn);
|
case 'potion': return this._actionOrWarnQuantiteZero('Boire', warn);
|
||||||
case 'livre': return this._actionOrWarnQuantiteZero('Lire', warn);
|
case 'livre': return this._actionOrWarnQuantiteZero('Lire', warn);
|
||||||
case 'conteneur': return 'Ouvrir';
|
|
||||||
case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined;
|
case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined;
|
||||||
case 'queue': case 'ombre': return this.system.refoulement > 0 ? 'Refouler' : undefined;
|
case 'queue': case 'ombre': return this.system.refoulement > 0 ? 'Refouler' : undefined;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async actionPrincipale(actor, onActionItem = async () => { }) {
|
||||||
|
if (!this.getActionPrincipale()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (await actor.actionNourritureboisson(this, onActionItem)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (this.type) {
|
||||||
|
case 'potion': return await actor.consommerPotion(this, onActionItem);
|
||||||
|
case 'livre': return await actor.actionLire(this);
|
||||||
|
case 'conteneur': return await this.sheet.render(true);
|
||||||
|
case 'herbe': return await actor.actionHerbe(this);
|
||||||
|
case 'queue': case 'ombre': return await actor.actionRefoulement(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_actionOrWarnQuantiteZero(actionName, warn) {
|
_actionOrWarnQuantiteZero(actionName, warn) {
|
||||||
if ((this.system.quantite ?? 0) <= 0) {
|
if ((this.system.quantite ?? 0) <= 0) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
@ -260,6 +316,42 @@ export class RdDItem extends Item {
|
|||||||
await this.quantiteIncDec(-nombre, options);
|
await this.quantiteIncDec(-nombre, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onCreateDecoupeComestible(actor) {
|
||||||
|
if (actor && this.isComestible() == 'brut' && this.system.sust != 1) {
|
||||||
|
if (this.system.sust < 1) {
|
||||||
|
await actor.updateEmbeddedDocuments('Item', [{
|
||||||
|
_id: this.id,
|
||||||
|
'system.sust': 0
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const sust = Math.floor(this.system.sust);
|
||||||
|
await actor.updateEmbeddedDocuments('Item', [{
|
||||||
|
_id: this.id,
|
||||||
|
'system.quantite': this.system.quantite * sust,
|
||||||
|
'system.encombrement': Misc.keepDecimals(this.system.encombrement / sust, 2),
|
||||||
|
'system.cout': Misc.keepDecimals(this.system.cout / sust, 2),
|
||||||
|
'system.sust': 1
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async empiler(item) {
|
||||||
|
if (this.isComestible() == 'brut') {
|
||||||
|
const sust = this.system.sust + item.system.sust;
|
||||||
|
const encombrement = this.system.encombrement + item.system.encombrement;
|
||||||
|
await this.update({
|
||||||
|
"system.sust": sust,
|
||||||
|
"system.encombrement": encombrement
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await this.quantiteIncDec(item.system.quantite);
|
||||||
|
}
|
||||||
|
await item.delete();
|
||||||
|
}
|
||||||
|
|
||||||
async quantiteIncDec(nombre, options = { diminuerQuantite: true, supprimerSiZero: false }) {
|
async quantiteIncDec(nombre, options = { diminuerQuantite: true, supprimerSiZero: false }) {
|
||||||
const quantite = Number(this.system.quantite ?? -1);
|
const quantite = Number(this.system.quantite ?? -1);
|
||||||
if (quantite >= 0) {
|
if (quantite >= 0) {
|
||||||
@ -297,8 +389,13 @@ export class RdDItem extends Item {
|
|||||||
return [false, `Impossible de regrouper ${this.name} avec ${other.name}`];
|
return [false, `Impossible de regrouper ${this.name} avec ${other.name}`];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const differences = Object.entries(this.system)
|
const excludedProperties = ['quantite', 'cout', 'encTotal'];
|
||||||
.filter(([key, value]) => !['quantite', 'cout', 'encTotal'].includes(key) && value != other.system[key]);
|
if (this.isComestible()) {
|
||||||
|
excludedProperties.push('sust', 'encombrement');
|
||||||
|
}
|
||||||
|
let differences = Object.entries(this.system)
|
||||||
|
.filter(([key, value]) => !excludedProperties.includes(key))
|
||||||
|
.filter(([key, value]) => value != other.system[key])
|
||||||
if (differences.length > 0) {
|
if (differences.length > 0) {
|
||||||
let message = `Impossible de regrouper les ${this.type} ${this.name}: `;
|
let message = `Impossible de regrouper les ${this.type} ${this.name}: `;
|
||||||
for (const [key, value] of differences) {
|
for (const [key, value] of differences) {
|
||||||
|
@ -14,6 +14,7 @@ import { RdDNameGen } from "./rdd-namegen.js";
|
|||||||
import { RdDConfirm } from "./rdd-confirm.js";
|
import { RdDConfirm } from "./rdd-confirm.js";
|
||||||
import { RdDCalendrier } from "./rdd-calendrier.js";
|
import { RdDCalendrier } from "./rdd-calendrier.js";
|
||||||
import { Environnement } from "./environnement.js";
|
import { Environnement } from "./environnement.js";
|
||||||
|
import { RdDItemCompetence } from "./item-competence.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// This table starts at 0 -> niveau -10
|
// This table starts at 0 -> niveau -10
|
||||||
@ -170,6 +171,7 @@ export class RdDUtility {
|
|||||||
//Items
|
//Items
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs',
|
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs',
|
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs',
|
||||||
|
'systems/foundryvtt-reve-de-dragon/templates/item/boutons-comestible.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.html',
|
'systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/item/partial-environnement.html',
|
'systems/foundryvtt-reve-de-dragon/templates/item/partial-environnement.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/item/partial-tab-environnement.html',
|
'systems/foundryvtt-reve-de-dragon/templates/item/partial-tab-environnement.html',
|
||||||
|
@ -595,6 +595,10 @@
|
|||||||
"environnement": {
|
"environnement": {
|
||||||
"milieu": "",
|
"milieu": "",
|
||||||
"environnement": []
|
"environnement": []
|
||||||
|
},
|
||||||
|
"comestible": {
|
||||||
|
"sust": 0,
|
||||||
|
"exotisme": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"competence": {
|
"competence": {
|
||||||
@ -699,13 +703,12 @@
|
|||||||
"templates": [ "description", "inventaire" ]
|
"templates": [ "description", "inventaire" ]
|
||||||
},
|
},
|
||||||
"nourritureboisson": {
|
"nourritureboisson": {
|
||||||
"templates": [ "description", "inventaire" ],
|
"templates": [ "description", "inventaire", "comestible"],
|
||||||
|
"cuisinier": "",
|
||||||
"boisson": false,
|
"boisson": false,
|
||||||
"desaltere": 0,
|
"desaltere": 0,
|
||||||
"alcoolise": false,
|
"alcoolise": false,
|
||||||
"force": 0,
|
"force": 0
|
||||||
"sust": 0,
|
|
||||||
"exotisme": 0
|
|
||||||
},
|
},
|
||||||
"herbe": {
|
"herbe": {
|
||||||
"templates": [ "description", "inventaire", "environnement"],
|
"templates": [ "description", "inventaire", "environnement"],
|
||||||
@ -714,17 +717,14 @@
|
|||||||
"categorie": ""
|
"categorie": ""
|
||||||
},
|
},
|
||||||
"ingredient": {
|
"ingredient": {
|
||||||
"templates": [ "description", "inventaire", "environnement" ],
|
"templates": [ "description", "inventaire", "environnement", "comestible"],
|
||||||
"niveau": 0,
|
"niveau": 0,
|
||||||
"base": 0,
|
"base": 0,
|
||||||
"sust": 0,
|
|
||||||
"exotisme": 0,
|
|
||||||
"categorie": ""
|
"categorie": ""
|
||||||
},
|
},
|
||||||
"faune": {
|
"faune": {
|
||||||
"templates": [ "description", "inventaire", "environnement"],
|
"templates": [ "description", "inventaire", "environnement", "comestible"],
|
||||||
"sust": 0,
|
"categorie": "",
|
||||||
"exotisme": 0,
|
|
||||||
"actor": {
|
"actor": {
|
||||||
"id": "",
|
"id": "",
|
||||||
"pack": "",
|
"pack": "",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
|
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
|
||||||
<div class="header-fields">
|
<div class="header-fields">
|
||||||
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
|
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
|
||||||
|
{{>'systems/foundryvtt-reve-de-dragon/templates/item/boutons-comestible.html'}}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@ -28,11 +29,15 @@
|
|||||||
<label>Créature correspondante</label>
|
<label>Créature correspondante</label>
|
||||||
<div>
|
<div>
|
||||||
{{#if system.actor.id}}
|
{{#if system.actor.id}}
|
||||||
|
{{#if isGM}}
|
||||||
<label>
|
<label>
|
||||||
{{>'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs'
|
{{>'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs'
|
||||||
pack=system.actor.pack id=system.actor.id name=system.actor.name}}
|
pack=system.actor.pack id=system.actor.id name=system.actor.name}}
|
||||||
</label>
|
</label>
|
||||||
<a class="linked-actor-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
<a class="linked-actor-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
|
{{else}}
|
||||||
|
<label>{{system.actor.name}}</label>
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<label>Pas de fiche de créature</label>
|
<label>Pas de fiche de créature</label>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<span><a class="creer-potion-base chat-card-button" data-actor-id="{{actorId}}">Fabriquer une potion depuis cette plante</a></span>
|
<span><a class="creer-potion-base chat-card-button" data-actor-id="{{actorId}}">Fabriquer une potion depuis cette plante</a></span>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{>'systems/foundryvtt-reve-de-dragon/templates/item/boutons-comestible.html'}}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@ -19,10 +20,6 @@
|
|||||||
<section class="sheet-body">
|
<section class="sheet-body">
|
||||||
<div class="tab items" data-group="primary" data-tab="informations">
|
<div class="tab items" data-group="primary" data-tab="informations">
|
||||||
<div class="flexcol">
|
<div class="flexcol">
|
||||||
<div class="form-group">
|
|
||||||
<label>Niveau (si applicable)</label>
|
|
||||||
<input class="attribute-value" type="text" name="system.niveau" value="{{system.niveau}}" data-dtype="Number" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Catégorie</label>
|
<label>Catégorie</label>
|
||||||
<select name="system.categorie" class="categorie" data-dtype="String">
|
<select name="system.categorie" class="categorie" data-dtype="String">
|
||||||
@ -31,6 +28,23 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
{{#if (eq isComestible 'brut')}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="system.sust">Sustentation</label>
|
||||||
|
<input class="attribute-value" type="number" name="system.sust" value="{{system.sust}}" data-dtype="Number" min="0"/>
|
||||||
|
</div>
|
||||||
|
{{#if (gt system.sust 0)}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="system.exotisme">Exotisme</label>
|
||||||
|
<input class="attribute-value" type="number" name="system.exotisme" value="{{system.exotisme}}" data-dtype="Number" min="-10" max="0"/>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Niveau (si applicable)</label>
|
||||||
|
<input class="attribute-value" type="text" name="system.niveau" value="{{system.niveau}}" data-dtype="Number" />
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.html"}}
|
{{>"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/partial-item-description.html"}}
|
||||||
|
8
templates/item/boutons-comestible.html
Normal file
8
templates/item/boutons-comestible.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{{#if (and isOwned isComestible)}}
|
||||||
|
<div class="form-group">
|
||||||
|
{{#if (eq isComestible 'brut')}}
|
||||||
|
<span><a class="preparer-nourriture chat-card-button" data-actor-id="{{actorId}}">Cuisiner</a></span>
|
||||||
|
{{/if}}
|
||||||
|
<span><a class="manger-nourriture chat-card-button" data-actor-id="{{actorId}}">Manger cru</a></span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
@ -9,7 +9,7 @@
|
|||||||
{{#unless (isFieldInventaireModifiable type 'encombrement')}}disabled{{/unless}}/>
|
{{#unless (isFieldInventaireModifiable type 'encombrement')}}disabled{{/unless}}/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="system.quantite">Quantité {{uniteQuantite type}}</label>
|
<label for="system.quantite">Quantité {{uniteQuantite id actorId}}</label>
|
||||||
<input class="attribute-value" type="text" name="system.quantite" value="{{system.quantite}}" data-dtype="Number"
|
<input class="attribute-value" type="text" name="system.quantite" value="{{system.quantite}}" data-dtype="Number"
|
||||||
{{#unless (isFieldInventaireModifiable type 'quantite')}}disabled{{/unless}}/>
|
{{#unless (isFieldInventaireModifiable type 'quantite')}}disabled{{/unless}}/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user