summaryrefslogtreecommitdiff
path: root/dungeon/src/map.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-10-23 15:01:10 -0400
committerFreya Murphy <freya@freyacat.org>2025-10-23 15:01:10 -0400
commitbdede767f3e5208eb78103f5fbdb83ec1255f293 (patch)
tree3c6ce828d8b1c8ddb02380a592a4210c9d3b97d9 /dungeon/src/map.rs
parentgraphics: refactor Assets, and add tile drawing! (diff)
downloadDungeonCrawl-bdede767f3e5208eb78103f5fbdb83ec1255f293.tar.gz
DungeonCrawl-bdede767f3e5208eb78103f5fbdb83ec1255f293.tar.bz2
DungeonCrawl-bdede767f3e5208eb78103f5fbdb83ec1255f293.zip
dungon: use EnumIter from strum to add values methods to enums
Diffstat (limited to 'dungeon/src/map.rs')
-rw-r--r--dungeon/src/map.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/dungeon/src/map.rs b/dungeon/src/map.rs
index a2cdd9a..fb42a77 100644
--- a/dungeon/src/map.rs
+++ b/dungeon/src/map.rs
@@ -1,6 +1,9 @@
//! The `map` module contains structures of the dungeon game map
//! including the current `Floor`, and map `Tile`.
+use strum::IntoEnumIterator;
+use strum_macros::EnumIter;
+
use crate::wfc::Wfc;
use std::{
cell::RefCell,
@@ -20,7 +23,7 @@ pub const TILE_COUNT: usize = MAP_SIZE_USIZE * MAP_SIZE_USIZE;
/// The `Tile` enum represents what is (or is not) at
/// any given spot in the dungeon grid.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, EnumIter)]
pub enum Tile {
/// `Wall` represents an impassible wall
Wall,
@@ -29,13 +32,15 @@ pub enum Tile {
/// `Stairs` represents stairs to another floor
Stairs,
}
-
impl Tile {
/// Returns a list of all possible tiles
- /// TODO! Use a crate for enum itterator
- #[must_use]
- pub fn all_tiles() -> Vec<Tile> {
- vec![Tile::Wall, Tile::Air, Tile::Stairs]
+ pub fn values() -> impl Iterator<Item = Self> {
+ Self::iter()
+ }
+}
+impl Default for Tile {
+ fn default() -> Self {
+ Self::Air
}
}