Various fixes

This commit is contained in:
2023-03-14 09:14:28 +01:00
parent a63ec19362
commit fef42b7093
8 changed files with 98 additions and 36 deletions

View File

@@ -96,27 +96,33 @@ export class MournbladeActor extends Actor {
armes.push(this.prepareBouclier(arme))
}
}
MournbladeUtility.sortArrayObjectsByName(armes)
return armes
}
/* -------------------------------------------- */
getDons() {
return this.items.filter(item => item.type == "don")
getItemSorted( types) {
let items = this.items.filter(item => types.includes(item.type )) || []
MournbladeUtility.sortArrayObjectsByName(items)
return items
}
getDons() {
return this.getItemSorted(["don"])
}
/* -------------------------------------------- */
getTendances() {
return this.items.filter(item => item.type == "tendance")
return this.getItemSorted(["tendance"])
}
getRunes() {
return this.items.filter(item => item.type == "rune")
return this.getItemSorted(["rune"])
}
/* -------------------------------------------- */
getEquipments() {
return this.items.filter(item => item.type == "equipement")
return this.getItemSorted(["monnaie"])
}
getMonnaies() {
return this.getItemSorted(["monnaie"])
}
/* -------------------------------------------- */
getArmors() {
return this.items.filter(item => item.type == "protection")
return this.getItemSorted(["protection"])
}
getOrigine() {
return this.items.find(item => item.type == "origine")
@@ -147,17 +153,8 @@ export class MournbladeActor extends Actor {
comp.push(item)
}
}
return comp.sort(function (a, b) {
let fa = a.name.toLowerCase(),
fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
})
MournbladeUtility.sortArrayObjectsByName(comp)
return comp
}
/* -------------------------------------------- */
@@ -359,11 +356,10 @@ export class MournbladeActor extends Actor {
async incDecQuantity(objetId, incDec = 0) {
let objetQ = this.items.get(objetId)
if (objetQ) {
let newQ = objetQ.system.quantity + incDec;
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity
let newQ = objetQ.system.quantite + incDec;
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
}
}
/* -------------------------------------------- */
getCompetence(compId) {
return this.items.get(compId)