unid wand names
This commit is contained in:
parent
1ec876a10d
commit
3474a782d7
3 changed files with 57 additions and 16 deletions
|
|
@ -11,6 +11,7 @@ pub struct MasterDungeonMap {
|
||||||
pub identified_items: HashSet<String>,
|
pub identified_items: HashSet<String>,
|
||||||
pub scroll_map: HashMap<String, (String, String)>,
|
pub scroll_map: HashMap<String, (String, String)>,
|
||||||
pub potion_map: HashMap<String, String>,
|
pub potion_map: HashMap<String, String>,
|
||||||
|
pub wand_map: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MasterDungeonMap {
|
impl MasterDungeonMap {
|
||||||
|
|
@ -21,6 +22,7 @@ impl MasterDungeonMap {
|
||||||
identified_items: HashSet::new(),
|
identified_items: HashSet::new(),
|
||||||
scroll_map: HashMap::new(),
|
scroll_map: HashMap::new(),
|
||||||
potion_map: HashMap::new(),
|
potion_map: HashMap::new(),
|
||||||
|
wand_map: HashMap::new(),
|
||||||
};
|
};
|
||||||
// TODO: Use stored RNG
|
// TODO: Use stored RNG
|
||||||
let mut rng = RandomNumberGenerator::new();
|
let mut rng = RandomNumberGenerator::new();
|
||||||
|
|
@ -33,6 +35,11 @@ impl MasterDungeonMap {
|
||||||
let unid_singular = make_potion_name(&mut rng, &mut used_potion_names);
|
let unid_singular = make_potion_name(&mut rng, &mut used_potion_names);
|
||||||
dm.potion_map.insert(potion_tag.to_string(), unid_singular);
|
dm.potion_map.insert(potion_tag.to_string(), unid_singular);
|
||||||
}
|
}
|
||||||
|
let mut used_wand_names: HashSet<String> = HashSet::new();
|
||||||
|
for wand_tag in crate::raws::get_wand_tags().iter() {
|
||||||
|
let unid_singular = make_wand_name(&mut rng, &mut used_wand_names);
|
||||||
|
dm.wand_map.insert(wand_tag.to_string(), unid_singular);
|
||||||
|
}
|
||||||
|
|
||||||
return dm;
|
return dm;
|
||||||
}
|
}
|
||||||
|
|
@ -98,8 +105,10 @@ fn make_scroll_name(rng: &mut RandomNumberGenerator) -> (String, String) {
|
||||||
return (singular, plural);
|
return (singular, plural);
|
||||||
}
|
}
|
||||||
|
|
||||||
const POTION_COLOURS: &[&str] =
|
const POTION_COLOURS: &[&str] = &[
|
||||||
&["red", "orange", "yellow", "green", "blue", "indigo", "violet", "black", "white", "silver", "gold"];
|
"red", "orange", "yellow", "green", "blue", "indigo", "violet", "black", "white", "silver", "gold", "rainbow",
|
||||||
|
"blood", "purple", "cyan", "brown", "grey",
|
||||||
|
];
|
||||||
const POTION_ADJECTIVES: &[&str] = &["swirling", "viscous", "effervescent", "slimy", "oily", "metallic"];
|
const POTION_ADJECTIVES: &[&str] = &["swirling", "viscous", "effervescent", "slimy", "oily", "metallic"];
|
||||||
|
|
||||||
fn make_potion_name(rng: &mut RandomNumberGenerator, used_names: &mut HashSet<String>) -> String {
|
fn make_potion_name(rng: &mut RandomNumberGenerator, used_names: &mut HashSet<String>) -> String {
|
||||||
|
|
@ -117,6 +126,32 @@ fn make_potion_name(rng: &mut RandomNumberGenerator, used_names: &mut HashSet<St
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const WAND_TYPES: &[&str] = &[
|
||||||
|
"iron",
|
||||||
|
"steel",
|
||||||
|
"silver",
|
||||||
|
"gold",
|
||||||
|
"octagonal",
|
||||||
|
"pointed",
|
||||||
|
"curved",
|
||||||
|
"jeweled",
|
||||||
|
"mahogany",
|
||||||
|
"crystalline",
|
||||||
|
"lead",
|
||||||
|
];
|
||||||
|
|
||||||
|
fn make_wand_name(rng: &mut RandomNumberGenerator, used_names: &mut HashSet<String>) -> String {
|
||||||
|
loop {
|
||||||
|
let mut name: String = WAND_TYPES[rng.roll_dice(1, WAND_TYPES.len() as i32) as usize - 1].to_string();
|
||||||
|
name += " wand";
|
||||||
|
|
||||||
|
if !used_names.contains(&name) {
|
||||||
|
used_names.insert(name.clone());
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn level_transition(ecs: &mut World, new_id: i32, offset: i32) -> Option<Vec<Map>> {
|
pub fn level_transition(ecs: &mut World, new_id: i32, offset: i32) -> Option<Vec<Map>> {
|
||||||
// Obtain master
|
// Obtain master
|
||||||
let dungeon_master = ecs.read_resource::<MasterDungeonMap>();
|
let dungeon_master = ecs.read_resource::<MasterDungeonMap>();
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ pub fn spawn_named_item(raws: &RawMaster, ecs: &mut World, key: &str, pos: Spawn
|
||||||
let dm = ecs.fetch::<crate::map::MasterDungeonMap>();
|
let dm = ecs.fetch::<crate::map::MasterDungeonMap>();
|
||||||
let scroll_names = dm.scroll_map.clone();
|
let scroll_names = dm.scroll_map.clone();
|
||||||
let potion_names = dm.potion_map.clone();
|
let potion_names = dm.potion_map.clone();
|
||||||
|
let wand_names = dm.wand_map.clone();
|
||||||
let identified_items = dm.identified_items.clone();
|
let identified_items = dm.identified_items.clone();
|
||||||
std::mem::drop(dm);
|
std::mem::drop(dm);
|
||||||
let mut eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
let mut eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
||||||
|
|
@ -197,6 +198,12 @@ pub fn spawn_named_item(raws: &RawMaster, ecs: &mut World, key: &str, pos: Spawn
|
||||||
plural += "s";
|
plural += "s";
|
||||||
eb = eb.with(ObfuscatedName { name: singular, plural: plural })
|
eb = eb.with(ObfuscatedName { name: singular, plural: plural })
|
||||||
}
|
}
|
||||||
|
"wand" => {
|
||||||
|
let singular = wand_names[&item_template.name.name].clone();
|
||||||
|
let mut plural = singular.clone();
|
||||||
|
plural += "s";
|
||||||
|
eb = eb.with(ObfuscatedName { name: singular, plural: plural })
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let singular = magic_item.naming.clone();
|
let singular = magic_item.naming.clone();
|
||||||
let mut plural = singular.clone();
|
let mut plural = singular.clone();
|
||||||
|
|
@ -686,6 +693,19 @@ pub fn get_potion_tags() -> Vec<String> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_wand_tags() -> Vec<String> {
|
||||||
|
let raws = &super::RAWS.lock().unwrap();
|
||||||
|
let mut result = Vec::new();
|
||||||
|
for item in raws.raws.items.iter() {
|
||||||
|
if let Some(magic) = &item.magic {
|
||||||
|
if &magic.naming == "wand" {
|
||||||
|
result.push(item.name.name.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_id_from_name(name: String) -> String {
|
pub fn get_id_from_name(name: String) -> String {
|
||||||
let raws = &super::RAWS.lock().unwrap();
|
let raws = &super::RAWS.lock().unwrap();
|
||||||
for item in &raws.raws.items {
|
for item in &raws.raws.items {
|
||||||
|
|
|
||||||
|
|
@ -69,20 +69,6 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||||
raws::SpawnType::Equipped { by: player },
|
raws::SpawnType::Equipped { by: player },
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
raws::spawn_named_entity(
|
|
||||||
&raws::RAWS.lock().unwrap(),
|
|
||||||
ecs,
|
|
||||||
"wand_fireball",
|
|
||||||
raws::SpawnType::Carried { by: player },
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
raws::spawn_named_entity(
|
|
||||||
&raws::RAWS.lock().unwrap(),
|
|
||||||
ecs,
|
|
||||||
"wand_magicmissile",
|
|
||||||
raws::SpawnType::Carried { by: player },
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
raws::spawn_named_entity(
|
raws::spawn_named_entity(
|
||||||
&raws::RAWS.lock().unwrap(),
|
&raws::RAWS.lock().unwrap(),
|
||||||
ecs,
|
ecs,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue