aboutsummaryrefslogtreecommitdiff
path: root/src/state.rs
diff options
context:
space:
mode:
authorLuis Ferro <luis.ferro@eggplant.io>2019-11-12 15:57:03 +0100
committerLuis Ferro <luis.ferro@eggplant.io>2019-11-12 15:57:03 +0100
commit44146c74c913a72f79f94280a5daa40f33e6c05b (patch)
treede900d2fe144ceffa6c6065cc5824a3960005224 /src/state.rs
parentfe183a3453a828c077db85cd72d3ce39410f2196 (diff)
parente8e931794052455d93517d35c75bb98b7829e70d (diff)
May not work
q!
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/state.rs b/src/state.rs
new file mode 100644
index 0000000..6dad58e
--- /dev/null
+++ b/src/state.rs
@@ -0,0 +1,62 @@
+use pancurses::Window;
+use std::env;
+
+use crate::entities::{Character, Entity};
+use crate::world::{Dungeon, Generatable, Level};
+
+pub struct State {
+ pub character: Character,
+ pub dungeon: Dungeon,
+ pub level: usize,
+}
+
+impl State {
+ pub fn new(
+ character: Character,
+ dungeon: Dungeon,
+ ) -> State {
+ State {
+ character: character,
+ dungeon: dungeon,
+ level: 0,
+ }
+ }
+
+ pub fn init(&mut self) {
+ self.dungeon.generate();
+ self.character.place(self.current_level().get_start_point());
+ }
+
+ pub fn debug(&self) {
+ match env::var("DEBUG") {
+ Ok(_) => {
+ self.dungeon.debug_levels();
+ },
+ Err(_) => ()
+ };
+ }
+
+ pub fn render_level(&self, window: &Window) {
+ self.current_level().render(window);
+ }
+
+ pub fn show_character(&self, window: &Window) {
+ self.character.render(window);
+
+ // window.mv(window.get_max_y() - 2, 0);
+ // window.clrtoeol();
+
+ // window.refresh();
+
+ // window.addstr(self.character.info() + "\n");
+
+ // window.mv(self.character.location.1 as i32,self.character.location.0 as i32);
+ // window.refresh();
+ // draw_block(&window, self.character.tile_type);
+ // window.refresh();
+ }
+
+ fn current_level(&self) -> &Level {
+ &self.dungeon.levels[self.level]
+ }
+} \ No newline at end of file