|
@@ -56,6 +56,21 @@ class CodeBox {
|
|
|
* @type {boolean}
|
|
|
*/
|
|
|
this.onTheHook = false;
|
|
|
+ /**
|
|
|
+ * Have we dived using `u`
|
|
|
+ *
|
|
|
+ * Until rising with `O`, all instructions except movement and mirror instructions are ignored.
|
|
|
+ * @type {boolean}
|
|
|
+ */
|
|
|
+ this.hasDove = false;
|
|
|
+ /**
|
|
|
+ * Constant of values to check when `this.hasDove == true`
|
|
|
+ *
|
|
|
+ * Includes `O` so that we can rise.
|
|
|
+ *
|
|
|
+ * @type {string[]}
|
|
|
+ */
|
|
|
+ this.MOVEMENT_AND_MIRRORS = [">", "<", "^", "v", "/", "\\", "|", "_", "#", "x", "`", "O"];
|
|
|
/**
|
|
|
* Are we currently processing code box instructions as a string
|
|
|
*
|
|
@@ -262,6 +277,14 @@ class CodeBox {
|
|
|
|
|
|
Execute(instruction) {
|
|
|
let output = null;
|
|
|
+
|
|
|
+ // Ignore non-movement and non-mirror instructions
|
|
|
+ if (this.hasDove) {
|
|
|
+ if (this.MOVEMENT_AND_MIRRORS.indexOf(instruction) < 0) {
|
|
|
+ return output;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
try{
|
|
|
switch(instruction) {
|
|
|
// NOP
|
|
@@ -340,6 +363,16 @@ class CodeBox {
|
|
|
case "'":
|
|
|
this.stringMode = !!this.stringMode ? 0 : dec(instruction);
|
|
|
break;
|
|
|
+ // Dive, Rise and Fisherman
|
|
|
+ case "u":
|
|
|
+ this.hasDove = true;
|
|
|
+ break;
|
|
|
+ case "O":
|
|
|
+ this.hasDove = false;
|
|
|
+ break;
|
|
|
+ case "`":
|
|
|
+ // TODO
|
|
|
+ break;
|
|
|
// Movement
|
|
|
case "^":
|
|
|
this.MoveUp();
|