forked from public/foundryvtt-reve-de-dragon
Appel à la chance
+ ajout RdDRoll pour jet avec callbacks
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDRollDialog } from "./rdd-roll-dialog.js";
|
||||
import { RdDRoll } from "./rdd-roll.js";
|
||||
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
@ -107,6 +108,10 @@ export class RdDActor extends Actor {
|
||||
return this.data.data.reve.reve.value;
|
||||
}
|
||||
|
||||
getChanceActuel() {
|
||||
return this.data.data.compteurs.chance.value;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getBestDraconic() {
|
||||
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
|
||||
@ -1004,7 +1009,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async reveActuelIncDec( value ) {
|
||||
async reveActuelIncDec( value ) {
|
||||
let reve = duplicate(this.data.data.reve.reve);
|
||||
reve.value = Math.max(reve.value + value, 0);
|
||||
await this.update( {"data.reve.reve": reve } );
|
||||
@ -1294,6 +1299,52 @@ export class RdDActor extends Actor {
|
||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||
}
|
||||
|
||||
async appelChance( )
|
||||
{
|
||||
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,
|
||||
{
|
||||
name: 'appelChance',
|
||||
label: 'Appel à la chance',
|
||||
callbacks: [
|
||||
{ action: rollData => this._appelChanceResultat(rollData) }
|
||||
]
|
||||
}
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
_appelChanceResultat(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"
|
||||
this.chanceActuelleIncDec(-1)
|
||||
}
|
||||
ChatMessage.create(message);
|
||||
}
|
||||
|
||||
async chanceActuelleIncDec(value) {
|
||||
let chance = duplicate(this.data.data.compteurs.chance);
|
||||
chance.value = Math.max(chance.value + value, 0);
|
||||
await this.update( {"data.compteurs.chance": chance } );
|
||||
}
|
||||
|
||||
ajustementAstrologique() {
|
||||
//TODO: selon heure et heure de naissance...
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCaracByName(caracName) {
|
||||
switch (caracName)
|
||||
{
|
||||
|
Reference in New Issue
Block a user