|
|
|
@ -10,6 +10,8 @@ import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
|
|
|
|
import { Misc } from "./misc.js";
|
|
|
|
|
|
|
|
|
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
|
|
|
|
import { RdDDice } from "./rdd-dice.js";
|
|
|
|
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
|
|
|
|
|
|
|
|
|
export class RdDActor extends Actor {
|
|
|
|
|
|
|
|
|
@ -120,11 +122,10 @@ export class RdDActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async performRoll(rollData) {
|
|
|
|
|
|
|
|
|
|
// Perform the roll
|
|
|
|
|
let rolled = await RdDResolutionTable.rollChances(rollData.rollTarget);
|
|
|
|
|
let rolled = await RdDResolutionTable.roll(rollData.carac, rollData.finalLevel);
|
|
|
|
|
//rolled.isPart = true; // Pour tester le particulières
|
|
|
|
|
rollData.rolled = rolled; // garder le résultat
|
|
|
|
|
console.log("performRoll", rollData, rolled)
|
|
|
|
|
this.currentRollData = rollData;
|
|
|
|
|
if (rolled.isPart && rollData.arme && !rollData.attackerRoll) { // Réussite particulière avec attaque -> choix !
|
|
|
|
|
let message = "<strong>Réussite particulière en attaque</strong>";
|
|
|
|
@ -221,7 +222,7 @@ export class RdDActor extends Actor {
|
|
|
|
|
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
|
|
|
|
|
+ "<br>Jet : " + rolled.roll + " sur "+ rolled.score + "% (" + rollData.selectedCarac.value + " à " +Misc.toSignedString(rollData.finalLevel) + ")"
|
|
|
|
|
+ RdDResolutionTable.explain(rolled)
|
|
|
|
|
+ "<br><strong>" + quality + "</strong>"
|
|
|
|
|
+ explications + xpmsg,
|
|
|
|
|
user: game.user._id,
|
|
|
|
@ -319,6 +320,76 @@ export class RdDActor extends Actor {
|
|
|
|
|
return explications
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async dormir(heures=1) {
|
|
|
|
|
for (let i=0; i<heures; i++) {
|
|
|
|
|
console.log("recuperationReve", this.data.data);
|
|
|
|
|
/**
|
|
|
|
|
* TODO: récupérer les segment de fatigue
|
|
|
|
|
*/
|
|
|
|
|
this.recuperationReve();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async recuperationReve() {
|
|
|
|
|
const seuil = this.data.data.reve.seuil.value;
|
|
|
|
|
const reve = this.getReveActuel();
|
|
|
|
|
console.log("recuperationReve", this.data.data);
|
|
|
|
|
let message = { title : "Récupération" }
|
|
|
|
|
if (reve > seuil) {
|
|
|
|
|
message.content = "Vous avez déjà récupéré suffisament (seuil " + seuil + ", rêve actuel "+reve+")";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let deRecuperation = await RdDDice.deDraconique();
|
|
|
|
|
console.log("recuperationReve", deRecuperation);
|
|
|
|
|
if (deRecuperation>=7)
|
|
|
|
|
{
|
|
|
|
|
// Rêve de Dragon !
|
|
|
|
|
message.content = "Vous faites un <strong>Rêve de Dragon</strong> de " + deRecuperation + " Points de rêve";
|
|
|
|
|
message.content += await this.combattreReveDeDragon(deRecuperation);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
message.content = "Vous récupérez " + deRecuperation + " Points de rêve";
|
|
|
|
|
await this.updatePointsDeReve(deRecuperation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ChatMessage.create( message );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async combattreReveDeDragon(force){
|
|
|
|
|
let draconic = this.getBestDraconic();
|
|
|
|
|
let niveau = Math.max(0, draconic.data.niveau);
|
|
|
|
|
let etat = this.data.data.compteurs.etat.value;
|
|
|
|
|
let difficulte = niveau - etat - force;
|
|
|
|
|
let reveActuel = this.getReveActuel();
|
|
|
|
|
let roll = await RdDResolutionTable.roll(reveActuel, difficulte);
|
|
|
|
|
let message = ""
|
|
|
|
|
const resultatRdD = await this.appliquerReveDeDragon(roll, force);
|
|
|
|
|
return resultatRdD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async appliquerReveDeDragon(roll, force) {
|
|
|
|
|
let message = "";
|
|
|
|
|
if (roll.isSuccess) {
|
|
|
|
|
message += "<br>Vous gagnez " + force + " points de Rêve";
|
|
|
|
|
this.updatePointDeSeuil();
|
|
|
|
|
await this.updatePointsDeReve(force);
|
|
|
|
|
}
|
|
|
|
|
if (roll.isPart) {
|
|
|
|
|
// TODO: Dialog pour choix entre HR opu général?
|
|
|
|
|
let tete = "à déterminer";
|
|
|
|
|
message += "<br>Vous gagnez une Tête de dragon: " + tete;
|
|
|
|
|
}
|
|
|
|
|
if (roll.isEchec) {
|
|
|
|
|
message += "<br>Vous subissez une Queue de Dragon";
|
|
|
|
|
this.ajouterQueue();
|
|
|
|
|
}
|
|
|
|
|
if (roll.isETotal) {
|
|
|
|
|
message += "<br>A cause de votre échec total, vous subissez une deuxième Queue de Dragon !"
|
|
|
|
|
this.ajouterQueue();
|
|
|
|
|
}
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async sortMisEnReserve(rollData, sort) {
|
|
|
|
|
let reserve = duplicate(this.data.data.reve.reserve);
|
|
|
|
@ -331,6 +402,11 @@ export class RdDActor extends Actor {
|
|
|
|
|
updateCarac( caracName, caracValue )
|
|
|
|
|
{
|
|
|
|
|
let caracpath = "data.carac." + caracName + ".value"
|
|
|
|
|
if (caracName == reve) {
|
|
|
|
|
if (caracValue > Misc.toInt(this.data.data.reve.seuil.value)) {
|
|
|
|
|
this.setPointDeSeuil(caracValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.update( { caracpath: caracValue } );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -499,18 +575,47 @@ export class RdDActor extends Actor {
|
|
|
|
|
let total = new Roll("d20").roll().total;
|
|
|
|
|
if ( total <= refoulement.value ) {
|
|
|
|
|
refoulement.value = 0;
|
|
|
|
|
|
|
|
|
|
let souffle = RdDRollTables.getSouffle();
|
|
|
|
|
ChatMessage.create( { title : "Souffle de Dragon",
|
|
|
|
|
content: game.user.name + " subit un Souffle de Dragon : " + souffle.name } );
|
|
|
|
|
this.actor.createOwnedItem(souffle);
|
|
|
|
|
|
|
|
|
|
this.ajouterSouffle();
|
|
|
|
|
ret = "souffle";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.update( {"data.reve.refoulement": refoulement } );
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ajouterSouffle() {
|
|
|
|
|
let souffle = RdDRollTables.getSouffle();
|
|
|
|
|
// ChatMessage.create({
|
|
|
|
|
// title: "Souffle de Dragon",
|
|
|
|
|
// content: this.name + " subit un Souffle de Dragon : " + souffle.name
|
|
|
|
|
// });
|
|
|
|
|
// this.actor.createOwnedItem(souffle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async ajouterQueue() {
|
|
|
|
|
// TODO: Déterminer si Thanatos a été utilisé? => laisser le joueur ne pas choisir Thanatos => choisir sa voie?
|
|
|
|
|
let utiliseThanatos = false;
|
|
|
|
|
let queue;
|
|
|
|
|
if (utiliseThanatos) {
|
|
|
|
|
queue = await RdDRollTables.getOmbre();
|
|
|
|
|
// mettre à jour: plus d'ombre en vue
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
queue = await RdDRollTables.getQueue();
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
// TODO: convertir la queue obtenue en nouvel item ...
|
|
|
|
|
// ou bien l'ajouter à la liste spécifique => this.data.data.reve.queues
|
|
|
|
|
this.createOwnedItem(queue);
|
|
|
|
|
|
|
|
|
|
ChatMessage.create({
|
|
|
|
|
title: "Queue de Dragon",
|
|
|
|
|
content: this.name + " subit un Queue de Dragon : " + queue.name
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return queue.name;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async deleteTMRRencontreAtPosition( ) {
|
|
|
|
|