12.0.36 - L'alchimie d'Astrobazzarh #740

Merged
uberwald merged 16 commits from VincentVk/foundryvtt-reve-de-dragon:v11 into v11 2025-01-19 09:50:20 +01:00
4 changed files with 44 additions and 29 deletions
Showing only changes of commit 425c6af672 - Show all commits

View File

@ -43,7 +43,7 @@ export class RdDBaseActorSheet extends ActorSheet {
effects: this.actor.effects effects: this.actor.effects
} }
RdDBaseActorSheet.filterItemsPerTypeForSheet(formData, this.actor.itemTypes); RdDUtility.filterItemsPerTypeForSheet(formData, this.actor.itemTypes);
formData.calc = { formData.calc = {
fortune: Monnaie.toSolsDeniers(this.actor.getFortune()), fortune: Monnaie.toSolsDeniers(this.actor.getFortune()),
prixTotalEquipement: this.actor.computePrixTotalEquipement(), prixTotalEquipement: this.actor.computePrixTotalEquipement(),
@ -79,22 +79,6 @@ export class RdDBaseActorSheet extends ActorSheet {
} }
} }
/* -------------------------------------------- */
static filterItemsPerTypeForSheet(formData, itemTypes) {
Object.values(ITEM_TYPES).forEach(t => {
formData[t + 's'] = Misc.arrayOrEmpty(itemTypes[t])
})
formData.maladiesPoisons = formData.maladies.concat(formData.poisons)
formData.competences = formData.competences.concat(formData.competencecreatures)
formData.monnaies = formData.monnaies.sort(Monnaie.triValeurEntiere())
formData.inventaires = RdDItem.getItemTypesInventaire('all')
.map(t => Misc.arrayOrEmpty(itemTypes[t]))
.reduce((a, b) => a.concat(b), [])
.sort(Misc.ascending(it => it.name));
}
/* -------------------------------------------- */ /** @override */ /* -------------------------------------------- */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
@ -105,7 +89,7 @@ export class RdDBaseActorSheet extends ActorSheet {
this.render(true); this.render(true);
}); });
this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat()); this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat());
this.html.find('.item-edit').click(async event => this.getItem(event)?.sheet.render(true)) this.html.find('.item-edit').click(async event => this.itemActionEdit(event))
this.html.find('.item-montrer').click(async event => this.getItem(event)?.postItemToChat()); this.html.find('.item-montrer').click(async event => this.getItem(event)?.postItemToChat());
this.html.find('.recherche') this.html.find('.recherche')
@ -147,6 +131,11 @@ export class RdDBaseActorSheet extends ActorSheet {
}); });
} }
itemActionEdit(event) {
const item = this.getItem(event);
return item?.sheet.render(true);
}
_rechercherKeyup(event) { _rechercherKeyup(event) {
const currentTarget = event.currentTarget; const currentTarget = event.currentTarget;
const nouvelleRecherche = this._optionRecherche(currentTarget); const nouvelleRecherche = this._optionRecherche(currentTarget);

View File

@ -1,4 +1,4 @@
import { ACTOR_TYPES, ITEM_TYPES } from "./constants.js"; import { ITEM_TYPES } from "./constants.js";
import { DialogItemVente } from "./achat-vente/dialog-item-vente.js"; import { DialogItemVente } from "./achat-vente/dialog-item-vente.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";

View File

@ -29,9 +29,10 @@ export class RdDConteneurItemSheet extends RdDItemInventaireSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
prepareConteneurData(formData) { prepareConteneurData(formData) {
RdDBaseActorSheet.filterItemsPerTypeForSheet(formData, this.actor.itemTypes); RdDUtility.filterItemsPerTypeForSheet(formData, this.actor.itemTypes);
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.inventaires); this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.inventaires);
formData.subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems; const subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems;
formData.subItems = subItems
} }
async _onDragStart(event) { async _onDragStart(event) {

View File

@ -19,10 +19,11 @@ import { RdDEmpoignade } from "./rdd-empoignade.js";
import { ExperienceLog } from "./actor/experience-log.js"; import { ExperienceLog } from "./actor/experience-log.js";
import { RdDCoeur } from "./coeur/rdd-coeur.js"; import { RdDCoeur } from "./coeur/rdd-coeur.js";
import { APP_ASTROLOGIE_REFRESH } from "./sommeil/app-astrologie.js"; import { APP_ASTROLOGIE_REFRESH } from "./sommeil/app-astrologie.js";
import { RDD_CONFIG } from "./constants.js"; import { ITEM_TYPES, RDD_CONFIG } from "./constants.js";
import { RdDBaseActor } from "./actor/base-actor.js"; import { RdDBaseActor } from "./actor/base-actor.js";
import { RdDCarac } from "./rdd-carac.js"; import { RdDCarac } from "./rdd-carac.js";
import { RdDTextEditor } from "./apps/rdd-text-roll-editor.js"; import { RdDTextEditor } from "./apps/rdd-text-roll-editor.js";
import { Monnaie } from "./item-monnaie.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
// This table starts at 0 -> niveau -10 // This table starts at 0 -> niveau -10
@ -264,7 +265,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html' 'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html'
]; ];
// foundry et options // foundry et options
Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path]) Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path])
Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name)); Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name));
@ -279,7 +280,7 @@ export class RdDUtility {
const html = options.fn(this); const html = options.fn(this);
return html.replace(rgx, "$& selected"); return html.replace(rgx, "$& selected");
}) })
// logic // logic
Handlebars.registerHelper('either', (a, b) => a ?? b); Handlebars.registerHelper('either', (a, b) => a ?? b);
// string manipulation // string manipulation
@ -295,9 +296,9 @@ export class RdDUtility {
// math // math
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1))); Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
Handlebars.registerHelper('repeat', function(n, block) { Handlebars.registerHelper('repeat', function (n, block) {
let accum = ''; let accum = '';
for(let i = 0; i < n; ++i){ for (let i = 0; i < n; ++i) {
accum += block.fn(i) accum += block.fn(i)
} }
return accum return accum
@ -465,13 +466,37 @@ export class RdDUtility {
return ligneObjet; return ligneObjet;
} }
static filterItemsPerTypeForSheet(formData, itemTypes) {
Object.values(ITEM_TYPES).forEach(t => {
formData[t + 's'] = Misc.arrayOrEmpty(itemTypes[t])
})
formData.maladiesPoisons = formData.maladies.concat(formData.poisons)
formData.competences = formData.competences.concat(formData.competencecreatures)
formData.monnaies = formData.monnaies.sort(Monnaie.triValeurEntiere())
formData.inventaires = RdDUtility.prepareInventaire(itemTypes)
}
static buildInventaireConteneur(actorId, itemId, options) { static buildInventaireConteneur(actorId, itemId, options) {
const actor = game.actors.get(actorId) const actor = game.actors.get(actorId)
const item = actor?.items.get(itemId) const item = actor?.items.get(itemId)
if (item) { if (item?.type == ITEM_TYPES.conteneur) {
return RdDUtility.buildContenuConteneur(item, options, { ouvert: true, profondeur: 1 }); const formData = {}
RdDUtility.filterItemsPerTypeForSheet(formData, actor.itemTypes);
RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.inventaires);
item.subItems = formData.conteneurs.find(it => it._id == itemId)?.subItems;
return RdDUtility.buildContenuConteneur(item, options, { ouvert: true, profondeur: 1 })
} }
return ''; return ''
}
static prepareInventaire(itemTypes) {
return RdDItem.getItemTypesInventaire('all')
.map(t => Misc.arrayOrEmpty(itemTypes[t]))
.reduce((a, b) => a.concat(b), [])
.sort(Misc.ascending(it => it.name))
} }
/* -------------------------------------------- */ /* -------------------------------------------- */