Alpha sort

This commit is contained in:
LeRatierBretonnien 2023-03-19 18:58:28 +01:00
parent 22ae4fb588
commit 0e5be07fb9
3 changed files with 63 additions and 67 deletions

View File

@ -91,6 +91,11 @@ export class HawkmoonActor extends Actor {
}
/* -------------------------------------------- */
getItemSorted(types) {
let items = this.items.filter(item => types.includes(item.type)) || []
HawkmoonUtility.sortArrayObjectsByName(items)
return items
}
getWeapons() {
let armes = []
for (let arme of this.items) {
@ -98,55 +103,37 @@ export class HawkmoonActor extends Actor {
armes.push(this.prepareArme(arme))
}
}
HawkmoonUtility.sortArrayObjectsByName(armes)
return armes
}
/* -------------------------------------------- */
getMonnaies() {
return this.items.filter( it => it.type == "monnaie")
return this.getItemSorted(["monnaie"])
}
/* ----------------------- --------------------- */
addMember( actorId) {
let members = duplicate(this.system.members)
members.push( {id: actorId} )
this.update ({'system.members': members})
}
async removeMember(actorId) {
let members = this.system.members.filter(it => it.id != actorId )
this.update ({'system.members': members})
}
/* ----------------------- --------------------- */
getEquipments() {
return this.items.filter(item => item.type == "equipement")
return this.getItemSorted(["equipement"])
}
/* ----------------------- --------------------- */
getArtefacts() {
return this.items.filter(item => item.type == "artefact")
return this.getItemSorted(["artefact"])
}
/* ----------------------- --------------------- */
getMonnaies() {
return this.items.filter(item => item.type == "monnaie")
}
/* -------------------------------------------- */
getArmors() {
return this.items.filter(item => item.type == "protection")
return this.getItemSorted(["protection"])
}
getHistoriques() {
return this.items.filter(item => item.type == "historique")
return this.getItemSorted(["historique"])
}
getProfils() {
return this.items.filter(item => item.type == "profil")
return this.getItemSorted(["profil"])
}
getTalents() {
return this.items.filter(item => item.type == "talent")
return this.getItemSorted(["talent"])
}
getRessources() {
return this.items.filter(item => item.type == "ressource")
return this.getItemSorted(["ressource"])
}
getContacts() {
return this.items.filter(item => item.type == "contact")
return this.getItemSorted(["contact"])
}
/* -------------------------------------------- */
getSkills() {
let comp = []
@ -167,17 +154,19 @@ export class HawkmoonActor 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;
HawkmoonUtility.sortArrayObjectsByName(comp)
return comp
}
if (fa > fb) {
return 1;
/* ----------------------- --------------------- */
addMember(actorId) {
let members = duplicate(this.system.members)
members.push({ id: actorId })
this.update({ 'system.members': members })
}
return 0;
})
async removeMember(actorId) {
let members = this.system.members.filter(it => it.id != actorId)
this.update({ 'system.members': members })
}
/* -------------------------------------------- */

View File

@ -61,6 +61,13 @@ export class HawkmoonUtility {
}
/* -------------------------------------------- */
static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => {
return a.name.localeCompare(b.name);
})
}
/* -------------------------------------------- */
static getModificateurOptions() {
let opt = []

View File

@ -1,7 +1,7 @@
{
"id": "fvtt-hawkmoon-cyd",
"description": "Hawkmoon RPG for FoundryVTT (CYD system - French)",
"version": "10.1.10",
"version": "10.1.11",
"authors": [
{
"name": "Uberwald/LeRatierBretonnien",
@ -35,7 +35,7 @@
"gridUnits": "m",
"license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.10.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.11.zip",
"languages": [
{
"lang": "fr",