From f4b0e04cece736a9d25f8032613a47aab840e0f1 Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Sat, 9 Jul 2022 02:23:42 -0400 Subject: [PATCH] V2.0.2 - Fix faulty array.splice in solver --- README.md | 2 +- config.example.ts | 2 +- src/solver/solver.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ad4743..703d7fa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# The Artificer - A Dice Rolling Discord Bot | V2.0.1 - 2022/07/08 +# The Artificer - A Dice Rolling Discord Bot | V2.0.2 - 2022/07/08 [![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-orange.svg)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=bugs)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=TheArtificer) diff --git a/config.example.ts b/config.example.ts index 18c0fde..509b0d5 100644 --- a/config.example.ts +++ b/config.example.ts @@ -1,6 +1,6 @@ export const config = { 'name': 'The Artificer', // Name of the bot - 'version': '2.0.1', // Version of the bot + 'version': '2.0.2', // Version of the bot 'token': 'the_bot_token', // Discord API Token for this bot 'localtoken': 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token" 'prefix': '[[', // Prefix for all commands diff --git a/src/solver/solver.ts b/src/solver/solver.ts index 45f5d23..c2c2e72 100644 --- a/src/solver/solver.ts +++ b/src/solver/solver.ts @@ -61,8 +61,10 @@ export const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails: throw new Error('UnbalancedParens'); } - // Replace the itemes between openParen and closeParen (including the parens) with its solved equilvalent by calling the solver on the items between openParen and closeParen (excluding the parens) - conf.splice(openParen, closeParen + 1, fullSolver(conf.slice(openParen + 1, closeParen), true)); + // Call the solver on the items between openParen and closeParen (excluding the parens) + const parenSolve = fullSolver(conf.slice(openParen + 1, closeParen), true); + // Replace the itemes between openParen and closeParen (including the parens) with its solved equilvalent + conf.splice(openParen, (closeParen - openParen + 1), parenSolve); // Determing if we need to add in a multiplication sign to handle implicit multiplication (like "(4)2" = 8) // insertedMult flags if there was a multiplication sign inserted before the parens