diff --git a/babel.config.js b/babel.config.js index 4ab6557..bc3098f 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,11 @@ module.exports = { - presets: ["@vue/cli-plugin-babel/preset"] + presets: ["@vue/cli-plugin-babel/preset"], + plugins: [ + [ + "module:@jetblack/operator-overloading", + { + enabled: true + } + ] + ] }; diff --git a/package-lock.json b/package-lock.json index dbfe0eb..095a510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ }, "devDependencies": { "@ivanv/vue-collapse-transition": "^1.0.2", + "@jetblack/operator-overloading": "^0.2.0", "@types/lodash.clonedeep": "^4.5.6", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", @@ -13073,6 +13074,12 @@ "integrity": "sha512-eWEameFXJM/1khcoKbITvKjYYXDP1WKQ/Xf9ItJVPoEjCiOdocR3AgDAERzDrNNg4oWK28gRGi+0ft8Te27zxw==", "dev": true }, + "node_modules/@jetblack/operator-overloading": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@jetblack/operator-overloading/-/operator-overloading-0.2.0.tgz", + "integrity": "sha512-Y6iNzYnNUoCUcRMoUL1NflWLHkrzkxCC6VHB5h57pcjiUaPHTidZH9uyz123d6utA9w9VO+cS7S/KLA1DEpS/g==", + "dev": true + }, "node_modules/@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -29717,6 +29724,12 @@ "integrity": "sha512-eWEameFXJM/1khcoKbITvKjYYXDP1WKQ/Xf9ItJVPoEjCiOdocR3AgDAERzDrNNg4oWK28gRGi+0ft8Te27zxw==", "dev": true }, + "@jetblack/operator-overloading": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@jetblack/operator-overloading/-/operator-overloading-0.2.0.tgz", + "integrity": "sha512-Y6iNzYnNUoCUcRMoUL1NflWLHkrzkxCC6VHB5h57pcjiUaPHTidZH9uyz123d6utA9w9VO+cS7S/KLA1DEpS/g==", + "dev": true + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", diff --git a/package.json b/package.json index 3100357..a40f139 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "devDependencies": { "@ivanv/vue-collapse-transition": "^1.0.2", + "@jetblack/operator-overloading": "^0.2.0", "@types/lodash.clonedeep": "^4.5.6", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", diff --git a/src/lib/break_eternity.ts b/src/lib/break_eternity.ts index 91fdd71..6e68354 100644 --- a/src/lib/break_eternity.ts +++ b/src/lib/break_eternity.ts @@ -882,6 +882,50 @@ export default class Decimal { return cost.div(currentRpS).add(cost.div(deltaRpS)); } + public [Symbol.for('+')](other: DecimalSource): DecimalSource { + return this.add(other); + } + + public [Symbol.for('-')](other: DecimalSource): DecimalSource { + return this.sub(other); + } + + public [Symbol.for('*')](other: DecimalSource): DecimalSource { + return this.times(other); + } + + public [Symbol.for('/')](other: DecimalSource): DecimalSource { + return this.div(other); + } + + public [Symbol.for('minus')](): DecimalSource { + return this.neg(); + } + + public [Symbol.for('==')](other: DecimalSource): boolean { + return this.eq(other); + } + + public [Symbol.for('>')](other: DecimalSource): boolean { + return this.gt(other); + } + + public [Symbol.for('<')](other: DecimalSource): boolean { + return this.lt(other); + } + + public [Symbol.for('>=')](other: DecimalSource): boolean { + return this.gte(other); + } + + public [Symbol.for('<=')](other: DecimalSource): boolean { + return this.lte(other); + } + + public [Symbol.for('!=')](other: DecimalSource): boolean { + return this.neq(other); + } + public normalize(): this { /* PSEUDOCODE: