#76 : Jets de dés assistés pour les méditations
This commit is contained in:
@ -299,6 +299,11 @@ export class RdDActorSheet extends ActorSheet {
|
||||
let tacheId = li.data('item-id');
|
||||
this.actor.rollTache( tacheId );
|
||||
});
|
||||
html.find('.meditation-label a').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
let meditationId = li.data('item-id');
|
||||
this.actor.rollMeditation( meditationId );
|
||||
});
|
||||
|
||||
// Points de reve actuel
|
||||
html.find('.ptreve-actuel a').click((event) => {
|
||||
|
@ -1708,7 +1708,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTache ( id ) {
|
||||
getTacheMeditation ( id ) {
|
||||
return this.data.items.find( item => item._id == id );
|
||||
}
|
||||
|
||||
@ -1757,6 +1757,60 @@ export class RdDActor extends Actor {
|
||||
this.updateEmbeddedEntity( "OwnedItem", rollData.tache);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollMeditation( id ) {
|
||||
let meditation = duplicate( this.getTacheMeditation( id ) );
|
||||
let competence = duplicate(this.getCompetence(meditation.data.competence));
|
||||
competence.data.defaut_carac = "intellect"; // Meditation = tjs avec intellect
|
||||
let meditationData = {
|
||||
competence: competence,
|
||||
meditation: meditation,
|
||||
diffConditions: 0,
|
||||
editLibre: false,
|
||||
editConditions: true,
|
||||
isHeure: false,
|
||||
isVeture: false,
|
||||
isComportement: false,
|
||||
isPurification: false,
|
||||
carac : { }
|
||||
};
|
||||
meditationData.carac["intellect"] = duplicate(this.data.data.carac["intellect"]);
|
||||
|
||||
console.log("rollMedittion !!!", meditationData);
|
||||
|
||||
const dialog = await RdDRoll.create(this, meditationData, {html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-meditation.html'}, {
|
||||
name: 'jet-meditation',
|
||||
label: 'Jet de Meditation ' + meditation.name,
|
||||
height: 600,
|
||||
callbacks: [
|
||||
this.createCallbackExperience(),
|
||||
{ condition: r=> r.rolled.isETotal, action: r => this._meditationETotal(r)},
|
||||
{ action: r => this._meditationResult(r) }
|
||||
]
|
||||
} );
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _meditationResult(meditationData) {
|
||||
this.santeIncDec( "fatigue", 2);
|
||||
|
||||
meditationData.diffLecture = -7;
|
||||
if (meditationData.rolled.isPart )
|
||||
meditationData.diffLecture = 0;
|
||||
else if (meditationData.rolled.isSign )
|
||||
meditationData.diffLecture = -3;
|
||||
|
||||
RdDResolutionTable.displayRollData(meditationData, this.name, 'chat-resultat-meditation.html');
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_meditationETotal(meditationData) {
|
||||
meditationData.meditation.data.malus--;
|
||||
this.updateEmbeddedEntity( "OwnedItem", meditationData.meditation);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _competenceResult(rollData) {
|
||||
RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-competence.html')
|
||||
|
@ -223,6 +223,7 @@ export class RdDResolutionTable {
|
||||
return duplicate(RdDResolutionTable.resolutionTable[caracValue][difficulte + 10]);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isAjustementAstrologique(rollData) {
|
||||
if (rollData.selectedCarac && rollData.selectedCarac.label.toLowerCase().includes('chance')) {
|
||||
return true;
|
||||
|
@ -218,12 +218,44 @@ export class RdDRoll extends Dialog {
|
||||
this.rollData.useMalusEncTotal = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
// Section Méditation
|
||||
html.find('#isHeure').change((event) => {
|
||||
this.rollData.isHeure = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#isPurification').change((event) => {
|
||||
this.rollData.isPurification = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#isVeture').change((event) => {
|
||||
this.rollData.isVeture = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#isComportement').change((event) => {
|
||||
this.rollData.isComportement = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_isIgnoreEtatGeneral(rollData) {
|
||||
return rollData.selectedCarac.ignoreEtatGeneral;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeDiffMeditation( rollData ) {
|
||||
let diff = 0;
|
||||
if ( rollData.meditation ) {
|
||||
diff = (!rollData.isHeure) ? diff - 2 : diff;
|
||||
diff = (!rollData.isVeture) ? diff - 2 : diff;
|
||||
diff = (!rollData.isComportement) ? diff - 2 : diff;
|
||||
diff = (!rollData.isisPuritication) ? diff - 2 : diff;
|
||||
diff = diff - rollData.meditation.data.malus; // Malus permanent éventuel
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeFinalLevel(rollData) {
|
||||
const etat = this._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
|
||||
@ -235,13 +267,15 @@ export class RdDRoll extends Dialog {
|
||||
// Gestion malus armure
|
||||
const malusArmureValue = this._computeMalusArmure(rollData);
|
||||
|
||||
const diffMeditation = this._computeDiffMeditation( rollData );
|
||||
const diffLibre = this._computeDiffLibre(rollData);
|
||||
const diffCompetence = this._computeDiffCompetence(rollData);
|
||||
const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0;
|
||||
|
||||
return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + ajustementChance + bonusTactique;
|
||||
return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeDiffCompetence(rollData) {
|
||||
if (rollData.competence) {
|
||||
return Misc.toInt(rollData.competence.data.niveau);
|
||||
@ -252,6 +286,7 @@ export class RdDRoll extends Dialog {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeDiffLibre(rollData) {
|
||||
let diffLibre = Misc.toInt(rollData.diffLibre);
|
||||
if (rollData.draconicList && rollData.selectedSort) {
|
||||
|
@ -188,6 +188,7 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-meditation.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html',
|
||||
|
Reference in New Issue
Block a user