|
|
|
@ -175,15 +175,15 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
async prepareData() {
|
|
|
|
|
if ( this.type == "personnage") {
|
|
|
|
|
this.computeCaracSecondaire();
|
|
|
|
|
if (this.data.data.furor.value == 0)
|
|
|
|
|
if (this.system.furor.value == 0)
|
|
|
|
|
await this.setEpuise();
|
|
|
|
|
else
|
|
|
|
|
await this.cleanEpuise();
|
|
|
|
|
if ( this.data.data.caracsecondaire.pv.value < (this.data.data.caracsecondaire.pv.max/4) )
|
|
|
|
|
if ( this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max/4) )
|
|
|
|
|
await this.setMeurtri();
|
|
|
|
|
else
|
|
|
|
|
await this.cleanMeurtri();
|
|
|
|
|
if ( this.data.data.caracsecondaire.pv.value < (this.data.data.caracsecondaire.pv.max/2) )
|
|
|
|
|
if ( this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max/2) )
|
|
|
|
|
await this.setBlesse();
|
|
|
|
|
else
|
|
|
|
|
await this.cleanBlesse();
|
|
|
|
@ -196,21 +196,21 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
if ( changed.data?.caracsecondaire?.pv?.value ) {
|
|
|
|
|
if ( changed.data.caracsecondaire.pv.value < 0 )
|
|
|
|
|
changed.data.caracsecondaire.pv.value = 0;
|
|
|
|
|
if ( changed.data.caracsecondaire.pv.value > this.data.data.caracsecondaire.pv.max )
|
|
|
|
|
changed.data.caracsecondaire.pv.value = this.data.data.caracsecondaire.pv.max;
|
|
|
|
|
if ( changed.data.caracsecondaire.pv.value > this.system.caracsecondaire.pv.max )
|
|
|
|
|
changed.data.caracsecondaire.pv.value = this.system.caracsecondaire.pv.max;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( changed.data?.furor?.value ) {
|
|
|
|
|
if ( changed.data.furor.value < 0 )
|
|
|
|
|
changed.data.furor.value = 0;
|
|
|
|
|
if ( changed.data.furor.value > this.data.data.furor.max )
|
|
|
|
|
changed.data.furor.value = this.data.data.furor.max;
|
|
|
|
|
if ( changed.data.furor.value > this.system.furor.max )
|
|
|
|
|
changed.data.furor.value = this.system.furor.max;
|
|
|
|
|
}
|
|
|
|
|
super._preUpdate(changed, options, user);
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getCompetences() {
|
|
|
|
|
let comp = this.data.items.filter( item => item.type == 'competence');
|
|
|
|
|
let comp = this.items.filter( item => item.type == 'competence');
|
|
|
|
|
return comp;
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
@ -226,95 +226,95 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getInitiativeScore() {
|
|
|
|
|
if ( this.type == 'personnage') {
|
|
|
|
|
return this.data.data.caracsecondaire.reaction.max;
|
|
|
|
|
return this.system.caracsecondaire.reaction.max;
|
|
|
|
|
} else {
|
|
|
|
|
return this.data.data.attributs.physique.values.defaut.value;
|
|
|
|
|
return this.system.attributs.physique.values.defaut.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getCompetencesGenerales() {
|
|
|
|
|
let comp = this.data.items.filter( item => item.type == 'competence' && item.data.data.categorie == 'generale');
|
|
|
|
|
let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'generale');
|
|
|
|
|
return comp.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getCompetencesMartiales() {
|
|
|
|
|
let comp = this.data.items.filter( item => item.type == 'competence' && item.data.data.categorie == 'martiale');
|
|
|
|
|
let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'martiale');
|
|
|
|
|
return comp.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getCompetencesMagiques() {
|
|
|
|
|
let comp = this.data.items.filter( item => item.type == 'competence' && item.data.data.categorie == 'magique');
|
|
|
|
|
let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'magique');
|
|
|
|
|
return comp.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getDons( ) {
|
|
|
|
|
let dons = this.data.items.filter( item => item.type == 'don');
|
|
|
|
|
let dons = this.items.filter( item => item.type == 'don');
|
|
|
|
|
return dons.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getEffetsMagiques( ) {
|
|
|
|
|
let effets = this.data.items.filter( item => item.type == 'effetmagique');
|
|
|
|
|
let effets = this.items.filter( item => item.type == 'effetmagique');
|
|
|
|
|
return effets.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getEffetsDeRunes( ) {
|
|
|
|
|
let effets = this.data.items.filter( item => item.type == 'effetderune');
|
|
|
|
|
let effets = this.items.filter( item => item.type == 'effetderune');
|
|
|
|
|
return effets.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getMonnaies( ) {
|
|
|
|
|
let monnaies = this.data.items.filter( item => item.type == 'monnaie');
|
|
|
|
|
let monnaies = this.items.filter( item => item.type == 'monnaie');
|
|
|
|
|
return monnaies.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getFaiblesses( ) {
|
|
|
|
|
let faib = this.data.items.filter( item => item.type == 'faiblesse');
|
|
|
|
|
let faib = this.items.filter( item => item.type == 'faiblesse');
|
|
|
|
|
return faib.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getBlessures( ) {
|
|
|
|
|
return this.data.items.filter( item => item.type == 'blessure');
|
|
|
|
|
return this.items.filter( item => item.type == 'blessure');
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getToutEquipements() {
|
|
|
|
|
return this.data.items.filter( item => item.type == 'equipement' || item.type == 'armure' || item.type == 'armecc' || item.type == 'armedist' || item.type == 'bouclier');
|
|
|
|
|
return this.items.filter( item => item.type == 'equipement' || item.type == 'armure' || item.type == 'armecc' || item.type == 'armedist' || item.type == 'bouclier');
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getArmes() {
|
|
|
|
|
return this.data.items.filter( item => (item.type == 'armecc' || item.type == 'armedist') && item.data.data.equipe );
|
|
|
|
|
return this.items.filter( item => (item.type == 'armecc' || item.type == 'armedist') && item.system.equipe );
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getArmures() {
|
|
|
|
|
return this.data.items.filter( item => item.type == 'armure' && item.data.data.equipe );
|
|
|
|
|
return this.items.filter( item => item.type == 'armure' && item.system.equipe );
|
|
|
|
|
}
|
|
|
|
|
getBoucliers() {
|
|
|
|
|
return this.data.items.filter( item => item.type == 'bouclier' && item.data.data.equipe );
|
|
|
|
|
return this.items.filter( item => item.type == 'bouclier' && item.system.equipe );
|
|
|
|
|
}
|
|
|
|
|
getProuessesMartiales() {
|
|
|
|
|
let prouesse = this.data.items.filter( item => item.type == 'prouesse' );
|
|
|
|
|
let prouesse = this.items.filter( item => item.type == 'prouesse' );
|
|
|
|
|
return prouesse.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
getSortsSejdr() {
|
|
|
|
|
let sort = this.data.items.filter( item => item.type == 'sortsejdr' );
|
|
|
|
|
let sort = this.items.filter( item => item.type == 'sortsejdr' );
|
|
|
|
|
return sort.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
getSortsGaldr() {
|
|
|
|
|
let sort = this.data.items.filter( item => item.type == 'sortgaldr' );
|
|
|
|
|
let sort = this.items.filter( item => item.type == 'sortgaldr' );
|
|
|
|
|
return sort.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
getRunes() {
|
|
|
|
|
let sort = this.data.items.filter( item => item.type == 'rune' );
|
|
|
|
|
let sort = this.items.filter( item => item.type == 'rune' );
|
|
|
|
|
return sort.sort( this.compareName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async setEpuise( ) {
|
|
|
|
|
if (!this.data.data.status.epuise) {
|
|
|
|
|
await this.update({ 'data.status.epuise': true});
|
|
|
|
|
this.data.data.status.epuise = true;
|
|
|
|
|
if (!this.system.status.epuise) {
|
|
|
|
|
await this.update({ 'system.status.epuise': true});
|
|
|
|
|
this.system.status.epuise = true;
|
|
|
|
|
}
|
|
|
|
|
/*let effect = this.getEffectByLabel('Epuisé');
|
|
|
|
|
if ( !effect ) {
|
|
|
|
@ -324,9 +324,9 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async cleanEpuise() {
|
|
|
|
|
if (this.data.data.status.epuise) {
|
|
|
|
|
await this.update({ 'data.status.epuise': false});
|
|
|
|
|
this.data.data.status.epuise = false;
|
|
|
|
|
if (this.system.status.epuise) {
|
|
|
|
|
await this.update({ 'system.status.epuise': false});
|
|
|
|
|
this.system.status.epuise = false;
|
|
|
|
|
}
|
|
|
|
|
/*let effect = this.getEffectByLabel('Epuisé');
|
|
|
|
|
if ( effect ) {
|
|
|
|
@ -335,7 +335,7 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async toggleEpuise( ) {
|
|
|
|
|
if ( this.data.data.status.epuise ) {
|
|
|
|
|
if ( this.system.status.epuise ) {
|
|
|
|
|
await this.cleanEpuise();
|
|
|
|
|
} else {
|
|
|
|
|
await this.setEpuise();
|
|
|
|
@ -343,14 +343,14 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
isEpuise() {
|
|
|
|
|
return this.data.data.status.epuise;
|
|
|
|
|
return this.system.status.epuise;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async setBlesse( ) {
|
|
|
|
|
if (!this.data.data.status.blesse) {
|
|
|
|
|
await this.update({ 'data.status.blesse': true} );
|
|
|
|
|
this.data.data.status.blesse = true;
|
|
|
|
|
if (!this.system.status.blesse) {
|
|
|
|
|
await this.update({ 'system.status.blesse': true} );
|
|
|
|
|
this.system.status.blesse = true;
|
|
|
|
|
}
|
|
|
|
|
/*let effect = this.getEffectByLabel('Blessé');
|
|
|
|
|
if ( !effect ) {
|
|
|
|
@ -360,9 +360,9 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async cleanBlesse() {
|
|
|
|
|
if (this.data.data.status.blesse) {
|
|
|
|
|
await this.update({ 'data.status.blesse': false} );
|
|
|
|
|
this.data.data.status.blesse = false;
|
|
|
|
|
if (this.system.status.blesse) {
|
|
|
|
|
await this.update({ 'system.status.blesse': false} );
|
|
|
|
|
this.system.status.blesse = false;
|
|
|
|
|
}
|
|
|
|
|
/*let effect = this.getEffectByLabel('Blessé');
|
|
|
|
|
if ( effect ) {
|
|
|
|
@ -372,37 +372,37 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
isBlesse() {
|
|
|
|
|
return this.data.data.status.blesse;
|
|
|
|
|
return this.system.status.blesse;
|
|
|
|
|
//return this.getEffectByLabel('Blessé');
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async setMeurtri( ) {
|
|
|
|
|
await this.setBlesse();
|
|
|
|
|
if (!this.data.data.status.meurtri) {
|
|
|
|
|
await this.update({ 'data.status.meurtri': true});
|
|
|
|
|
this.data.data.status.meurtri = true;
|
|
|
|
|
if (!this.system.status.meurtri) {
|
|
|
|
|
await this.update({ 'system.status.meurtri': true});
|
|
|
|
|
this.system.status.meurtri = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async cleanMeurtri() {
|
|
|
|
|
if (this.data.data.status.meurtri) {
|
|
|
|
|
await this.update({ 'data.status.meurtri': false});
|
|
|
|
|
this.data.data.status.meurtri = false;
|
|
|
|
|
if (this.system.status.meurtri) {
|
|
|
|
|
await this.update({ 'system.status.meurtri': false});
|
|
|
|
|
this.system.status.meurtri = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
isMeurtri() {
|
|
|
|
|
return this.data.data.status.meurtri;
|
|
|
|
|
return this.system.status.meurtri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async decrementFuror( nbFuror) {
|
|
|
|
|
await this.update( { 'data.furor.value': this.data.data.furor.value - nbFuror } );
|
|
|
|
|
await this.update( { 'system.furor.value': this.system.furor.value - nbFuror } );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getCurrentFuror() {
|
|
|
|
|
return this.data.data.furor.value;
|
|
|
|
|
return this.system.furor.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
@ -421,8 +421,8 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getCarac( caracName ) {
|
|
|
|
|
for( let key in this.data.data.carac) {
|
|
|
|
|
let categ = this.data.data.carac[key];
|
|
|
|
|
for( let key in this.system.carac) {
|
|
|
|
|
let categ = this.system.carac[key];
|
|
|
|
|
for( let carac in categ.carac) {
|
|
|
|
|
if (carac.toLowerCase() == caracName.toLowerCase() ) {
|
|
|
|
|
return deepClone(categ.carac[carac]);
|
|
|
|
@ -434,50 +434,50 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
computeCaracSecondaire( ) {
|
|
|
|
|
if ( this.type == "personnage") {
|
|
|
|
|
let basecorps = this.data.data.carac.corps.carac;
|
|
|
|
|
let basecorps = this.system.carac.corps.carac;
|
|
|
|
|
let sumcorps = basecorps.puissance.value + basecorps.agilite.value + basecorps.vigueur.value
|
|
|
|
|
let baseesprit = this.data.data.carac.esprit.carac;
|
|
|
|
|
let baseesprit = this.system.carac.esprit.carac;
|
|
|
|
|
let sumesprit = baseesprit.intellect.value + baseesprit.perception.value + baseesprit.tenacite.value
|
|
|
|
|
let baseame = this.data.data.carac.ame.carac;
|
|
|
|
|
let baseame = this.system.carac.ame.carac;
|
|
|
|
|
let sumame = baseame.charisme.value + baseame.communication.value + baseame.instinct.value
|
|
|
|
|
|
|
|
|
|
let newPV = (sumcorps*3) + (sumesprit *2) + sumame;
|
|
|
|
|
if ( newPV != this.data.data.caracsecondaire.pv.max) {
|
|
|
|
|
this.data.data.caracsecondaire.pv.max = newPV;
|
|
|
|
|
this.update( { 'data.caracsecondaire.pv.max': newPV });
|
|
|
|
|
if ( newPV != this.system.caracsecondaire.pv.max) {
|
|
|
|
|
this.system.caracsecondaire.pv.max = newPV;
|
|
|
|
|
this.update( { 'system.caracsecondaire.pv.max': newPV });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.data.data.caracsecondaire.reaction.value = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value;
|
|
|
|
|
this.data.data.caracsecondaire.reaction.max = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value;
|
|
|
|
|
this.system.caracsecondaire.reaction.value = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value;
|
|
|
|
|
this.system.caracsecondaire.reaction.max = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value;
|
|
|
|
|
|
|
|
|
|
this.data.data.caracsecondaire.defensephy.value = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value;
|
|
|
|
|
this.data.data.caracsecondaire.defensephy.max = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value;
|
|
|
|
|
this.system.caracsecondaire.defensephy.value = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value;
|
|
|
|
|
this.system.caracsecondaire.defensephy.max = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value;
|
|
|
|
|
|
|
|
|
|
this.data.data.caracsecondaire.defensemen.value = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value;
|
|
|
|
|
this.data.data.caracsecondaire.defensemen.max = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value;
|
|
|
|
|
this.system.caracsecondaire.defensemen.value = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value;
|
|
|
|
|
this.system.caracsecondaire.defensemen.max = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value;
|
|
|
|
|
|
|
|
|
|
this.data.data.caracsecondaire.deplacement.value = basecorps.agilite.value + basecorps.vigueur.value;
|
|
|
|
|
this.data.data.caracsecondaire.deplacement.max = basecorps.agilite.value + basecorps.vigueur.value;
|
|
|
|
|
this.system.caracsecondaire.deplacement.value = basecorps.agilite.value + basecorps.vigueur.value;
|
|
|
|
|
this.system.caracsecondaire.deplacement.max = basecorps.agilite.value + basecorps.vigueur.value;
|
|
|
|
|
|
|
|
|
|
this.data.data.caracsecondaire.capaenc.value = (basecorps.puissance.value * 2) + basecorps.vigueur.value;
|
|
|
|
|
this.data.data.caracsecondaire.capaenc.max = (basecorps.puissance.value * 2) + basecorps.vigueur.value;
|
|
|
|
|
this.system.caracsecondaire.capaenc.value = (basecorps.puissance.value * 2) + basecorps.vigueur.value;
|
|
|
|
|
this.system.caracsecondaire.capaenc.max = (basecorps.puissance.value * 2) + basecorps.vigueur.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async equiperObject( equipementId ) {
|
|
|
|
|
let item = this.data.items.find( item => item.id == equipementId );
|
|
|
|
|
if (item && item.data.data) {
|
|
|
|
|
let update = { _id: item.id, "data.equipe": !item.data.data.equipe };
|
|
|
|
|
let item = this.items.find( item => item.id == equipementId );
|
|
|
|
|
if (item && item.system) {
|
|
|
|
|
let update = { _id: item.id, "data.equipe": !item.system.equipe };
|
|
|
|
|
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async updateCompetence( compId, niveau) {
|
|
|
|
|
let comp = this.data.items.find( item => item.type == 'competence' && item.id == compId);
|
|
|
|
|
let comp = this.items.find( item => item.type == 'competence' && item.id == compId);
|
|
|
|
|
console.log("Comp updated!!!!", compId, niveau);
|
|
|
|
|
if (comp) {
|
|
|
|
|
const update = { _id: comp.id, 'data.niveau': niveau };
|
|
|
|
|
const update = { _id: comp.id, 'system.niveau': niveau };
|
|
|
|
|
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
|
|
|
|
} else {
|
|
|
|
|
ui.notifications.warn("Compétence inconnue", compId)
|
|
|
|
@ -491,9 +491,9 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async rollAttribute( attrkey, subAttrKey = 'defaut') {
|
|
|
|
|
let attr = duplicate(this.data.data.attributs[attrkey]);
|
|
|
|
|
let attr = duplicate(this.system.attributs[attrkey]);
|
|
|
|
|
console.log("ATTR : ", attr, attrkey, subAttrKey);
|
|
|
|
|
let subAttr = duplicate(this.data.data.attributs[attrkey].values[subAttrKey] );
|
|
|
|
|
let subAttr = duplicate(this.system.attributs[attrkey].values[subAttrKey] );
|
|
|
|
|
if ( attr ) {
|
|
|
|
|
subAttr.label = subAttr.label || "";
|
|
|
|
|
let title = `Attribut : ${attr.label} ${subAttr.label} : ${subAttr.value}`;
|
|
|
|
@ -503,11 +503,11 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
actorImg: this.img,
|
|
|
|
|
actorId: this.id,
|
|
|
|
|
attr: attr,
|
|
|
|
|
valuePhysique: this.data.data.attributs["physique"].values["defaut"].value,
|
|
|
|
|
valuePhysique: this.system.attributs["physique"].values["defaut"].value,
|
|
|
|
|
subAttr: subAttr,
|
|
|
|
|
rollMode: game.settings.get("core", "rollMode"),
|
|
|
|
|
title: title,
|
|
|
|
|
isBlesse: this.data.data.etat.etat == "blesse",
|
|
|
|
|
isBlesse: this.system.etat.etat == "blesse",
|
|
|
|
|
optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15),
|
|
|
|
|
bonusMalus: 0,
|
|
|
|
|
bonusdefense: 0,
|
|
|
|
@ -525,8 +525,8 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async rollCarac( categName, caracName) {
|
|
|
|
|
let carac = duplicate(this.data.data.carac[categName].carac[caracName]);
|
|
|
|
|
console.log("CARAC : ", carac, this.data.data.carac);
|
|
|
|
|
let carac = duplicate(this.system.carac[categName].carac[caracName]);
|
|
|
|
|
console.log("CARAC : ", carac, this.system.carac);
|
|
|
|
|
if ( carac) {
|
|
|
|
|
let rollData = {
|
|
|
|
|
mode: "carac",
|
|
|
|
@ -559,7 +559,7 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async rollCompetence( competenceId ) {
|
|
|
|
|
let competence = this.data.items.find( item => item.type == 'competence' && item.id == competenceId);
|
|
|
|
|
let competence = this.items.find( item => item.type == 'competence' && item.id == competenceId);
|
|
|
|
|
if ( competence) {
|
|
|
|
|
let rollData = {
|
|
|
|
|
mode: "competence",
|
|
|
|
@ -568,7 +568,7 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
actorId: this.id,
|
|
|
|
|
img: competence.img,
|
|
|
|
|
rollMode: game.settings.get("core", "rollMode"),
|
|
|
|
|
title: `Compétence ${competence.name} : ${competence.data.data.niveau}`,
|
|
|
|
|
title: `Compétence ${competence.name} : ${competence.system.niveau}`,
|
|
|
|
|
competence: duplicate(competence),
|
|
|
|
|
isEpuise: this.isEpuise(),
|
|
|
|
|
isBlesse: this.isBlesse(),
|
|
|
|
@ -593,18 +593,18 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
let attackData = duplicate(attackMode[mode]);
|
|
|
|
|
if ( attackData){
|
|
|
|
|
attackData.mode = mode;
|
|
|
|
|
attackData.carac = duplicate(this.data.data.carac[attackData.categName].carac[attackData.caracName]);
|
|
|
|
|
attackData.carac = duplicate(this.system.carac[attackData.categName].carac[attackData.caracName]);
|
|
|
|
|
if ( attackData.malus != 0) {
|
|
|
|
|
let malusTab = attackData.malus.split(';');
|
|
|
|
|
attackData.malus = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
attackData.malus = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
}
|
|
|
|
|
if ( attackData.protection != 0) {
|
|
|
|
|
let malusTab = attackData.protection.split(';');
|
|
|
|
|
attackData.protection = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
attackData.protection = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
}
|
|
|
|
|
if ( attackData.bonusdegats != 0) {
|
|
|
|
|
let malusTab = attackData.bonusdegats.split(';');
|
|
|
|
|
attackData.bonusdegats = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
attackData.bonusdegats = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return attackData;
|
|
|
|
@ -615,18 +615,18 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
let attackData = duplicate( tirMode[mode] );
|
|
|
|
|
if ( attackData){
|
|
|
|
|
attackData.mode = mode;
|
|
|
|
|
attackData.carac = duplicate(this.data.data.carac[attackData.categName].carac[attackData.caracName]);
|
|
|
|
|
attackData.carac = duplicate(this.system.carac[attackData.categName].carac[attackData.caracName]);
|
|
|
|
|
if ( attackData.malus != 0) {
|
|
|
|
|
let malusTab = attackData.malus.split(';');
|
|
|
|
|
attackData.malus = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
attackData.malus = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
}
|
|
|
|
|
if ( attackData.protection != 0) {
|
|
|
|
|
let malusTab = attackData.protection.split(';');
|
|
|
|
|
attackData.protection = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
attackData.protection = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
}
|
|
|
|
|
if ( attackData.bonusdegats != 0) {
|
|
|
|
|
let malusTab = attackData.bonusdegats.split(';');
|
|
|
|
|
attackData.bonusdegats = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
attackData.bonusdegats = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return attackData;
|
|
|
|
@ -634,17 +634,17 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async rollSort( sortId, magie) {
|
|
|
|
|
let sort = this.data.items.find( item => item.id == sortId);
|
|
|
|
|
let competence = this.data.items.find( item => item.type == 'competence' && item.name.toLowerCase().includes(magie));
|
|
|
|
|
let sort = this.items.find( item => item.id == sortId);
|
|
|
|
|
let competence = this.items.find( item => item.type == 'competence' && item.name.toLowerCase().includes(magie));
|
|
|
|
|
console.log("SORT :", sortId, sort, competence );
|
|
|
|
|
|
|
|
|
|
let carac;
|
|
|
|
|
if ( magie == "sejdr") {
|
|
|
|
|
carac = duplicate(this.data.data.carac.ame.carac.instinct);
|
|
|
|
|
carac = duplicate(this.system.carac.ame.carac.instinct);
|
|
|
|
|
} else if ( magie == "rune") {
|
|
|
|
|
carac = duplicate(this.data.data.carac.ame.carac.communication);
|
|
|
|
|
carac = duplicate(this.system.carac.ame.carac.communication);
|
|
|
|
|
} else {
|
|
|
|
|
carac = duplicate(this.data.data.carac.ame.carac.charisme);
|
|
|
|
|
carac = duplicate(this.system.carac.ame.carac.charisme);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( sort && competence) {
|
|
|
|
@ -659,8 +659,8 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
rollMode: game.settings.get("core", "rollMode"),
|
|
|
|
|
title: magie + " - " + sort.name,
|
|
|
|
|
selectedCarac: carac,
|
|
|
|
|
agiliteCarac: duplicate(this.data.data.carac.corps.carac.agilite),
|
|
|
|
|
instinctCarac: duplicate(this.data.data.carac.ame.carac.instinct),
|
|
|
|
|
agiliteCarac: duplicate(this.system.carac.corps.carac.agilite),
|
|
|
|
|
instinctCarac: duplicate(this.system.carac.ame.carac.instinct),
|
|
|
|
|
sort: duplicate(sort),
|
|
|
|
|
competence: duplicate(competence),
|
|
|
|
|
dureeGaldr: "1d5a",
|
|
|
|
@ -691,9 +691,9 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async rollArme( armeId ) {
|
|
|
|
|
let arme = this.data.items.find( item => item.id == armeId);
|
|
|
|
|
let compName = armeCategorieToCompetence[arme.data.data.categorie];
|
|
|
|
|
let competence = this.data.items.find( item => item.type == 'competence' && item.name == compName);
|
|
|
|
|
let arme = this.items.find( item => item.id == armeId);
|
|
|
|
|
let compName = armeCategorieToCompetence[arme.system.categorie];
|
|
|
|
|
let competence = this.items.find( item => item.type == 'competence' && item.name == compName);
|
|
|
|
|
console.log("ARME :", armeId, arme, competence );
|
|
|
|
|
|
|
|
|
|
if ( arme && competence) {
|
|
|
|
@ -714,7 +714,7 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
img: competence.img,
|
|
|
|
|
rollMode: game.settings.get("core", "rollMode"),
|
|
|
|
|
title: "Attaque !",
|
|
|
|
|
selectedCarac: duplicate(this.data.data.carac.corps.carac.agilite),
|
|
|
|
|
selectedCarac: duplicate(this.system.carac.corps.carac.agilite),
|
|
|
|
|
arme: duplicate(arme),
|
|
|
|
|
competence: duplicate(competence),
|
|
|
|
|
bonusdefense: 0,
|
|
|
|
@ -740,16 +740,16 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getEncTotal( ) {
|
|
|
|
|
let encTotal = 0;
|
|
|
|
|
for( let item of this.data.items) {
|
|
|
|
|
for( let item of this.items) {
|
|
|
|
|
if (item.type == "equipement" || item.type == "armecc"
|
|
|
|
|
|| item.type == "armedist" || item.type == "armure" || item.type == "monnaie" || item.type == "bouclier") {
|
|
|
|
|
encTotal += (item.data.data.enc * item.data.data.quantite);
|
|
|
|
|
encTotal += (item.system.enc * item.system.quantite);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for( let item of this.data.items) {
|
|
|
|
|
if (item.type == "bouclier" && item.data.data.equipe) {
|
|
|
|
|
encTotal -= (item.data.data.enc * item.data.data.quantite);
|
|
|
|
|
encTotal += (item.data.data.enccomb * item.data.data.quantite);
|
|
|
|
|
for( let item of this.items) {
|
|
|
|
|
if (item.type == "bouclier" && item.system.equipe) {
|
|
|
|
|
encTotal -= (item.system.enc * item.system.quantite);
|
|
|
|
|
encTotal += (item.system.enccomb * item.system.quantite);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return encTotal;
|
|
|
|
@ -758,9 +758,9 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getProtectionTotal( ) {
|
|
|
|
|
let protectionTotal = 0;
|
|
|
|
|
for( let item of this.data.items) {
|
|
|
|
|
if (item.type == "armure" && item.data.data.equipe) {
|
|
|
|
|
protectionTotal += Number(item.data.data.protection);
|
|
|
|
|
for( let item of this.items) {
|
|
|
|
|
if (item.type == "armure" && item.system.equipe) {
|
|
|
|
|
protectionTotal += Number(item.system.protection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return protectionTotal;
|
|
|
|
@ -768,9 +768,9 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getDpBouclier( ) {
|
|
|
|
|
let dpBouclier = 0;
|
|
|
|
|
for( let item of this.data.items) {
|
|
|
|
|
if (item.type == "bouclier" && item.data.data.equipe) {
|
|
|
|
|
dpBouclier += Number(item.data.data.defensebonus);
|
|
|
|
|
for( let item of this.items) {
|
|
|
|
|
if (item.type == "bouclier" && item.system.equipe) {
|
|
|
|
|
dpBouclier += Number(item.system.defensebonus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dpBouclier;
|
|
|
|
@ -778,20 +778,20 @@ export class YggdrasillActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async incrementeQuantite( objetId ) {
|
|
|
|
|
let objetQ = this.data.items.find( item => item.id == objetId );
|
|
|
|
|
let objetQ = this.items.find( item => item.id == objetId );
|
|
|
|
|
if (objetQ) {
|
|
|
|
|
let newQ = objetQ.data.data.quantite + 1;
|
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantite': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
|
let newQ = objetQ.system.quantite + 1;
|
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async decrementeQuantite( objetId ) {
|
|
|
|
|
let objetQ = this.data.items.find( item => item.id == objetId );
|
|
|
|
|
let objetQ = this.items.find( item => item.id == objetId );
|
|
|
|
|
if (objetQ) {
|
|
|
|
|
let newQ = objetQ.data.data.quantite - 1;
|
|
|
|
|
let newQ = objetQ.system.quantite - 1;
|
|
|
|
|
newQ = (newQ <= 0) ? 0 : newQ;
|
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantite': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|