#44 - Gestion sur encombrement corrigée

This commit is contained in:
sladecraven 2020-11-27 12:20:13 +01:00
parent dca4e28044
commit 793036d2b8
12 changed files with 83 additions and 29 deletions

View File

@ -91,7 +91,6 @@ export class RdDActorSheet extends ActorSheet {
// Mise à jour de l'encombrement total
this.actor.computeEncombrementTotal();
// Common data
data.data.competenceByCategory = data.competenceByCategory;
data.data.encombrementTotal = this.actor.encombrementTotal;
@ -112,6 +111,7 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.filterItemsPerTypeForSheet(data );
data.data.sortReserve = data.data.reve.reserve.list;
RdDUtility.buildArbreDeConteneur( this, data );
data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
return data;
}

View File

@ -723,7 +723,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
computeEtatGeneral( )
computeEtatGeneral( )
{
let data = this.data.data;
// Pas d'état général pour les entités forçage à 0
@ -732,12 +732,14 @@ export class RdDActor extends Actor {
return;
}
// Pour les autres
let state = 0;
let state = 0, surenc = 0;
state = state - (data.sante.vie.max - data.sante.vie.value);
if (data.sante.fatigue) // Creatures n'ont pas de fatigue
state = state + RdDUtility.currentFatigueMalus(data.sante.fatigue.value, data.sante.endurance.max);
state = state - this.detectSurEncombrement();
data.compteurs.etat.value = state;
state = state;
surenc = -this.detectSurEncombrement();
data.compteurs.etat.value = state;
data.compteurs.surenc.value = surenc;
}
/* -------------------------------------------- */
@ -1081,8 +1083,11 @@ export class RdDActor extends Actor {
diffLibre: sortList[0].data.difficulte, // Per default at startup
coutreve: Array(20).fill().map((item, index) => 1 + index),
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
difficultesLibres: CONFIG.RDD.difficultesLibres
}
difficultesLibres: CONFIG.RDD.difficultesLibres,
surencMalusFlag: false, // A ne pas utiliser pour les sorts
surencMalusValue: 0,
surencMalusApply: false
}
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData);
new RdDRollDialog("sort", html, rollData, this ).render(true);
}
@ -1106,7 +1111,10 @@ export class RdDActor extends Actor {
etat: this.data.data.compteurs.etat.value,
finalLevel: 0,
diffConditions: 0,
diffLibre: 0
diffLibre: 0,
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
surencMalusValue: this.data.data.compteurs.surenc.value,
surencMalusApply: false
}
console.log(caracName, rollData);
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
@ -1179,7 +1187,10 @@ export class RdDActor extends Actor {
diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0,
attackerRoll: attackerRoll,
finalLevel: 0,
coupsNonMortels: false
coupsNonMortels: false,
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
surencMalusValue: this.data.data.compteurs.surenc.value,
surencMalusApply: false
}
if ( competence.type == 'competencecreature') { // Specific case for Creatures

View File

@ -142,9 +142,19 @@ export class RdDRollDialog extends Dialog {
console.log("RdDRollDialog - Cout reve", ptreve);
updateRollResult(rollData);
});
html.find('#ptreve-variable').change((event) => {
let ptreve = Misc.toInt(event.currentTarget.value);
this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac
console.log("RdDRollDialog - Cout reve", ptreve);
updateRollResult(rollData);
});
html.find('#coupsNonMortels').change((event) => {
this.rollData.mortalite = event.currentTarget.checked ? "non-mortel" : "non-mortel";
});
html.find('#surencMalusApply').change((event) => {
this.rollData.surencMalusApply = event.currentTarget.checked;
updateRollResult(rollData);
});
}
/* -------------------------------------------- */
@ -152,14 +162,15 @@ export class RdDRollDialog extends Dialog {
let etat = Misc.toInt(rollData.etat);
const diffLibre = Misc.toInt(rollData.diffLibre);
const diffConditions = Misc.toInt(rollData.diffConditions);
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
if (rollData.competence) {
return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions;
return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions + malusEnc;
}
if (rollData.draconicList) {
let diffSort = (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") ? diffLibre : Misc.toInt(rollData.selectedSort.data.difficulte);
return etat + Misc.toInt(rollData.selectedDraconic.data.niveau) + diffSort + diffConditions;
}
return etat + diffLibre + diffConditions;
return etat + diffLibre + diffConditions + malusEnc;
}
/* -------------------------------------------- */

View File

@ -149,6 +149,8 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html',
// Calendrier
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
// Conteneur/item in Actor sheet
@ -237,7 +239,7 @@ export class RdDUtility {
if (!niveau) niveau = 1;
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']( { item: objet} );
if (objet.type == 'conteneur') {
str = str + "<ul class='item-list alterne-list list-item-margin"+niveau+"1'>";
str = str + "<ul class='item-list alterne-list list-item-margin"+niveau+"'>";
for (let subItem of objet.subItems) {
str = str + this.buildConteneur(subItem, niveau+1);
}

View File

@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.91",
"version": "0.9.92",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 48,
"templateVersion": 51,
"author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"],

View File

@ -54,6 +54,10 @@
"etat": {
"value": 0,
"label": "Etat général"
},
"surenc": {
"value": 0,
"label": "Sur-encombrement"
}
},
"attributs": {
@ -182,7 +186,11 @@
"etat": {
"value": 0,
"label": "Etat général"
}
},
"surenc": {
"value": 0,
"label": "Sur-encombrement"
}
}
},
"common": {
@ -468,6 +476,10 @@
"value": 0,
"label": "Etat général"
},
"surenc": {
"value": 0,
"label": "Sur-encombrement"
},
"ethylisme": {
"value": 0,
"label": "Ethylisme",

View File

@ -179,18 +179,22 @@
{{!-- Equipment Tab --}}
<div class="tab items" data-group="primary" data-tab="items">
<span cass=item-name>Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}}</span>
<hr>
<span cass=item-name>Porté sur soi</span>
<ol class="item-list alterne-list">
<li class="competence-header flexrow">
<span class="competence-title competence-label">Nom</span>
<span class="competence-title competence-label">Q.</span>
<span class="competence-title competence-value">Enc.</span>
<span class="competence-title competence-value">Equiper</span>
<span class="competence-title competence-value">Editer/Suppr.</span>
</li>
{{#each data.objets as |item id|}}
{{#unless item.estContenu}}
{{#if (ne item.type 'conteneur')}}
<li class="item flexrow list-item" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<h4 class="item-name">{{item.name}}</h4>
{{#if item.data.quantite}}
<h4 class="item-quantite">{{item.data.quantite}}</h4>
{{/if}}
<span class="item-name">{{item.name}}</span>
<span class="item-quantite">{{item.data.quantite}}</span>
<span class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</span>
<div class="item-controls">
<a class="item-control item-equip" title="Equiper">{{#if item.data.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>

View File

@ -1,8 +1,8 @@
<li class="item flexrow list-item" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<h4 class="item-name">{{item.name}}</h4>
<h4 class="item-quantite">{{item.data.quantite}}</h4>
<h4 class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</h4>
<span class="item-name">{{item.name}}</span>
<span class="item-quantite">{{item.data.quantite}}</span>
<span class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</span>
<div class="item-controls">
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>

View File

@ -554,17 +554,23 @@
{{!-- Equipment Tab --}}
<div class="tab items" data-group="primary" data-tab="items">
<span cass=item-name>Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}}</span>
<span cass=item-name>Porté sur soi</span>
<span cass=item-name>Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}} <b>{{data.surEncombrementMessage}}</b></span>
<ul class="item-list alterne-list">
<li class="competence-header flexrow">
<span class="competence-title competence-label">Nom</span>
<span class="competence-title competence-label">Q.</span>
<span class="competence-title competence-value">Enc.</span>
<span class="competence-title competence-value">Equiper</span>
<span class="competence-title competence-value">Editer/Suppr.</span>
</li>
{{#each data.objets as |item id|}}
{{#unless item.estContenu}}
{{#if (ne item.type 'conteneur')}}
<li class="item flexrow list-item" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<h4 class="item-name">{{item.name}}</h4>
<h4 class="item-quantite">{{item.data.quantite}}</h4>
<h4 class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</h4>
<span class="item-name">{{item.name}}</span>
<span class="item-quantite">{{item.data.quantite}}</span>
<span class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</span>
<div class="item-controls">
<a class="item-control item-equip" title="Equiper">{{#if item.data.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>

View File

@ -37,6 +37,7 @@
<input class="attribute-value" type="checkbox" id="coupsNonMortels" name="coupsNonMortels" {{#if coupsNonMortels}}checked{{/if}}/>
</div>
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
<div class="form-group">
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
</div>

View File

@ -18,6 +18,7 @@
{{/select}}
</select>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
<div class="form-group">
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
</div>

View File

@ -0,0 +1,6 @@
{{#if surencMalusFlag}}
<div class="form-group">
<label for="xp">Appliquer le malus de sur-encombrement ? </label>
<input class="attribute-value" type="checkbox" id="surencMalusApply" name="surencMalusApply" {{#if surencMalusApply}}checked{{/if}}/>
</div>
{{/if}}