1
0
Fork 0
mirror of https://github.com/em-squared/5e-drs.git synced 2025-10-29 04:34:19 +00:00
5e-drs/docs/.vuepress/theme/util/monsterHelpers.js
2020-04-15 16:27:16 +02:00

41 lines
1 KiB
JavaScript

import {stats} from '../../data/stats'
// Calcul du modificateur de caractéristique
export function getModifier (score) {
return Math.floor((score - 10) / 2)
}
// Ajoute un + devant les valeurs positives pour l'affichage
export function displayBonus (value) {
if (value >= 0) {
value = '+' + value
}
return value
}
// Affichage d'un score de caractéristiques sous la forme 16 (+3)
export function displayAbilityScore (score) {
let modifier = getModifier(score)
if (modifier >= 0) {
modifier = '+' + modifier
}
return score + ' (' + modifier + ')'
}
// Calcul du bonus de maîtrise en fonction du niveau
export function getProficiencyBonus (level) {
return Math.ceil(level / 4) + 1
}
// Affiche l'indice de dangerosité
export function displayChallenge (challenge, xp = false) {
let result = ''
if (stats.challenges[challenge]) {
result += stats.challenges[challenge].label
if (xp) {
result += ' (PX : ' + stats.challenges[challenge].xp + ')'
}
return result
}
return challenge
}