Add the Aspect sheet and update some translation keys for the actor sheet
This commit is contained in:
parent
c0d677cd77
commit
763a0982d5
22 changed files with 1277 additions and 84 deletions
|
|
@ -9,7 +9,8 @@ export const partials = [
|
|||
|
||||
export async function registerHandlebarsHelpers() {
|
||||
Handlebars.registerHelper({
|
||||
"dotdungeon-array": createArray
|
||||
"dotdungeon-array": createArray,
|
||||
"dotdungeon-toFriendlyDuration": toFriendlyDuration,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -33,4 +34,30 @@ export async function preloadHandlebarsTemplates() {
|
|||
|
||||
function createArray(...args) {
|
||||
return args.slice(0, -1);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
const secondsInAMinute = 60;
|
||||
const secondsInAnHour = 60 * secondsInAMinute;
|
||||
/**
|
||||
* Converts a duration into a more human-friendly format
|
||||
* @param {number} duration The length of time in seconds
|
||||
* @returns The human-friendly time string
|
||||
*/
|
||||
function toFriendlyDuration(duration) {
|
||||
let friendly = ``;
|
||||
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