Nevermind we're just doing the 'furthest' rolls

This commit is contained in:
dakedres 2023-05-23 23:19:25 -06:00
parent 1e6022c0bd
commit d51d400e04

View File

@ -113,22 +113,6 @@ const handleMessage = (message, respond) => {
rollDice(dice, respond)
}
const bleemRoll = (dice, rolls, comparison, resultDistance = -1) => {
let result = 0
let pseudoMedian = Math.floor(dice.size / 2)
for(let roll of rolls) {
let distance = Math.abs(roll - pseudoMedian)
if(comparison(result, resultDistance)) {
result = roll
resultDistance = distance
}
}
return result
}
const rollDice = (dice, respond) => {
if(dice.size > 255) {
respond('That die is way too big... .-.')
@ -148,7 +132,6 @@ const rollDice = (dice, respond) => {
let result = 0
let operationSymbol = dice.operation
let response = ''
let comparison
switch(dice.mode.toLowerCase()) {
case 'd':
@ -164,11 +147,17 @@ const rollDice = (dice, respond) => {
break
case 'f':
result = bleemRoll(dice, rolls, (l, r) => l > r, -1)
break
let pseudoMedian = Math.floor(dice.size / 2)
let resultDistance = -1
case 'b':
result = bleemRoll(dice, rolls, (l, r) => l < r, Infinity)
for(let roll of rolls) {
let distance = Math.abs(roll - pseudoMedian)
if(distance > resultDistance) {
result = roll
resultDistance = distance
}
}
break
}