v10.7.20 - la cuirasse de Sémolosse #662

Merged
uberwald merged 2 commits from VincentVk/foundryvtt-reve-de-dragon:v10 into v10 2023-07-12 08:09:07 +02:00
2 changed files with 11 additions and 9 deletions
Showing only changes of commit e58d88fab6 - Show all commits

View File

@ -298,7 +298,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
async verifierPotionsEnchantees() {
let potionsEnchantees = this.filterItems(it => it.type == 'potion' && it.system.categorie.toLowerCase().includes('enchant'));
let potionsEnchantees = this.filterItems(it => it.system.categorie.toLowerCase().includes('enchant'), 'potion');
for (let potion of potionsEnchantees) {
if (!potion.system.prpermanent) {
console.log(potion);
@ -1124,7 +1124,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
async computeMalusArmure() {
if (this.isPersonnage()) {
const malusArmure = this.filterItems(it => it.type == 'armure' && it.system.equipe)
const malusArmure = this.filterItems(it => it.system.equipe, 'armure')
.map(it => it.system.malus ?? 0)
.reduce(Misc.sum(), 0);
// Mise à jour éventuelle du malus armure
@ -1297,8 +1297,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
buildTMRInnaccessible() {
const tmrInnaccessibles = this.filterItems(it => Draconique.isCaseTMR(it) &&
EffetsDraconiques.isInnaccessible(it));
const tmrInnaccessibles = this.filterItems(it => Draconique.isCaseTMR(it) && EffetsDraconiques.isInnaccessible(it));
return tmrInnaccessibles.map(it => it.system.coord);
}
@ -2363,8 +2362,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
async creerTacheDepuisLivre(item, options = { renderSheet: true }) {
const nomTache = "Lire " + item.name;
const filterTacheLecture = it => it.type == 'tache' && it.name == nomTache;
let tachesExistantes = this.filterItems(filterTacheLecture);
let tachesExistantes = findTache(nomTache);
if (tachesExistantes.length == 0) {
const tache = {
name: nomTache, type: 'tache',
@ -2380,13 +2378,17 @@ export class RdDActor extends RdDBaseActor {
}
}
await this.createEmbeddedDocuments('Item', [tache], options);
tachesExistantes = this.filterItems(filterTacheLecture);
tachesExistantes = findTache(nomTache)
}
return tachesExistantes.length > 0 ? tachesExistantes[0] : undefined;
function findTache(name) {
return this.filterItems(it => it.name == name, 'tache');
}
}
blessuresASoigner() {
// TODO or not TODO: filtrer les blessures poour lesquels on ne peut plus faire de premiers soins?
// TODO or not TODO: filtrer les blessures pour lesquelles on ne peut plus faire de premiers soins?
return this.filterItems(it => it.system.gravite > 0 && it.system.gravite <= 6 && !(it.system.premierssoins.done && it.system.soinscomplets.done), 'blessure')
}

View File

@ -119,7 +119,7 @@ export class RdDBaseActor extends Actor {
}
listItems(type = undefined) { return (type ? this.itemTypes[type] : this.items); }
filterItems(filter, type = undefined) { return type ? this.itemTypes[type]?.filter(filter) ?? [] : []; }
filterItems(filter, type = undefined) { return (type ? this.itemTypes[type] : this.items)?.filter(filter); }
findItemLike(idOrName, type) {
return this.getItem(idOrName, type)
?? Misc.findFirstLike(idOrName, this.listItems(type), { description: Misc.typeName('Item', type) });