Alpha sort
This commit is contained in:
parent
22ae4fb588
commit
0e5be07fb9
@ -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() {
|
getWeapons() {
|
||||||
let armes = []
|
let armes = []
|
||||||
for (let arme of this.items) {
|
for (let arme of this.items) {
|
||||||
@ -98,55 +103,37 @@ export class HawkmoonActor extends Actor {
|
|||||||
armes.push(this.prepareArme(arme))
|
armes.push(this.prepareArme(arme))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HawkmoonUtility.sortArrayObjectsByName(armes)
|
||||||
return armes
|
return armes
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
|
||||||
getMonnaies() {
|
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() {
|
getEquipments() {
|
||||||
return this.items.filter(item => item.type == "equipement")
|
return this.getItemSorted(["equipement"])
|
||||||
}
|
}
|
||||||
/* ----------------------- --------------------- */
|
|
||||||
getArtefacts() {
|
getArtefacts() {
|
||||||
return this.items.filter(item => item.type == "artefact")
|
return this.getItemSorted(["artefact"])
|
||||||
}
|
}
|
||||||
/* ----------------------- --------------------- */
|
|
||||||
getMonnaies() {
|
|
||||||
return this.items.filter(item => item.type == "monnaie")
|
|
||||||
}
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
getArmors() {
|
getArmors() {
|
||||||
return this.items.filter(item => item.type == "protection")
|
return this.getItemSorted(["protection"])
|
||||||
}
|
}
|
||||||
getHistoriques() {
|
getHistoriques() {
|
||||||
return this.items.filter(item => item.type == "historique")
|
return this.getItemSorted(["historique"])
|
||||||
}
|
}
|
||||||
getProfils() {
|
getProfils() {
|
||||||
return this.items.filter(item => item.type == "profil")
|
return this.getItemSorted(["profil"])
|
||||||
}
|
}
|
||||||
getTalents() {
|
getTalents() {
|
||||||
return this.items.filter(item => item.type == "talent")
|
return this.getItemSorted(["talent"])
|
||||||
}
|
}
|
||||||
getRessources() {
|
getRessources() {
|
||||||
return this.items.filter(item => item.type == "ressource")
|
return this.getItemSorted(["ressource"])
|
||||||
}
|
}
|
||||||
getContacts() {
|
getContacts() {
|
||||||
return this.items.filter(item => item.type == "contact")
|
return this.getItemSorted(["contact"])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSkills() {
|
getSkills() {
|
||||||
let comp = []
|
let comp = []
|
||||||
@ -167,17 +154,19 @@ export class HawkmoonActor extends Actor {
|
|||||||
comp.push(item)
|
comp.push(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return comp.sort(function (a, b) {
|
HawkmoonUtility.sortArrayObjectsByName(comp)
|
||||||
let fa = a.name.toLowerCase(),
|
return comp
|
||||||
fb = b.name.toLowerCase();
|
|
||||||
if (fa < fb) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
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 })
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -61,6 +61,13 @@ export class HawkmoonUtility {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static sortArrayObjectsByName(myArray) {
|
||||||
|
myArray.sort((a, b) => {
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getModificateurOptions() {
|
static getModificateurOptions() {
|
||||||
let opt = []
|
let opt = []
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "fvtt-hawkmoon-cyd",
|
"id": "fvtt-hawkmoon-cyd",
|
||||||
"description": "Hawkmoon RPG for FoundryVTT (CYD system - French)",
|
"description": "Hawkmoon RPG for FoundryVTT (CYD system - French)",
|
||||||
"version": "10.1.10",
|
"version": "10.1.11",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Uberwald/LeRatierBretonnien",
|
"name": "Uberwald/LeRatierBretonnien",
|
||||||
@ -35,7 +35,7 @@
|
|||||||
"gridUnits": "m",
|
"gridUnits": "m",
|
||||||
"license": "LICENSE.txt",
|
"license": "LICENSE.txt",
|
||||||
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json",
|
"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": [
|
"languages": [
|
||||||
{
|
{
|
||||||
"lang": "fr",
|
"lang": "fr",
|
||||||
|
Loading…
Reference in New Issue
Block a user