@pokecord/core
Version:
Pokécord core
26 lines (25 loc) • 710 B
JavaScript
function random(){
return Math.round(Math.random() * 31);
}
function randomIvSet(){
// heakth, atk, def, spatk, spdef, speed
return `${this.random()};${this.random()};${this.random()};${this.random()};${this.random()};${this.random()};${this.random()}`
}
function getIvPercentage(x){
if(typeof(x) !== 'string'){
throw new TypeError(`Entered value for getIvPercentage must be a string`)
}
const e = x.split(";");
let t1 = e[0]/31;
let t2 = e[1]/31;
let t3 = e[2]/31;
let t4 = e[3]/31;
let t5 = e[4]/31;
let t6 = e[5]/31;
let tot = t1 + t2 +t3 + t4 + t5 + t6;
let fi = `${tot/6}`;
return Number((fi*100).toFixed(2))
}
module.exports = {
random, randomIvSet, getIvPercentage
}