forked from public/foundryvtt-reve-de-dragon
Preliminary verssion for fight
This commit is contained in:
@ -42,10 +42,11 @@ export class RdDActorSheet extends ActorSheet {
|
||||
}
|
||||
list.push(item);
|
||||
}
|
||||
// Competence per category
|
||||
data.competenceByCategory = {};
|
||||
if (data.itemsByType.competence) {
|
||||
for (const item of data.itemsByType.competence) {
|
||||
console.log("Push...", item, item.data.categorie);
|
||||
//console.log("Push...", item, item.data.categorie);
|
||||
let list = data.competenceByCategory[item.data.categorie];
|
||||
if (!list) {
|
||||
list = [];
|
||||
@ -55,6 +56,17 @@ export class RdDActorSheet extends ActorSheet {
|
||||
}
|
||||
}
|
||||
|
||||
// Update arme list with niveau from the associated competence
|
||||
if (data.itemsByType.arme) {
|
||||
for (const arme of data.itemsByType.arme) {
|
||||
arme.data.niveau = 0; // Per default, TODO to be fixed
|
||||
for ( const melee of data.competenceByCategory.melee ) {
|
||||
if (melee.name == arme.data.competence )
|
||||
arme.data.niveau = melee.data.niveau
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//endurance.max below is normal, this the base used to compute the grid.
|
||||
data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>";
|
||||
data.data.materiel = this._checkNull(data.itemsByType['objet']);
|
||||
@ -63,7 +75,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
data.data.livres = this._checkNull(data.itemsByType['livre']);
|
||||
data.data.potions = this._checkNull(data.itemsByType['potions']);
|
||||
data.data.competenceByCategory = data.competenceByCategory;
|
||||
|
||||
data.data.armes = data.itemsByType.arme;
|
||||
//console.log(">>>>> data update");
|
||||
|
||||
return data;
|
||||
@ -97,48 +109,48 @@ export class RdDActorSheet extends ActorSheet {
|
||||
let compName = event.currentTarget.text;
|
||||
this.actor.rollCompetence( compName);
|
||||
});
|
||||
|
||||
// Roll Weapon
|
||||
html.find('.arme-label a').click((event) => {
|
||||
let armeName = event.currentTarget.text;
|
||||
this.actor.rollArme( armeName);
|
||||
});
|
||||
|
||||
// On carac change
|
||||
$(".carac-value").change((event) => {
|
||||
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
|
||||
console.log("Value changed :", event, caracName);
|
||||
//console.log("Value changed :", event, caracName);
|
||||
this.actor.updateCarac( caracName, parseInt(event.target.value) );
|
||||
} );
|
||||
// On competence change
|
||||
$(".competence-value").change((event) => {
|
||||
let compName = event.currentTarget.attributes.compname.value;
|
||||
console.log("Competence changed :", compName);
|
||||
//console.log("Competence changed :", compName);
|
||||
this.actor.updateCompetence( compName, parseInt(event.target.value) );
|
||||
} );
|
||||
|
||||
$("#vie-plus").click((event) => {
|
||||
this.actor.santeIncDec("vie", 1);
|
||||
this.actor.update({"data.sante.vie.value": this.actor.data.data.sante.vie.value});
|
||||
this.render(true);
|
||||
});
|
||||
$("#vie-moins").click((event) => {
|
||||
this.actor.santeIncDec("vie", -1);
|
||||
this.actor.update({"data.sante.vie.value": this.actor.data.data.sante.vie.value});
|
||||
this.render(true);
|
||||
});
|
||||
$("#endurance-plus").click((event) => {
|
||||
this.actor.santeIncDec("endurance", 1);
|
||||
this.actor.update({"data.sante.endurance.value": this.actor.data.data.sante.endurance.value});
|
||||
this.render(true);
|
||||
});
|
||||
$("#endurance-moins").click((event) => {
|
||||
this.actor.santeIncDec("endurance", -1);
|
||||
this.actor.update({"data.sante.endurance.value": this.actor.data.data.sante.endurance.value});
|
||||
this.render(true);
|
||||
});
|
||||
$("#fatigue-plus").click((event) => {
|
||||
this.actor.santeIncDec("fatigue", 1);
|
||||
this.actor.update({"data.sante.fatigue.value": this.actor.data.data.sante.fatigue.value});
|
||||
this.render(true);
|
||||
});
|
||||
$("#fatigue-moins").click((event) => {
|
||||
this.actor.santeIncDec("fatigue", -1);
|
||||
this.actor.update({"data.sante.fatigue.value": this.actor.data.data.sante.fatigue.value});
|
||||
this.render(true);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user