Randomly choose which map builder to use

This commit is contained in:
Timothy Warren 2021-12-02 15:00:06 -05:00
parent 86d46b8d5b
commit 0f8d4d8fab

View File

@ -1,7 +1,9 @@
mod bsp_dungeon;
mod common; mod common;
mod simple_map; mod simple_map;
use crate::{Map, Position}; use crate::{Map, Position};
use bsp_dungeon::BspDungeonBuilder;
use common::*; use common::*;
use simple_map::SimpleMapBuilder; use simple_map::SimpleMapBuilder;
use specs::prelude::*; use specs::prelude::*;
@ -16,6 +18,9 @@ pub trait MapBuilder {
} }
pub fn random_builder(new_depth: i32) -> Box<dyn MapBuilder> { pub fn random_builder(new_depth: i32) -> Box<dyn MapBuilder> {
// Note that until we have a second map type, this isn't even slightly random let mut rng = rltk::RandomNumberGenerator::new();
Box::new(SimpleMapBuilder::new(new_depth)) match rng.roll_dice(1, 2) {
1 => Box::new(BspDungeonBuilder::new(new_depth)),
_ => Box::new(SimpleMapBuilder::new(new_depth)),
}
} }