|
@@ -84,6 +84,12 @@ class CodeBox {
|
|
|
* @type {?Date}
|
|
|
*/
|
|
|
this.datetime = null;
|
|
|
+ /**
|
|
|
+ * Should the code box be printed?
|
|
|
+ *
|
|
|
+ * @type {boolean}
|
|
|
+ */
|
|
|
+ this.print = false;
|
|
|
|
|
|
this.codeBoxDOM = document.getElementById(codeBoxID);
|
|
|
if(!this.codeBoxDOM) {
|
|
@@ -162,6 +168,23 @@ class CodeBox {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /** Prints the code box to the console */
|
|
|
+ PrintCodeBox() {
|
|
|
+ let output = "";
|
|
|
+ for (let y = 0; y < this.box.length; y++) {
|
|
|
+ for (let x = 0; x < this.box[y].length; x++) {
|
|
|
+ let instruction = this.box[y][x];
|
|
|
+ if (x == this.pointer.X && y == this.pointer.Y) {
|
|
|
+ instruction = `*${instruction}*`;
|
|
|
+ }
|
|
|
+ output += `${instruction} `;
|
|
|
+ }
|
|
|
+ output += "\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(output);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Make all the rows in the code box the same length
|
|
|
*
|
|
@@ -429,6 +452,8 @@ class CodeBox {
|
|
|
}
|
|
|
|
|
|
Swim() {
|
|
|
+ if(this.print) { this.PrintCodeBox(); }
|
|
|
+
|
|
|
const instruction = this.box[this.pointer.Y][this.pointer.X];
|
|
|
this.datetime = new Date();
|
|
|
|