mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Adding Prettier
* Added prettier with automatic useage on pre-commit to avoid style breakage * Ran Prettier on the project
This commit is contained in:
parent
820c2df1f4
commit
b24cdcc9ed
136 changed files with 13929 additions and 12206 deletions
|
|
@ -1,7 +1,7 @@
|
|||
export const loadCompendiumOptions = async (compendiums) => {
|
||||
export const loadCompendiumOptions = async compendiums => {
|
||||
const compendiumValues = [];
|
||||
|
||||
for(var compendium of compendiums){
|
||||
for (var compendium of compendiums) {
|
||||
const values = await getCompendiumOptions(compendium);
|
||||
compendiumValues.push(values);
|
||||
}
|
||||
|
|
@ -9,11 +9,11 @@ export const loadCompendiumOptions = async (compendiums) => {
|
|||
return compendiumValues;
|
||||
};
|
||||
|
||||
const getCompendiumOptions = async (compendium) => {
|
||||
const getCompendiumOptions = async compendium => {
|
||||
const compendiumPack = await game.packs.get(compendium);
|
||||
|
||||
|
||||
const values = [];
|
||||
for(var value of compendiumPack.index){
|
||||
for (var value of compendiumPack.index) {
|
||||
const document = await compendiumPack.getDocument(value._id);
|
||||
values.push(document);
|
||||
}
|
||||
|
|
@ -34,24 +34,23 @@ export const getWidthOfText = (txt, fontsize, allCaps, bold) => {
|
|||
// getWidthOfText.e.innerText = txt;
|
||||
// return getWidthOfText.e.offsetWidth;
|
||||
const text = allCaps ? txt.toUpperCase() : txt;
|
||||
if(getWidthOfText.c === undefined){
|
||||
getWidthOfText.c=document.createElement('canvas');
|
||||
getWidthOfText.ctx=getWidthOfText.c.getContext('2d');
|
||||
if (getWidthOfText.c === undefined) {
|
||||
getWidthOfText.c = document.createElement('canvas');
|
||||
getWidthOfText.ctx = getWidthOfText.c.getContext('2d');
|
||||
}
|
||||
var fontspec = `${bold ? 'bold': ''} ${fontsize}px` + ' ' + 'Signika, sans-serif';
|
||||
if(getWidthOfText.ctx.font !== fontspec)
|
||||
getWidthOfText.ctx.font = fontspec;
|
||||
var fontspec = `${bold ? 'bold' : ''} ${fontsize}px` + ' ' + 'Signika, sans-serif';
|
||||
if (getWidthOfText.ctx.font !== fontspec) getWidthOfText.ctx.font = fontspec;
|
||||
|
||||
return getWidthOfText.ctx.measureText(text).width;
|
||||
}
|
||||
};
|
||||
|
||||
export const padArray = (arr, len, fill) => {
|
||||
return arr.concat(Array(len).fill(fill)).slice(0,len);
|
||||
}
|
||||
return arr.concat(Array(len).fill(fill)).slice(0, len);
|
||||
};
|
||||
|
||||
export const getTier = (level, asNr) => {
|
||||
switch(Math.floor((level+1)/3)){
|
||||
case 1:
|
||||
switch (Math.floor((level + 1) / 3)) {
|
||||
case 1:
|
||||
return asNr ? 1 : 'tier1';
|
||||
case 2:
|
||||
return asNr ? 2 : 'tier2';
|
||||
|
|
@ -60,23 +59,26 @@ export const getTier = (level, asNr) => {
|
|||
default:
|
||||
return asNr ? 0 : 'tier0';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const capitalize = (string) => {
|
||||
export const capitalize = string => {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
};
|
||||
|
||||
export const getPathValue = (path, entity, numeric) => {
|
||||
const pathValue = foundry.utils.getProperty(entity, path);
|
||||
if(pathValue) return numeric ? Number.parseInt(pathValue) : pathValue;
|
||||
if (pathValue) return numeric ? Number.parseInt(pathValue) : pathValue;
|
||||
|
||||
return numeric ? Number.parseInt(path) : path;
|
||||
};
|
||||
|
||||
export const generateId = (title, length) => {
|
||||
const id = title.split(" ").map((w, i) => {
|
||||
const p = w.slugify({replacement: "", strict: true});
|
||||
return i ? p.titleCase() : p;
|
||||
}).join("");
|
||||
return Number.isNumeric(length) ? id.slice(0, length).padEnd(length, "0") : id;
|
||||
}
|
||||
const id = title
|
||||
.split(' ')
|
||||
.map((w, i) => {
|
||||
const p = w.slugify({ replacement: '', strict: true });
|
||||
return i ? p.titleCase() : p;
|
||||
})
|
||||
.join('');
|
||||
return Number.isNumeric(length) ? id.slice(0, length).padEnd(length, '0') : id;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue