1
0
Fork 0
mirror of https://github.com/em-squared/5e-drs.git synced 2025-10-29 12:44:20 +00:00
5e-drs/docs/.vuepress/theme/util/monsterHelpers.js

42 lines
1 KiB
JavaScript
Raw Normal View History

2020-04-15 16:27:16 +02:00
import {stats} from '../../data/stats'
2020-04-10 16:37:48 +02:00
// 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
}
2020-04-15 16:27:16 +02:00
// 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
}