From 75b2806c9341e7694d3a60b05947d3a0e8fd017c Mon Sep 17 00:00:00 2001
From: Olivier Gagnon <oli.gagnon4418@gmail.com>
Date: Sat, 29 May 2021 12:10:17 -0400
Subject: [PATCH] Added new SF -1 called Bypass

---
 src/Constants.ts          | 44 ++-------------------------------------
 src/Exploits/Exploit.ts   |  2 ++
 src/NetscriptFunctions.js | 13 ++++++++++++
 3 files changed, 17 insertions(+), 42 deletions(-)

diff --git a/src/Constants.ts b/src/Constants.ts
index b974d4c96..d8f32357f 100644
--- a/src/Constants.ts
+++ b/src/Constants.ts
@@ -231,47 +231,7 @@ export const CONSTANTS: IMap<any> = {
     v0.51.9 - 2021-05-17 offline progress and exports!
     -------
 
-    Alias
-    * several commands can be included in 1 alias. Recursive alias now work to
-      a depth of 10. (@Dawe)
-
-    Offline
-
-    * Offline money gain has been reworked (it is more generous)
-    * If you're not working anywhere and go offline the game will work for you
-      at all your factions evenly.
-
-    Export
-    * Exporting now gives +1 favor to all joined factions every 24h.
-
-    Corp
-    * Self-fund with an invalid name no longer takes away 150b anyway.
-    * Can no longer export negative amount
-
-    Bladeburner
-    * No longer waste overflowing time.
-
-    Text Editors
-    * All settings will now be saved and loaded correctly.
-
-    Terminal
-    * 'scan' now works for servers that are more than 21 character long.
-
-    Misc.
-    * ls now correctly lists all files.
-    * importing auto save+reloads (@Dawe)
-    * Fix a bug where .fconf could not be created
-    * Fix formatting inconsistencies for some logs of netscript functions.
-    * Fix a bug where Cashroot starter kit would appear as [object Object] in 
-      confirmation dialog.
-    * Fix some ram not displayed as 0.00GB
-    * Fix error message throw undefined variable error
-    * City hall now has some generic text if you can't create a corp yet.
-    * Deleting a file without extension now returns an appropriate error message.
-    * Fixed an issue where bladeburner would miscalculate the cost of hospitalization.
-    * It is now possible to suppress bladeburner "action stopped" popup.
-    * Updated several dependencies (big who cares, I know)
-    * ls no longer prints lingering newline.
-    * Money earned/spent by sleeves is now tracked under Character>Money
+    SF -1
+    * Added a new SF -1: Bypass
     `,
 }
\ No newline at end of file
diff --git a/src/Exploits/Exploit.ts b/src/Exploits/Exploit.ts
index deb0dc5e1..03bb480a0 100644
--- a/src/Exploits/Exploit.ts
+++ b/src/Exploits/Exploit.ts
@@ -14,6 +14,7 @@ export enum Exploit {
     UndocumentedFunctionCall = 'UndocumentedFunctionCall',
     Unclickable = 'Unclickable',
     PrototypeTampering = 'PrototypeTampering',
+    Bypass = 'Bypass',
     // To the players reading this. Yes you're supposed to add EditSaveFile by
     // editing your save file, yes you could add them all, no we don't care
     // that's not the point.
@@ -27,6 +28,7 @@ const names: {
     'EditSaveFile': 'by editing your save file.',
     'PrototypeTampering': 'by tampering with Numbers prototype.',
     'Unclickable': 'by clicking the unclickable.',
+    'Bypass': 'by circumventing the ram cost of document.',
 }
 
 
diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js
index a34bc2852..53960def4 100644
--- a/src/NetscriptFunctions.js
+++ b/src/NetscriptFunctions.js
@@ -4442,6 +4442,19 @@ function NetscriptFunctions(workerScript) {
         exploit: function() {
             Player.giveExploit(Exploit.UndocumentedFunctionCall);
         },
+        bypass: function(doc) {
+            // reset both fields first
+            doc.completely_unused_field = undefined;
+            document.completely_unused_field = undefined;
+            // set one to true and check that it affected the other.
+            document.completely_unused_field = true;
+            console.log(workerScript.ramUsage);
+            if(doc.completely_unused_field && workerScript.ramUsage === 1.6) {
+                Player.giveExploit(Exploit.Bypass);
+            }
+            doc.completely_unused_field = undefined;
+            document.completely_unused_field = undefined;
+        },
         flags: function(data) {
             data = toNative(data);
             // We always want the help flag.