From 06dd4ad863d6f77428ad799c4a93ca599ddf9b19 Mon Sep 17 00:00:00 2001
From: Guillaume Pasquet <guillaume.pasquet@eggplant.io>
Date: Tue, 12 Nov 2019 10:53:22 +0100
Subject: Better debug

---
 src/main.rs | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 022315c..1b76d47 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,6 +8,7 @@ mod character;
 mod computer;
 mod world;
 
+use std::env;
 use character::Player;
 use character::Character;
 use computer::Enemy;
@@ -51,6 +52,7 @@ fn debug_level(level: Level) {
     }
 }
 
+
 fn main() {
     let mut level = 0;
     let mut dungeon = Dungeon::new(80, 24, 5);
@@ -69,14 +71,22 @@ fn main() {
     );
     character.place(start_location);
 
-    dungeon.levels.into_iter().map(debug_level);
-
-    // let window = initscr();
+    // Dump the whole dungeon structure in terminal for debugging
+    match env::var("DEBUG") {
+        Ok(_) => {
+            for l in dungeon.levels {
+                debug_level(l);
+            }
+            return
+        },
+        Err(_) => ()
+    };
 
-    // render_dungeon(&window, &world);
+    let window = initscr();
 
-    // window.refresh();
+    render_level(&window, &dungeon.levels[0]);
+    window.refresh();
+    window.getch();
 
-    // window.getch();
-    // endwin();
+    endwin();
 }
-- 
cgit v1.2.3