diff --git a/module/actor/entity.js b/module/actor/entity.js
index 09d8ab95..561e52eb 100644
--- a/module/actor/entity.js
+++ b/module/actor/entity.js
@@ -382,7 +382,8 @@ export default class Actor5e extends Actor {
// push to derived since based on attributes
// data.attributes.hp.tempmax = sizeData.shldDiceRolled[].reduce((a, b) => a + b, 0) + str.mod * shld.diceMax;
// if (data.attributes.hp.temp === null) data.attributes.hp.temp = data.attributes.hp.tempmax;
- data.attributes.pwrdice.die = SW5E.powerDieTypes[tiers];
+ sizeData.pwrDice = SW5E.powerDieTypes[tiers];
+ data.attributes.power.die = sizeData.pwrDice;
data.attributes.cost.baseBuild = sizeData.buildBaseCost;
data.attributes.workforce.minBuild = sizeData.buildMinWorkforce;
data.attributes.workforce.max = data.attributes.workforce.minBuild * 5;
@@ -406,7 +407,7 @@ export default class Actor5e extends Actor {
data.attributes.workforce.minEquip = sizeData.equipMinWorkforce;
data.attributes.equip.cargoCap = sizeData.cargoCap;
data.attributes.fuel.cost = sizeData.fuelCost;
- data.attributes.fuel.value = sizeData.fuelCap;
+ data.attributes.fuel.cap = sizeData.fuelCap;
data.attributes.equip.foodCap = sizeData.foodCap;
@@ -782,12 +783,10 @@ export default class Actor5e extends Actor {
/* -------------------------------------------- */
_computeFuel(actorData) {
- let fuel = actorData.data.attributes.fuel.value;
+ const fuel = actorData.data.attributes.fuel;
// Compute Fuel percentage
- fuel = fuel.toNearest(0.1);
- const max = actorData.data.attributes.fuel.cap;
- const pct = Math.clamped((fuel * 100) / max, 0, 100);
- return { value: fuel.toNearest(0.1), max, pct, fueled: pct > 0 };
+ const pct = Math.clamped((fuel.value.toNearest(0.1) * 100) / fuel.cap, 0, 100);
+ return { ...fuel, pct, fueled: pct > 0 };
}
/* -------------------------------------------- */
diff --git a/module/actor/sheets/newSheet/starship.js b/module/actor/sheets/newSheet/starship.js
index b9218b36..145a87e8 100644
--- a/module/actor/sheets/newSheet/starship.js
+++ b/module/actor/sheets/newSheet/starship.js
@@ -137,6 +137,10 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
super.activateListeners(html);
html.find(".health .rollable").click(this._onRollHPFormula.bind(this));
html.find('.refuel').click(this._onIncrementFuelLevel.bind(this));
+ html.find('.burnfuel').click(this._onDecrementFuelLevel.bind(this));
+ html.find('#engineslidervalue')[0].addEventListener('input', this._engineSliderUpdate.bind(this));
+ html.find('#shieldslidervalue')[0].addEventListener('input', this._shieldSliderUpdate.bind(this));
+ html.find('#weaponslidervalue')[0].addEventListener('input', this._weaponSliderUpdate.bind(this));
}
/* -------------------------------------------- */
@@ -163,17 +167,31 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
* @private
*/
_onIncrementFuelLevel(event) {
- event.preventDefault();
- const fuelcaparray = this.actor.data.effects.changes;
- var fuelcappos = fuelcaparray.indexOf('fuel.cap');
- const refuel = this.actor.data.effect.changes[fuelcappos].value;
- this.actor.update({"data.attributes.fuel.value": refuel});
+ // event.preventDefault();
+ // const fuelcaparray = this.actor.data.effects.changes;
+ // var fuelcappos = fuelcaparray.indexOf('fuel.cap');
+ // const refuel = this.actor.data.effect.changes[fuelcappos].value;
+ this.actor.update({"data.attributes.fuel.value": this.actor.data.data.attributes.fuel.cap});
}
-}
- function engineSliderUpdate(num) {
+
+ /* -------------------------------------------- */
+
+ /**
+ * Handle a starship burning fuel
+ * @param {Event} event The original click event
+ * @private
+ */
+ _onDecrementFuelLevel(event) {
+ // event.preventDefault();
+ // const fuelcaparray = this.actor.data.effects.changes;
+ // var fuelcappos = fuelcaparray.indexOf('fuel.cap');
+ // const refuel = this.actor.data.effect.changes[fuelcappos].value;
+ this.actor.update({"data.attributes.fuel.value": this.actor.data.data.attributes.fuel.value - 1});
+ }
+ _engineSliderUpdate(input) {
var symbol;
var coefficient;
- switch(num) {
+ switch(input.target.value) {
case "0":
symbol = "↓";
coefficient = 0.5;
@@ -188,13 +206,13 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
};
let slideroutput = symbol;
document.querySelector('#engineslideroutput').value = slideroutput;
- this.actor.update({"data.attributes.engpow": coefficient});
+ this.actor.update({"data.attributes.power.routing.engines": coefficient});
}
- function shieldSliderUpdate(num) {
+ _shieldSliderUpdate(input) {
var symbol;
var coefficient;
- switch(num) {
+ switch(input.target.value) {
case "0":
symbol = "↓";
coefficient = 0.5;
@@ -209,13 +227,13 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
};
let slideroutput = symbol;
document.querySelector('#shieldslideroutput').value = slideroutput;
- this.actor.update({"data.attributes.shieldpow": coefficient});
+ this.actor.update({"data.attributes.power.routing.shields": coefficient});
}
- function weaponSliderUpdate(num) {
+ _weaponSliderUpdate(input) {
var symbol;
var coefficient;
- switch(num) {
+ switch(input.target.value) {
case "0":
symbol = "↓";
coefficient = 0.5;
@@ -230,5 +248,6 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
};
let slideroutput = symbol;
document.querySelector('#weaponslideroutput').value = slideroutput;
- this.actor.update({"data.attributes.weaponpow": coefficient});
+ this.actor.update({"data.attributes.power.routing.weapons": coefficient});
}
+}
diff --git a/sw5e.js b/sw5e.js
index 394af593..70960e28 100644
--- a/sw5e.js
+++ b/sw5e.js
@@ -292,6 +292,10 @@ Handlebars.registerHelper('round', function(value) {
return Math.floor(value);
});
+Handlebars.registerHelper('debug', function(value) {
+ console.log(value)
+ return value;
+})
function setFolderBackground(html) {
html.find("header.folder-header").each(function() {
diff --git a/templates/actors/newActor/starship.html b/templates/actors/newActor/starship.html
index c1369cb3..cc990e5d 100644
--- a/templates/actors/newActor/starship.html
+++ b/templates/actors/newActor/starship.html
@@ -175,7 +175,7 @@
|
@@ -224,11 +224,11 @@