diff options
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/state.rs b/src/state.rs new file mode 100644 index 0000000..3e8516b --- /dev/null +++ b/src/state.rs @@ -0,0 +1,48 @@ +use pancurses::Window; +use std::env; + +use crate::character::Character; +use crate::character::Player; +use crate::computer::Enemy; +use crate::world::{Dungeon, Generable, 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); + } + + fn current_level(&self) -> &Level { + &self.dungeon.levels[self.level] + } +}
\ No newline at end of file |