Foundryv14 migration
This commit is contained in:
@@ -8,120 +8,122 @@ const statusEffects = [
|
||||
{ yggdrasill: true, id: 'blesse', label: 'Blessé', icon: 'icons/svg/blood.svg' },
|
||||
{ yggdrasill: true, id: 'meurtri', label: 'Meurtri', icon: 'icons/svg/falling.svg' }
|
||||
]
|
||||
const armeCategorieToCompetence = { "lutte": "Lutte", "improvisee": "Armes Improvisées", "courte":"Armes courtes", "longue": "Armes longues", "deuxmains": "Armes à deux mains",
|
||||
"hast": "Armes d'Hast", "tir": "Armes de tir", "jet": "Lancer" }
|
||||
const attackMode = {
|
||||
"classique": {
|
||||
"categName": "corps",
|
||||
"caracName": "agilite",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": 0,
|
||||
"label": "Attaque Classique",
|
||||
"description": "Attaque classique"
|
||||
},
|
||||
"force": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": "puissance;1",
|
||||
"label": "Attaque en Force",
|
||||
"description": "Attaque en Force : Malus: 0, +PUI en dégats"
|
||||
},
|
||||
"devastatrice": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": "puissance;1",
|
||||
"bonusdegats": "puissance;3",
|
||||
"protection": 0,
|
||||
"label": "Attaque Dévastatrice",
|
||||
"description": "Attaque Dévastratrice : Malus -PUI, +PUI*3 en dégats"
|
||||
},
|
||||
"precise": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "0",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;1",
|
||||
"label": "Attaque Précise",
|
||||
"description": "Attaque précise : Malus : 0, protection réduite de -PER"
|
||||
},
|
||||
"visee": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "perception;1",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;3",
|
||||
"label": "Attaque Visée",
|
||||
"description": "Attaque visée : Malus : -PER, protection réduite de -PER"
|
||||
}
|
||||
const armeCategorieToCompetence = {
|
||||
"lutte": "Lutte", "improvisee": "Armes Improvisées", "courte": "Armes courtes", "longue": "Armes longues", "deuxmains": "Armes à deux mains",
|
||||
"hast": "Armes d'Hast", "tir": "Armes de tir", "jet": "Lancer"
|
||||
}
|
||||
const attackMode = {
|
||||
"classique": {
|
||||
"categName": "corps",
|
||||
"caracName": "agilite",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": 0,
|
||||
"label": "Attaque Classique",
|
||||
"description": "Attaque classique"
|
||||
},
|
||||
"force": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": "puissance;1",
|
||||
"label": "Attaque en Force",
|
||||
"description": "Attaque en Force : Malus: 0, +PUI en dégats"
|
||||
},
|
||||
"devastatrice": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": "puissance;1",
|
||||
"bonusdegats": "puissance;3",
|
||||
"protection": 0,
|
||||
"label": "Attaque Dévastatrice",
|
||||
"description": "Attaque Dévastratrice : Malus -PUI, +PUI*3 en dégats"
|
||||
},
|
||||
"precise": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "0",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;1",
|
||||
"label": "Attaque Précise",
|
||||
"description": "Attaque précise : Malus : 0, protection réduite de -PER"
|
||||
},
|
||||
"visee": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "perception;1",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;3",
|
||||
"label": "Attaque Visée",
|
||||
"description": "Attaque visée : Malus : -PER, protection réduite de -PER"
|
||||
}
|
||||
const tirMode = {
|
||||
"pose": {
|
||||
"categName": "corps",
|
||||
"caracName": "agilite",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": 0,
|
||||
"label": "Tir posé",
|
||||
"description": "Tir posé"
|
||||
},
|
||||
"arrettir": {
|
||||
"categName": "ame",
|
||||
"caracName": "instinct",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": "instinct;1",
|
||||
"label": "Tir d'Arrêt (Tir)",
|
||||
"description": "Tir d'Arrêt (Tir) : Malus: 0, +INS en dégats"
|
||||
},
|
||||
"arretjet": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": "puissance;1",
|
||||
"label": "Tir d'Arrêt (Jet)",
|
||||
"description": "Tir d'Arrêt (Jet) : Malus: 0, +PUI en dégats"
|
||||
},
|
||||
"impacttir": {
|
||||
"categName": "ame",
|
||||
"caracName": "instinct",
|
||||
"malus": "instinct;1",
|
||||
"protection": 0,
|
||||
"bonusdegats": "instinct;3",
|
||||
"label": "Tir d'Impact (Tir)",
|
||||
"description": "Tir d'Impact (Tir) : Malus: -INS, +INS*3 en dégats"
|
||||
},
|
||||
"impactjet": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": "puissance;1",
|
||||
"protection": 0,
|
||||
"bonusdegats": "puissance;3",
|
||||
"label": "Attaque d'Impact (Jet)",
|
||||
"description": "Attaque d'Impact (Jet) : Malus: -PUI, +PUI*3 en dégats"
|
||||
},
|
||||
"precision": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "0",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;1",
|
||||
"label": "Tir de Précision",
|
||||
"description": "Tir de Précision : Malus : 0, protection réduite de -PER"
|
||||
},
|
||||
"vise": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "perception;1",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;3",
|
||||
"label": "Tir Visée",
|
||||
"description": "Tir visée : Malus : -PER, protection réduite de -PER"
|
||||
}
|
||||
}
|
||||
const tirMode = {
|
||||
"pose": {
|
||||
"categName": "corps",
|
||||
"caracName": "agilite",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": 0,
|
||||
"label": "Tir posé",
|
||||
"description": "Tir posé"
|
||||
},
|
||||
"arrettir": {
|
||||
"categName": "ame",
|
||||
"caracName": "instinct",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": "instinct;1",
|
||||
"label": "Tir d'Arrêt (Tir)",
|
||||
"description": "Tir d'Arrêt (Tir) : Malus: 0, +INS en dégats"
|
||||
},
|
||||
"arretjet": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": 0,
|
||||
"protection": 0,
|
||||
"bonusdegats": "puissance;1",
|
||||
"label": "Tir d'Arrêt (Jet)",
|
||||
"description": "Tir d'Arrêt (Jet) : Malus: 0, +PUI en dégats"
|
||||
},
|
||||
"impacttir": {
|
||||
"categName": "ame",
|
||||
"caracName": "instinct",
|
||||
"malus": "instinct;1",
|
||||
"protection": 0,
|
||||
"bonusdegats": "instinct;3",
|
||||
"label": "Tir d'Impact (Tir)",
|
||||
"description": "Tir d'Impact (Tir) : Malus: -INS, +INS*3 en dégats"
|
||||
},
|
||||
"impactjet": {
|
||||
"categName": "corps",
|
||||
"caracName": "puissance",
|
||||
"malus": "puissance;1",
|
||||
"protection": 0,
|
||||
"bonusdegats": "puissance;3",
|
||||
"label": "Attaque d'Impact (Jet)",
|
||||
"description": "Attaque d'Impact (Jet) : Malus: -PUI, +PUI*3 en dégats"
|
||||
},
|
||||
"precision": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "0",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;1",
|
||||
"label": "Tir de Précision",
|
||||
"description": "Tir de Précision : Malus : 0, protection réduite de -PER"
|
||||
},
|
||||
"vise": {
|
||||
"categName": "esprit",
|
||||
"caracName": "perception",
|
||||
"malus": "perception;1",
|
||||
"bonusdegats": 0,
|
||||
"protection": "perception;3",
|
||||
"label": "Tir Visée",
|
||||
"description": "Tir visée : Malus : -PER, protection réduite de -PER"
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -------------------------------------------- */
|
||||
@@ -135,8 +137,8 @@ export class YggdrasillActor extends Actor {
|
||||
/**
|
||||
* Override the create() function to provide additional SoS functionality.
|
||||
*
|
||||
* This overrided create() function adds initial items
|
||||
* Namely: Basic skills, money,
|
||||
* This overrided create() function adds initial items
|
||||
* Namely: Basic skills, money,
|
||||
*
|
||||
* @param {Object} data Barebones actor data which this function adds onto.
|
||||
* @param {Object} options (Unused) Additional options which customize the creation workflow.
|
||||
@@ -163,29 +165,32 @@ export class YggdrasillActor extends Actor {
|
||||
|
||||
return super.create(data, options);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareBaseData() {
|
||||
if ( this.type == "personnage") {
|
||||
if (game.release.generation >= 14) {
|
||||
super.prepareBaseData();
|
||||
}
|
||||
if (this.type == "personnage") {
|
||||
this.computeCaracSecondaire();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async prepareData() {
|
||||
if ( this.type == "personnage") {
|
||||
if (this.type == "personnage") {
|
||||
this.computeCaracSecondaire();
|
||||
if (this.system.furor.value == 0)
|
||||
if (this.system.furor.value == 0)
|
||||
await this.setEpuise();
|
||||
else
|
||||
else
|
||||
await this.cleanEpuise();
|
||||
if ( this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max/4) )
|
||||
if (this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max / 4))
|
||||
await this.setMeurtri();
|
||||
else
|
||||
else
|
||||
await this.cleanMeurtri();
|
||||
if ( this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max/2) )
|
||||
if (this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max / 2))
|
||||
await this.setBlesse();
|
||||
else
|
||||
else
|
||||
await this.cleanBlesse();
|
||||
}
|
||||
super.prepareData();
|
||||
@@ -193,39 +198,39 @@ export class YggdrasillActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_preUpdate(changed, options, user) {
|
||||
if ( changed.system?.caracsecondaire?.pv?.value ) {
|
||||
if ( changed.system.caracsecondaire.pv.value < 0 )
|
||||
if (changed.system?.caracsecondaire?.pv?.value) {
|
||||
if (changed.system.caracsecondaire.pv.value < 0)
|
||||
changed.system.caracsecondaire.pv.value = 0;
|
||||
if ( changed.system.caracsecondaire.pv.value > this.system.caracsecondaire.pv.max )
|
||||
changed.system.caracsecondaire.pv.value = this.system.caracsecondaire.pv.max;
|
||||
if (changed.system.caracsecondaire.pv.value > this.system.caracsecondaire.pv.max)
|
||||
changed.system.caracsecondaire.pv.value = this.system.caracsecondaire.pv.max;
|
||||
}
|
||||
|
||||
if ( changed.system?.furor?.value ) {
|
||||
if ( changed.system.furor.value < 0 )
|
||||
|
||||
if (changed.system?.furor?.value) {
|
||||
if (changed.system.furor.value < 0)
|
||||
changed.system.furor.value = 0;
|
||||
if ( changed.system.furor.value > this.system.furor.max )
|
||||
if (changed.system.furor.value > this.system.furor.max)
|
||||
changed.system.furor.value = this.system.furor.max;
|
||||
}
|
||||
super._preUpdate(changed, options, user);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCompetences() {
|
||||
let comp = this.items.filter( item => item.type == 'competence');
|
||||
let comp = this.items.filter(item => item.type == 'competence');
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
compareName( a, b) {
|
||||
if ( a.name < b.name ) {
|
||||
compareName(a, b) {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if ( a.name > b.name ) {
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore() {
|
||||
if ( this.type == 'personnage') {
|
||||
if (this.type == 'personnage') {
|
||||
return this.system.caracsecondaire.reaction.max;
|
||||
} else {
|
||||
return this.system.attributs.physique.values.defaut.value;
|
||||
@@ -234,86 +239,86 @@ export class YggdrasillActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCompetencesGenerales() {
|
||||
let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'generale');
|
||||
return comp.sort( this.compareName );
|
||||
let comp = this.items.filter(item => item.type == 'competence' && item.system.categorie == 'generale');
|
||||
return comp.sort(this.compareName);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCompetencesMartiales() {
|
||||
let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'martiale');
|
||||
return comp.sort( this.compareName );
|
||||
let comp = this.items.filter(item => item.type == 'competence' && item.system.categorie == 'martiale');
|
||||
return comp.sort(this.compareName);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCompetencesMagiques() {
|
||||
let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'magique');
|
||||
return comp.sort( this.compareName );
|
||||
let comp = this.items.filter(item => item.type == 'competence' && item.system.categorie == 'magique');
|
||||
return comp.sort(this.compareName);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDons( ) {
|
||||
let dons = this.items.filter( item => item.type == 'don');
|
||||
return dons.sort( this.compareName );
|
||||
getDons() {
|
||||
let dons = this.items.filter(item => item.type == 'don');
|
||||
return dons.sort(this.compareName);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEffetsMagiques( ) {
|
||||
let effets = this.items.filter( item => item.type == 'effetmagique');
|
||||
return effets.sort( this.compareName );
|
||||
getEffetsMagiques() {
|
||||
let effets = this.items.filter(item => item.type == 'effetmagique');
|
||||
return effets.sort(this.compareName);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEffetsDeRunes( ) {
|
||||
let effets = this.items.filter( item => item.type == 'effetderune');
|
||||
return effets.sort( this.compareName );
|
||||
getEffetsDeRunes() {
|
||||
let effets = this.items.filter(item => item.type == 'effetderune');
|
||||
return effets.sort(this.compareName);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getMonnaies( ) {
|
||||
let monnaies = this.items.filter( item => item.type == 'monnaie');
|
||||
return monnaies.sort( this.compareName );
|
||||
getMonnaies() {
|
||||
let monnaies = this.items.filter(item => item.type == 'monnaie');
|
||||
return monnaies.sort(this.compareName);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getFaiblesses( ) {
|
||||
let faib = this.items.filter( item => item.type == 'faiblesse');
|
||||
return faib.sort( this.compareName );
|
||||
getFaiblesses() {
|
||||
let faib = this.items.filter(item => item.type == 'faiblesse');
|
||||
return faib.sort(this.compareName);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getBlessures( ) {
|
||||
return this.items.filter( item => item.type == 'blessure');
|
||||
getBlessures() {
|
||||
return this.items.filter(item => item.type == 'blessure');
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getToutEquipements() {
|
||||
return this.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.items.filter( item => (item.type == 'armecc' || item.type == 'armedist') && item.system.equipe );
|
||||
return this.items.filter(item => (item.type == 'armecc' || item.type == 'armedist') && item.system.equipe);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getArmures() {
|
||||
return this.items.filter( item => item.type == 'armure' && item.system.equipe );
|
||||
return this.items.filter(item => item.type == 'armure' && item.system.equipe);
|
||||
}
|
||||
getBoucliers() {
|
||||
return this.items.filter( item => item.type == 'bouclier' && item.system.equipe );
|
||||
getBoucliers() {
|
||||
return this.items.filter(item => item.type == 'bouclier' && item.system.equipe);
|
||||
}
|
||||
getProuessesMartiales() {
|
||||
let prouesse = this.items.filter( item => item.type == 'prouesse' );
|
||||
return prouesse.sort( this.compareName );
|
||||
let prouesse = this.items.filter(item => item.type == 'prouesse');
|
||||
return prouesse.sort(this.compareName);
|
||||
}
|
||||
getSortsSejdr() {
|
||||
let sort = this.items.filter( item => item.type == 'sortsejdr' );
|
||||
return sort.sort( this.compareName );
|
||||
let sort = this.items.filter(item => item.type == 'sortsejdr');
|
||||
return sort.sort(this.compareName);
|
||||
}
|
||||
getSortsGaldr() {
|
||||
let sort = this.items.filter( item => item.type == 'sortgaldr' );
|
||||
return sort.sort( this.compareName );
|
||||
let sort = this.items.filter(item => item.type == 'sortgaldr');
|
||||
return sort.sort(this.compareName);
|
||||
}
|
||||
getRunes() {
|
||||
let sort = this.items.filter( item => item.type == 'rune' );
|
||||
return sort.sort( this.compareName );
|
||||
let sort = this.items.filter(item => item.type == 'rune');
|
||||
return sort.sort(this.compareName);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setEpuise( ) {
|
||||
async setEpuise() {
|
||||
if (!this.system.status.epuise) {
|
||||
await this.update({ 'system.status.epuise': true});
|
||||
await this.update({ 'system.status.epuise': true });
|
||||
this.system.status.epuise = true;
|
||||
}
|
||||
/*let effect = this.getEffectByLabel('Epuisé');
|
||||
@@ -325,18 +330,18 @@ export class YggdrasillActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async cleanEpuise() {
|
||||
if (this.system.status.epuise) {
|
||||
await this.update({ 'system.status.epuise': false});
|
||||
await this.update({ 'system.status.epuise': false });
|
||||
this.system.status.epuise = false;
|
||||
}
|
||||
/*let effect = this.getEffectByLabel('Epuisé');
|
||||
if ( effect ) {
|
||||
await this.deleteEmbeddedDocuments("ActiveEffect", [ effect.id ]);
|
||||
await this.deleteEmbeddedDocuments("ActiveEffect", [ effect.id ]);
|
||||
}*/
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async toggleEpuise( ) {
|
||||
if ( this.system.status.epuise ) {
|
||||
await this.cleanEpuise();
|
||||
async toggleEpuise() {
|
||||
if (this.system.status.epuise) {
|
||||
await this.cleanEpuise();
|
||||
} else {
|
||||
await this.setEpuise();
|
||||
}
|
||||
@@ -347,9 +352,9 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setBlesse( ) {
|
||||
async setBlesse() {
|
||||
if (!this.system.status.blesse) {
|
||||
await this.update({ 'system.status.blesse': true} );
|
||||
await this.update({ 'system.status.blesse': true });
|
||||
this.system.status.blesse = true;
|
||||
}
|
||||
/*let effect = this.getEffectByLabel('Blessé');
|
||||
@@ -361,12 +366,12 @@ export class YggdrasillActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async cleanBlesse() {
|
||||
if (this.system.status.blesse) {
|
||||
await this.update({ 'system.status.blesse': false} );
|
||||
await this.update({ 'system.status.blesse': false });
|
||||
this.system.status.blesse = false;
|
||||
}
|
||||
/*let effect = this.getEffectByLabel('Blessé');
|
||||
if ( effect ) {
|
||||
await this.deleteEmbeddedDocuments("ActiveEffect", [ effect.id ]);
|
||||
await this.deleteEmbeddedDocuments("ActiveEffect", [ effect.id ]);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -376,17 +381,17 @@ export class YggdrasillActor extends Actor {
|
||||
//return this.getEffectByLabel('Blessé');
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async setMeurtri( ) {
|
||||
async setMeurtri() {
|
||||
await this.setBlesse();
|
||||
if (!this.system.status.meurtri) {
|
||||
await this.update({ 'system.status.meurtri': true});
|
||||
await this.update({ 'system.status.meurtri': true });
|
||||
this.system.status.meurtri = true;
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async cleanMeurtri() {
|
||||
if (this.system.status.meurtri) {
|
||||
await this.update({ 'system.status.meurtri': false});
|
||||
await this.update({ 'system.status.meurtri': false });
|
||||
this.system.status.meurtri = false;
|
||||
}
|
||||
}
|
||||
@@ -396,8 +401,8 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async decrementFuror( nbFuror) {
|
||||
await this.update( { 'system.furor.value': this.system.furor.value - nbFuror } );
|
||||
async decrementFuror(nbFuror) {
|
||||
await this.update({ 'system.furor.value': this.system.furor.value - nbFuror });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -419,11 +424,11 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCarac( caracName ) {
|
||||
for( let key in this.system.carac) {
|
||||
getCarac(caracName) {
|
||||
for (let key in this.system.carac) {
|
||||
let categ = this.system.carac[key];
|
||||
for( let carac in categ.carac) {
|
||||
if (carac.toLowerCase() == caracName.toLowerCase() ) {
|
||||
for (let carac in categ.carac) {
|
||||
if (carac.toLowerCase() == caracName.toLowerCase()) {
|
||||
return foundry.utils.deepClone(categ.carac[carac]);
|
||||
}
|
||||
}
|
||||
@@ -431,16 +436,16 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeCaracSecondaire( ) {
|
||||
if ( this.type == "personnage") {
|
||||
computeCaracSecondaire() {
|
||||
if (this.type == "personnage") {
|
||||
let basecorps = this.system.carac.corps.carac;
|
||||
let sumcorps = basecorps.puissance.value + basecorps.agilite.value + basecorps.vigueur.value
|
||||
let baseesprit = this.system.carac.esprit.carac;
|
||||
let sumesprit = baseesprit.intellect.value + baseesprit.perception.value + baseesprit.tenacite.value
|
||||
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;
|
||||
|
||||
let newPV = (sumcorps * 3) + (sumesprit * 2) + sumame;
|
||||
this.system.caracsecondaire.pv.max = newPV;
|
||||
|
||||
this.system.caracsecondaire.reaction.value = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value;
|
||||
@@ -478,16 +483,16 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equiperObject( equipementId ) {
|
||||
let item = this.items.find( item => item.id == equipementId );
|
||||
async equiperObject(equipementId) {
|
||||
let item = this.items.find(item => item.id == equipementId);
|
||||
if (item && item.system) {
|
||||
let update = { _id: item.id, "system.equipe": !item.system.equipe };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async updateCompetence( compId, niveau) {
|
||||
let comp = this.items.find( item => item.type == 'competence' && item.id == compId);
|
||||
async updateCompetence(compId, niveau) {
|
||||
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, 'system.niveau': niveau };
|
||||
@@ -498,21 +503,21 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildListeActionsCombat( ) {
|
||||
buildListeActionsCombat() {
|
||||
let armes = [];
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAttribute( attrkey, subAttrKey = 'defaut') {
|
||||
async rollAttribute(attrkey, subAttrKey = 'defaut') {
|
||||
let attr = foundry.utils.duplicate(this.system.attributs[attrkey]);
|
||||
console.log("ATTR : ", attr, attrkey, subAttrKey);
|
||||
let subAttr = foundry.utils.duplicate(this.system.attributs[attrkey].values[subAttrKey] );
|
||||
if ( attr ) {
|
||||
let subAttr = foundry.utils.duplicate(this.system.attributs[attrkey].values[subAttrKey]);
|
||||
if (attr) {
|
||||
subAttr.label = subAttr.label || "";
|
||||
let title = `Attribut : ${attr.label} ${subAttr.label} : ${subAttr.value}`;
|
||||
let rollData = {
|
||||
mode: "attribut",
|
||||
alias: this.name,
|
||||
alias: this.name,
|
||||
actorImg: this.img,
|
||||
actorId: this.id,
|
||||
attr: attr,
|
||||
@@ -523,45 +528,45 @@ export class YggdrasillActor extends Actor {
|
||||
isBlesse: this.system.etat.etat == "blesse",
|
||||
}
|
||||
this.addDefaultRoll(rollData)
|
||||
await YggdrasillRollDialog.create( this, rollData);
|
||||
await YggdrasillRollDialog.create(this, rollData);
|
||||
} else {
|
||||
ui.notifications.warn("Attribut non trouvée");
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
addDefaultRoll(rollData) {
|
||||
rollData.optionsBonusMalus= YggdrasillUtility.createOptions(-15, 15)
|
||||
rollData.bonusMalus= 0
|
||||
rollData.optionsFuror= YggdrasillUtility.createOptions(0, this.getCurrentFuror())
|
||||
rollData.furorUsage= 0
|
||||
rollData.optionsBD= YggdrasillUtility.createOptions(0, +15)
|
||||
rollData.sr= 0
|
||||
rollData.optionsBonusMalus = YggdrasillUtility.createOptions(-15, 15)
|
||||
rollData.bonusMalus = 0
|
||||
rollData.optionsFuror = YggdrasillUtility.createOptions(0, this.getCurrentFuror())
|
||||
rollData.furorUsage = 0
|
||||
rollData.optionsBD = YggdrasillUtility.createOptions(0, +15)
|
||||
rollData.sr = 0
|
||||
rollData.puissanceRune = 1
|
||||
rollData.optionsPuissanceRune= YggdrasillUtility.createOptions(1, +15)
|
||||
rollData.supportRune= "peau"
|
||||
rollData.optionsPuissanceRune = YggdrasillUtility.createOptions(1, +15)
|
||||
rollData.supportRune = "peau"
|
||||
|
||||
rollData.config= game.system.config
|
||||
rollData.config = game.system.config
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async rollCarac( categName, caracName) {
|
||||
async rollCarac(categName, caracName) {
|
||||
let carac = foundry.utils.duplicate(this.system.carac[categName].carac[caracName]);
|
||||
if ( carac) {
|
||||
if (carac) {
|
||||
let rollData = {
|
||||
mode: "carac",
|
||||
alias: this.name,
|
||||
alias: this.name,
|
||||
actorImg: this.img,
|
||||
actorId: this.id,
|
||||
img: `systems/fvtt-yggdrasill/images/icons/icon_carac_${categName}.png`,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
title: `Caractéristique ${carac.label} : ${carac.value}`,
|
||||
selectedCarac: carac,
|
||||
selectedCarac: carac,
|
||||
isEpuise: this.isEpuise(),
|
||||
isBlesse: this.isBlesse(),
|
||||
isMeurtri: this.isMeurtri(),
|
||||
}
|
||||
this.addDefaultRoll(rollData)
|
||||
console.log("CARAC : ", rollData, this.system.carac);
|
||||
await YggdrasillRollDialog.create( this, rollData);
|
||||
await YggdrasillRollDialog.create(this, rollData);
|
||||
} else {
|
||||
ui.notifications.warn("Caractéristique non trouvée");
|
||||
}
|
||||
@@ -569,12 +574,12 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence( competenceId ) {
|
||||
let competence = this.items.find( item => item.type == 'competence' && item.id == competenceId);
|
||||
if ( competence) {
|
||||
async rollCompetence(competenceId) {
|
||||
let competence = this.items.find(item => item.type == 'competence' && item.id == competenceId);
|
||||
if (competence) {
|
||||
let rollData = {
|
||||
mode: "competence",
|
||||
alias: this.name,
|
||||
alias: this.name,
|
||||
actorImg: this.img,
|
||||
actorId: this.id,
|
||||
img: competence.img,
|
||||
@@ -586,28 +591,28 @@ export class YggdrasillActor extends Actor {
|
||||
isMeurtri: this.isMeurtri(),
|
||||
}
|
||||
this.addDefaultRoll(rollData)
|
||||
await YggdrasillRollDialog.create( this, rollData);
|
||||
await YggdrasillRollDialog.create(this, rollData);
|
||||
} else {
|
||||
ui.notifications.warn("Compétence non trouvée");
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAttaqueData( mode ) {
|
||||
getAttaqueData(mode) {
|
||||
let attackData = foundry.utils.duplicate(attackMode[mode]);
|
||||
if ( attackData){
|
||||
if (attackData) {
|
||||
attackData.mode = mode;
|
||||
const categ = this.system.carac[attackData.categName];
|
||||
attackData.carac = foundry.utils.duplicate(categ?.carac[attackData.caracName] ?? {});
|
||||
if ( attackData.malus != 0) {
|
||||
if (attackData.malus != 0) {
|
||||
let malusTab = attackData.malus.split(';');
|
||||
attackData.malus = (categ?.carac[malusTab[0]]?.value ?? 0) * Number(malusTab[1]);
|
||||
}
|
||||
if ( attackData.protection != 0) {
|
||||
if (attackData.protection != 0) {
|
||||
let malusTab = attackData.protection.split(';');
|
||||
attackData.protection = (categ?.carac[malusTab[0]]?.value ?? 0) * Number(malusTab[1]);
|
||||
}
|
||||
if ( attackData.bonusdegats != 0) {
|
||||
if (attackData.bonusdegats != 0) {
|
||||
let malusTab = attackData.bonusdegats.split(';');
|
||||
attackData.bonusdegats = (categ?.carac[malusTab[0]]?.value ?? 0) * Number(malusTab[1]);
|
||||
}
|
||||
@@ -616,21 +621,21 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTirData( mode) {
|
||||
let attackData = foundry.utils.duplicate( tirMode[mode] );
|
||||
if ( attackData){
|
||||
getTirData(mode) {
|
||||
let attackData = foundry.utils.duplicate(tirMode[mode]);
|
||||
if (attackData) {
|
||||
attackData.mode = mode;
|
||||
const categ = this.system.carac[attackData.categName];
|
||||
attackData.carac = foundry.utils.duplicate(categ?.carac[attackData.caracName] ?? {});
|
||||
if ( attackData.malus != 0) {
|
||||
if (attackData.malus != 0) {
|
||||
let malusTab = attackData.malus.split(';');
|
||||
attackData.malus = (categ?.carac[malusTab[0]]?.value ?? 0) * Number(malusTab[1]);
|
||||
}
|
||||
if ( attackData.protection != 0) {
|
||||
if (attackData.protection != 0) {
|
||||
let malusTab = attackData.protection.split(';');
|
||||
attackData.protection = (categ?.carac[malusTab[0]]?.value ?? 0) * Number(malusTab[1]);
|
||||
}
|
||||
if ( attackData.bonusdegats != 0) {
|
||||
if (attackData.bonusdegats != 0) {
|
||||
let malusTab = attackData.bonusdegats.split(';');
|
||||
attackData.bonusdegats = (categ?.carac[malusTab[0]]?.value ?? 0) * Number(malusTab[1]);
|
||||
}
|
||||
@@ -639,32 +644,32 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollSort( sortId, 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 );
|
||||
|
||||
async rollSort(sortId, 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 = foundry.utils.duplicate(this.system.carac.ame.carac.instinct);
|
||||
} else if ( magie == "rune") {
|
||||
carac = foundry.utils.duplicate(this.system.carac.ame.carac.communication);
|
||||
if (magie == "sejdr") {
|
||||
carac = foundry.utils.duplicate(this.system.carac.ame.carac.instinct);
|
||||
} else if (magie == "rune") {
|
||||
carac = foundry.utils.duplicate(this.system.carac.ame.carac.communication);
|
||||
} else {
|
||||
carac = foundry.utils.duplicate(this.system.carac.ame.carac.charisme);
|
||||
carac = foundry.utils.duplicate(this.system.carac.ame.carac.charisme);
|
||||
}
|
||||
|
||||
if ( sort && competence) {
|
||||
|
||||
if (sort && competence) {
|
||||
|
||||
let rollData = {
|
||||
mode: magie,
|
||||
isMagie: true,
|
||||
alias: this.name,
|
||||
alias: this.name,
|
||||
actorImg: this.img,
|
||||
actorId: this.id,
|
||||
img: sort.img,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
title: magie + " - " + sort.name,
|
||||
selectedCarac: carac,
|
||||
selectedCarac: carac,
|
||||
agiliteCarac: foundry.utils.duplicate(this.system.carac.corps.carac.agilite),
|
||||
instinctCarac: foundry.utils.duplicate(this.system.carac.ame.carac.instinct),
|
||||
sort: foundry.utils.duplicate(sort),
|
||||
@@ -679,32 +684,32 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
this.addDefaultRoll(rollData)
|
||||
rollData.sr = 14
|
||||
await YggdrasillRollDialog.create( this, rollData);
|
||||
await YggdrasillRollDialog.create(this, rollData);
|
||||
} else {
|
||||
ui.notifications.warn("Sortilège ou Compétence non trouvée !", sort, compName);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollArme( armeId ) {
|
||||
let arme = this.items.find( item => item.id == armeId);
|
||||
async rollArme(armeId) {
|
||||
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) {
|
||||
|
||||
let competence = this.items.find(item => item.type == 'competence' && item.name == compName);
|
||||
console.log("ARME :", armeId, arme, competence);
|
||||
|
||||
if (arme && competence) {
|
||||
|
||||
let attackDef
|
||||
if (arme.type == 'armecc') {
|
||||
attackDef = this.getAttaqueData("classique");
|
||||
} else {
|
||||
} else {
|
||||
attackDef = this.getTirData("pose");
|
||||
}
|
||||
|
||||
let rollData = {
|
||||
mode: arme.type,
|
||||
attackDef: attackDef,
|
||||
alias: this.name,
|
||||
alias: this.name,
|
||||
actorImg: this.img,
|
||||
actorId: this.id,
|
||||
img: competence.img,
|
||||
@@ -720,22 +725,22 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
this.addDefaultRoll(rollData)
|
||||
rollData.sr = 14
|
||||
await YggdrasillRollDialog.create( this, rollData);
|
||||
await YggdrasillRollDialog.create(this, rollData);
|
||||
} else {
|
||||
ui.notifications.warn("Arme ou Compétence Martiale non trouvée !", arme, compName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getEncTotal( ) {
|
||||
getEncTotal() {
|
||||
let encTotal = 0;
|
||||
for( let item of this.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") {
|
||||
|| item.type == "armedist" || item.type == "armure" || item.type == "monnaie" || item.type == "bouclier") {
|
||||
encTotal += (item.system.enc * (item.system.quantite || 1));
|
||||
}
|
||||
}
|
||||
for( let item of this.items) {
|
||||
for (let item of this.items) {
|
||||
if (item.type == "bouclier" && item.system.equipe) {
|
||||
encTotal -= (item.system.enc * (item.system.quantite || 1));
|
||||
encTotal += (item.system.enccomb * (item.system.quantite || 1));
|
||||
@@ -745,19 +750,19 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getProtectionTotal( ) {
|
||||
getProtectionTotal() {
|
||||
let protectionTotal = 0;
|
||||
for( let item of this.items) {
|
||||
for (let item of this.items) {
|
||||
if (item.type == "armure" && item.system.equipe) {
|
||||
protectionTotal += Number(item.system.protection);
|
||||
}
|
||||
}
|
||||
return protectionTotal;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getDpBouclier( ) {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getDpBouclier() {
|
||||
let dpBouclier = 0;
|
||||
for( let item of this.items) {
|
||||
for (let item of this.items) {
|
||||
if (item.type == "bouclier" && item.system.equipe) {
|
||||
dpBouclier += Number(item.system.defensebonus);
|
||||
}
|
||||
@@ -766,22 +771,22 @@ export class YggdrasillActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async incrementeQuantite( objetId ) {
|
||||
let objetQ = this.items.find( item => item.id == objetId );
|
||||
async incrementeQuantite(objetId) {
|
||||
let objetQ = this.items.find(item => item.id == objetId);
|
||||
if (objetQ) {
|
||||
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.items.find( item => item.id == objetId );
|
||||
async decrementeQuantite(objetId) {
|
||||
let objetQ = this.items.find(item => item.id == objetId);
|
||||
if (objetQ) {
|
||||
let newQ = objetQ.system.quantite - 1;
|
||||
newQ = (newQ <= 0) ? 0 : newQ;
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user