From 5a0f7b2b057f24d83d522b98720f7c6430ddc081 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 31 Jan 2022 08:47:18 -0500 Subject: [PATCH] Add ItemMagicTemplate struct to raws --- src/map/themes.rs | 1 + src/map_builders.rs | 1 + src/map_builders/mushroom_forest.rs | 22 +++++++++++++++++- src/map_builders/prefab_builder.rs | 4 ++++ .../prefab_builder/prefab_sections.rs | 22 ++++++++++++++++++ src/raws/item_structs.rs | 23 +++++++++++++------ 6 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/map/themes.rs b/src/map/themes.rs index ff1ca4a..fdde2ae 100644 --- a/src/map/themes.rs +++ b/src/map/themes.rs @@ -6,6 +6,7 @@ use crate::colors; pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) { let (glyph, mut fg, mut bg) = match map.depth { + 8 | 9 => get_mushroom_glyph(idx, map), 7 => { let x = idx as i32 % map.width; if x > map.width - 16 { diff --git a/src/map_builders.rs b/src/map_builders.rs index 2b1b8bf..77a829f 100644 --- a/src/map_builders.rs +++ b/src/map_builders.rs @@ -361,6 +361,7 @@ pub fn level_builder( 6 => dwarf_fort_builder(new_depth, rng, width, height), 7 => mushroom_entrance(new_depth, rng, width, height), 8 => mushroom_builder(new_depth, rng, width, height), + 9 => mushroom_exit(new_depth, rng, width, height), _ => random_builder(new_depth, rng, width, height), } } diff --git a/src/map_builders/mushroom_forest.rs b/src/map_builders/mushroom_forest.rs index 51a8b08..43c1368 100644 --- a/src/map_builders/mushroom_forest.rs +++ b/src/map_builders/mushroom_forest.rs @@ -1,4 +1,4 @@ -use super::prefab_builder::prefab_sections::UNDERGROUND_FORT; +use super::prefab_builder::prefab_sections::{DROW_ENTRY, UNDERGROUND_FORT}; use super::{ AreaEndingPosition, AreaStartingPosition, BuilderChain, CellularAutomataBuilder, CullUnreachable, PrefabBuilder, VoronoiSpawning, WaveformCollapseBuilder, XEnd, XStart, YEnd, @@ -43,3 +43,23 @@ pub fn mushroom_builder( chain } + +pub fn mushroom_exit( + new_depth: i32, + _rng: &mut rltk::RandomNumberGenerator, + width: i32, + height: i32, +) -> BuilderChain { + let mut chain = BuilderChain::new(new_depth, width, height, "Into The Mushroom Grove"); + chain + .start_with(CellularAutomataBuilder::new()) + .with(WaveformCollapseBuilder::new()) + .with(AreaStartingPosition::new(XStart::Center, YStart::Center)) + .with(CullUnreachable::new()) + .with(AreaStartingPosition::new(XStart::Right, YStart::Center)) + .with(AreaEndingPosition::new(XEnd::Left, YEnd::Center)) + .with(VoronoiSpawning::new()) + .with(PrefabBuilder::sectional(DROW_ENTRY)); + + chain +} diff --git a/src/map_builders/prefab_builder.rs b/src/map_builders/prefab_builder.rs index a6a3dfe..b1c6054 100644 --- a/src/map_builders/prefab_builder.rs +++ b/src/map_builders/prefab_builder.rs @@ -101,6 +101,10 @@ impl PrefabBuilder { }); } '>' => build_data.map.tiles[idx] = TileType::DownStairs, + 'e' => { + build_data.map.tiles[idx] = TileType::Floor; + build_data.spawn_list.push((idx, "Dark Elf".to_string())); + } 'g' => { build_data.map.tiles[idx] = TileType::Floor; build_data.spawn_list.push((idx, "Goblin".to_string())); diff --git a/src/map_builders/prefab_builder/prefab_sections.rs b/src/map_builders/prefab_builder/prefab_sections.rs index f4a4c9d..d2fd547 100644 --- a/src/map_builders/prefab_builder/prefab_sections.rs +++ b/src/map_builders/prefab_builder/prefab_sections.rs @@ -103,3 +103,25 @@ const ORC_CAMP_TXT: &str = " ≈≈≈≈o≈≈≈≈≈ "; + +#[allow(dead_code)] +pub const DROW_ENTRY: PrefabSection = PrefabSection { + template: DROW_ENTRY_TXT, + width: 12, + height: 10, + placement: (HorizontalPlacement::Center, VerticalPlacement::Center), +}; + +#[allow(dead_code)] +const DROW_ENTRY_TXT: &str = " + + ########## + # # + # > # + # # + #e # + e # + #e # + ########## + +"; diff --git a/src/raws/item_structs.rs b/src/raws/item_structs.rs index 9e5331c..c5b445a 100644 --- a/src/raws/item_structs.rs +++ b/src/raws/item_structs.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use ::serde::Deserialize; -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct Item { pub name: String, pub renderable: Option, @@ -15,9 +15,10 @@ pub struct Item { pub vendor_category: Option, pub magic: Option, pub attributes: Option, + pub template_magic: Option, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct Renderable { pub glyph: String, pub fg: String, @@ -27,13 +28,13 @@ pub struct Renderable { pub y_size: Option, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct Consumable { pub effects: HashMap, pub charges: Option, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct Weapon { pub range: String, pub attribute: String, @@ -44,23 +45,31 @@ pub struct Weapon { pub proc_effects: Option>, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct Wearable { pub armor_class: f32, pub slot: String, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct MagicItem { pub class: String, pub naming: String, pub cursed: Option, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] pub struct ItemAttributeBonus { pub might: Option, pub fitness: Option, pub quickness: Option, pub intelligence: Option, } + +#[derive(Deserialize, Debug, Clone)] +pub struct ItemMagicTemplate { + pub unidentified_name: String, + pub bonus_min: i32, + pub bonus_max: i32, + pub include_cursed: bool, +}