forked from public/foundryvtt-reve-de-dragon
Utilise RdDRoll pour les caracs
ajout d'un callback dédié à l'expérience limite de la table de résolution à 60 (rêve actuel jusqu'à 3x limite)
This commit is contained in:
105
module/actor.js
105
module/actor.js
@ -1355,66 +1355,95 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCarac( caracName )
|
||||
{
|
||||
let carac = this.getCaracByName(caracName);
|
||||
let rollData = {
|
||||
selectedCarac: carac,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: this.data.data.compteurs.etat.value,
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: 0,
|
||||
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
|
||||
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
|
||||
surencMalusValue: this.data.data.compteurs.surenc.value,
|
||||
surencMalusApply: false,
|
||||
isNatation: false,
|
||||
useEncForNatation: false
|
||||
}
|
||||
console.log(caracName, rollData);
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
|
||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||
_createCallbackExperience() {
|
||||
return {
|
||||
condition: r => r.rolled.isPart && r.finalLevel < 0 && game.settings.get("core", "rollMode") != 'selfroll',
|
||||
action: r => this._appliquerAjoutExperience(r)
|
||||
};
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async appelChance( )
|
||||
async _appliquerAjoutExperience(rollData) {
|
||||
// TODO: si pas de compétence, minimum 1 pour carac
|
||||
// TODO: appliquer l'expérience automatiquement
|
||||
let xpmsg = RdDResolutionTable.buildXpMessage(rollData.rolled, rollData.finalLevel);
|
||||
let message = ChatUtility.prepareChatMessage('gmroll', this.name);
|
||||
message.content = "<strong>" + rollData.selectedCarac.label + "</strong>"
|
||||
+ xpmsg;
|
||||
ChatMessage.create(message);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCarac( caracName )
|
||||
{
|
||||
let rollData = {
|
||||
selectedCarac: this.getCaracByName('chance-actuelle'),
|
||||
diffConditions: this.ajustementAstrologique()
|
||||
}
|
||||
|
||||
const dialog = await RdDRoll.create(
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||
this,
|
||||
rollData,
|
||||
let rollData = { selectedCarac: this.getCaracByName(caracName) };
|
||||
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
{html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html'},
|
||||
{
|
||||
name: 'appelChance',
|
||||
label: 'Appel à la chance',
|
||||
name: 'jet-'+caracName,
|
||||
label: 'Lancer : '+rollData.selectedCarac.label,
|
||||
callbacks: [
|
||||
{ action: rollData => this._appelChanceResultat(rollData) }
|
||||
this._createCallbackExperience(),
|
||||
{ action: this._rollCaracResult }
|
||||
]
|
||||
}
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
async _rollCaracResult(rollData) {
|
||||
let rolled = rollData.rolled;
|
||||
|
||||
let resumeCompetence = (rollData.diffLibre + rollData.diffConditions);
|
||||
let explications = "<br>Points de taches : " + rolled.ptTache;
|
||||
|
||||
// Final chat message
|
||||
let chatOptions = {
|
||||
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + resumeCompetence + "</strong>"
|
||||
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
|
||||
+ RdDResolutionTable.explain(rolled)
|
||||
+ explications
|
||||
}
|
||||
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_appelChanceResultat(rollData) {
|
||||
async rollAppelChance( )
|
||||
{
|
||||
let rollData = {
|
||||
selectedCarac: this.getCaracByName('chance-actuelle'),
|
||||
diffConditions: this.ajustementAstrologique()
|
||||
}
|
||||
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html'},
|
||||
{
|
||||
name: 'appelChance',
|
||||
label: 'Appel à la chance',
|
||||
callbacks: [
|
||||
this._createCallbackExperience(),
|
||||
{ action: this._appelChanceResult }
|
||||
]
|
||||
}
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
_appelChanceResult(rollData) {
|
||||
const message = {
|
||||
user: game.user._id,
|
||||
alias: this.name,
|
||||
content: this.name + " fait appel à la chance" + RdDResolutionTable.explain(rollData.rolled)
|
||||
};
|
||||
if (rollData.rolled.isSuccess) {
|
||||
message.content += "<br>Dépense d'un point de chance, l'action peut être retentée"
|
||||
message.content += "<br>Un point de chance est dépensée, l'action peut être retentée"
|
||||
this.chanceActuelleIncDec(-1)
|
||||
}
|
||||
ChatMessage.create(message);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async chanceActuelleIncDec(value) {
|
||||
let chance = duplicate(this.data.data.compteurs.chance);
|
||||
|
Reference in New Issue
Block a user