#111 Gestion armes magiques

This commit is contained in:
sladecraven 2021-01-29 20:10:43 +01:00
parent f15067fff8
commit 543f6c2658
8 changed files with 71 additions and 19 deletions

View File

@ -32,7 +32,7 @@ export class RdDBonus {
let dmg = { total: 0 };
if (rollData.arme && rollData.arme.name.toLowerCase() == "esquive") {
// Specific case management
ui.notifications.warn("Calcul de bonus dégats sur eswquive");
ui.notifications.warn("Calcul de bonus dégats sur esquive !");
} else {
dmg.dmgArme = RdDBonus._dmgArme(rollData);
dmg.penetration = RdDBonus._peneration(rollData);
@ -74,9 +74,15 @@ export class RdDBonus {
/* -------------------------------------------- */
static _dmgArme(rollData) {
return rollData.arme == undefined ? 0 : (rollData.arme.data.dommagesReels ?? Number(rollData.arme.data.dommages ?? 0));
let dmg1 = 0;
if ( rollData.arme) {
dmg1 = rollData.arme.data.dommagesReels ?? Number(rollData.arme.data.dommages ?? 0);
dmg1 += (rollData.arme.data.magique) ? rollData.arme.data.ecaille_efficacite : 0;
}
return dmg1;
}
/* -------------------------------------------- */
static _peneration(rollData) {
return parseInt(rollData.arme?.data.penetration ?? 0);
}

View File

@ -756,8 +756,29 @@ export class RdDCombat {
defenderRoll.show = defenderRoll.show || {}
const dmg = attackerRoll.dmg.dmgArme + attackerRoll.dmg.dmgActor;
let resistance = Misc.toInt(defenderRoll.arme.data.resistance);
let arme = defenderRoll.arme;
let msg = "";
if ( arme.data.magique ) {
defenderRoll.show.deteriorationArme = 'resiste'; // Par défaut
if (arme.data.resistance_magique == undefined) arme.data.resistance_magique = 0; // Quick fix
if ( dmg > arme.data.resistance_magique) { // Jet uniquement si dommages supérieur à résistance magique (cf. 274)
let resistance = Misc.toInt(arme.data.resistance);
// Jet de résistance de l'arme de parade (p.132)
let resistRoll = await RdDResolutionTable.rollData({
caracValue: resistance,
finalLevel: - dmg,
showDice: false
});
if ( !resistRoll.rolled.isSuccess) {
let perteResistance = ( dmg - arme.data.resistance_magique)
resistance -= perteResistance;
defenderRoll.show.deteriorationArme = resistance <= 0 ? 'brise': 'perte';
defenderRoll.show.perteResistance = perteResistance;
this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance });
}
}
} else {
let resistance = Misc.toInt(arme.data.resistance);
// Jet de résistance de l'arme de parade (p.132)
let resistRoll = await RdDResolutionTable.rollData({
caracValue: resistance,
@ -772,6 +793,7 @@ export class RdDCombat {
defenderRoll.show.perteResistance = dmg;
this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance });
}
}
// Si l'arme de parade n'est pas un bouclier, jet de désarmement (p.132)
if (ReglesOptionelles.isUsing('defenseurDesarme') && resistance > 0 && RdDItemArme.getCategorieParade(defenderRoll.arme) != 'boucliers') {
let desarme = await RdDResolutionTable.rollData({

View File

@ -191,6 +191,7 @@ export class RdDRoll extends Dialog {
});
}
/* -------------------------------------------- */
async updateRollResult() {
let rollData = this.rollData;
@ -235,6 +236,7 @@ export class RdDRoll extends Dialog {
}
/* -------------------------------------------- */
async buildAjustements(rollData){
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData);
return html;
@ -244,7 +246,6 @@ export class RdDRoll extends Dialog {
_computeFinalLevel(rollData) {
return RollDataAjustements.sum(rollData.ajustements);
}
/* -------------------------------------------- */
_computeDiffCompetence(rollData) {
if (rollData.competence) {
@ -265,6 +266,7 @@ export class RdDRoll extends Dialog {
return diffLibre;
}
/* -------------------------------------------- */
_computeMalusArmure(rollData) {
let malusArmureValue = 0;
if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {

View File

@ -93,6 +93,12 @@ export const referenceAjustements = {
getLabel: (rollData, actor) => Misc.getFractionHtml(rollData.diviseurSignificative),
getDescr: (rollData, actor) => rollData.diviseurSignificative > 1 ? `Facteur significative <span class="rdd-diviseur">&times;${Misc.getFractionHtml(rollData.diviseurSignificative)}</span>` : ''
},
isEcaille: {
isVisible: (rollData, actor) => rollData.arme && rollData.arme.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0,
isUsed: (rollData, actor) => rollData.arme && rollData.arme.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0,
getLabel: (rollData, actor) => "Ecaille d'Efficacité: ",
getValue: (rollData, actor) => (rollData.arme && rollData.arme.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0) ? rollData.arme.data.ecaille_efficacite : 0,
},
finesse: {
isUsed: (rollData, actor) => RdDBonus.isDefenseAttaqueFinesse(rollData),
getDescr: (rollData, actor) => 'Attaque particulière en finesse',

View File

@ -2,11 +2,11 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.3.5",
"version": "1.3.6",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9",
"templateVersion": 85,
"templateVersion": 86,
"author": "LeRatierBretonnien",
"authors": [
{

View File

@ -595,6 +595,9 @@
"competence": "",
"cout": 0,
"portee_courte": 0,
"magique": false,
"ecaille_efficacite": 0,
"resistance_magique": 0,
"portee_moyenne": 0,
"portee_extreme": 0,
"rapide": false,

View File

@ -21,4 +21,5 @@
Significative requise <span class="rdd-diviseur">&times;{{{ajustements.facteurSign.label}}}</span>!
</span>
{{/if}}
</div>

View File

@ -72,6 +72,18 @@
<label for="xp">Prix (sols) </label>
<input class="attribute-value" type="text" name="data.cout" value="{{data.cout}}" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="xp">Magique ? </label>
<input class="attribute-value" type="checkbox" name="data.magique" {{#if data.magique}}checked{{/if}}/>
</div>
<div class="form-group">
<label for="penetration">Résistance magique </label>
<input class="attribute-value" type="text" name="data.resistance_magique" value="{{data.resistance_magique}}" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="penetration">Nombre d'Ecailles d'Efficacité </label>
<input class="attribute-value" type="text" name="data.ecaille_efficacite" value="{{data.ecaille_efficacite}}" data-dtype="Number"/>
</div>
<div class="flexcol">
<span><label>Description : </label></span>
<div class="form-group editor">