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 ea0a874e38
commit 8b60052f65
17 changed files with 488 additions and 30 deletions

View file

@ -118,7 +118,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);
@ -727,6 +731,19 @@ export default class Actor5e extends Actor {
/* -------------------------------------------- */
/* Event Handlers */
/* -------------------------------------------- */
_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
/* -------------------------------------------- */
/** @inheritdoc */
async _preCreate(data, options, user) {