diff --git a/changelog.md b/changelog.md index e14f321..9d06af2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # The Modding Tree changelog: -# v2.5 (beta) +# v2.5: Dreams Really Do Come True - - Optimizations, hopefully a significant amount. - Added OOM/s point gen display at high values (thanks to Ducdat!) - Only one tab will display if the window is not wide enough (also thanks to Ducdat!) @@ -12,6 +12,7 @@ - Locked (not yet visible) milestones no longer take up space. Also fixed hidden milestones taking a tiny bit of space. - Re-centered respec buttons. - Force-displayed tooltips are not hidden by resets. +- Added formatting support for very small numbers. Disabled in most places by default because rounding errors can cause issues. Access it with formatSmall, or enable it globally by adding "allowSmall: true" to modInfo. # v2.4.1 - 4/29/21 - A number of minor fixes, many thanks to thepaperpilot. diff --git a/js/Demo/demoMod.js b/js/Demo/demoMod.js index 36f7cc9..746281f 100644 --- a/js/Demo/demoMod.js +++ b/js/Demo/demoMod.js @@ -11,8 +11,8 @@ let modInfo = { // Set your version in num and name let VERSION = { - num: "2.4.2", - name: "Rationalized Edition", + num: "2.5", + name: "Dreams Really Do Come True", } let changelog = `

Changelog:


diff --git a/js/game.js b/js/game.js index 8935d52..07d23b4 100644 --- a/js/game.js +++ b/js/game.js @@ -5,8 +5,8 @@ var scrolled = false; // Don't change this const TMT_VERSION = { - tmtNum: "2.4.2", - tmtName: "Rationalized Edition" + tmtNum: "2.5", + tmtName: "Dreams Really Do Come True" } function getResetGain(layer, useType = null) { diff --git a/js/technical/systemComponents.js b/js/technical/systemComponents.js index 41ad73c..0aee64e 100644 --- a/js/technical/systemComponents.js +++ b/js/technical/systemComponents.js @@ -106,7 +106,7 @@ var systemComponents = {

{{format(player.points)}}

{{modInfo.pointsName}}
- ({{tmp.other.oompsMag != 0 ? format(tmp.other.oomps) + " OOM" + (tmp.other.oompsMag < 0 ? "^OOM" : tmp.other.oompsMag > 1 ? "^" + tmp.other.oompsMag : "") + "s" : format(getPointGen())}}/sec) + ({{tmp.other.oompsMag != 0 ? format(tmp.other.oomps) + " OOM" + (tmp.other.oompsMag < 0 ? "^OOM" : tmp.other.oompsMag > 1 ? "^" + tmp.other.oompsMag : "") + "s" : formatSmall(getPointGen())}}/sec)
` diff --git a/js/utils/NumberFormating.js b/js/utils/NumberFormating.js index c26784b..0fa5cc8 100644 --- a/js/utils/NumberFormating.js +++ b/js/utils/NumberFormating.js @@ -22,6 +22,7 @@ function commaFormat(num, precision) { function regularFormat(num, precision) { if (num === null || num === undefined) return "NaN" if (num.mag < 0.001) return (0).toFixed(precision) + if (num.mag < 0.01) precision = 3 return num.toStringWithDecimalPlaces(precision) } @@ -35,7 +36,8 @@ function sumValues(x) { return x.reduce((a, b) => Decimal.add(a, b)) } -function format(decimal, precision = 2,) { +function format(decimal, precision = 2, small) { + small = small || modInfo.allowSmall decimal = new Decimal(decimal) if (isNaN(decimal.sign) || isNaN(decimal.layer) || isNaN(decimal.mag)) { player.hasNaN = true; @@ -52,7 +54,18 @@ function format(decimal, precision = 2,) { else if (decimal.gte("1e1000")) return exponentialFormat(decimal, 0) else if (decimal.gte(1e9)) return exponentialFormat(decimal, precision) else if (decimal.gte(1e3)) return commaFormat(decimal, 0) - else return regularFormat(decimal, precision) + else if (decimal.gte(0.001) || !small) return regularFormat(decimal, precision) + else if (decimal.eq(0)) return (0).toFixed(precision) + + decimal = invertOOM(decimal) + let val = "" + if (decimal.lt(1e1000)){ + val = exponentialFormat(decimal, precision) + } + else + val = format(decimal, precision) + return val.replace(/([^(?:e|F)]*)$/, '-$1') + } function formatWhole(decimal) { @@ -78,3 +91,17 @@ function toPlaces(x, precision, maxAccepted) { } return result } + +// Will also display very small numbers +function formatSmall(x, precision=2) { + return format(x, precision, true) +} + +function invertOOM(x){ + let e = x.log10().ceil() + let m = x.div(Decimal.pow(10, e)) + e = e.neg() + x = new Decimal(10).pow(e).times(m) + + return x +} \ No newline at end of file