Fix: édition des compétences de créatures
This commit is contained in:
parent
912b1d3df3
commit
388629d36e
@ -3,20 +3,20 @@ import { RdDActorSheet } from "./actor-sheet.js";
|
|||||||
export class RdDActorEntiteSheet extends RdDActorSheet {
|
export class RdDActorEntiteSheet extends RdDActorSheet {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
static get defaultOptions() {
|
static get defaultOptions() {
|
||||||
return mergeObject(super.defaultOptions, {
|
return mergeObject(super.defaultOptions, {
|
||||||
classes: ["rdd", "sheet", "actor"],
|
classes: ["rdd", "sheet", "actor"],
|
||||||
template: "systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html",
|
template: "systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html",
|
||||||
width: 640,
|
width: 640,
|
||||||
height: 720,
|
height: 720,
|
||||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}],
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
|
||||||
dragDrop: [{dragSelector: ".item-list .item", dropSelector: undefined}]
|
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** @override */
|
/** @override */
|
||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
// Everything below here is only needed if the sheet is editable
|
// Everything below here is only needed if the sheet is editable
|
||||||
@ -24,17 +24,17 @@ export class RdDActorEntiteSheet extends RdDActorSheet {
|
|||||||
|
|
||||||
// On competence change
|
// On competence change
|
||||||
this.html.find('.creature-carac').change(async event => {
|
this.html.find('.creature-carac').change(async event => {
|
||||||
let compName = event.currentTarget.attributes.compname.value;
|
let compName = event.currentTarget.attributes.compname.value;
|
||||||
this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.value) );
|
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
|
||||||
} );
|
});
|
||||||
this.html.find('.creature-niveau').change(async event => {
|
this.html.find('.creature-niveau').change(async event => {
|
||||||
let compName = event.currentTarget.attributes.compname.value;
|
let compName = event.currentTarget.attributes.compname.value;
|
||||||
this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.value) );
|
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
|
||||||
} );
|
});
|
||||||
this.html.find('.creature-dommages').change(async event => {
|
this.html.find('.creature-dommages').change(async event => {
|
||||||
let compName = event.currentTarget.attributes.compname.value;
|
let compName = event.currentTarget.attributes.compname.value;
|
||||||
this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) );
|
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
|
||||||
} );
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -847,17 +847,21 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCreatureCompetence(idOrName, fieldName, compValue) {
|
async updateCreatureCompetence(idOrName, fieldName, value) {
|
||||||
let competence = this.getCompetence(idOrName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (competence) {
|
if (competence) {
|
||||||
const update = { _id: competence.id }
|
function getPath(fieldName) {
|
||||||
if (fieldName == "niveau")
|
switch (fieldName) {
|
||||||
update['system.niveau'] = compValue;
|
case "niveau": return 'system.niveau';
|
||||||
else if (fieldName == "dommages")
|
case "dommages": return 'system.dommages';
|
||||||
update['system.dommages'] = compValue;
|
case "carac_value": return 'system.carac_value';
|
||||||
else
|
}
|
||||||
update['system.carac_value'] = compValue;
|
return undefined
|
||||||
await this.updateEmbeddedDocuments('Item', [update]); // updates one EmbeddedEntity
|
}
|
||||||
|
const path = getPath(fieldName);
|
||||||
|
if (path){
|
||||||
|
await this.updateEmbeddedDocuments('Item', [{ _id: competence.id, [path]: value }]); // updates one EmbeddedEntity
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1158,6 +1158,8 @@ div.competence-column div.categorie-competence{
|
|||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
.sante-value,
|
.sante-value,
|
||||||
|
.competence-carac,
|
||||||
|
.competence-damage,
|
||||||
.competence-value {
|
.competence-value {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
flex-basis: 2rem;
|
flex-basis: 2rem;
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<span>{{comp.name}}</span>
|
<span>{{comp.name}}</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<input class="competence-value creature-carac" type="text" compname="{{comp.name}}"
|
<input class="competence-carac" type="text" compname="{{comp.name}}" name="{{comp._id}}.carac"
|
||||||
value="{{comp.system.carac_value}}" data-dtype="number"
|
value="{{comp.system.carac_value}}" data-dtype="number"
|
||||||
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
|
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
|
||||||
<input class="competence-value creature-niveau" type="text" compname="{{comp.name}}"
|
<input class="competence-value creature-niveau" type="text" compname="{{comp.name}}" name="{{comp._id}}.niveau"
|
||||||
value="{{numberFormat comp.system.niveau decimals=0 sign=true}}" data-dtype="number"
|
value="{{numberFormat comp.system.niveau decimals=0 sign=true}}" data-dtype="number"
|
||||||
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
|
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
|
||||||
<input class="competence-value creature-dommages" type="text" compname="{{comp.name}}"
|
<input class="competence-damage creature-dommages" type="text" compname="{{comp.name}}" name="{{comp._id}}.dommages"
|
||||||
value="{{numberFormat comp.system.dommages decimals=0 sign=true}}" data-dtype="number"
|
value="{{numberFormat comp.system.dommages decimals=0 sign=true}}" data-dtype="number"
|
||||||
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
|
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
|
||||||
{{#if @root.options.vueDetaillee}}
|
{{#if @root.options.vueDetaillee}}
|
||||||
|
Loading…
Reference in New Issue
Block a user