diff --git a/src/PersonObjects/formulas/skill.ts b/src/PersonObjects/formulas/skill.ts index 86f422ce4..2aa52bff4 100644 --- a/src/PersonObjects/formulas/skill.ts +++ b/src/PersonObjects/formulas/skill.ts @@ -9,9 +9,14 @@ export function calculateExp(skill: number, mult = 1): number { export function calculateSkillProgress(exp: number, mult = 1): ISkillProgress { const currentSkill = calculateSkill(exp, mult); const nextSkill = currentSkill + 1; + let baseExperience = calculateExp(currentSkill, mult); if (baseExperience < 0) baseExperience = 0; - const nextExperience = calculateExp(nextSkill, mult) + + let nextExperience = calculateExp(nextSkill, mult) + if (nextExperience < 0) nextExperience = 0; + + const normalize = (value: number): number => ((value - baseExperience) * 100) / (nextExperience - baseExperience); return { currentSkill, @@ -19,7 +24,7 @@ export function calculateSkillProgress(exp: number, mult = 1): ISkillProgress { baseExperience, experience: exp, nextExperience, - progress: exp / nextExperience, + progress: (nextExperience - baseExperience !== 0) ? normalize(exp) : 99.99 } } @@ -32,7 +37,7 @@ export interface ISkillProgress { progress: number; } -export function getEmptySkillProgress() { +export function getEmptySkillProgress(): ISkillProgress { return { currentSkill: 0, nextSkill: 0, baseExperience: 0, experience: 0, nextExperience: 0, diff --git a/src/ui/React/StatsProgressBar.tsx b/src/ui/React/StatsProgressBar.tsx index 7811a8c30..085d5afca 100644 --- a/src/ui/React/StatsProgressBar.tsx +++ b/src/ui/React/StatsProgressBar.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import LinearProgress from "@mui/material/LinearProgress"; -import { TableCell, Tooltip } from "@mui/material"; +import { TableCell, Tooltip, Typography } from "@mui/material"; import { characterOverviewStyles } from "./CharacterOverview"; import { ISkillProgress } from "src/PersonObjects/formulas/skill"; import { numeralWrapper } from "../numeralFormat"; @@ -9,6 +9,7 @@ interface IProgressProps { min: number; max: number; current: number; + progress: number; color?: React.CSSProperties["color"]; } @@ -17,21 +18,22 @@ interface IStatsOverviewCellProps { color?: React.CSSProperties["color"]; } -export function StatsProgressBar({ min, max, current, color }: IProgressProps): React.ReactElement { - const normalise = (value: number): number => ((value - min) * 100) / (max - min); - const tooltipText = ( - <> - Experience: {numeralWrapper.formatExp(current)}/{numeralWrapper.formatExp(max)} +export function StatsProgressBar({ min, max, current, progress, color }: IProgressProps): React.ReactElement { + const tooltip = ( + + Progress:  + {numeralWrapper.formatExp(current - min)} / {numeralWrapper.formatExp(max - min)}
- {normalise(current).toFixed(2)}% - + Remaining:  + {numeralWrapper.formatExp(max - current)} ({progress.toFixed(2)}%) +
); return ( - +