#54 Gestion complète du malus armure
This commit is contained in:
parent
d614206859
commit
18c7eb767d
@ -91,7 +91,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
|
||||
|
||||
// Mise à jour de l'encombrement total
|
||||
this.actor.computeEncombrementTotal();
|
||||
this.actor.computeEncombrementTotalEtMalusArmure();
|
||||
// Common data
|
||||
data.data.competenceByCategory = data.competenceByCategory;
|
||||
data.data.encombrementTotal = this.actor.encombrementTotal;
|
||||
|
@ -91,7 +91,7 @@ export class RdDActor extends Actor {
|
||||
_prepareCharacterData(actorData) {
|
||||
// Initialize empty items
|
||||
RdDUtility.computeCarac(actorData.data);
|
||||
this.computeEncombrementTotal();
|
||||
this.computeEncombrementTotalEtMalusArmure();
|
||||
this.computeEtatGeneral();
|
||||
}
|
||||
|
||||
@ -751,9 +751,15 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeEncombrementTotal( ) {
|
||||
async computeEncombrementTotalEtMalusArmure( ) {
|
||||
let totalEnc = 0;
|
||||
let malusArmureData = duplicate(this.data.data.attributs.malusarmure);
|
||||
let newMalusArmure = 0;
|
||||
for (const item of this.data.items) {
|
||||
if ( item.type == 'armure' && item.data.equipe ) { // Armure équipée, intégration du malus armure total
|
||||
newMalusArmure += item.data.malus;
|
||||
}
|
||||
// Calcul encombrement
|
||||
if ( item.data && item.data.encombrement != undefined ) {
|
||||
if ( !Number(item.data.encombrement) ) item.data.encombrement = 0; // Auto-fix
|
||||
if (!item.data.quantite) item.data.quantite = 1; // Auto-fix
|
||||
@ -764,8 +770,14 @@ export class RdDActor extends Actor {
|
||||
item.data.encTotal = 0; // Force default enc
|
||||
}
|
||||
}
|
||||
// Mise à jour valeur totale et états
|
||||
this.encombrementTotal = totalEnc;
|
||||
this.detectSurEncombrement();
|
||||
// Mise à jour éventuelle du malus armure
|
||||
if (newMalusArmure != malusArmureData.value) {
|
||||
malusArmureData.value = newMalusArmure;
|
||||
await this.update( {"data.attributs.malusarmure": malusArmureData } );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1137,6 +1149,7 @@ export class RdDActor extends Actor {
|
||||
coutreve: Array(20).fill().map((item, index) => 1 + index),
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
malusArmureValue: 0,
|
||||
surencMalusFlag: false, // A ne pas utiliser pour les sorts
|
||||
surencMalusValue: 0,
|
||||
surencMalusApply: false,
|
||||
@ -1168,6 +1181,7 @@ export class RdDActor extends Actor {
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: 0,
|
||||
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
|
||||
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
|
||||
surencMalusValue: this.data.data.compteurs.surenc.value,
|
||||
surencMalusApply: false,
|
||||
@ -1249,6 +1263,7 @@ export class RdDActor extends Actor {
|
||||
attackerRoll: attackerRoll,
|
||||
finalLevel: 0,
|
||||
coupsNonMortels: false,
|
||||
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
|
||||
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
|
||||
surencMalusValue: this.data.data.compteurs.surenc.value,
|
||||
surencMalusApply: false,
|
||||
@ -1315,7 +1330,7 @@ export class RdDActor extends Actor {
|
||||
if ( item && item.data.data ) {
|
||||
let update = {_id: item._id, "data.equipe": !item.data.data.equipe };
|
||||
await this.updateEmbeddedEntity("OwnedItem", update);
|
||||
this.computeEncombrementTotal(); // Mise à jour encombrement
|
||||
this.computeEncombrementTotalEtMalusArmure(); // Mise à jour encombrement
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,11 +86,11 @@ export class RdDRollDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
// Mise à jour valeurs
|
||||
$("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
|
||||
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
|
||||
$(".table-resolution").remove();
|
||||
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
|
||||
|
||||
}
|
||||
|
||||
// Setup everything onload
|
||||
@ -170,6 +170,16 @@ export class RdDRollDialog extends Dialog {
|
||||
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
|
||||
let diffLibre = Misc.toInt(rollData.diffLibre);
|
||||
let malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0;
|
||||
|
||||
// Gestion malus armure
|
||||
let malusArmureValue = 0;
|
||||
if ( rollData.malusArmureValue != 0 && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée" )) {
|
||||
$("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue );
|
||||
malusArmureValue = rollData.malusArmureValue;
|
||||
} else {
|
||||
$("#addon-message").text("" );
|
||||
}
|
||||
|
||||
let diffCompetence = 0;
|
||||
if (rollData.competence) {
|
||||
diffCompetence = Misc.toInt(rollData.competence.data.niveau);
|
||||
@ -178,7 +188,8 @@ export class RdDRollDialog extends Dialog {
|
||||
diffCompetence = Misc.toInt(rollData.selectedDraconic.data.niveau);
|
||||
diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
|
||||
}
|
||||
return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation;
|
||||
|
||||
return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -219,7 +219,7 @@ export class RdDUtility {
|
||||
}
|
||||
}
|
||||
}
|
||||
actorSheet.actor.computeEncombrementTotal();
|
||||
actorSheet.actor.computeEncombrementTotalEtMalusArmure();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -43,7 +43,7 @@
|
||||
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Ajustement final : </label><label id="roll-param">10 / 0</label>
|
||||
<label>Ajustement final : </label><label id="roll-param">10 / 0</label> <label name="addon-message" id="addon-message"></label>
|
||||
</div>
|
||||
<div id="resolutionTable">
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Ajustement final : </label><label id="roll-param">10 / 0</label>
|
||||
<label>Ajustement final : </label><label id="roll-param">10 / 0</label> <label name="addon-message" id="addon-message"></label>
|
||||
</div>
|
||||
<div id="resolutionTable">
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Ajustement final : </label><label id="roll-param">10 / 0</label>
|
||||
<label>Ajustement final : </label><label id="roll-param">10 / 0</label> <label name="addon-message" id="addon-message"></label>
|
||||
</div>
|
||||
<div id="resolutionTable">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user