Editer la protection naturelle

This commit is contained in:
Vincent Vandemeulebrouck 2020-12-18 01:10:03 +01:00
parent da24ff7232
commit 30d1ddef78
4 changed files with 23 additions and 5 deletions

View File

@ -435,6 +435,10 @@ export class RdDActorSheet extends ActorSheet {
this.actor.setPointsDeSeuil(event.currentTarget.value);
} );
html.find('#attribut-protection-edit').change((event) => {
this.actor.updateProtectionValue( event.currentTarget.attributes.name.value, parseInt(event.target.value) );
} );
// On stress change
html.find('.compteur-edit').change((event) => {
let fieldName = event.currentTarget.attributes.name.value;

View File

@ -528,12 +528,19 @@ export class RdDActor extends Actor {
async updateCompteurValue( fieldName, fieldValue )
{
//console.log("Update", fieldName, fieldValue);
let content;
let compteurs = duplicate(this.data.data.compteurs);
compteurs[fieldName].value = fieldValue;
await this.update( {"data.compteurs": compteurs } );
}
/* -------------------------------------------- */
async updateProtectionValue( fieldName, fieldValue )
{
let attributs = duplicate(this.data.data.attributs);
attributs[fieldName].value = fieldValue;
await this.update( {"data.attributs": attributs } );
}
/* -------------------------------------------- */
/** Teste si le conteneur de destination a suffisament de capacité
* pour recevoir le nouvel objet
@ -1694,7 +1701,8 @@ export class RdDActor extends Actor {
this.updateEmbeddedEntity("OwnedItem", update);
}
}
protection = Math.max(protection - Misc.toInt(arme.data.penetration), 0);
const penetration = arme ? Misc.toInt(arme.data.penetration) : 0;
protection = Math.max(protection - penetration, 0);
protection += this.getProtectionNaturelle();
console.log("Final protect", protection);
return protection;

View File

@ -81,7 +81,7 @@
"protection": {
"type": "number",
"value": 0,
"label": "Protection",
"label": "Protection naturelle",
"derivee": false
}
}
@ -189,7 +189,7 @@
"protection": {
"type": "number",
"value": 0,
"label": "Protection",
"label": "Protection naturelle",
"derivee": false
}
},

View File

@ -125,7 +125,13 @@
<ul class="carac-list">
{{#each data.attributs as |attr key|}}
<li class="competence flexrow list-item" data-attribute="{{key}}">
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} : {{attr.value}}</span>
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} :
{{#if (eq key 'protection')}}
<input id="attribut-protection-edit" type="text" name="{{key}}" value="{{attr.value}}" data-dtype="number"/><span/>
{{else}}
{{attr.value}}
{{/if}}
</span>
</li>
{{/each}}
</ul>