diff options
Diffstat (limited to 'src/names/artifact.rs')
| -rw-r--r-- | src/names/artifact.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/names/artifact.rs b/src/names/artifact.rs index af24b3d..336eef4 100644 --- a/src/names/artifact.rs +++ b/src/names/artifact.rs @@ -2,22 +2,31 @@ //! called once a scholar has told you what it is. use rand::RngExt; +use serde::{Deserialize, Serialize}; use super::{Culture, pick}; use crate::seed::Rng; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Artifact { /// What you see when you find it: "a humming ochre lattice". pub unidentified: String, /// Its true name: "the Lacquered Orrery of Teshemond". pub true_name: String, + /// Whether a scholar has told you its true name. + pub identified: bool, +} + +impl Artifact { + /// What you call it: its true name once you know it. + pub fn name(&self) -> &str { + if self.identified { &self.true_name } else { &self.unidentified } + } } pub fn artifact(rng: &mut Rng) -> Artifact { let look = format!("{} {} {}", pick(QUALITIES, rng), pick(COLOURS, rng), pick(SHAPES, rng)); - let article = if look.starts_with(['a', 'e', 'i', 'o', 'u']) { "an" } else { "a" }; - let unidentified = format!("{article} {look}"); + let unidentified = super::a(&look); let object = pick(OBJECTS, rng); let culture = Culture::ALL[rng.random_range(..Culture::ALL.len())]; @@ -28,7 +37,7 @@ pub fn artifact(rng: &mut Rng) -> Artifact { 3 => format!("the {} {object}", pick(EPITHETS, rng)), _ => format!("the {object} {}", pick(CLAUSES, rng)), }; - Artifact { unidentified, true_name } + Artifact { unidentified, true_name, identified: false } } const QUALITIES: &[&str] = &[ |