Make the friendly duration be a getter on the Aspect class
This commit is contained in:
parent
b19d248bc8
commit
649381cfdd
1 changed files with 23 additions and 1 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import { DotDungeonItem } from "./GenericItem.mjs";
|
||||
|
||||
const secondsInAMinute = 60;
|
||||
const secondsInAnHour = 60 * secondsInAMinute;
|
||||
|
||||
export class Aspect extends DotDungeonItem {
|
||||
async _preCreate() {
|
||||
if (this.isEmbedded) {
|
||||
|
|
@ -16,5 +19,24 @@ export class Aspect extends DotDungeonItem {
|
|||
|
||||
return await this.actor?.preItemEmbed(this);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
get friendlyDuration() {
|
||||
let friendly = ``;
|
||||
let duration = this.system.deactivateAfter;
|
||||
if (duration >= secondsInAnHour) {
|
||||
let hours = Math.floor(duration / secondsInAnHour);
|
||||
friendly += `${hours}h`;
|
||||
duration -= hours * secondsInAnHour;
|
||||
};
|
||||
if (duration >= secondsInAMinute) {
|
||||
let minutes = Math.floor(duration / secondsInAMinute);
|
||||
friendly += `${minutes}m`;
|
||||
duration -= minutes * secondsInAMinute;
|
||||
};
|
||||
if (duration > 0) {
|
||||
friendly += `${duration}s`;
|
||||
};
|
||||
return friendly;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue