1
0
Fork 0

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
1 changed files with 7 additions and 2 deletions

View File

@ -1,7 +1,9 @@
mod bsp_dungeon;
mod common;
mod simple_map;
use crate::{Map, Position};
use bsp_dungeon::BspDungeonBuilder;
use common::*;
use simple_map::SimpleMapBuilder;
use specs::prelude::*;
@ -16,6 +18,9 @@ pub trait 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
Box::new(SimpleMapBuilder::new(new_depth))
let mut rng = rltk::RandomNumberGenerator::new();
match rng.roll_dice(1, 2) {
1 => Box::new(BspDungeonBuilder::new(new_depth)),
_ => Box::new(SimpleMapBuilder::new(new_depth)),
}
}