From f105002847ffe3b5c89d02bb1f792b3ca372a417 Mon Sep 17 00:00:00 2001 From: Snarling <84951833+Snarling@users.noreply.github.com> Date: Sun, 17 Oct 2021 20:02:22 -0400 Subject: [PATCH 1/2] Reduce repetitive code sections Iteratively define general actions instead of defining each individually. Remove anonymous function that automatically runs, placing code into main section of file so that it still automatically runs. (untested - I don't have a local copy set up yet to test these changes on) --- src/Bladeburner/GeneralActions.tsx | 45 +++++++++--------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/Bladeburner/GeneralActions.tsx b/src/Bladeburner/GeneralActions.tsx index 89c1f02e5..fa4728f85 100644 --- a/src/Bladeburner/GeneralActions.tsx +++ b/src/Bladeburner/GeneralActions.tsx @@ -3,35 +3,16 @@ import { IMap } from "../types"; export const GeneralActions: IMap = {}; -(function () { - // General Actions - let actionName; - actionName = "Training"; - GeneralActions[actionName] = new Action({ - name: actionName, - }); - - actionName = "Field Analysis"; - GeneralActions[actionName] = new Action({ - name: actionName, - }); - - actionName = "Recruitment"; - GeneralActions[actionName] = new Action({ - name: actionName, - }); - - actionName = "Diplomacy"; - GeneralActions[actionName] = new Action({ - name: actionName, - }); - - actionName = "Hyperbolic Regeneration Chamber"; - GeneralActions[actionName] = new Action({ - name: actionName, - }); - actionName = "Incite Violence"; - GeneralActions[actionName] = new Action({ - name: actionName, - }); -})(); +let actionNames : Array = [ + "Training", + "Field Analysis", + "Recruitment", + "Diplomacy", + "Hyperbolic Regeneration Chamber", + "Incite Violence" +]; +for (let actionName of actionNames){ + GeneralActions[actionName] = new Action({ + name: actionName, + }); +} From 6bfec83d9136b40a9fb96d5c6ee2c02700357588 Mon Sep 17 00:00:00 2001 From: Snarling <84951833+Snarling@users.noreply.github.com> Date: Mon, 18 Oct 2021 00:02:23 -0400 Subject: [PATCH 2/2] Update GeneralActions.tsx --- src/Bladeburner/GeneralActions.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Bladeburner/GeneralActions.tsx b/src/Bladeburner/GeneralActions.tsx index fa4728f85..62c962eec 100644 --- a/src/Bladeburner/GeneralActions.tsx +++ b/src/Bladeburner/GeneralActions.tsx @@ -4,15 +4,16 @@ import { IMap } from "../types"; export const GeneralActions: IMap = {}; let actionNames : Array = [ - "Training", - "Field Analysis", - "Recruitment", - "Diplomacy", - "Hyperbolic Regeneration Chamber", - "Incite Violence" + "Training", + "Field Analysis", + "Recruitment", + "Diplomacy", + "Hyperbolic Regeneration Chamber", + "Incite Violence" ]; + for (let actionName of actionNames){ - GeneralActions[actionName] = new Action({ - name: actionName, - }); -} + GeneralActions[actionName] = new Action({ + name: actionName, + }); +} \ No newline at end of file