Fix: niveau de compétence dans dialog roll
This commit is contained in:
parent
77f0a93eb6
commit
f0b042626f
@ -786,7 +786,7 @@ export class RdDActor extends Actor {
|
|||||||
let comp = this.getCompetence(compName);
|
let comp = this.getCompetence(compName);
|
||||||
if (comp) {
|
if (comp) {
|
||||||
let troncList = RdDItemCompetence.isTronc(compName);
|
let troncList = RdDItemCompetence.isTronc(compName);
|
||||||
let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(comp.data.categorie);
|
let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(Misc.data(comp).data.categorie);
|
||||||
if (troncList) {
|
if (troncList) {
|
||||||
let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : ";
|
let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : ";
|
||||||
for (let troncName of troncList) {
|
for (let troncName of troncList) {
|
||||||
@ -1068,7 +1068,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async computeIsHautRevant() {
|
computeIsHautRevant() {
|
||||||
const tplData = Misc.templateData(this);
|
const tplData = Misc.templateData(this);
|
||||||
tplData.attributs.hautrevant.value = this.listItemsData('tete').find(it => Grammar.toLowerCaseNoAccent(it.name) == 'don de haut-reve')
|
tplData.attributs.hautrevant.value = this.listItemsData('tete').find(it => Grammar.toLowerCaseNoAccent(it.name) == 'don de haut-reve')
|
||||||
? "Haut rêvant"
|
? "Haut rêvant"
|
||||||
@ -1893,25 +1893,25 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async checkCompetenceXP(compName, newXP = undefined) {
|
async checkCompetenceXP(compName, newXP = undefined) {
|
||||||
let competence = this.getCompetence(compName);
|
let compData = Misc.data(this.getCompetence(compName));
|
||||||
if (competence && newXP && newXP == competence.data.xp) { // Si édition, mais sans changement XP
|
if (compData && newXP && newXP == compData.data.xp) { // Si édition, mais sans changement XP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newXP = (newXP) ? newXP : competence.data.xp;
|
newXP = (newXP) ? newXP : compData.data.xp;
|
||||||
if (competence && newXP > 0) {
|
if (compData && newXP > 0) {
|
||||||
let xpNeeded = RdDItemCompetence.getCompetenceNextXp(competence.data.niveau + 1);
|
let xpNeeded = RdDItemCompetence.getCompetenceNextXp(compData.data.niveau + 1);
|
||||||
if (newXP >= xpNeeded) {
|
if (newXP >= xpNeeded) {
|
||||||
let newCompetence = duplicate(competence);
|
let newCompData = duplicate(compData);
|
||||||
newCompetence.data.niveau += 1;
|
newCompData.data.niveau += 1;
|
||||||
newCompetence.data.xp = newXP;
|
newCompData.data.xp = newXP;
|
||||||
|
|
||||||
let xpData = {
|
let xpData = {
|
||||||
alias: this.name,
|
alias: this.name,
|
||||||
competence: newCompetence.name,
|
competence: newCompData.name,
|
||||||
niveau: newCompetence.data.niveau,
|
niveau: newCompData.data.niveau,
|
||||||
xp: newCompetence.data.xp,
|
xp: newCompData.data.xp,
|
||||||
archetype: newCompetence.data.niveau_archetype,
|
archetype: newCompData.data.niveau_archetype,
|
||||||
archetypeWarning: newCompetence.data.niveau > competence.data.niveau_archetype
|
archetypeWarning: newCompData.data.niveau > compData.data.niveau_archetype
|
||||||
}
|
}
|
||||||
ChatUtility.createChatMessage(this.name, "default", {
|
ChatUtility.createChatMessage(this.name, "default", {
|
||||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData)
|
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData)
|
||||||
@ -2196,7 +2196,7 @@ export class RdDActor extends Actor {
|
|||||||
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const competence = this.getCompetence(compName);
|
const competence = Misc.data(this.getCompetence(compName));
|
||||||
if (compName && !competence) {
|
if (compName && !competence) {
|
||||||
ui.notifications.warn(`${this.name} n'a pas de compétence correspondant à ${compName}`)
|
ui.notifications.warn(`${this.name} n'a pas de compétence correspondant à ${compName}`)
|
||||||
return;
|
return;
|
||||||
@ -2219,7 +2219,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCompetence(name) {
|
async rollCompetence(name) {
|
||||||
let rollData = { competence: this.getCompetence(name) }
|
let rollData = { competence: Misc.data(this.getCompetence(name)) }
|
||||||
|
|
||||||
if (rollData.competence.type == 'competencecreature') {
|
if (rollData.competence.type == 'competencecreature') {
|
||||||
if (rollData.competence.data.iscombat) {
|
if (rollData.competence.data.iscombat) {
|
||||||
@ -2270,7 +2270,7 @@ export class RdDActor extends Actor {
|
|||||||
async rollTache(id) {
|
async rollTache(id) {
|
||||||
const actorData = Misc.data(this);
|
const actorData = Misc.data(this);
|
||||||
const tacheData = Misc.data(this.getTache(id));
|
const tacheData = Misc.data(this.getTache(id));
|
||||||
const compData = duplicate(Misc.data(this.getCompetence(tacheData.data.competence)));
|
const compData = Misc.data(this.getCompetence(tacheData.data.competence));
|
||||||
compData.data.defaut_carac = tacheData.data.carac; // Patch !
|
compData.data.defaut_carac = tacheData.data.carac; // Patch !
|
||||||
|
|
||||||
let rollData = {
|
let rollData = {
|
||||||
@ -2319,7 +2319,7 @@ export class RdDActor extends Actor {
|
|||||||
mergeObject(artData, {
|
mergeObject(artData, {
|
||||||
oeuvre: oeuvre,
|
oeuvre: oeuvre,
|
||||||
art: oeuvre.type,
|
art: oeuvre.type,
|
||||||
competence: duplicate(this.getCompetence(oeuvre.data.competence ?? artData.art)),
|
competence: Misc.data(this.getCompetence(oeuvre.data.competence ?? artData.art)),
|
||||||
diffLibre: - (oeuvre.data.niveau ?? 0),
|
diffLibre: - (oeuvre.data.niveau ?? 0),
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
use: { libre: false, conditions: true },
|
use: { libre: false, conditions: true },
|
||||||
@ -2381,14 +2381,14 @@ export class RdDActor extends Actor {
|
|||||||
_getCaracDanse(oeuvre) {
|
_getCaracDanse(oeuvre) {
|
||||||
if (oeuvre.data.agilite) { return "agilite"; }
|
if (oeuvre.data.agilite) { return "agilite"; }
|
||||||
else if (oeuvre.data.apparence) { return "apparence"; }
|
else if (oeuvre.data.apparence) { return "apparence"; }
|
||||||
const competence = this.getCompetence(oeuvre.data.competence);
|
const compData = Misc.data(this.getCompetence(oeuvre.data.competence));
|
||||||
return competence.data.defaut_carac;
|
return compData.data.defaut_carac;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollMusique(id) {
|
async rollMusique(id) {
|
||||||
const artData = { art: 'musique', verbe: 'Jouer' };
|
const artData = { art: 'musique', verbe: 'Jouer' };
|
||||||
const oeuvre = duplicate(this.getItemOfType(id, artData.art));
|
const oeuvre = Misc.data(this.getItemOfType(id, artData.art));
|
||||||
await this._rollArt(artData, "ouie", oeuvre);
|
await this._rollArt(artData, "ouie", oeuvre);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2400,7 +2400,7 @@ export class RdDActor extends Actor {
|
|||||||
proportions: 1,
|
proportions: 1,
|
||||||
ajouterEquipement: false
|
ajouterEquipement: false
|
||||||
};
|
};
|
||||||
const oeuvre = duplicate(this.getRecetteCuisine(id));
|
const oeuvre = Misc.data(this.getRecetteCuisine(id));
|
||||||
await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r));
|
await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2451,8 +2451,8 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollMeditation(id) {
|
async rollMeditation(id) {
|
||||||
let meditation = duplicate(this.getMeditation(id));
|
let meditation = Misc.data(this.getMeditation(id));
|
||||||
let competence = duplicate(this.getCompetence(meditation.data.competence));
|
let competence = Misc.data(this.getCompetence(meditation.data.competence));
|
||||||
competence.data.defaut_carac = "intellect"; // Meditation = tjs avec intellect
|
competence.data.defaut_carac = "intellect"; // Meditation = tjs avec intellect
|
||||||
let meditationData = {
|
let meditationData = {
|
||||||
competence: competence,
|
competence: competence,
|
||||||
@ -2467,7 +2467,7 @@ export class RdDActor extends Actor {
|
|||||||
use: { libre: false, conditions: true, },
|
use: { libre: false, conditions: true, },
|
||||||
carac: {}
|
carac: {}
|
||||||
};
|
};
|
||||||
meditationData.carac["intellect"] = duplicate(Misc.templateData(this).carac["intellect"]);
|
meditationData.carac["intellect"] = Misc.templateData(this).carac["intellect"];
|
||||||
|
|
||||||
console.log("rollMeditation !!!", meditationData);
|
console.log("rollMeditation !!!", meditationData);
|
||||||
|
|
||||||
@ -2625,7 +2625,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async ajouteNombreAstral(data) {
|
async ajouteNombreAstral(data) {
|
||||||
// Gestion expérience (si existante)
|
// Gestion expérience (si existante)
|
||||||
data.competence = this.getCompetence("astrologie");
|
data.competence = Misc.data(this.getCompetence("astrologie"));
|
||||||
data.selectedCarac = Misc.templateData(this).carac["vue"];
|
data.selectedCarac = Misc.templateData(this).carac["vue"];
|
||||||
this._appliquerAjoutExperience(data);
|
this._appliquerAjoutExperience(data);
|
||||||
|
|
||||||
@ -2760,7 +2760,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
rollArme(compName, armeName = undefined) {
|
rollArme(compName, armeName = undefined) {
|
||||||
let arme = armeName ? this.data.items.find(it => Misc.data(it).name == armeName && RdDItemArme.isArme(it)) : undefined;
|
let arme = armeName ? this.data.items.find(it => Misc.data(it).name == armeName && RdDItemArme.isArme(it)) : undefined;
|
||||||
let competence = this.getCompetence(compName);
|
let competence = Misc.data(this.getCompetence(compName));
|
||||||
|
|
||||||
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
||||||
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
|
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
|
||||||
@ -3207,7 +3207,7 @@ export class RdDActor extends Actor {
|
|||||||
let recette = this.getItemOfType(recetteId, 'recettealchimique');
|
let recette = this.getItemOfType(recetteId, 'recettealchimique');
|
||||||
const actorData = Misc.data(this);
|
const actorData = Misc.data(this);
|
||||||
if (recette) {
|
if (recette) {
|
||||||
let competence = this.getCompetence("alchimie");
|
let competence = Misc.data(this.getCompetence("alchimie"));
|
||||||
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
|
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
|
||||||
let rollData = {
|
let rollData = {
|
||||||
recette: recette,
|
recette: recette,
|
||||||
|
@ -796,11 +796,9 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// # utilisation esquive
|
// # utilisation esquive
|
||||||
let esquiveUsage = 0;
|
const esquive = Misc.data(this.defender.getCompetence("esquive"));
|
||||||
let esquive = this.defender.getCompetence("esquive");
|
const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps"));
|
||||||
if (esquive) {
|
const esquiveUsage = esquive ? this.defender.getItemUse(esquive._id) : 0;
|
||||||
esquiveUsage = this.defender.getItemUse(esquive._id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const paramChatDefense = {
|
const paramChatDefense = {
|
||||||
passeArme: attackerRoll.passeArme,
|
passeArme: attackerRoll.passeArme,
|
||||||
@ -810,7 +808,7 @@ export class RdDCombat {
|
|||||||
attackerId: this.attackerId,
|
attackerId: this.attackerId,
|
||||||
esquiveUsage: esquiveUsage,
|
esquiveUsage: esquiveUsage,
|
||||||
defenderTokenId: this.defenderTokenId,
|
defenderTokenId: this.defenderTokenId,
|
||||||
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"),
|
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && corpsACorps,
|
||||||
armes: this._filterArmesParade(this.defender, attackerRoll.competence, attackerRoll.arme),
|
armes: this._filterArmesParade(this.defender, attackerRoll.competence, attackerRoll.arme),
|
||||||
diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0,
|
diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0,
|
||||||
attaqueParticuliere: attackerRoll.particuliere,
|
attaqueParticuliere: attackerRoll.particuliere,
|
||||||
@ -955,12 +953,13 @@ export class RdDCombat {
|
|||||||
_prepareParade(attackerRoll, armeParade) {
|
_prepareParade(attackerRoll, armeParade) {
|
||||||
const compName = armeParade.data.competence;
|
const compName = armeParade.data.competence;
|
||||||
const armeAttaque = attackerRoll.arme;
|
const armeAttaque = attackerRoll.arme;
|
||||||
|
const parade = Misc.data(this.defender.getCompetence(compName));
|
||||||
|
|
||||||
let defenderRoll = {
|
let defenderRoll = {
|
||||||
passeArme: attackerRoll.passeArme,
|
passeArme: attackerRoll.passeArme,
|
||||||
diffLibre: attackerRoll.diffLibre,
|
diffLibre: attackerRoll.diffLibre,
|
||||||
attackerRoll: attackerRoll,
|
attackerRoll: attackerRoll,
|
||||||
competence: this.defender.getCompetence(compName),
|
competence: parade,
|
||||||
arme: armeParade,
|
arme: armeParade,
|
||||||
surprise: this.defender.getSurprise(true),
|
surprise: this.defender.getSurprise(true),
|
||||||
needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(armeAttaque, armeParade),
|
needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(armeAttaque, armeParade),
|
||||||
@ -1011,7 +1010,7 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async esquive(attackerRoll) {
|
async esquive(attackerRoll) {
|
||||||
let esquive = this.defender.getCompetence("esquive");
|
const esquive = Misc.data(this.defender.getCompetence("esquive"));
|
||||||
if (esquive == undefined) {
|
if (esquive == undefined) {
|
||||||
ui.notifications.error(this.defender.name + " n'a pas de compétence 'esquive'");
|
ui.notifications.error(this.defender.name + " n'a pas de compétence 'esquive'");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user