Compare commits

...

2 Commits

Author SHA1 Message Date
catloversg
c06c6590c9 BUGFIX: calculateExp throws errors in edge cases (#2667) 2026-04-17 00:57:50 -07:00
catloversg
45bce6e45e MISC: Reduce achievements check interval (#2650) 2026-04-15 18:47:29 -07:00
3 changed files with 9 additions and 13 deletions

View File

@@ -4,19 +4,10 @@ import { AchievementList } from "./AchievementList";
import { achievements } from "./Achievements"; import { achievements } from "./Achievements";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import { Player } from "@player"; import { Player } from "@player";
import { makeStyles } from "tss-react/mui";
const useStyles = makeStyles()({
root: {
width: 50,
userSelect: "none",
},
});
export function AchievementsRoot(): JSX.Element { export function AchievementsRoot(): JSX.Element {
const { classes } = useStyles();
return ( return (
<div className={classes.root} style={{ width: "100%" }}> <div style={{ width: "100%" }}>
<Typography variant="h4">Achievements</Typography> <Typography variant="h4">Achievements</Typography>
<Box mx={2}> <Box mx={2}>
<Typography> <Typography>

View File

@@ -5,6 +5,11 @@ import { clampNumber } from "../../utils/helpers/clampNumber";
* stat level. Stat-agnostic (same formula for every stat) * stat level. Stat-agnostic (same formula for every stat)
*/ */
export function calculateSkill(exp: number, mult = 1): number { export function calculateSkill(exp: number, mult = 1): number {
// Mult can be 0 in BN12 when the player has a very high SF12 level. In this case, the skill level will never change
// from its initial value (1 for most stats, except intelligence).
if (mult === 0) {
return 1;
}
const value = Math.floor(mult * (32 * Math.log(exp + 534.6) - 200)); const value = Math.floor(mult * (32 * Math.log(exp + 534.6) - 200));
return clampNumber(value, 1); return clampNumber(value, 1);
} }
@@ -12,7 +17,7 @@ export function calculateSkill(exp: number, mult = 1): number {
export function calculateExp(skill: number, mult = 1): number { export function calculateExp(skill: number, mult = 1): number {
const floorSkill = Math.floor(skill); const floorSkill = Math.floor(skill);
let value = Math.exp((skill / mult + 200) / 32) - 534.6; let value = Math.exp((skill / mult + 200) / 32) - 534.6;
if (skill === floorSkill && Number.isFinite(skill)) { if (skill === floorSkill && Number.isFinite(skill) && Number.isFinite(value)) {
// Check for floating point rounding issues that would cause the inverse // Check for floating point rounding issues that would cause the inverse
// operation to return the wrong result. // operation to return the wrong result.
let calcSkill = calculateSkill(value, mult); let calcSkill = calculateSkill(value, mult);

View File

@@ -157,7 +157,7 @@ const Engine = {
messages: 150, messages: 150,
mechanicProcess: 5, // Process Bladeburner mechanicProcess: 5, // Process Bladeburner
contractGeneration: 3000, // Generate Coding Contracts contractGeneration: 3000, // Generate Coding Contracts
achievementsCounter: 60, // Check if we have new achievements achievementsCounter: 5, // Check if we have new achievements
}, },
decrementAllCounters: function (numCycles = 1) { decrementAllCounters: function (numCycles = 1) {
@@ -215,7 +215,7 @@ const Engine = {
if (Engine.Counters.achievementsCounter <= 0) { if (Engine.Counters.achievementsCounter <= 0) {
calculateAchievements(); calculateAchievements();
Engine.Counters.achievementsCounter = 300; Engine.Counters.achievementsCounter = 5;
} }
// This **MUST** remain the last block in the function! // This **MUST** remain the last block in the function!