summaryrefslogtreecommitdiff
path: root/dungeon/src/lib.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-10-07 11:01:19 -0400
committerFreya Murphy <freya@freyacat.org>2025-10-08 19:37:15 -0400
commitb11f074ceba10af62b35b414ecaa51a8f13c6550 (patch)
treed12979f7eeb384f94b145ea763a97dcde353745b /dungeon/src/lib.rs
parentInitial commit (diff)
downloadDungeonCrawl-b11f074ceba10af62b35b414ecaa51a8f13c6550.tar.gz
DungeonCrawl-b11f074ceba10af62b35b414ecaa51a8f13c6550.tar.bz2
DungeonCrawl-b11f074ceba10af62b35b414ecaa51a8f13c6550.zip
initial baseline
Diffstat (limited to 'dungeon/src/lib.rs')
-rw-r--r--dungeon/src/lib.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/dungeon/src/lib.rs b/dungeon/src/lib.rs
new file mode 100644
index 0000000..66faec3
--- /dev/null
+++ b/dungeon/src/lib.rs
@@ -0,0 +1,58 @@
+//! The `dungon` crate contains the core functionality for
+//! interacting with a `Dungeon` and its components.
+
+mod map;
+mod pos;
+
+pub use map::*;
+pub use pos::*;
+
+/// The `Dungeon` type represents the game state of the
+/// dungeon crawler.
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+pub struct Dungeon {
+ player: Entity,
+ floor: Floor,
+}
+impl Dungeon {
+ /// Creates a new `Dungeon`.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// use dungeon::Dungeon;
+ ///
+ /// let dungeon = Dungeon::new();
+ /// ```
+ #[must_use]
+ pub fn new() -> Self {
+ let floor = Floor::generate();
+ let player = Entity::player(floor.player_start());
+
+ Self { player, floor }
+ }
+
+ /// Creates a new `Dungeon` with a provided seed.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// use dungeon::Dungeon;
+ ///
+ /// let seed = 234690523482u64;
+ /// let dungeon = Dungeon::new_seeded(seed);
+ /// ```
+ #[must_use]
+ pub fn new_seeded(seed: u64) -> Self {
+ let floor = Floor::generate_seeded(seed);
+ let player = Entity::player(floor.player_start());
+
+ Self { player, floor }
+ }
+}
+
+impl Default for Dungeon {
+ fn default() -> Self {
+ Self::new()
+ }
+}