Kaynağa Gözat

Add toggle for block count

Added a parameter to the render function to toggle the display of the
count of block tiles on the screen
ApisNecros 2 ay önce
ebeveyn
işleme
a34f2c8173
2 değiştirilmiş dosya ile 6 ekleme ve 4 silme
  1. 1 2
      13/13_1.js
  2. 5 2
      13/common.js

+ 1 - 2
13/13_1.js

@@ -12,5 +12,4 @@ const sampleInput = [104, 1, 104, 2, 104, 3, 104, 6, 104, 5, 104, 4, 99];
 const arcade = new Computer(input);
 arcade.Run();
 
-// console.log(arcade.outputValues);
-render(arcade.outputValues);
+render(arcade.outputValues, true);

+ 5 - 2
13/common.js

@@ -10,9 +10,10 @@ const gameTiles = [
  * Render the arcade screen
  *
  * @param {number[]} screenState An array of numbers represent the state of the arcade screen
+ * @param {boolean} countBlocks Display a count of block tiles on the screen
  * @returns {void}
  */
-function render(screenState) {
+function render(screenState, countBlocks = false) {
     if (screenState.length % 3 != 0) {
         console.warn("screenState length is not divisible by three!");
     }
@@ -53,7 +54,9 @@ function render(screenState) {
 
     console.clear();
     console.log(boardString);
-    console.log("\n", "Block tiles: ", blockTileCount);
+    if (countBlocks) {
+        console.log("\n", "Block tiles: ", blockTileCount);
+    }
 }
 
 function normalizeBoard(board, width, height) {