From 5e4ec334a74e3f2a4a505aa486d8b3a007498191 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Wed, 19 May 2021 23:27:23 -0500 Subject: [PATCH] Implemented "main" UI and added big number abstraction --- public/images/discord.png | Bin 0 -> 1990 bytes public/images/options_wheel.png | Bin 0 -> 4419 bytes src/App.vue | 77 ++++++++++++- src/components/system/Nav.vue | 184 ++++++++++++++++++++++++++++++++ src/components/system/TPS.vue | 28 +++++ src/data/mod.js | 39 +++++++ src/data/themes.js | 27 +++++ src/lib/break_eternity.js | 2 + src/store/index.js | 4 +- src/util/bignum.js | 19 ++++ src/util/break_eternity.js | 142 ++++++++++++++++++++++++ src/util/load.js | 15 +++ vue.config.js | 5 + 13 files changed, 538 insertions(+), 4 deletions(-) create mode 100644 public/images/discord.png create mode 100644 public/images/options_wheel.png create mode 100644 src/components/system/Nav.vue create mode 100644 src/components/system/TPS.vue create mode 100644 src/data/mod.js create mode 100644 src/data/themes.js create mode 100644 src/lib/break_eternity.js create mode 100644 src/util/bignum.js create mode 100644 src/util/break_eternity.js create mode 100644 src/util/load.js create mode 100644 vue.config.js diff --git a/public/images/discord.png b/public/images/discord.png new file mode 100644 index 0000000000000000000000000000000000000000..14fc5779958d5a9f9f6df3d0cdd39b23af1c991d GIT binary patch literal 1990 zcmV;%2RZnOP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2U|%*K~#8N?VSm% z9a9{KTRRm?iYOIpiV&eBmJr06T4O1RS}U}KG(}46X@pve*a@nZD6zFPYAdZ!L93{x zB#otZ4YAYW`|h3ByuRLh-^|=Q=gsRozvRoAnfvD6Grv1?=A8fe&wah3qN1XrqN1Xr zmL>I0%BD4P%-n4$wu6me1-Er`{Q~n~#@JB?qjDL| z*}Nvjt*}yML(kFXa7A)8XHwoX`e^W`*AsOl^sg?aS6-tJOv;|9wPDxlVtQpZn#;!K zVzcU6kJXk*nOb?y=;fiOwap#1Vp677-liieqoUD)6pap~XmlV&qXQ`#9Z1pWK#E2O zQW=f@8y3JUc+U+P^e)VVAHer1jml#5zwkPo2gVWhf=A&uF!-KUemUpE#;`M-4X?l= z=u&mH(SN~s*a`N9kKrnK6GnnV-ACYRI12{D;q5RGe+IbEW3VGU4zpqZWZOQlJ=_Ps zLYF9WTy^A_xvNrW#5R=;`Q#b=8jOOsK~pr=NrY$M1<>>bV@D16hccCtx~&Ud6^Fpq z@HE^6Hb(>DO3?h=vrA|+^|~ZkPNl9g`g*t+)=J8s!Lx5x7GpaTb?r-GNY|^y_n!=2 zC6|ItOkT6Qh0$Mv(?T17XV?@f?F49{qTZh6UNJ9$v-I9Htw$bZHac`0?Tzgg@Fq8p z%1#Jjvf^{R+1ey6Wcd%u8z9S#wkd@+T2se!pdR?b>ZWkwGZ#Udxlh3S>SFN2`v9#E(vDbk8;vsM>+zu0Xtq)}y`Nb5f5JtC!KpP5Etjo1vB4K;22G_x+m9?d1 z9K*<7$E)*T7+ziMRK~Fjy-|lS+RJxNb+Mt$X)}sfOO0MLbXxB?2J;1`X&%k&x0xzT zA&fS0JI!$0rv)^$o;FO%jxs`5PrkNFb+Nvv-=7q<+ol#NgwYNP(#Sy1x7Ed(`ZOs! z%4lFc&BsLFH;vL}i~d^%85WYhkhJqK&q1e6j~zU0qTfw7msyWOf0cgJ=0$hueK2SKZi8 zR)W1*y%%h@Z03gYc{Oi%{H^sH3aeK(6rjwPES1U{RI)d50bIj@HVO=xgW-+r2(ZbS z4pU(U*mi!+{x#zz?CUVy$60+A-7F`E<;G3yk(gXFsgut>hr+*0dqtHt-9Y2+fD5T$ z-C1wm+p~BRxD!lrQSR%R??dokgFO?MHP`mGADA>_z1rH}ci=Rb&F9t4!Q=BxKd?(_ z@{SKdrB!L8cOHbPTT?l>K~VFCl$>=AwN346llvNlGkm%Oc*dHA*(1MA$cUv6d1|n;DrZ8e6VVMno&Y}G)ZMfv z^hqWf?tD7eii(OVrF!-H YA9w!&c$<<$hyVZp07*qoM6N<$f((q%8~^|S literal 0 HcmV?d00001 diff --git a/public/images/options_wheel.png b/public/images/options_wheel.png new file mode 100644 index 0000000000000000000000000000000000000000..9a60fff4c724a67754ac451c3d0e157b59fed738 GIT binary patch literal 4419 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 literal 0 HcmV?d00001 diff --git a/src/App.vue b/src/App.vue index 2b524b8..9f07def 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,16 +1,89 @@ diff --git a/src/components/system/Nav.vue b/src/components/system/Nav.vue new file mode 100644 index 0000000..30a3c7b --- /dev/null +++ b/src/components/system/Nav.vue @@ -0,0 +1,184 @@ + + + + + diff --git a/src/components/system/TPS.vue b/src/components/system/TPS.vue new file mode 100644 index 0000000..45f6c86 --- /dev/null +++ b/src/components/system/TPS.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/src/data/mod.js b/src/data/mod.js new file mode 100644 index 0000000..e43da3e --- /dev/null +++ b/src/data/mod.js @@ -0,0 +1,39 @@ +// import TreeTab from '../components/system/TreeTab.vue'; +// Import Decimal and numberUtils from a different file to globally change which big num library gets used +import Decimal, * as numberUtils from '../util/break_eternity.js'; + +export default { + // General Info + title: "The Modding Tree X", + id: "tmt-x", + author: "thepaperpilot", + discordName: "TMT-X Server", + discordLink: "https://discord.gg/WzejVAx", + + // Gameplay Options + getStartingData() { + return { + points: new Decimal(10), + } + }, + // TODO getPointGen or some abstract version? + hasWon() { + return false; + }, + + // Version + versionNumber: "0.0", + versionTitle: "Initial Commit", + + // UI options + allowSmall: false, + useHeader: true, + //defaultTab: TreeTab + + // Advanced Options + /* eslint-disable-next-line no-unused-vars */ + fixOldSave(oldVersion) { + }, + bigNum: { Decimal, ...numberUtils }, + maxTickLength: 3600 +}; diff --git a/src/data/themes.js b/src/data/themes.js new file mode 100644 index 0000000..8d8a8c2 --- /dev/null +++ b/src/data/themes.js @@ -0,0 +1,27 @@ +const defaultTheme = { + "--background": "#0f0f0f", + "--background_tooltip": "rgba(0, 0, 0, 0.75)", + "--background_nav": "#0f0f0f", + "--color": "#dfdfdf", + "--points": "#ffffff", + "--locked": "#bf8f8f", + "--link": "#02f2f2" +}; + +export default { + default: defaultTheme, + paper: { + ...defaultTheme, + "--background": "#2a323d", + "--background_nav": "#333c4a" + }, + aquad: { + ...defaultTheme, + "--background": "#001f3f", + "--background_tooltip": "rgba(0, 15, 31, 0.75)", + "--background_nav": "#001f3f", + "--color": "#bfdfff", + "--points": "#dfefff", + "--locked": "#c4a7b3" + } +}; diff --git a/src/lib/break_eternity.js b/src/lib/break_eternity.js new file mode 100644 index 0000000..857f825 --- /dev/null +++ b/src/lib/break_eternity.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +"use strict";function _instanceof(t,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](t):t instanceof r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,r){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t=t||self).Decimal=r()}(void 0,function(){var t=Math.log10(9e15),r=function(){for(var t=[],r=-323;r<=308;r++)t.push(Number("1e"+r));return function(r){return t[r+323]}}(),i=function(t){return h.fromValue_noAlloc(t)},e=function(t,r,i){return h.fromComponents(t,r,i)},n=function(t,r,i){return h.fromComponents_noNormalize(t,r,i)},a=function(t,r){var i=r+1,e=Math.ceil(Math.log10(Math.abs(t))),n=Math.round(t*Math.pow(10,i-e))*Math.pow(10,e-i);return parseFloat(n.toFixed(Math.max(i-e,0)))},s=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},o=function(t){var r,i,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10;if(!Number.isFinite(t))return t;if(0===t)return t;if(1===t)return.5671432904097838;r=t<10?0:Math.log(t)-Math.log(Math.log(t));for(var n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r)1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n(1,0,1);return i(t).tetrate(r,e)},h.iteratedexp=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n(1,0,1);return i(t).iteratedexp(r,e)},h.iteratedlog=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return i(t).iteratedlog(r,e)},h.layeradd10=function(t,r){return i(t).layeradd10(r)},h.layeradd=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return i(t).layeradd(r,e)},h.slog=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return i(t).slog(r)},h.lambertw=function(t){return i(t).lambertw()},h.ssqrt=function(t){return i(t).ssqrt()},h.pentate=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n(1,0,1);return i(t).pentate(r,e)},h.affordGeometricSeries=function(t,r,e,n){return this.affordGeometricSeries_core(i(t),i(r),i(e),n)},h.sumGeometricSeries=function(t,r,e,n){return this.sumGeometricSeries_core(t,i(r),i(e),n)},h.affordArithmeticSeries=function(t,r,e,n){return this.affordArithmeticSeries_core(i(t),i(r),i(e),i(n))},h.sumArithmeticSeries=function(t,r,e,n){return this.sumArithmeticSeries_core(i(t),i(r),i(e),i(n))},h.efficiencyOfPurchase=function(t,r,e){return this.efficiencyOfPurchase_core(i(t),i(r),i(e))},h.randomDecimalForTesting=function(t){if(20*Math.random()<1)return n(0,0,0);var r=Math.random()>.5?1:-1;if(20*Math.random()<1)return n(r,0,1);var i=Math.floor(Math.random()*(t+1)),a=0===i?616*Math.random()-308:16*Math.random();Math.random()>.9&&(a=Math.trunc(a));var s=Math.pow(10,a);return Math.random()>.9&&(s=Math.trunc(s)),e(r,i,s)},h.affordGeometricSeries_core=function(t,r,i,e){var n=r.mul(i.pow(e));return h.floor(t.div(n).mul(i.sub(1)).add(1).log10().div(i.log10()))},h.sumGeometricSeries_core=function(t,r,i,e){return r.mul(i.pow(e)).mul(h.sub(1,i.pow(t))).div(h.sub(1,i))},h.affordArithmeticSeries_core=function(t,r,i,e){var n=r.add(e.mul(i)).sub(i.div(2)),a=n.pow(2);return n.neg().add(a.add(i.mul(t).mul(2)).sqrt()).div(i).floor()},h.sumArithmeticSeries_core=function(t,r,i,e){var n=r.add(e.mul(i));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(i)))},h.efficiencyOfPurchase_core=function(t,r,i){return t.div(r).add(t.div(i))},h.prototype.normalize=function(){if(0===this.sign||0===this.mag&&0===this.layer)return this.sign=0,this.mag=0,this.layer=0,this;if(0===this.layer&&this.mag<0&&(this.mag=-this.mag,this.sign=-this.sign),0===this.layer&&this.mag<1/9e15)return this.layer+=1,this.mag=Math.log10(this.mag),this;var r=Math.abs(this.mag),i=Math.sign(this.mag);if(r>=9e15)return this.layer+=1,this.mag=i*Math.log10(r),this;for(;r0;)this.layer-=1,0===this.layer?this.mag=Math.pow(10,this.mag):(this.mag=i*Math.pow(10,r),r=Math.abs(this.mag),i=Math.sign(this.mag));return 0===this.layer&&(this.mag<0?(this.mag=-this.mag,this.sign=-this.sign):0===this.mag&&(this.sign=0)),this},h.prototype.fromComponents=function(t,r,i){return this.sign=t,this.layer=r,this.mag=i,this.normalize(),this},h.prototype.fromComponents_noNormalize=function(t,r,i){return this.sign=t,this.layer=r,this.mag=i,this},h.prototype.fromMantissaExponent=function(t,r){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=r+Math.log10(t),this.normalize(),this},h.prototype.fromMantissaExponent_noNormalize=function(t,r){return this.fromMantissaExponent(t,r),this},h.prototype.fromDecimal=function(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this},h.prototype.fromNumber=function(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this};h.prototype.fromString=function(t){var r=(t=t.replace(",","")).split("^^^");if(2===r.length){var n=parseFloat(r[0]),a=parseFloat(r[1]),o=1;if(2===(l=r[1].split(";")).length){o=parseFloat(l[1]);isFinite(o)||(o=1)}if(isFinite(n)&&isFinite(a)){var u=h.pentate(n,a,o);return this.sign=u.sign,this.layer=u.layer,this.mag=u.mag,this}}var g=t.split("^^");if(2===g.length){var l;n=parseFloat(g[0]),a=parseFloat(g[1]);if(2===(l=g[1].split(";")).length){o=parseFloat(l[1]);isFinite(o)||(o=1)}if(isFinite(n)&&isFinite(a)){u=h.tetrate(n,a,o);return this.sign=u.sign,this.layer=u.layer,this.mag=u.mag,this}}var m,f=t.split("^");if(2===f.length){n=parseFloat(f[0]);var c=parseFloat(f[1]);if(isFinite(n)&&isFinite(c)){u=h.pow(n,c);return this.sign=u.sign,this.layer=u.layer,this.mag=u.mag,this}}if(2===(m=(t=t.trim().toLowerCase()).split("pt")).length){n=10,a=parseFloat(m[0]),m[1]=m[1].replace("(",""),m[1]=m[1].replace(")","");o=parseFloat(m[1]);if(isFinite(o)||(o=1),isFinite(n)&&isFinite(a)){u=h.tetrate(n,a,o);return this.sign=u.sign,this.layer=u.layer,this.mag=u.mag,this}}if(2===(m=t.split("p")).length){n=10,a=parseFloat(m[0]),m[1]=m[1].replace("(",""),m[1]=m[1].replace(")","");o=parseFloat(m[1]);if(isFinite(o)||(o=1),isFinite(n)&&isFinite(a)){u=h.tetrate(n,a,o);return this.sign=u.sign,this.layer=u.layer,this.mag=u.mag,this}}var p=t.split("e"),y=p.length-1;if(0===y){var d=parseFloat(t);if(isFinite(d))return this.fromNumber(d)}else if(1===y){d=parseFloat(t);if(isFinite(d)&&0!==d)return this.fromNumber(d)}var M=t.split("e^");if(2===M.length){this.sign=1,"-"==M[0].charAt(0)&&(this.sign=-1);for(var b="",N=0;N=43&&v<=57||101===v))return this.layer=parseFloat(b),this.mag=parseFloat(M[1].substr(N+1)),this.normalize(),this;b+=M[1].charAt(N)}}if(y<1)return this.sign=0,this.layer=0,this.mag=0,this;var _=parseFloat(p[0]);if(0===_)return this.sign=0,this.layer=0,this.mag=0,this;c=parseFloat(p[p.length-1]);if(y>=2){var F=parseFloat(p[p.length-2]);isFinite(F)&&(c*=Math.sign(F),c+=s(F))}if(isFinite(_))if(1===y)this.sign=Math.sign(_),this.layer=1,this.mag=c+Math.log10(Math.abs(_));else{if(this.sign=Math.sign(_),this.layer=y,2===y){u=h.mul(e(1,2,c),i(_));return this.sign=u.sign,this.layer=u.layer,this.mag=u.mag,this}this.mag=c}else this.sign="-"===p[0]?-1:1,this.layer=y,this.mag=c;return this.normalize(),this},h.prototype.fromValue=function(t){return _instanceof(t,h)?this.fromDecimal(t):"number"==typeof t?this.fromNumber(t):"string"==typeof t?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)},h.prototype.toNumber=function(){return Number.isFinite(this.layer)?0===this.layer?this.sign*this.mag:1===this.layer?this.sign*Math.pow(10,this.mag):this.mag>0?this.sign>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:0:Number.NaN},h.prototype.mantissaWithDecimalPlaces=function(t){return isNaN(this.m)?Number.NaN:0===this.m?0:a(this.m,t)},h.prototype.magnitudeWithDecimalPlaces=function(t){return isNaN(this.mag)?Number.NaN:0===this.mag?0:a(this.mag,t)},h.prototype.toString=function(){return 0===this.layer?this.mag<1e21&&this.mag>1e-7||0===this.mag?(this.sign*this.mag).toString():this.m+"e"+this.e:1===this.layer?this.m+"e"+this.e:this.layer<=5?(-1===this.sign?"-":"")+"e".repeat(this.layer)+this.mag:(-1===this.sign?"-":"")+"(e^"+this.layer+")"+this.mag},h.prototype.toExponential=function(t){return 0===this.layer?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)},h.prototype.toFixed=function(t){return 0===this.layer?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)},h.prototype.toPrecision=function(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)},h.prototype.valueOf=function(){return this.toString()},h.prototype.toJSON=function(){return this.toString()},h.prototype.toStringWithDecimalPlaces=function(t){return 0===this.layer?this.mag<1e21&&this.mag>1e-7||0===this.mag?(this.sign*this.mag).toFixed(t):a(this.m,t)+"e"+a(this.e,t):1===this.layer?a(this.m,t)+"e"+a(this.e,t):this.layer<=5?(-1===this.sign?"-":"")+"e".repeat(this.layer)+a(this.mag,t):(-1===this.sign?"-":"")+"(e^"+this.layer+")"+a(this.mag,t)},h.prototype.abs=function(){return n(0===this.sign?0:1,this.layer,this.mag)},h.prototype.neg=function(){return n(-this.sign,this.layer,this.mag)},h.prototype.negate=function(){return this.neg()},h.prototype.negated=function(){return this.neg()},h.prototype.sign=function(){return this.sign},h.prototype.sgn=function(){return this.sign},h.prototype.round=function(){return this.mag<0?h.dZero:0===this.layer?e(this.sign,0,Math.round(this.mag)):this},h.prototype.floor=function(){return this.mag<0?h.dZero:0===this.layer?e(this.sign,0,Math.floor(this.mag)):this},h.prototype.ceil=function(){return this.mag<0?h.dZero:0===this.layer?e(this.sign,0,Math.ceil(this.mag)):this},h.prototype.trunc=function(){return this.mag<0?h.dZero:0===this.layer?e(this.sign,0,Math.trunc(this.mag)):this},h.prototype.add=function(t){var r,a,s=i(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(s.layer))return s;if(0===this.sign)return s;if(0===s.sign)return this;if(this.sign===-s.sign&&this.layer===s.layer&&this.mag===s.mag)return n(0,0,0);if(this.layer>=2||s.layer>=2)return this.maxabs(s);if(h.cmpabs(this,s)>0?(r=this,a=s):(r=s,a=this),0===r.layer&&0===a.layer)return i(r.sign*r.mag+a.sign*a.mag);var o=r.layer*Math.sign(r.mag),u=a.layer*Math.sign(a.mag);if(o-u>=2)return r;if(0===o&&-1===u){if(Math.abs(a.mag-Math.log10(r.mag))>17)return r;var g=Math.pow(10,Math.log10(r.mag)-a.mag),l=a.sign+r.sign*g;return e(Math.sign(l),1,a.mag+Math.log10(Math.abs(l)))}if(1===o&&0===u){if(Math.abs(r.mag-Math.log10(a.mag))>17)return r;g=Math.pow(10,r.mag-Math.log10(a.mag)),l=a.sign+r.sign*g;return e(Math.sign(l),1,Math.log10(a.mag)+Math.log10(Math.abs(l)))}if(Math.abs(r.mag-a.mag)>17)return r;g=Math.pow(10,r.mag-a.mag),l=a.sign+r.sign*g;return e(Math.sign(l),1,a.mag+Math.log10(Math.abs(l)))},h.prototype.plus=function(t){return this.add(t)},h.prototype.sub=function(t){return this.add(i(t).neg())},h.prototype.subtract=function(t){return this.sub(t)},h.prototype.minus=function(t){return this.sub(t)},h.prototype.mul=function(t){var r,a,s=i(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(s.layer))return s;if(0===this.sign||0===s.sign)return n(0,0,0);if(this.layer===s.layer&&this.mag===-s.mag)return n(this.sign*s.sign,0,1);if(this.layer>s.layer||this.layer==s.layer&&Math.abs(this.mag)>Math.abs(s.mag)?(r=this,a=s):(r=s,a=this),0===r.layer&&0===a.layer)return i(r.sign*a.sign*r.mag*a.mag);if(r.layer>=3||r.layer-a.layer>=2)return e(r.sign*a.sign,r.layer,r.mag);if(1===r.layer&&0===a.layer)return e(r.sign*a.sign,1,r.mag+Math.log10(a.mag));if(1===r.layer&&1===a.layer)return e(r.sign*a.sign,1,r.mag+a.mag);if(2===r.layer&&1===a.layer){var o=e(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(e(Math.sign(a.mag),a.layer-1,Math.abs(a.mag)));return e(r.sign*a.sign,o.layer+1,o.sign*o.mag)}if(2===r.layer&&2===a.layer){o=e(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(e(Math.sign(a.mag),a.layer-1,Math.abs(a.mag)));return e(r.sign*a.sign,o.layer+1,o.sign*o.mag)}throw Error("Bad arguments to mul: "+this+", "+t)},h.prototype.multiply=function(t){return this.mul(t)},h.prototype.times=function(t){return this.mul(t)},h.prototype.div=function(t){var r=i(t);return this.mul(r.recip())},h.prototype.divide=function(t){return this.div(t)},h.prototype.divideBy=function(t){return this.div(t)},h.prototype.dividedBy=function(t){return this.div(t)},h.prototype.recip=function(){return 0===this.mag?h.dNaN:0===this.layer?e(this.sign,0,1/this.mag):e(this.sign,this.layer,-this.mag)},h.prototype.reciprocal=function(){return this.recip()},h.prototype.reciprocate=function(){return this.recip()},h.prototype.cmp=function(t){var r=i(t);return this.sign>r.sign?1:this.sign0?this.layer:-this.layer,n=r.mag>0?r.layer:-r.layer;return e>n?1:er.mag?1:this.mag0?r:this},h.prototype.clamp=function(t,r){return this.max(t).min(r)},h.prototype.clampMin=function(t){return this.max(t)},h.prototype.clampMax=function(t){return this.min(t)},h.prototype.cmp_tolerance=function(t,r){var e=i(t);return this.eq_tolerance(e,r)?0:this.cmp(e)},h.prototype.compare_tolerance=function(t,r){return this.cmp_tolerance(t,r)},h.prototype.eq_tolerance=function(t,r){var e=i(t);if(null==r&&(r=1e-7),this.sign!==e.sign)return!1;if(Math.abs(this.layer-e.layer)>1)return!1;var n=this.mag,a=e.mag;return this.layer>e.layer&&(a=s(a)),this.layer0?e(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):e(1,0,Math.log10(this.mag))},h.prototype.log10=function(){return this.sign<=0?h.dNaN:this.layer>0?e(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):e(this.sign,0,Math.log10(this.mag))},h.prototype.log=function(t){return t=i(t),this.sign<=0?h.dNaN:t.sign<=0?h.dNaN:1===t.sign&&0===t.layer&&1===t.mag?h.dNaN:0===this.layer&&0===t.layer?e(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):h.div(this.log10(),t.log10())},h.prototype.log2=function(){return this.sign<=0?h.dNaN:0===this.layer?e(this.sign,0,Math.log2(this.mag)):1===this.layer?e(Math.sign(this.mag),0,3.321928094887362*Math.abs(this.mag)):2===this.layer?e(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):e(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))},h.prototype.ln=function(){return this.sign<=0?h.dNaN:0===this.layer?e(this.sign,0,Math.log(this.mag)):1===this.layer?e(Math.sign(this.mag),0,2.302585092994046*Math.abs(this.mag)):2===this.layer?e(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):e(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))},h.prototype.logarithm=function(t){return this.log(t)},h.prototype.pow=function(t){var r=this,e=i(t);if(0===r.sign)return r;if(1===r.sign&&0===r.layer&&1===r.mag)return r;if(0===e.sign)return n(1,0,1);if(1===e.sign&&0===e.layer&&1===e.mag)return r;var a=r.absLog10().mul(e).pow10();return-1===this.sign&&e.toNumber()%2==1?a.neg():a},h.prototype.pow10=function(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return h.dNaN;var t=this;if(0===t.layer){var r=Math.pow(10,t.sign*t.mag);if(Number.isFinite(r)&&Math.abs(r)>.1)return e(1,0,r);if(0===t.sign)return h.dOne;t=n(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>0?e(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>0?e(-t.sign,t.layer+1,-t.mag):h.dOne},h.prototype.pow_base=function(t){return i(t).pow(this)},h.prototype.root=function(t){var r=i(t);return this.pow(r.recip())},h.prototype.factorial=function(){return this.mag<0?this.toNumber().add(1).gamma():0===this.layer?this.add(1).gamma():1===this.layer?h.exp(h.mul(this,h.ln(this).sub(1))):h.exp(this)},h.prototype.gamma=function(){if(this.mag<0)return this.recip();if(0===this.layer){if(this.lt(n(1,0,24)))return i(function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;for(var r=1;t<10;)r*=t,++t;var i=.9189385332046727;i+=(.5+(t-=1))*Math.log(t),i-=t;var e=t*t,n=t;return i+=1/(12*n),i+=1/(360*(n*=e)),i+=1/(1260*(n*=e)),i+=1/(1680*(n*=e)),i+=1/(1188*(n*=e)),i+=691/(360360*(n*=e)),i+=7/(1092*(n*=e)),i+=3617/(122400*(n*=e)),Math.exp(i)/r}(this.sign*this.mag));var t=this.mag-1,r=.9189385332046727;r+=(t+.5)*Math.log(t);var e=t*t,a=t,s=12*a,o=1/s,u=(r-=t)+o;if(u===r)return h.exp(r);if((u=(r=u)-(o=1/(s=360*(a*=e))))===r)return h.exp(r);r=u;var g=1/(s=1260*(a*=e));return r+=g,r-=g=1/(s=1680*(a*=e)),h.exp(r)}return 1===this.layer?h.exp(h.mul(this,h.ln(this).sub(1))):h.exp(this)},h.prototype.lngamma=function(){return this.gamma().ln()},h.prototype.exp=function(){return this.mag<0?h.dOne:0===this.layer&&this.mag<=709.7?i(Math.exp(this.sign*this.mag)):0===this.layer?e(1,1,this.sign*Math.log10(Math.E)*this.mag):1===this.layer?e(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):e(1,this.layer+1,this.sign*this.mag)},h.prototype.sqr=function(){return this.pow(2)},h.prototype.sqrt=function(){if(0===this.layer)return i(Math.sqrt(this.sign*this.mag));if(1===this.layer)return e(1,2,Math.log10(this.mag)-.3010299956639812);var t=h.div(n(this.sign,this.layer-1,this.mag),n(1,0,2));return t.layer+=1,t.normalize(),t},h.prototype.cube=function(){return this.pow(3)},h.prototype.cbrt=function(){return this.pow(1/3)},h.prototype.tetrate=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n(1,0,1);if(t===Number.POSITIVE_INFINITY){var e=h.ln(this).neg();return e.lambertw().div(e)}if(t<0)return h.iteratedlog(r,this,-t);r=i(r);var a=t-(t=Math.trunc(t));0!==a&&(r.eq(h.dOne)?(++t,r=new h(a)):r=this.eq(10)?r.layeradd10(a):r.layeradd(a,this));for(var s=0;s3)return n(r.sign,r.layer+(t-s-1),r.mag);if(s>100)return r}return r},h.prototype.iteratedexp=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n(1,0,1);return this.tetrate(t,r)},h.prototype.iteratedlog=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<0)return h.tetrate(t,-r,this);t=i(t);var e=i(this),n=r-(r=Math.trunc(r));if(e.layer-t.layer>3){var a=Math.min(r,e.layer-t.layer-3);r-=a,e.layer-=a}for(var s=0;s100)return e}return n>0&&n<1&&(e=t.eq(10)?e.layeradd10(-n):e.layeradd(-n,t)),e},h.prototype.slog=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;if(this.mag<0)return h.dNegOne;t=i(t);var r=0,e=i(this);if(e.layer-t.layer>3){var n=e.layer-t.layer-3;r+=n,e.layer-=n}for(var a=0;a<100;++a)if(e.lt(h.dZero))e=h.pow(t,e),r-=1;else{if(e.lte(h.dOne))return i(r+e.toNumber()-1);r+=1,e=h.log(e,t)}return i(r)},h.prototype.layeradd10=function(t){t=h.fromValue_noAlloc(t).toNumber();var r,e=i(this);t>=1&&(t-=r=Math.trunc(t),e.layer+=r);if(t<=-1&&(t-=r=Math.trunc(t),e.layer+=r,e.layer<0))for(var n=0;n<100;++n){if(e.layer++,e.mag=Math.log10(e.mag),!isFinite(e.mag))return e;if(e.layer>=0)break}if(t>0){for(var a=0;Number.isFinite(e.mag)&&e.mag<10;)e.mag=Math.pow(10,e.mag),++a;for(e.mag>1e10&&(e.mag=Math.log10(e.mag),e.layer++),(s=Math.log10(Math.log(1e10)/Math.log(e.mag),10))0;)e.mag=Math.log10(e.mag),--a}else if(t<0){for(a=0;Number.isFinite(e.mag)&&e.mag<10;)e.mag=Math.pow(10,e.mag),++a;var s;for(e.mag>1e10&&(e.mag=Math.log10(e.mag),e.layer++),(s=Math.log10(1/Math.log10(e.mag)))>t&&(e.mag=1e10,e.layer--,t-=s),e.mag=Math.pow(e.mag,Math.pow(10,t));a>0;)e.mag=Math.log10(e.mag),--a}for(;e.layer<0;)e.layer++,e.mag=Math.log10(e.mag);return e.normalize(),e},h.prototype.layeradd=function(t,r){var i=this.slog(r).toNumber()+t;return i>=0?h.tetrate(r,i):Number.isFinite(i)?i>=-1?h.log(h.tetrate(r,i+1),r):void h.log(h.log(h.tetrate(r,i+2),r),r):h.dNaN},h.prototype.lambertw=function(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");return this.mag<0?i(o(this.toNumber())):0===this.layer?i(o(this.sign*this.mag)):1===this.layer?u(this):2===this.layer?u(this):this.layer>=3?n(this.sign,this.layer-1,this.mag):void 0};var u=function(t){var r,i,e,n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10;if(!Number.isFinite(t.mag))return t;if(0===t)return t;if(1===t)return.5671432904097838;h.abs(t);r=h.ln(t);for(var s=0;s<100;++s){if(i=h.exp(-r),e=r.sub(t.mul(i)),n=r.sub(e.div(r.add(1).sub(r.add(2).mul(e).div(h.mul(2,r).add(2))))),h.abs(n.sub(r)).lt(h.abs(n).mul(a)))return n;r=n}throw Error("Iteration failed to converge: "+t)};return h.prototype.ssqrt=function(){if(1==this.sign&&this.layer>=3)return n(this.sign,this.layer-1,this.mag);var t=this.ln();return t.div(t.lambertw())},h.prototype.pentate=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n(1,0,1);r=i(r);var e=t-(t=Math.trunc(t));0!==e&&(r.eq(h.dOne)?(++t,r=new h(e)):r=this.eq(10)?r.layeradd10(e):r.layeradd(e,this));for(var a=0;a10)return r}return r},h.prototype.sin=function(){return this.mag<0?this:0===this.layer?i(Math.sin(this.sign*this.mag)):n(0,0,0)},h.prototype.cos=function(){return this.mag<0?h.dOne:0===this.layer?i(Math.cos(this.sign*this.mag)):n(0,0,0)},h.prototype.tan=function(){return this.mag<0?this:0===this.layer?i(Math.tan(this.sign*this.mag)):n(0,0,0)},h.prototype.asin=function(){return this.mag<0?this:0===this.layer?i(Math.asin(this.sign*this.mag)):n(Number.NaN,Number.NaN,Number.NaN)},h.prototype.acos=function(){return this.mag<0?i(Math.acos(this.toNumber())):0===this.layer?i(Math.acos(this.sign*this.mag)):n(Number.NaN,Number.NaN,Number.NaN)},h.prototype.atan=function(){return this.mag<0?this:0===this.layer?i(Math.atan(this.sign*this.mag)):i(Math.atan(Infinity*this.sign))},h.prototype.sinh=function(){return this.exp().sub(this.negate().exp()).div(2)},h.prototype.cosh=function(){return this.exp().add(this.negate().exp()).div(2)},h.prototype.tanh=function(){return this.sinh().div(this.cosh())},h.prototype.asinh=function(){return h.ln(this.add(this.sqr().add(1).sqrt()))},h.prototype.acosh=function(){return h.ln(this.add(this.sqr().sub(1).sqrt()))},h.prototype.atanh=function(){return this.abs().gte(1)?n(Number.NaN,Number.NaN,Number.NaN):h.ln(this.add(1).div(i(1).sub(this))).div(2)},h.prototype.ascensionPenalty=function(t){return 0===t?this:this.root(h.pow(10,t))},h.prototype.egg=function(){return this.add(9)},h.prototype.lessThanOrEqualTo=function(t){return this.cmp(t)<1},h.prototype.lessThan=function(t){return this.cmp(t)<0},h.prototype.greaterThanOrEqualTo=function(t){return this.cmp(t)>-1},h.prototype.greaterThan=function(t){return this.cmp(t)>0},h}();return h.dZero=n(0,0,0),h.dOne=n(1,0,1),h.dNegOne=n(-1,0,1),h.dTwo=n(1,0,2),h.dTen=n(1,0,10),h.dNaN=n(Number.NaN,Number.NaN,Number.NaN),h.dInf=n(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h.dNegInf=n(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),h.dNumberMax=e(1,0,Number.MAX_VALUE),h.dNumberMin=e(1,0,Number.MIN_VALUE),h}); \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 5effd6f..14b938e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,11 +1,11 @@ import Vue from 'vue' import Vuex from 'vuex' +import { getInitialStore } from '../util/load.js'; Vue.use(Vuex) export default new Vuex.Store({ - state: { - }, + state: getInitialStore(), mutations: { }, actions: { diff --git a/src/util/bignum.js b/src/util/bignum.js new file mode 100644 index 0000000..c2b5eb2 --- /dev/null +++ b/src/util/bignum.js @@ -0,0 +1,19 @@ +// This class is just used to lookup the correct bignum library set in modInfo and pass it, along with its format utility functions, through this file +// This way switching out big number libraries just needs to happen in mod.js, not every file that needs big numbers + +import modInfo from '../data/mod.js'; + +export const { + Decimal, + exponentialFormat, + commaFormat, + regularFormat, + format, + formatWhole, + formatTime, + toPlaces, + formatSmall, + invertOOM +} = modInfo.bigNum; + +export default Decimal; diff --git a/src/util/break_eternity.js b/src/util/break_eternity.js new file mode 100644 index 0000000..bc03dcc --- /dev/null +++ b/src/util/break_eternity.js @@ -0,0 +1,142 @@ +import Decimal from '../lib/break_eternity.js'; +import modInfo from '../data/mod.js'; + +export default Decimal; + +const decimalOne = new Decimal(1); + +export function exponentialFormat(num, precision, mantissa = true) { + let e = num.log10().floor(); + let m = num.div(Decimal.pow(10, e)); + if(m.toStringWithDecimalPlaces(precision) === 10) { + m = decimalOne; + e = e.add(1); + } + e = (e.gte(1e9) ? format(e, 3) : (e.gte(10000) ? commaFormat(e, 0) : e.toStringWithDecimalPlaces(0))) + if (mantissa) { + return m.toStringWithDecimalPlaces(precision)+"e"+e; + } else { + return "e"+e; + } +} + +export function commaFormat(num, precision) { + if (num === null || num === undefined) { + return "NaN"; + } + if (num.mag < 0.001) { + return (0).toFixed(precision); + } + let init = num.toStringWithDecimalPlaces(precision) + let portions = init.split(".") + portions[0] = portions[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + if (portions.length == 1) return portions[0] + return portions[0] + "." + portions[1] +} + +export function regularFormat(num, precision) { + if (num === null || num === undefined) { + return "NaN"; + } + if (num.mag < 0.0001) { + return (0).toFixed(precision); + } + if (num.mag < 0.1 && precision !== 0) { + precision = Math.max(precision, 4); + } + return num.toStringWithDecimalPlaces(precision); +} + +export 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; + return "NaN"; + } + if (decimal.sign<0) { + return "-"+format(decimal.neg(), precision); + } + if (decimal.mag === Number.POSITIVE_INFINITY) { + return "Infinity"; + } + if (decimal.gte("eeee1000")) { + const slog = decimal.slog(); + if (slog.gte(1e6)) { + return "F" + format(slog.floor()); + } else { + return Decimal.pow(10, slog.sub(slog.floor())).toStringWithDecimalPlaces(3) + "F" + commaFormat(slog.floor(), 0); + } + } else if (decimal.gte("1e100000")) { + return exponentialFormat(decimal, 0, false); + } 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 if (decimal.gte(0.001) || !small) { + return regularFormat(decimal, precision); + } else if (decimal.eq(0)) { + return (0).toFixed(precision); + } + + decimal = invertOOM(decimal); + if (decimal.lt("1e1000")){ + const val = exponentialFormat(decimal, precision); + return val.replace(/([^(?:e|F)]*)$/, '-$1'); + } else { + return format(decimal, precision) + "⁻¹"; + } +} + +export function formatWhole(decimal) { + decimal = new Decimal(decimal); + if (decimal.sign<0) { + return "-"+formatWhole(decimal.neg()); + } + if (decimal.gte(1e9)) { + return format(decimal, 2); + } + if (decimal.lte(0.98) && !decimal.eq(0)) { + return format(decimal, 2); + } + return format(decimal, 0); +} + +export function formatTime(s) { + if (s<60) { + return format(s)+"s"; + } else if (s<3600) { + return formatWhole(Math.floor(s/60))+"m "+format(s%60)+"s"; + } else if (s<86400) { + return formatWhole(Math.floor(s/3600))+"h "+formatWhole(Math.floor(s/60)%60)+"m "+format(s%60)+"s"; + } else if (s<31536000) { + return formatWhole(Math.floor(s/84600)%365)+"d " + formatWhole(Math.floor(s/3600)%24)+"h "+formatWhole(Math.floor(s/60)%60)+"m "+format(s%60)+"s"; + } else { + return formatWhole(Math.floor(s/31536000))+"y "+formatWhole(Math.floor(s/84600)%365)+"d " + formatWhole(Math.floor(s/3600)%24)+"h "+formatWhole(Math.floor(s/60)%60)+"m "+format(s%60)+"s"; + } +} + +export function toPlaces(x, precision, maxAccepted) { + x = new Decimal(x); + let result = x.toStringWithDecimalPlaces(precision); + if (new Decimal(result).gte(maxAccepted)) { + result = new Decimal(maxAccepted - Math.pow(0.1, precision)).toStringWithDecimalPlaces(precision); + } + return result; +} + +// Will also display very small numbers +export function formatSmall(x, precision=2) { + return format(x, precision, true); +} + +export 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; +} diff --git a/src/util/load.js b/src/util/load.js new file mode 100644 index 0000000..2da7025 --- /dev/null +++ b/src/util/load.js @@ -0,0 +1,15 @@ +import modInfo from '../data/mod.js'; + +export function getInitialStore() { + return { + tabs: ["tree-tab"], + time: Date.now(), + autosave: true, + offlineProd: true, + timePlayed: 0, + keepGoing: false, + hasNaN: false, + lastTenTicks: [], + ...modInfo.getStartingData() + } +} diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..55d9578 --- /dev/null +++ b/vue.config.js @@ -0,0 +1,5 @@ +module.exports = { + publicPath: process.env.NODE_ENV === 'production' + ? '/The-Modding-Tree-X' + : '/' +};