#16 Gestion des critiques en combat

This commit is contained in:
sladecraven 2020-11-14 21:22:29 +01:00
parent a7ac184ca3
commit 09cfdf922e
4 changed files with 43 additions and 19 deletions

View File

@ -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,7 +176,9 @@ 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 if ( !rollData.needSignificative && rolled.isSuccess) {
explications += "<br><strong>Attaque parée/esquivée !</strong>";
} else {
explications += "<br><strong>Esquive/Parade échouée, encaissement !</strong>";
@ -166,10 +186,7 @@ export class RdDActor extends Actor {
}
} 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;

View File

@ -99,7 +99,7 @@ export class RdDRollDialog extends Dialog {
$("#carac").val(rollData.competence.data.defaut_carac);
}
// Si sort, for les points de reve à 1
if (!rollData.selectedSort.data.ptreve_reel)
if (rollData.selectedSort && !rollData.selectedSort.data.ptreve_reel)
rollData.selectedSort.data.ptreve_reel = 1;
$("#bonusmalus").val(rollData.bmValue);
updateRollResult(rollData);

View File

@ -539,7 +539,6 @@ export class RdDUtility {
html.on("click", '#parer-button', event => {
event.preventDefault();
//let attackerActor = game.actors.get(event.currentTarget.attributes['data-attackerid'].value );
let defenderActor = game.actors.get(event.currentTarget.attributes['data-defenderid'].value );
let armeId = event.currentTarget.attributes['data-armeid'].value;
let rollData = defenderActor.currentRollData;
@ -548,13 +547,21 @@ export class RdDUtility {
html.on("click", '#esquiver-button', event => {
event.preventDefault();
//let attackerActor = game.actors.get(event.currentTarget.attributes['data-attackerid'].value );
let defenderActor = game.actors.get(event.currentTarget.attributes['data-defenderid'].value );
let rollData = defenderActor.currentRollData;
console.log("Esquive !", rollData, defenderActor);
defenderActor.esquiverAttaque( rollData );
});
html.on("click", '#particuliere-attaque', event => {
event.preventDefault();
let attackerActor = game.actors.get(event.currentTarget.attributes['data-attackerid'].value );
let rollData = attackerActor.currentRollData;
rollData.particuliereAttaque = game.actors.get(event.currentTarget.attributes['data-mode'].value );
console.log("Particulère !", rollData);
attackerActor.continueRoll( rollData );
});
}
/* -------------------------------------------- */

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.40",
"version": "0.9.41",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 44,