pelican-jdr/static/bestiaire.js
Kazhnuz 4e8af1fd5f a
2021-10-05 21:03:43 +02:00

85 lines
2.5 KiB
JavaScript

let data = {
"files": [
{"title":"Animaux", "file":"animals.json"}
],
"archetypes": {
"tiny":{
"pv":10, "pe":20,
"FOR":30, "INT":50, "CHA":40,
"CON":20, "SAG":80, "DIS":80,
"HAB":90, "VOL":40, "REL":50,
"PER":50,
"PHY":0, "SPE":0, "MEN":0,
"VIG":-2, "JET":1, "PSY":1
},
"small":{
"pv":15, "pe":20,
"FOR":40, "INT":50, "CHA":35,
"CON":30, "SAG":50, "DIS":70,
"HAB":80, "VOL":45, "REL":50,
"PER":50,
"VIG":0, "JET":0, "PSY":0
},
"medium":{
"pv":35, "pe":20,
"FOR":50, "INT":40, "CHA":50,
"CON":40, "SAG":40, "DIS":50,
"HAB":60, "VOL":50, "REL":50,
"PER":50,
"VIG":1, "JET":0, "PSY":0
},
},
"traits": {
"predateur":{"boost1":"PHY", "boost2":"INS", "malus":"FIN", "pv":0, "pe":0},
"craintif":{"boost1":"DIS", "boost2":"FIN", "malus":"", "pv":10, "pe":-10},
"domestique":{"boost1":"REL", "boost2":"AUR", "malus":"INS", "pv":-10, "pe":0}
},
"levels": [
{"base":0, "min":10, "max":70, "boost1":15, "boost2":5, "malus":-15, "dice":2, "pv":1},
{"base":10, "min":10, "max":70, "boost1":20, "boost2":10, "malus":-15, "dice":2, "pv":1.25},
{"base":10, "min":10, "max":70, "boost1":20, "boost2":10, "malus":-15, "dice":3, "pv":1.5},
{"base":20, "min":10, "max":70, "boost1":20, "boost2":10, "malus":-15, "dice":3, "pv":2},
{"base":20, "min":10, "max":70, "boost1":20, "boost2":10, "malus":-15, "dice":3, "pv":3}
],
"dices": ["1D2", "1D4", "1D6", "1D8", "1D12", "1D20"]
}
function getPV(level, size, trait) {
var levelData = getLevelData(level);
var sizeData = getSizeData(size);
var traitData = getTraitData(trait);
return Math.floor((sizeData.pv + traitData.pv) * levelData.pv);
}
function getPE(level, size, trait) {
var levelData = getLevelData(level);
var sizeData = getSizeData(size);
var traitData = getTraitData(trait);
return Math.floor((sizeData.pe + traitData.pe) * levelData.pv);
}
function getLevelData(level) {
var levelValue = Math.min(Math.max(0, level - 1), 4)
var allLevelsData = data["levels"]
return allLevelsData[levelValue]
}
function getSizeData(size) {
var allSizeData = data["stats"]
return allSizeData[size]
}
function getTraitData(trait) {
var allTraitsData = data["traits"]
return allTraitsData[trait]
}
function getStat(type, level, size, trait) {
var levelData = getLevelData(level);
var sizeData = getSizeData(size);
var traitData = getTraitData(trait);
return sizeData[type] + levelData.base;
}