forked from GitHub-Mirrors/foundry-sw5e
Integrate changes from the Prof
Received as-is changes from the Prof.
This commit is contained in:
parent
ea0a874e38
commit
8b60052f65
17 changed files with 488 additions and 30 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue