const { MAXIMUM } = require("./constants"); const { MAX_LEVEL_ELITE } = MAXIMUM; const a = 1; const b = -1; const levels = { pirateLevel(points) { const c = points * 2 / 250 * -1; const discriminant = Math.pow(b, 2) - 4 * a * c; const x1 = (-b + Math.sqrt(discriminant)) / (2 * a); const currentLevel = Math.floor(x1); return currentLevel; }, eliteLevel(points) { const c = points * 2 / 750 * -1; const discriminant = Math.pow(b, 2) - 4 * a * c; const x1 = (-b + Math.sqrt(discriminant)) / (2 * a); const currentLevel = Math.floor(x1); return Math.min(currentLevel, MAX_LEVEL_ELITE); }, fishingLevel(points) { const c = points * 2 / 525 * -1; const discriminant = Math.pow(b, 2) - 4 * a * c; const x1 = (-b + Math.sqrt(discriminant)) / (2 * a); const currentLevel = Math.floor(x1); return currentLevel; }, guildLevel(points) { const c = points * 2 / 20 * -1; const discriminant = Math.pow(b, 2) - 4 * a * c; const x1 = (-b + Math.sqrt(discriminant)) / (2 * a); const currentLevel = Math.floor(x1); return currentLevel; } }; module.exports = levels;