Integrate changes from the Prof

Received as-is changes from the Prof.
This commit is contained in:
supervj 2021-05-21 14:58:11 -04:00
parent cacc43740e
commit b3344ba8b9
19 changed files with 490 additions and 30 deletions

View file

@ -77,7 +77,11 @@ export default class Actor5e extends Actor {
// Inventory encumbrance
data.attributes.encumbrance = this._computeEncumbrance(actorData);
if (actorData.type === "starship") {
data.attributes.fuel = this._computeFuel(actorData);
}
// Prepare skills
this._prepareSkills(actorData, bonuses, checkBonus, originalSkills);
@ -647,8 +651,17 @@ export default class Actor5e extends Actor {
const pct = Math.clamped((weight * 100) / max, 0, 100);
return { value: weight.toNearest(0.1), max, pct, encumbered: pct > (2/3) };
}
/* -------------------------------------------- */
_computeFuel(actorData) {
let fuel = actorData.data.attributes.fuel.value;
// 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 };
}
/* -------------------------------------------- */
/* Socket Listeners and Handlers
/* -------------------------------------------- */

View file

@ -17,6 +17,7 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
return mergeObject(super.defaultOptions, {
classes: ["sw5e", "sheet", "actor", "starship"],
width: 800,
height: 775,
tabs: [{
navSelector: ".root-tabs",
contentSelector: ".sheet-body",
@ -135,6 +136,7 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
activateListeners(html) {
super.activateListeners(html);
html.find(".health .rollable").click(this._onRollHPFormula.bind(this));
html.find('.refuel').click(this._onIncrementFuelLevel.bind(this));
}
/* -------------------------------------------- */
@ -153,4 +155,81 @@ export default class ActorSheet5eStarship extends ActorSheet5e {
this.actor.update({"data.attributes.hp.value": hp, "data.attributes.hp.max": hp});
}
/* -------------------------------------------- */
/**
* Handle refueling a starship
* @param {Event} event The original click event
* @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});
}
function engineSliderUpdate(num) {
var symbol;
var coefficient;
switch(num) {
case "0":
symbol = "↓";
coefficient = 0.5;
break;
case "1":
symbol = "=";
coefficient = 1;
break;
case "2":
symbol = "↑";
coefficient = 2;
};
let slideroutput = symbol;
document.querySelector('#engineslideroutput').value = slideroutput;
this.actor.update({"data.attributes.engpow": coefficient});
}
function shieldSliderUpdate(num) {
var symbol;
var coefficient;
switch(num) {
case "0":
symbol = "↓";
coefficient = 0.5;
break;
case "1":
symbol = "=";
coefficient = 1;
break;
case "2":
symbol = "↑";
coefficient = 2;
};
let slideroutput = symbol;
document.querySelector('#shieldslideroutput').value = slideroutput;
this.actor.update({"data.attributes.shieldpow": coefficient});
}
function weaponSliderUpdate(num) {
var symbol;
var coefficient;
switch(num) {
case "0":
symbol = "↓";
coefficient = 0.5;
break;
case "1":
symbol = "=";
coefficient = 1;
break;
case "2":
symbol = "↑";
coefficient = 2;
};
let slideroutput = symbol;
document.querySelector('#weaponslideroutput').value = slideroutput;
this.actor.update({"data.attributes.weaponpow": coefficient});
}
}

View file

@ -367,6 +367,7 @@ SW5E.movementTypes = {
"crawl": "SW5E.MovementCrawl",
"fly": "SW5E.MovementFly",
"roll": "SW5E.MovementRoll",
"space": "SW5E.MovementSpace",
"swim": "SW5E.MovementSwim",
"turn": "SW5E.MovementTurn",
"walk": "SW5E.MovementWalk",