Affichage du contenu d'un conteneur
Les actions qui modifient le contenu doivent forcer un render
This commit is contained in:
parent
ef56b58d72
commit
db0f8e50d2
139
module/actor.js
139
module/actor.js
@ -289,10 +289,10 @@ export class RdDActor extends Actor {
|
|||||||
return etatGeneral;
|
return etatGeneral;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getActivePoisons( ) {
|
getActivePoisons() {
|
||||||
return duplicate( this.data.items.filter( item => item.type == 'poison' && item.data.data.active) );
|
return duplicate(this.data.items.filter(item => item.type == 'poison' && item.data.data.active));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getMalusArmure() {
|
getMalusArmure() {
|
||||||
return Misc.toInt(Misc.templateData(this).attributs?.malusarmure?.value);
|
return Misc.toInt(Misc.templateData(this).attributs?.malusarmure?.value);
|
||||||
@ -313,7 +313,7 @@ export class RdDActor extends Actor {
|
|||||||
return Misc.templateData(this).compteurs.surenc?.value ?? 0;
|
return Misc.templateData(this).compteurs.surenc?.value ?? 0;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getCompetence(idOrName, options={}) {
|
getCompetence(idOrName, options = {}) {
|
||||||
return RdDItemCompetence.findCompetence(this.data.items, idOrName, options);
|
return RdDItemCompetence.findCompetence(this.data.items, idOrName, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
getItemOfType(idOrName, type) {
|
getItemOfType(idOrName, type) {
|
||||||
return this.data.items.find(it => it.id == idOrName && it.type == type)
|
return this.data.items.find(it => it.id == idOrName && it.type == type)
|
||||||
?? Misc.findFirstLike(idOrName, this.data.items,{filter: it => it.type == type, description: type});
|
?? Misc.findFirstLike(idOrName, this.data.items, { filter: it => it.type == type, description: type });
|
||||||
}
|
}
|
||||||
|
|
||||||
getMonnaie(id) {
|
getMonnaie(id) {
|
||||||
@ -931,7 +931,7 @@ export class RdDActor extends Actor {
|
|||||||
const niveau = Number(compData.data.niveau);
|
const niveau = Number(compData.data.niveau);
|
||||||
const stressTransforme = Misc.data(this).data.compteurs.experience.value;
|
const stressTransforme = Misc.data(this).data.compteurs.experience.value;
|
||||||
const xpRequis = RdDItemCompetence.getCompetenceNextXp(niveau) - compData.data.xp;
|
const xpRequis = RdDItemCompetence.getCompetenceNextXp(niveau) - compData.data.xp;
|
||||||
if (stressTransforme <= 0 || niveau >= compData.data.niveau_archetype || xpRequis <=0) {
|
if (stressTransforme <= 0 || niveau >= compData.data.niveau_archetype || xpRequis <= 0) {
|
||||||
ui.notifications.info(`La compétence ne peut pas augmenter!
|
ui.notifications.info(`La compétence ne peut pas augmenter!
|
||||||
stress disponible: ${stressTransforme}
|
stress disponible: ${stressTransforme}
|
||||||
expérience requise: ${xpRequis}
|
expérience requise: ${xpRequis}
|
||||||
@ -941,7 +941,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
const xpUtilise = Math.min(stressTransforme, xpRequis);
|
const xpUtilise = Math.min(stressTransforme, xpRequis);
|
||||||
const stressTransformeRestant = Math.max(0, stressTransforme - xpUtilise);
|
const stressTransformeRestant = Math.max(0, stressTransforme - xpUtilise);
|
||||||
const gainNiveau = xpUtilise>=xpRequis ? 1 : 0;
|
const gainNiveau = xpUtilise >= xpRequis ? 1 : 0;
|
||||||
|
|
||||||
await this.update({ "data.compteurs.experience.value": stressTransformeRestant });
|
await this.update({ "data.compteurs.experience.value": stressTransformeRestant });
|
||||||
const nouveauNiveau = niveau + gainNiveau;
|
const nouveauNiveau = niveau + gainNiveau;
|
||||||
@ -949,7 +949,7 @@ export class RdDActor extends Actor {
|
|||||||
"data.xp": Math.max(compData.data.xp - xpRequis, 0),
|
"data.xp": Math.max(compData.data.xp - xpRequis, 0),
|
||||||
"data.niveau": nouveauNiveau,
|
"data.niveau": nouveauNiveau,
|
||||||
});
|
});
|
||||||
this.updateExperienceLog('Dépense stress', xpUtilise, `Stress en ${competence.name} ${gainNiveau? "pour passer à "+nouveauNiveau : ""}`);
|
this.updateExperienceLog('Dépense stress', xpUtilise, `Stress en ${competence.name} ${gainNiveau ? "pour passer à " + nouveauNiveau : ""}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -1046,7 +1046,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompteurValue(fieldName, fieldValue, raison = 'Inconnue') {
|
async updateCompteurValue(fieldName, fieldValue, raison = 'Inconnue') {
|
||||||
await this.update({ [`data.compteurs.${fieldName}.value`]: fieldValue });
|
await this.update({ [`data.compteurs.${fieldName}.value`]: fieldValue });
|
||||||
await this.addStressExperienceLog(fieldName, fieldValue, 'forcé: '+raison);
|
await this.addStressExperienceLog(fieldName, fieldValue, 'forcé: ' + raison);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -1067,11 +1067,11 @@ export class RdDActor extends Actor {
|
|||||||
distribuerStress(compteur, stress, motif) {
|
distribuerStress(compteur, stress, motif) {
|
||||||
if (game.user.isGM && this.hasPlayerOwner && this.isPersonnage()) {
|
if (game.user.isGM && this.hasPlayerOwner && this.isPersonnage()) {
|
||||||
switch (compteur) {
|
switch (compteur) {
|
||||||
case 'stress': case 'experience':
|
case 'stress': case 'experience':
|
||||||
const message = `${this.name} a reçu ${stress} points ${compteur == 'stress' ? "de stress" : "d'expérience"} (raison : ${motif})`;
|
const message = `${this.name} a reçu ${stress} points ${compteur == 'stress' ? "de stress" : "d'expérience"} (raison : ${motif})`;
|
||||||
this.addCompteurValue(compteur, stress, motif);
|
this.addCompteurValue(compteur, stress, motif);
|
||||||
ui.notifications.info(message);
|
ui.notifications.info(message);
|
||||||
game.users.players.filter(player => player.active && player.character?.id == this.id)
|
game.users.players.filter(player => player.active && player.character?.id == this.id)
|
||||||
.forEach(player => ChatUtility.notifyUser(player.id, 'info', message));
|
.forEach(player => ChatUtility.notifyUser(player.id, 'info', message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1139,7 +1139,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** Supprime un item d'un conteneur, sur la base
|
/** Supprime un item d'un conteneur, sur la base
|
||||||
* de leurs ID */
|
* de leurs ID */
|
||||||
async enleverDeConteneur(item, conteneur, objetVersConteneur) {
|
async enleverDeConteneur(item, conteneur, onEnleverDeConteneur) {
|
||||||
if (conteneur?.isConteneur()) {
|
if (conteneur?.isConteneur()) {
|
||||||
let data2use = duplicate(Misc.data(conteneur));
|
let data2use = duplicate(Misc.data(conteneur));
|
||||||
let contenu = data2use.data.contenu;
|
let contenu = data2use.data.contenu;
|
||||||
@ -1150,20 +1150,20 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
item.data.estContenu = false;
|
item.data.estContenu = false;
|
||||||
await this.updateEmbeddedDocuments('Item', [data2use]);
|
await this.updateEmbeddedDocuments('Item', [data2use]);
|
||||||
delete objetVersConteneur[item.id];
|
onEnleverDeConteneur();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** Ajoute un item dans un conteneur, sur la base
|
/** Ajoute un item dans un conteneur, sur la base
|
||||||
* de leurs ID */
|
* de leurs ID */
|
||||||
async ajouterDansConteneur(item, conteneur, objetVersConteneur) {
|
async ajouterDansConteneur(item, conteneur, onAjouterDansConteneur) {
|
||||||
if (conteneur?.isConteneur()) {
|
if (conteneur?.isConteneur()) {
|
||||||
let data2use = duplicate(Misc.data(conteneur));
|
let data2use = duplicate(Misc.data(conteneur));
|
||||||
data2use.data.contenu.push(item.id);
|
data2use.data.contenu.push(item.id);
|
||||||
item.data.estContenu = true;
|
item.data.estContenu = true;
|
||||||
await this.updateEmbeddedDocuments('Item', [data2use]);
|
await this.updateEmbeddedDocuments('Item', [data2use]);
|
||||||
objetVersConteneur[item.id] = conteneur.id;
|
onAjouterDansConteneur(conteneur.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,27 +1185,28 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async processDropItem(event, dragData, objetVersConteneur) {
|
async processDropItem(params, onEnleverConteneur, onAjouterDansConteneur) {
|
||||||
console.log("DRAG", this.id, dragData);
|
const targetActorId = this.id;
|
||||||
const itemId = dragData.id || dragData.data._id;
|
const sourceActorId = params.sourceActorId;
|
||||||
if (dragData.actorId && dragData.actorId != this.id) {
|
const itemId = params.itemId;
|
||||||
console.log("Moving objects", dragData);
|
const destId = params.destId;
|
||||||
this.moveItemsBetweenActors(itemId, dragData.actorId);
|
const srcId = params.srcId;
|
||||||
|
if (sourceActorId && sourceActorId != targetActorId) {
|
||||||
|
console.log("Moving objects", sourceActorId, targetActorId, itemId);
|
||||||
|
this.moveItemsBetweenActors(itemId, sourceActorId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let result = true;
|
let result = true;
|
||||||
const destId = $(event.target).parents(".item").attr("data-item-id");
|
|
||||||
const item = this.getObjet(itemId);
|
const item = this.getObjet(itemId);
|
||||||
if (item?.isEquipement() && dragData.actorId == this.id) {
|
if (item?.isEquipement() && sourceActorId == targetActorId) {
|
||||||
// rangement
|
// rangement
|
||||||
const srcId = objetVersConteneur[itemId];
|
|
||||||
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
||||||
const dest = this.getObjet(destId);
|
const dest = this.getObjet(destId);
|
||||||
const src = this.getObjet(srcId);
|
const src = this.getObjet(srcId);
|
||||||
// changer de conteneur
|
// changer de conteneur
|
||||||
if (this.conteneurPeutContenir(dest, item)) {
|
if (this.conteneurPeutContenir(dest, item)) {
|
||||||
await this.enleverDeConteneur(item, src, objetVersConteneur);
|
await this.enleverDeConteneur(item, src, params.onEnleverConteneur);
|
||||||
await this.ajouterDansConteneur(item, dest, objetVersConteneur);
|
await this.ajouterDansConteneur(item, dest, params.onAjouterDansConteneur);
|
||||||
}
|
}
|
||||||
else if (dest?.isEquipementSimilaire(item)) {
|
else if (dest?.isEquipementSimilaire(item)) {
|
||||||
await this.regrouperEquipementsSimilaires(item, dest);
|
await this.regrouperEquipementsSimilaires(item, dest);
|
||||||
@ -1572,7 +1573,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async finDeRound(options = {terminer:false}) {
|
async finDeRound(options = { terminer: false }) {
|
||||||
for (let effect of this.getActiveEffects()) {
|
for (let effect of this.getActiveEffects()) {
|
||||||
if (effect.duration.type !== 'none' && (effect.duration.remaining <= 0 || options.terminer)) {
|
if (effect.duration.type !== 'none' && (effect.duration.remaining <= 0 || options.terminer)) {
|
||||||
if (effect.data.origin) {
|
if (effect.data.origin) {
|
||||||
@ -1584,11 +1585,11 @@ export class RdDActor extends Actor {
|
|||||||
ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.data.label))} !` });
|
ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.data.label))} !` });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( this.type == 'personnage') {
|
if (this.type == 'personnage') {
|
||||||
// Gestion blessure graves : -1 pt endurance
|
// Gestion blessure graves : -1 pt endurance
|
||||||
let nbGraves = this.countBlessuresNonSoigneeByName( 'graves');
|
let nbGraves = this.countBlessuresNonSoigneeByName('graves');
|
||||||
if ( nbGraves > 0) {
|
if (nbGraves > 0) {
|
||||||
await this.santeIncDec("endurance", -1 );
|
await this.santeIncDec("endurance", -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1598,7 +1599,7 @@ export class RdDActor extends Actor {
|
|||||||
if (this.isEntiteCauchemar()) {
|
if (this.isEntiteCauchemar()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!game.combat && sonne){
|
if (!game.combat && sonne) {
|
||||||
ui.notifications.info("Le personnage est hors combat, il ne reste donc pas sonné");
|
ui.notifications.info("Le personnage est hors combat, il ne reste donc pas sonné");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1629,7 +1630,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
countBlessuresNonSoigneeByName(name) {
|
countBlessuresNonSoigneeByName(name) {
|
||||||
let blessures = Misc.templateData(this).blessures[name].liste;
|
let blessures = Misc.templateData(this).blessures[name].liste;
|
||||||
return blessures.filter( b => b.active && !b.psdone).length;
|
return blessures.filter(b => b.active && !b.psdone).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -1809,7 +1810,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async jetDeMoral(situation, messageReussi = undefined, messageManque = undefined) {
|
async jetDeMoral(situation, messageReussi = undefined, messageManque = undefined) {
|
||||||
const jetMoral = await this._jetDeMoral(situation);
|
const jetMoral = await this._jetDeMoral(situation);
|
||||||
const finMessage = (jetMoral.succes ? messageReussi : messageManque) ?? (jetMoral.ajustement == 0 ? "Vous gardez votre moral": jetMoral.ajustement > 0 ? "Vous gagnez du moral" : "Vous perdez du moral");
|
const finMessage = (jetMoral.succes ? messageReussi : messageManque) ?? (jetMoral.ajustement == 0 ? "Vous gardez votre moral" : jetMoral.ajustement > 0 ? "Vous gagnez du moral" : "Vous perdez du moral");
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||||
content: `${finMessage} - jet ${jetMoral.succes ? "réussi" : "manqué"} en situation ${situation} (${jetMoral.jet}/${jetMoral.difficulte}).`
|
content: `${finMessage} - jet ${jetMoral.succes ? "réussi" : "manqué"} en situation ${situation} (${jetMoral.jet}/${jetMoral.difficulte}).`
|
||||||
@ -1893,23 +1894,20 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async actionItem(item) {
|
async actionItem(item, onActionItem = async ()=>{}) {
|
||||||
if (!item.getActionPrincipale()) return;
|
if (!item.getActionPrincipale()) return;
|
||||||
switch (Misc.data(item).type) {
|
switch (Misc.data(item).type) {
|
||||||
case 'nourritureboisson': return await this.actionNourritureboisson(item);
|
case 'nourritureboisson': return await this.actionNourritureboisson(item, onActionItem);
|
||||||
case 'potion': return await this.actionPotion(item);
|
case 'potion': return await this.consommerPotion(item, onActionItem);
|
||||||
case 'livre': return await this.actionLire(item);
|
case 'livre': return await this.actionLire(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async actionNourritureboisson(item) {
|
async actionNourritureboisson(item, onActionItem) {
|
||||||
const dialog = await DialogConsommer.create(this, item);
|
const dialog = await DialogConsommer.create(this, item, onActionItem);
|
||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async actionPotion(item) {
|
|
||||||
return await this.consommerPotion(item)
|
|
||||||
}
|
|
||||||
async actionLire(item) {
|
async actionLire(item) {
|
||||||
const tache = await this.creerTacheDepuisLivre(item, { renderSheet: false });
|
const tache = await this.creerTacheDepuisLivre(item, { renderSheet: false });
|
||||||
if (tache) {
|
if (tache) {
|
||||||
@ -1979,7 +1977,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async manger(item, doses, options = { diminuerQuantite: true}) {
|
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||||
const sust = Misc.templateData(item).sust;
|
const sust = Misc.templateData(item).sust;
|
||||||
if (sust > 0) {
|
if (sust > 0) {
|
||||||
await this.updateCompteurValue('sust', Misc.keepDecimals(Misc.templateData(this).compteurs.sust.value + sust * doses, 1));
|
await this.updateCompteurValue('sust', Misc.keepDecimals(Misc.templateData(this).compteurs.sust.value + sust * doses, 1));
|
||||||
@ -2478,14 +2476,14 @@ export class RdDActor extends Actor {
|
|||||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
async rollCaracCompetence(caracName, compName, diff, options = { title: "", apprecier: false}) {
|
async rollCaracCompetence(caracName, compName, diff, options = { title: "", apprecier: false }) {
|
||||||
const carac = this.getCaracByName(caracName);
|
const carac = this.getCaracByName(caracName);
|
||||||
if (!carac) {
|
if (!carac) {
|
||||||
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const competence = Misc.data(this.getCompetence(compName));
|
const competence = Misc.data(this.getCompetence(compName));
|
||||||
if (options.apprecier && competence){
|
if (options.apprecier && competence) {
|
||||||
const minQualite = Math.max(0, competence.data.niveau);
|
const minQualite = Math.max(0, competence.data.niveau);
|
||||||
if (diff <= minQualite) {
|
if (diff <= minQualite) {
|
||||||
ui.notifications.info(`${this.name} a un niveau ${competence.data.niveau} en ${competence.name}, trop élevé pour apprécier la qualité de ${diff}`)
|
ui.notifications.info(`${this.name} a un niveau ${competence.data.niveau} en ${competence.name}, trop élevé pour apprécier la qualité de ${diff}`)
|
||||||
@ -2623,7 +2621,7 @@ export class RdDActor extends Actor {
|
|||||||
} else {
|
} else {
|
||||||
rollData.tache.data.nb_jet_echec++;
|
rollData.tache.data.nb_jet_echec++;
|
||||||
}
|
}
|
||||||
rollData.tache.data.tentatives = rollData.tache.data.nb_jet_succes+rollData.tache.data.nb_jet_echec;
|
rollData.tache.data.tentatives = rollData.tache.data.nb_jet_succes + rollData.tache.data.nb_jet_echec;
|
||||||
|
|
||||||
this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
||||||
this.santeIncDec("fatigue", rollData.tache.data.fatigue);
|
this.santeIncDec("fatigue", rollData.tache.data.fatigue);
|
||||||
@ -3107,8 +3105,8 @@ export class RdDActor extends Actor {
|
|||||||
case 'chance-actuelle': case 'chance actuelle':
|
case 'chance-actuelle': case 'chance actuelle':
|
||||||
return carac.chance;
|
return carac.chance;
|
||||||
}
|
}
|
||||||
let entry = Misc.findFirstLike(name, Object.entries(carac), {mapper:it => it[1].label, description: 'caractéristique'});
|
let entry = Misc.findFirstLike(name, Object.entries(carac), { mapper: it => it[1].label, description: 'caractéristique' });
|
||||||
return entry.length>0 ? carac[entry[0]] : undefined;
|
return entry.length > 0 ? carac[entry[0]] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -3183,7 +3181,7 @@ export class RdDActor extends Actor {
|
|||||||
rollArme(arme) {
|
rollArme(arme) {
|
||||||
let competence = Misc.data(this.getCompetence(arme.data.competence));
|
let competence = Misc.data(this.getCompetence(arme.data.competence));
|
||||||
if (arme || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
if (arme || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
||||||
if ( competence.data.ispossession ) {
|
if (competence.data.ispossession) {
|
||||||
RdDPossession.managePosession(this, competence);
|
RdDPossession.managePosession(this, competence);
|
||||||
} else {
|
} else {
|
||||||
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
|
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
|
||||||
@ -3347,16 +3345,16 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
// Chaque dé fait au minmum la difficulté libre
|
// Chaque dé fait au minmum la difficulté libre
|
||||||
if (ReglesOptionelles.isUsing('degat-minimum-malus-libre')) {
|
if (ReglesOptionelles.isUsing('degat-minimum-malus-libre')) {
|
||||||
if ( rollData.diffLibre < 0 ) {
|
if (rollData.diffLibre < 0) {
|
||||||
let valeurMin = Math.abs(rollData.diffLibre);
|
let valeurMin = Math.abs(rollData.diffLibre);
|
||||||
formula += "min"+valeurMin;
|
formula += "min" + valeurMin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Chaque dé fait au minmum la difficulté libre
|
// Chaque dé fait au minmum la difficulté libre
|
||||||
if (ReglesOptionelles.isUsing('degat-ajout-malus-libre')) {
|
if (ReglesOptionelles.isUsing('degat-ajout-malus-libre')) {
|
||||||
if ( rollData.diffLibre < 0 ) {
|
if (rollData.diffLibre < 0) {
|
||||||
let valeurMin = Math.abs(rollData.diffLibre);
|
let valeurMin = Math.abs(rollData.diffLibre);
|
||||||
formula += "+"+valeurMin;
|
formula += "+" + valeurMin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3364,17 +3362,17 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
// 1 dé fait au minmum la difficulté libre
|
// 1 dé fait au minmum la difficulté libre
|
||||||
if (ReglesOptionelles.isUsing('degat-minimum-malus-libre-simple')) {
|
if (ReglesOptionelles.isUsing('degat-minimum-malus-libre-simple')) {
|
||||||
if ( rollData.diffLibre < 0 ) {
|
if (rollData.diffLibre < 0) {
|
||||||
let valeurMin = Math.abs(rollData.diffLibre);
|
let valeurMin = Math.abs(rollData.diffLibre);
|
||||||
if ( roll.terms[0].results[0].result < valeurMin) {
|
if (roll.terms[0].results[0].result < valeurMin) {
|
||||||
roll.terms[0].results[0].result = valeurMin;
|
roll.terms[0].results[0].result = valeurMin;
|
||||||
} else if (roll.terms[0].results[1].result < valeurMin) {
|
} else if (roll.terms[0].results[1].result < valeurMin) {
|
||||||
roll.terms[0].results[1].result = valeurMin;
|
roll.terms[0].results[1].result = valeurMin;
|
||||||
}
|
}
|
||||||
roll._total = roll.terms[0].results[0].result + roll.terms[0].results[1].result;
|
roll._total = roll.terms[0].results[0].result + roll.terms[0].results[1].result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const armure = await this.computeArmure(rollData);
|
const armure = await this.computeArmure(rollData);
|
||||||
const jetTotal = roll.total + rollData.dmg.total - armure;
|
const jetTotal = roll.total + rollData.dmg.total - armure;
|
||||||
|
|
||||||
@ -3683,7 +3681,7 @@ export class RdDActor extends Actor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Misc.isUniqueConnectedGM()) {
|
if (!Misc.isUniqueConnectedGM()) {
|
||||||
RdDActor.remoteActorCall({actorId: achat.vendeurId ?? achat.acheteurId, method: 'achatVente', args: [achat]});
|
RdDActor.remoteActorCall({ actorId: achat.vendeurId ?? achat.acheteurId, method: 'achatVente', args: [achat] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3701,7 +3699,7 @@ export class RdDActor extends Actor {
|
|||||||
if (acheteur) {
|
if (acheteur) {
|
||||||
let resteAcheteur = await acheteur.depenser(coutDeniers);
|
let resteAcheteur = await acheteur.depenser(coutDeniers);
|
||||||
if (resteAcheteur < 0) {
|
if (resteAcheteur < 0) {
|
||||||
ChatUtility.notifyUser(achat.userId, 'warn', `Vous n'avez pas assez d'argent pour payer ${Math.ceil(coutDeniers/100)} sols !`);
|
ChatUtility.notifyUser(achat.userId, 'warn', `Vous n'avez pas assez d'argent pour payer ${Math.ceil(coutDeniers / 100)} sols !`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3726,9 +3724,9 @@ export class RdDActor extends Actor {
|
|||||||
type: vente.item.type,
|
type: vente.item.type,
|
||||||
img: vente.item.img,
|
img: vente.item.img,
|
||||||
name: vente.item.name,
|
name: vente.item.name,
|
||||||
data: mergeObject(vente.item.data, {quantite: isItemEmpilable ? achat.quantiteTotal : undefined}),
|
data: mergeObject(vente.item.data, { quantite: isItemEmpilable ? achat.quantiteTotal : undefined }),
|
||||||
}
|
}
|
||||||
let listeAchat = isItemEmpilable ? [achatData] : Array.from({length: achat.quantiteTotal}, (_, i) => achatData)
|
let listeAchat = isItemEmpilable ? [achatData] : Array.from({ length: achat.quantiteTotal }, (_, i) => achatData)
|
||||||
let items = await acheteur.createEmbeddedDocuments("Item", listeAchat)
|
let items = await acheteur.createEmbeddedDocuments("Item", listeAchat)
|
||||||
if (achat.choix.consommer && vente.item.type == 'nourritureboisson') {
|
if (achat.choix.consommer && vente.item.type == 'nourritureboisson') {
|
||||||
achat.choix.doses = achat.choix.nombreLots;
|
achat.choix.doses = achat.choix.nombreLots;
|
||||||
@ -3742,7 +3740,7 @@ export class RdDActor extends Actor {
|
|||||||
chatAchatItem.quantiteTotal = achat.quantiteTotal;
|
chatAchatItem.quantiteTotal = achat.quantiteTotal;
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
user: achat.userId,
|
user: achat.userId,
|
||||||
speaker: {alias: (acheteur ?? vendeur).name} ,
|
speaker: { alias: (acheteur ?? vendeur).name },
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||||
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', chatAchatItem)
|
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', chatAchatItem)
|
||||||
});
|
});
|
||||||
@ -3953,7 +3951,7 @@ export class RdDActor extends Actor {
|
|||||||
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5;
|
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!potionData.data.magique || potionData.rolled.isSuccess) {
|
if (!potionData.data.magique || potionData.rolled.isSuccess) {
|
||||||
this.bonusRecuperationPotion = potionData.data.herbeBonus;
|
this.bonusRecuperationPotion = potionData.data.herbeBonus;
|
||||||
}
|
}
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
@ -4058,7 +4056,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async consommerPotion(potion) {
|
async consommerPotion(potion, onActionItem = async () => {}) {
|
||||||
const potionData = Misc.data(potion);
|
const potionData = Misc.data(potion);
|
||||||
|
|
||||||
if (potionData.data.categorie.includes('Soin')) {
|
if (potionData.data.categorie.includes('Soin')) {
|
||||||
@ -4068,7 +4066,8 @@ export class RdDActor extends Actor {
|
|||||||
} else {
|
} else {
|
||||||
this.consommerPotionGenerique(potionData);
|
this.consommerPotionGenerique(potionData);
|
||||||
}
|
}
|
||||||
this.diminuerQuantiteObjet(potion.id, 1, { supprimerSiZero: potionData.supprimer });
|
await this.diminuerQuantiteObjet(potion.id, 1, { supprimerSiZero: potionData.supprimer });
|
||||||
|
await onActionItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -4119,7 +4118,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enleverActiveEffectById(id) {
|
enleverActiveEffectById(id) {
|
||||||
if (game.user.isGM){
|
if (game.user.isGM) {
|
||||||
const existing = this.getEffectById(id);
|
const existing = this.getEffectById(id);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.delete();
|
existing.delete();
|
||||||
@ -4128,7 +4127,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
enleverTousLesEffets() {
|
enleverTousLesEffets() {
|
||||||
if (game.user.isGM){
|
if (game.user.isGM) {
|
||||||
this.deleteEmbeddedDocuments('ActiveEffect', this.getActiveEffects().map(it => it.id));
|
this.deleteEmbeddedDocuments('ActiveEffect', this.getActiveEffects().map(it => it.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,22 +2,23 @@ import { Misc } from "./misc.js";
|
|||||||
|
|
||||||
export class DialogConsommer extends Dialog {
|
export class DialogConsommer extends Dialog {
|
||||||
|
|
||||||
static async create(actor, item, template = undefined, options = {}) {
|
static async create(actor, item, onActionItem = async ()=>{}) {
|
||||||
const consommerData = DialogConsommer.prepareData(actor, item, options);
|
const consommerData = DialogConsommer.prepareData(actor, item);
|
||||||
const html = await renderTemplate(template ?? `systems/foundryvtt-reve-de-dragon/templates/dialog-item-consommer.html`, consommerData);
|
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-item-consommer.html', consommerData);
|
||||||
return new DialogConsommer(actor, item, consommerData, html, options)
|
return new DialogConsommer(actor, item, consommerData, html, onActionItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(actor, item, consommerData, html, options = {}) {
|
constructor(actor, item, consommerData, html, onActionItem = async ()=>{}) {
|
||||||
mergeObject(options, { classes: ["dialogconsommer"], width: 350, height: 450, 'z-index': 99999 }, { overwrite: false })
|
const options = { classes: ["dialogconsommer"], width: 350, height: 450, 'z-index': 99999 };
|
||||||
|
|
||||||
let conf = {
|
let conf = {
|
||||||
title: consommerData.title,
|
title: consommerData.title,
|
||||||
content: html,
|
content: html,
|
||||||
default: consommerData.buttonName,
|
default: consommerData.buttonName,
|
||||||
buttons: {
|
buttons: {
|
||||||
[consommerData.buttonName]: {
|
[consommerData.buttonName]: {
|
||||||
label: consommerData.buttonName, callback: it => this.onConsommer(it)
|
label: consommerData.buttonName, callback: async it => {
|
||||||
|
await this.onConsommer(it);
|
||||||
|
await onActionItem();}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -32,18 +33,18 @@ export class DialogConsommer extends Dialog {
|
|||||||
async onConsommer(event) {
|
async onConsommer(event) {
|
||||||
await $(".se-forcer").change();
|
await $(".se-forcer").change();
|
||||||
await $(".consommer-doses").change();
|
await $(".consommer-doses").change();
|
||||||
this.actor.consommer(this.item, this.consommerData.choix);
|
await this.actor.consommer(this.item, this.consommerData.choix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static prepareData(actor, item, options) {
|
static prepareData(actor, item) {
|
||||||
const itemData = duplicate(Misc.data(item));
|
const itemData = duplicate(Misc.data(item));
|
||||||
let consommerData = {
|
let consommerData = {
|
||||||
item: itemData,
|
item: itemData,
|
||||||
cuisine: Misc.data(actor.getCompetence('cuisine')),
|
cuisine: Misc.data(actor.getCompetence('cuisine')),
|
||||||
choix: {
|
choix: {
|
||||||
doses: options.doses ?? 1,
|
doses: 1,
|
||||||
seForcer: options.seForcer ?? false,
|
seForcer: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (itemData.type) {
|
switch (itemData.type) {
|
||||||
|
@ -8,6 +8,7 @@ import { Misc } from "./misc.js";
|
|||||||
import { HtmlUtility } from "./html-utility.js";
|
import { HtmlUtility } from "./html-utility.js";
|
||||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||||
import { SYSTEM_RDD } from "./constants.js";
|
import { SYSTEM_RDD } from "./constants.js";
|
||||||
|
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the basic ItemSheet with some very simple modifications
|
* Extend the basic ItemSheet with some very simple modifications
|
||||||
@ -63,15 +64,15 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async getData() {
|
async getData() {
|
||||||
const objectData = Misc.data(this.object);
|
const objectData = Misc.data(this.object);
|
||||||
|
|
||||||
let formData = {
|
let formData = {
|
||||||
|
id: this.object.id,
|
||||||
title: objectData.name,
|
title: objectData.name,
|
||||||
id: objectData.id,
|
|
||||||
type: objectData.type,
|
type: objectData.type,
|
||||||
img: objectData.img,
|
img: objectData.img,
|
||||||
name: objectData.name,
|
name: objectData.name,
|
||||||
data: objectData.data,
|
data: objectData.data,
|
||||||
isGM: game.user.isGM,
|
isGM: game.user.isGM,
|
||||||
|
actorId: this.actor?.id,
|
||||||
owner: this.document.isOwner,
|
owner: this.document.isOwner,
|
||||||
editable: this.isEditable,
|
editable: this.isEditable,
|
||||||
cssClass: this.isEditable ? "editable" : "locked",
|
cssClass: this.isEditable ? "editable" : "locked",
|
||||||
@ -79,7 +80,9 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
}
|
}
|
||||||
if (this.actor) {
|
if (this.actor) {
|
||||||
formData.isOwned = true;
|
formData.isOwned = true;
|
||||||
formData.actorId = this.actor.id;
|
if (objectData.type == 'conteneur') {
|
||||||
|
this.prepareConteneurData(formData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences();
|
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences();
|
||||||
@ -96,7 +99,7 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
}
|
}
|
||||||
if (formData.type == 'gemme') {
|
if (formData.type == 'gemme') {
|
||||||
formData.gemmeTypeList = RdDGemme.getGemmeTypeOptionList();
|
formData.gemmeTypeList = RdDGemme.getGemmeTypeOptionList();
|
||||||
RdDGemme.calculDataDerivees( formData.data );
|
RdDGemme.calculDataDerivees(formData.data);
|
||||||
}
|
}
|
||||||
if (formData.type == 'potion') {
|
if (formData.type == 'potion') {
|
||||||
if (this.dateUpdated) {
|
if (this.dateUpdated) {
|
||||||
@ -113,14 +116,25 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepareConteneurData(formData) {
|
||||||
|
formData.itemsByType = Misc.classify(this.actor.items.map(i => foundry.utils.deepClone(i.data)));
|
||||||
|
RdDUtility.filterEquipementParType(formData);
|
||||||
|
|
||||||
|
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
||||||
|
formData.subItems = formData.conteneurs.find(it => it._id == this.object.id)?.subItems;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** @override */
|
/** @override */
|
||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
let itemSheetDialog = this;
|
||||||
|
|
||||||
HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.object.isOwned);
|
HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.object.isOwned);
|
||||||
HtmlUtility._showControlWhen($(".item-magique"), this.object.isMagique());
|
HtmlUtility._showControlWhen($(".item-magique"), this.object.isMagique());
|
||||||
|
|
||||||
// Everything below here is only needed if the sheet is editable
|
// Everything below here is only needed if the sheet is editable
|
||||||
if (!this.options.editable) return;
|
if (!this.options.editable) return;
|
||||||
|
|
||||||
@ -168,13 +182,37 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
html.find('.item-split').click(async event => {
|
||||||
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
await RdDSheetUtility.splitItem(item, this.actor, async () => itemSheetDialog.render(true));
|
||||||
|
});
|
||||||
|
html.find('.item-edit').click(async event => {
|
||||||
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
item.sheet.render(true);
|
||||||
|
});
|
||||||
|
html.find('.item-delete').click(async event => {
|
||||||
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
|
RdDUtility.confirmerSuppression(this, li);
|
||||||
|
});
|
||||||
|
html.find('.item-vendre').click(async event => {
|
||||||
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
item?.proposerVente();
|
||||||
|
});
|
||||||
|
html.find('.item-action').click(async event => {
|
||||||
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onSelectCategorie(event) {
|
async _onSelectCategorie(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.object.isCompetence()){
|
if (this.object.isCompetence()) {
|
||||||
let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value);
|
let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value);
|
||||||
Misc.templateData(this.object).base = level;
|
Misc.templateData(this.object).base = level;
|
||||||
$("#base").val(level);
|
$("#base").val(level);
|
||||||
@ -198,4 +236,6 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
|
|
||||||
return this.object.update(formData);
|
return this.object.update(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,8 @@ export class RdDUtility {
|
|||||||
Handlebars.registerHelper('le', str => Grammar.articleDetermine(str));
|
Handlebars.registerHelper('le', str => Grammar.articleDetermine(str));
|
||||||
Handlebars.registerHelper('un', str => Grammar.articleIndetermine(str));
|
Handlebars.registerHelper('un', str => Grammar.articleIndetermine(str));
|
||||||
Handlebars.registerHelper('accord', (genre, ...args) => Grammar.accord(genre, args));
|
Handlebars.registerHelper('accord', (genre, ...args) => Grammar.accord(genre, args));
|
||||||
Handlebars.registerHelper('buildConteneur', (objet) => { return RdDUtility.buildConteneur(objet); });
|
Handlebars.registerHelper('buildConteneur', (objet) => { return new Handlebars.SafeString(RdDUtility.buildConteneur(objet)); });
|
||||||
|
Handlebars.registerHelper('buildContenu', (objet) => { return new Handlebars.SafeString(RdDUtility.buildContenu(objet, 1, true)); });
|
||||||
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
|
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
|
||||||
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
|
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
|
||||||
Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord));
|
Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord));
|
||||||
@ -355,15 +356,9 @@ export class RdDUtility {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static filterItemsPerTypeForSheet(formData) {
|
static filterItemsPerTypeForSheet(formData) {
|
||||||
formData.materiel = this.checkNull(formData.itemsByType['objet']);
|
|
||||||
formData.conteneurs = this.checkNull(formData.itemsByType['conteneur']);
|
RdDUtility.filterEquipementParType(formData);
|
||||||
formData.armes = this.checkNull(formData.itemsByType['arme']);
|
|
||||||
formData.armures = this.checkNull(formData.itemsByType['armure']);
|
|
||||||
formData.livres = this.checkNull(formData.itemsByType['livre']);
|
|
||||||
formData.potions = this.checkNull(formData.itemsByType['potion']);
|
|
||||||
formData.ingredients = this.checkNull(formData.itemsByType['ingredient']);
|
|
||||||
formData.munitions = this.checkNull(formData.itemsByType['munition']);
|
|
||||||
formData.herbes = this.checkNull(formData.itemsByType['herbe']);
|
|
||||||
formData.sorts = this.checkNull(formData.itemsByType['sort']);
|
formData.sorts = this.checkNull(formData.itemsByType['sort']);
|
||||||
formData.signesdraconiques = this.checkNull(formData.itemsByType['signedraconique']);
|
formData.signesdraconiques = this.checkNull(formData.itemsByType['signedraconique']);
|
||||||
formData.queues = this.checkNull(formData.itemsByType['queue']);
|
formData.queues = this.checkNull(formData.itemsByType['queue']);
|
||||||
@ -371,34 +366,50 @@ export class RdDUtility {
|
|||||||
formData.ombres = this.checkNull(formData.itemsByType['ombre']);
|
formData.ombres = this.checkNull(formData.itemsByType['ombre']);
|
||||||
formData.tetes = this.checkNull(formData.itemsByType['tete']);
|
formData.tetes = this.checkNull(formData.itemsByType['tete']);
|
||||||
formData.taches = this.checkNull(formData.itemsByType['tache']);
|
formData.taches = this.checkNull(formData.itemsByType['tache']);
|
||||||
formData.monnaie = this.checkNull(formData.itemsByType['monnaie']);
|
|
||||||
formData.nourritureboissons = this.checkNull(formData.itemsByType['nourritureboisson']);
|
|
||||||
formData.meditations = this.checkNull(formData.itemsByType['meditation']);
|
formData.meditations = this.checkNull(formData.itemsByType['meditation']);
|
||||||
formData.chants = this.checkNull(formData.itemsByType['chant']);
|
formData.chants = this.checkNull(formData.itemsByType['chant']);
|
||||||
formData.danses = this.checkNull(formData.itemsByType['danse']);
|
formData.danses = this.checkNull(formData.itemsByType['danse']);
|
||||||
formData.musiques = this.checkNull(formData.itemsByType['musique']);
|
formData.musiques = this.checkNull(formData.itemsByType['musique']);
|
||||||
formData.oeuvres = this.checkNull(formData.itemsByType['oeuvre']);
|
formData.oeuvres = this.checkNull(formData.itemsByType['oeuvre']);
|
||||||
formData.jeux = this.checkNull(formData.itemsByType['jeu']);
|
formData.jeux = this.checkNull(formData.itemsByType['jeu']);
|
||||||
formData.gemmes = this.checkNull(formData.itemsByType['gemme']);
|
|
||||||
formData.recettescuisine = this.checkNull(formData.itemsByType['recettecuisine']);
|
formData.recettescuisine = this.checkNull(formData.itemsByType['recettecuisine']);
|
||||||
formData.recettesAlchimiques = this.checkNull(formData.itemsByType['recettealchimique']);
|
formData.recettesAlchimiques = this.checkNull(formData.itemsByType['recettealchimique']);
|
||||||
formData.maladies = this.checkNull(formData.itemsByType['maladie']);
|
formData.maladies = this.checkNull(formData.itemsByType['maladie']);
|
||||||
formData.poisons = this.checkNull(formData.itemsByType['poison']);
|
formData.poisons = this.checkNull(formData.itemsByType['poison']);
|
||||||
formData.possessions = this.checkNull(formData.itemsByType['possession']);
|
formData.possessions = this.checkNull(formData.itemsByType['possession']);
|
||||||
formData.maladiesPoisons = formData.maladies.concat( formData.poisons);
|
formData.maladiesPoisons = formData.maladies.concat( formData.poisons);
|
||||||
formData.objets = formData.conteneurs.concat(formData.materiel)
|
formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
static filterEquipementParType(formData) {
|
||||||
|
formData.conteneurs = this.checkNull(formData.itemsByType['conteneur']);
|
||||||
|
|
||||||
|
formData.materiel = this.checkNull(formData.itemsByType['objet']);
|
||||||
|
formData.armes = this.checkNull(formData.itemsByType['arme']);
|
||||||
|
formData.armures = this.checkNull(formData.itemsByType['armure']);
|
||||||
|
formData.munitions = this.checkNull(formData.itemsByType['munition']);
|
||||||
|
formData.livres = this.checkNull(formData.itemsByType['livre']);
|
||||||
|
formData.potions = this.checkNull(formData.itemsByType['potion']);
|
||||||
|
formData.ingredients = this.checkNull(formData.itemsByType['ingredient']);
|
||||||
|
formData.herbes = this.checkNull(formData.itemsByType['herbe']);
|
||||||
|
formData.monnaie = this.checkNull(formData.itemsByType['monnaie']);
|
||||||
|
formData.monnaie.sort(Monnaie.triValeurDenier());
|
||||||
|
formData.nourritureboissons = this.checkNull(formData.itemsByType['nourritureboisson']);
|
||||||
|
formData.gemmes = this.checkNull(formData.itemsByType['gemme']);
|
||||||
|
|
||||||
|
formData.objets = formData.conteneurs
|
||||||
|
.concat(formData.materiel)
|
||||||
.concat(formData.armes)
|
.concat(formData.armes)
|
||||||
.concat(formData.armures)
|
.concat(formData.armures)
|
||||||
.concat(formData.munitions)
|
.concat(formData.munitions)
|
||||||
.concat(formData.livres)
|
.concat(formData.livres)
|
||||||
.concat(formData.potions)
|
.concat(formData.potions)
|
||||||
.concat(formData.herbes)
|
|
||||||
.concat(formData.ingredients)
|
.concat(formData.ingredients)
|
||||||
|
.concat(formData.herbes)
|
||||||
|
.concat(formData.monnaie)
|
||||||
.concat(formData.nourritureboissons)
|
.concat(formData.nourritureboissons)
|
||||||
.concat(formData.gemmes)
|
.concat(formData.gemmes);
|
||||||
.concat(formData.monnaie);
|
|
||||||
formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []);
|
|
||||||
formData.monnaie.sort(Monnaie.triValeurDenier());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -456,18 +467,27 @@ export class RdDUtility {
|
|||||||
//console.log("OBJ:", objet);
|
//console.log("OBJ:", objet);
|
||||||
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({ item: objet });
|
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({ item: objet });
|
||||||
if (objet.type == 'conteneur') {
|
if (objet.type == 'conteneur') {
|
||||||
//console.log("ITEM DISPLAYED", objet );
|
const afficherContenu = this.getAfficheContenu(objet._id);
|
||||||
if (this.getAfficheContenu(objet._id)) {
|
str = str + RdDUtility.buildContenu(objet, niveau, afficherContenu);
|
||||||
str = str + "<ul class='item-list alterne-list item-display-show list-item-margin" + niveau + "'>";
|
|
||||||
} else {
|
|
||||||
str = str + "<ul class='item-list alterne-list item-display-hide list-item-margin" + niveau + "'>";
|
|
||||||
}
|
|
||||||
for (let subItem of objet.subItems) {
|
|
||||||
str = str + this.buildConteneur(subItem, niveau + 1);
|
|
||||||
}
|
|
||||||
str = str + "</ul>";
|
|
||||||
}
|
}
|
||||||
return new Handlebars.SafeString(str);
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static buildContenu(objet, niveau, afficherContenu) {
|
||||||
|
if (!niveau) niveau = 1;
|
||||||
|
objet.niveau = niveau;
|
||||||
|
let strContenu = "";
|
||||||
|
//console.log("ITEM DISPLAYED", objet );
|
||||||
|
if (afficherContenu) {
|
||||||
|
strContenu = "<ul class='item-list alterne-list item-display-show list-item-margin" + niveau + "'>";
|
||||||
|
} else {
|
||||||
|
strContenu = "<ul class='item-list alterne-list item-display-hide list-item-margin" + niveau + "'>";
|
||||||
|
}
|
||||||
|
for (let subItem of objet.subItems) {
|
||||||
|
strContenu = strContenu + this.buildConteneur(subItem, niveau + 1);
|
||||||
|
}
|
||||||
|
strContenu = strContenu + "</ul>";
|
||||||
|
return strContenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -24,6 +24,13 @@
|
|||||||
<label for="xp">Prix (sols) </label>
|
<label for="xp">Prix (sols) </label>
|
||||||
<input class="attribute-value" type="text" name="data.cout" value="{{data.cout}}" data-dtype="Number"/>
|
<input class="attribute-value" type="text" name="data.cout" value="{{data.cout}}" data-dtype="Number"/>
|
||||||
</div>
|
</div>
|
||||||
|
{{#if isOwned}}
|
||||||
|
<div class="flexcol">
|
||||||
|
<span><label>Contenu : </label></span>
|
||||||
|
{{buildContenu this}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user