forked from public/foundryvtt-reve-de-dragon
Sync with head
This commit is contained in:
@ -7,6 +7,25 @@ import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Override the create() function to provide additional RdD functionality.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
static async create(data, options) {
|
||||
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
|
||||
if (data.items) {
|
||||
return super.create(data, options);
|
||||
}
|
||||
super.create(data, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
prepareData() {
|
||||
@ -25,16 +44,67 @@ export class RdDActor extends Actor {
|
||||
* Prepare Character type specific data
|
||||
*/
|
||||
_prepareCharacterData(actorData) {
|
||||
// Initialize empty items
|
||||
RdDUtility.computeCarac(actorData.data);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
performRoll( html, rollData ) {
|
||||
let myroll = new Roll("d100");
|
||||
myroll.roll();
|
||||
let quality = "Echec";
|
||||
let tache = 0;
|
||||
//console.log(">>> ROLL", rollData.selectedCarac.label, rollData.rollTarget.score, myroll.total );
|
||||
let result = myroll.total;
|
||||
if (result <= rollData.rollTarget.part) {
|
||||
quality = "Réussite Particulière!";
|
||||
tache = 4;
|
||||
} else if (result <= (rollData.rollTarget.score /2) ) {
|
||||
quality = "Réussite Significative";
|
||||
tache = 2;
|
||||
} else if (result <= (rollData.rollTarget.score) ) {
|
||||
quality = "Réussite Normale";
|
||||
tache = 1;
|
||||
} else if (result < (rollData.rollTarget.epart) ) {
|
||||
quality = "Echec Normal";
|
||||
tache = 0;
|
||||
} else if (result < (rollData.rollTarget.etotal) ) {
|
||||
quality = "Echec Particulier";
|
||||
tache = -2;
|
||||
} else if (result >= (rollData.rollTarget.etotal) ) {
|
||||
quality = "Echec Total";
|
||||
tache = -4;
|
||||
}
|
||||
|
||||
let chatOptions = { "content": "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong><br>Modificateur : " + rollData.bmValue + " - " +
|
||||
rollData.selectedCarac.value + " / " + rollData.finalLevelStr + "<br><strong>Résutat : </strong>" + myroll.total + "<br>" +
|
||||
"<strong>" + quality + "</strong><br>Points de taches : " + tache ,
|
||||
"title": "Test"
|
||||
}
|
||||
ChatMessage.create( chatOptions );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateCarac( caracName, caracValue )
|
||||
{
|
||||
let data = this.data.data;
|
||||
data.carac[caracName].value = caracValue; // Force update ?
|
||||
RdDUtility.computeCarac( data );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollCompetence( compName ) {
|
||||
|
||||
let compItem = RdDUtility.findCompetence( this.data.items, compName);
|
||||
console.log("Roll !", compItem );
|
||||
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', compItem).then(dlg =>
|
||||
let rollData = {
|
||||
"competence": compItem,
|
||||
"carac": this.data.data.carac,
|
||||
"bonusmalusTable": CONFIG.RDD.bonusmalus,
|
||||
"bmValue": 0,
|
||||
"finalLevel": 0
|
||||
}
|
||||
CONFIG.currentRollData = rollData;
|
||||
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData).then(dlg =>
|
||||
{
|
||||
new Dialog(
|
||||
{
|
||||
@ -44,8 +114,8 @@ export class RdDActor extends Actor {
|
||||
{
|
||||
rollButton:
|
||||
{
|
||||
label: "Lancer"
|
||||
//callback: html => dialogOptions.callback(html, roll)
|
||||
label: "Lancer",
|
||||
callback: html => this.performRoll(html, rollData)
|
||||
}
|
||||
},
|
||||
default: "rollButton"
|
||||
@ -53,8 +123,7 @@ export class RdDActor extends Actor {
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
getRollData() {
|
||||
const data = super.getRollData();
|
||||
|
Reference in New Issue
Block a user