Preparation fiche perso
This commit is contained in:
@ -97,6 +97,56 @@ export class TeDeumActor extends Actor {
|
||||
TeDeumUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateCarac(c, key) {
|
||||
c.name = game.system.tedeum.config.caracteristiques[key].label
|
||||
c.generalqualite = game.system.tedeum.config.descriptionValeur[c.value].qualite
|
||||
c.qualite = game.system.tedeum.config.descriptionValeur[c.value][key]
|
||||
c.dice = game.system.tedeum.config.descriptionValeur[c.value].dice
|
||||
c.negativeDice = game.system.tedeum.config.descriptionValeur[c.value].negativeDice
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareCaracteristiques() {
|
||||
let carac = foundry.utils.deepClone(this.system.caracteristiques)
|
||||
for (let key in carac) {
|
||||
let c = carac[key]
|
||||
this.updateCarac(c, key)
|
||||
}
|
||||
return carac
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
prepareProvidence() {
|
||||
let providence = foundry.utils.deepClone(this.system.providence)
|
||||
providence.name = "Providence"
|
||||
providence.qualite = game.system.tedeum.config.providence[providence.value].labelM
|
||||
providence.dice = game.system.tedeum.config.providence[providence.value].diceValue
|
||||
return providence
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
filterCompetencesByCarac(key) {
|
||||
let comp = this.items.filter(item => item.type == 'competence' && item.system.caracteristique == key)
|
||||
comp.forEach(c => {
|
||||
if (c.system.isBase) {
|
||||
c.system.score = this.system.caracteristiques[c.system.caracteristique].value
|
||||
}
|
||||
})
|
||||
return foundry.utils.deepClone( comp || {} )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareArbreCompetences() {
|
||||
let arbre = foundry.utils.deepClone(this.system.caracteristiques)
|
||||
for (let key in arbre) {
|
||||
let c = arbre[key]
|
||||
this.updateCarac(c, key)
|
||||
c.competences = this.filterCompetencesByCarac(key)
|
||||
}
|
||||
return arbre
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.items.find(item => item.id == id);
|
||||
@ -193,31 +243,6 @@ export class TeDeumActor extends Actor {
|
||||
return init + (subValue.total / 100)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSubActors() {
|
||||
let subActors = [];
|
||||
for (let id of this.system.subactors) {
|
||||
subActors.push(duplicate(game.actors.get(id)))
|
||||
}
|
||||
return subActors;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addSubActor(subActorId) {
|
||||
let subActors = duplicate(this.system.subactors);
|
||||
subActors.push(subActorId);
|
||||
await this.update({ 'system.subactors': subActors });
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async delSubActor(subActorId) {
|
||||
let newArray = [];
|
||||
for (let id of this.system.subactors) {
|
||||
if (id != subActorId) {
|
||||
newArray.push(id);
|
||||
}
|
||||
}
|
||||
await this.update({ 'system.subactors': newArray });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async deleteAllItemsByType(itemType) {
|
||||
let items = this.items.filter(item => item.type == itemType);
|
||||
|
Reference in New Issue
Block a user