added bonds tab and base logic

This commit is contained in:
The Last Scrub
2020-06-27 15:03:47 -07:00
parent 8507bf2202
commit 13e8a6465b
4 changed files with 82 additions and 5 deletions
+47 -1
View File
@@ -142,7 +142,6 @@ export class DeltaGreenActorSheet extends ActorSheet {
event.preventDefault();
let targetskill = event.target.getAttribute("data-typeskill");
//let updatedData = duplicate(this.actor.data.data);
this._showNewTypeSkillDialog(targetskill);
});
@@ -165,6 +164,19 @@ export class DeltaGreenActorSheet extends ActorSheet {
this.actor.update({"data": updatedData});
});
html.find('.btn-add-bond').click(event => {
event.preventDefault();
this._addNewBond();
});
html.find('.btn-remove-bond').click(event => {
event.preventDefault();
let skillindex = event.target.getAttribute("data-index");
this._removeBond(skillindex);
});
}
_showNewTypeSkillDialog(targetskill){
@@ -204,6 +216,40 @@ export class DeltaGreenActorSheet extends ActorSheet {
this.actor.update({"data": updatedData});
}
_addNewBond(){
let updatedData = duplicate(this.actor.data.data);
let updatedBonds = [];
let x;
for(x in updatedData.bonds){
if(Number.isNumeric(x)){
updatedBonds.push(updatedData.bonds[x]);
}
}
updatedBonds.push({"description": "New", "score": updatedData.statistics.cha.value});
updatedData.bonds = updatedBonds;
this.actor.update({"data": updatedData});
}
_removeBond(pos){
let updatedData = duplicate(this.actor.data.data);
let updatedBonds = [];
let x;
for(x in updatedData.bonds){
if(Number.isNumeric(x) && x != pos){
updatedBonds.push(updatedData.bonds[x]);
}
}
updatedData.bonds = updatedBonds;
this.actor.update({"data": updatedData});
}
/**
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
* @param {Event} event The originating click event