chance to log dungeon features per clock turn
This commit is contained in:
parent
050973eae4
commit
a038a3f586
6 changed files with 59 additions and 8 deletions
|
|
@ -3,6 +3,33 @@ use specs::prelude::*;
|
|||
use crate::data::events::*;
|
||||
|
||||
const TRY_SPAWN_CHANCE: i32 = 70;
|
||||
const FEATURE_MESSAGE_CHANCE: i32 = 110;
|
||||
|
||||
pub fn maybe_map_message(ecs: &mut World) {
|
||||
let mut maybe_message = false;
|
||||
let map = ecs.fetch::<Map>();
|
||||
if map.messages.is_empty() {
|
||||
return;
|
||||
}
|
||||
// Scope for borrow checker (ECS)
|
||||
{
|
||||
let clock = ecs.read_storage::<Clock>();
|
||||
let turns = ecs.read_storage::<TakingTurn>();
|
||||
let mut rng = ecs.write_resource::<rltk::RandomNumberGenerator>();
|
||||
for (_c, _t) in (&clock, &turns).join() {
|
||||
if rng.roll_dice(1, FEATURE_MESSAGE_CHANCE) == 1 {
|
||||
maybe_message = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if maybe_message {
|
||||
let mut logger = gamelog::Logger::new();
|
||||
for message in map.messages.clone() {
|
||||
logger = logger.append(message);
|
||||
}
|
||||
logger.log();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_spawn_interval(ecs: &mut World) {
|
||||
let mut try_spawn = false;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::collections::{ HashSet, HashMap };
|
|||
mod tiletype;
|
||||
pub use tiletype::{ tile_cost, tile_opaque, tile_walkable, TileType, get_dest, Destination };
|
||||
mod interval_spawning_system;
|
||||
pub use interval_spawning_system::try_spawn_interval;
|
||||
pub use interval_spawning_system::{ maybe_map_message, try_spawn_interval };
|
||||
pub mod dungeon;
|
||||
pub use dungeon::{ level_transition, MasterDungeonMap };
|
||||
pub mod themes;
|
||||
|
|
@ -30,6 +30,7 @@ pub struct Map {
|
|||
pub name: String,
|
||||
pub short_name: String,
|
||||
pub depth: i32,
|
||||
pub messages: HashSet<String>,
|
||||
pub difficulty: i32,
|
||||
pub bloodstains: HashMap<usize, RGB>,
|
||||
pub view_blocked: HashSet<usize>,
|
||||
|
|
@ -70,6 +71,7 @@ impl Map {
|
|||
id: new_id,
|
||||
name: name.to_string(),
|
||||
short_name: short_name.to_string(),
|
||||
messages: HashSet::new(),
|
||||
depth: depth,
|
||||
difficulty: difficulty,
|
||||
bloodstains: HashMap::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue