forked from public/foundryvtt-reve-de-dragon
#16 Gestion des critiques en combat
This commit is contained in:
@ -124,6 +124,29 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async performRoll(rollData) {
|
||||
|
||||
// Perform the roll
|
||||
let rolled = RdDResolutionTable.rollChances(rollData.rollTarget);
|
||||
//rolled.isPart = true; // Pour tester le particulières
|
||||
rollData.rolled = rolled; // garder le résultat
|
||||
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>";
|
||||
message = message + "<br><a class='chat-card-button' id='particuliere-attaque' data-mode='force' data-attackerid='" + this.data._id + "'>Attaquer en Force</a>";
|
||||
message = message + "<br><a class='chat-card-button' id='particuliere-attaque' data-mode='rapidite' data-attackerid='"+ this.data._id + "'>Attaquer en Rapidité</a>";
|
||||
message = message + "<br><a class='chat-card-button' id='particuliere-attaque' data-mode='finesse' data-attackerid='"+ this.data._id + "'>Attaquer en Finesse</a>";
|
||||
ChatMessage.create( {content : message, whisper: ChatMessage.getWhisperRecipients( this.name ) } );
|
||||
} else {
|
||||
this.continueRoll(rollData);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async continueRoll(rollData) {
|
||||
|
||||
let rolled = rollData.rolled;
|
||||
let result = rolled.roll;
|
||||
let quality = rolled.quality
|
||||
|
||||
// Manage weapon categories when parrying (cf. page 115 )
|
||||
let need_resist = false; // Do we need to make resistance roll for defender ?
|
||||
if (rollData.arme && rollData.attackerRoll) { // Manage parade depeding on weapon type, and change roll results
|
||||
@ -136,15 +159,10 @@ export class RdDActor extends Actor {
|
||||
if (attCategory.match("epee") && (defCategory == "hache" || defCategory == "lance"))
|
||||
need_resist = true;
|
||||
}
|
||||
if (this.data.data.sante.sonne.value)
|
||||
{
|
||||
if (this.data.data.sante.sonne.value || rollData.particuliereAttaque == "finesse") {
|
||||
rollData.needSignificative = true;
|
||||
}
|
||||
|
||||
let rolled = RdDResolutionTable.rollChances(rollData.rollTarget);
|
||||
let result = rolled.roll;
|
||||
let quality = rolled.quality
|
||||
|
||||
console.log(">>> ROLL", rollData, rolled);
|
||||
let xpmsg = RdDResolutionTable.buildXpMessage(rolled, rollData.finalLevel);
|
||||
|
||||
@ -158,18 +176,17 @@ export class RdDActor extends Actor {
|
||||
explications = ""
|
||||
// In case of fight, replace the message per dommages + localization. it indicates if result is OK or not
|
||||
if (rollData.attackerRoll) { // Defense case !
|
||||
if (rolled.isSuccess) {
|
||||
if (rollData.needSignificative && rolled.isSign ) {
|
||||
explications += "<br><strong>Attaque parée/esquivée !</strong>";
|
||||
} else {
|
||||
} else if ( !rollData.needSignificative && rolled.isSuccess) {
|
||||
explications += "<br><strong>Attaque parée/esquivée !</strong>";
|
||||
} else {
|
||||
explications += "<br><strong>Esquive/Parade échouée, encaissement !</strong>";
|
||||
encaisser = true;
|
||||
}
|
||||
} else { // This is the attack roll!
|
||||
if (rolled.isSuccess) {
|
||||
if (rolled.isPart) { // Particulière !
|
||||
console.log("TODO Gérer critique!");
|
||||
}
|
||||
rollData.domArmePlusDom = this._calculBonusDommages(rollData.selectedCarac, rollData.arme);
|
||||
rollData.domArmePlusDom = this._calculBonusDommages(rollData.selectedCarac, rollData.arme, rollData.particuliereAttaque == "force" );
|
||||
rollData.degats = new Roll("2d10").roll().total + rollData.domArmePlusDom;
|
||||
rollData.loc = RdDUtility.getLocalisation();
|
||||
for (let target of game.user.targets) {
|
||||
@ -223,8 +240,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
_calculBonusDommages(carac, arme) {
|
||||
const dmgArme = parseInt(arme.data.dommages);
|
||||
_calculBonusDommages(carac, arme, isForce=false) {
|
||||
const dmgArme = parseInt(arme.data.dommages) + (isForce)? 5 : 0;
|
||||
const dmgPerso = parseInt(this.data.data.attributs.plusdom.value);
|
||||
if (carac.label == "Tir") {
|
||||
return dmgArme;
|
||||
|
Reference in New Issue
Block a user