diff --git a/bin_efo/src/commands/entity_generic.rs b/bin_efo/src/commands/entity_generic.rs index 5ab2ed3..18147bf 100644 --- a/bin_efo/src/commands/entity_generic.rs +++ b/bin_efo/src/commands/entity_generic.rs @@ -122,7 +122,6 @@ pub(crate) struct DelArgs { /// Arguments required for showing any entity pub(crate) struct ShowArgs { /// The identifier either a name or a @tag - #[arg(long, short)] identifier: Option, #[arg(long, short)] @@ -223,7 +222,7 @@ pub fn handle_entity_commands( } /// Function handler for the create subcommand -fn handle_create_entity( +pub(crate) fn handle_create_entity( entity_args: &EntityArgs, e_type: &EntityType, main_epoch: &mut EpochConfig, diff --git a/bin_efo/src/commands/generate.rs b/bin_efo/src/commands/generate.rs index a9046e5..f715a31 100644 --- a/bin_efo/src/commands/generate.rs +++ b/bin_efo/src/commands/generate.rs @@ -99,12 +99,12 @@ pub struct Qty { /// If set to `false` the generator will produce a *short* representation #[arg(long, action = clap::ArgAction::SetFalse, default_value_t = true)] short: bool, - /// Generate only a name, no underlying structure. - /// - /// When this flag is present the generator prints only the name string - /// rather than any additional data or formatting. - #[arg(long="name", action = clap::ArgAction::SetTrue, default_value_t = false)] - name_only: bool, + // /// Generate only a name, no underlying structure. + // /// + // /// When this flag is present the generator prints only the name string + // /// rather than any additional data or formatting. + // #[arg(long="dry", action = clap::ArgAction::SetFalse, default_value_t = true)] + // dry: bool, } /// Handles the subcommand for generating various kinds of entities. @@ -133,11 +133,9 @@ pub fn gen_handler(cmd: &GenCmd) -> Result<(), AppError> { fn handle_calamity(args: &Qty) -> Result<(), EpochError> { for _ in 0..args.number { let name = NAMING.generate_calamity_name(); - if args.name_only { - println!("{}", name); - } else { - unimplemented!("DEPENS ON : CHARACTER CREATION") - } + // if args.dry { + println!("{}", name); + // } } Ok(()) } @@ -146,11 +144,11 @@ fn handle_calamity(args: &Qty) -> Result<(), EpochError> { fn handle_blocker(args: &Qty) -> Result<(), EpochError> { for _ in 0..args.number { let name = NAMING.generate_blocker_name(); - if args.name_only { - println!("{}", name); - } else { - unimplemented!("DEPENS ON : CHARACTER CREATION") - } + // if args.name_only { + println!("{}", name); + // } else { + // unimplemented!("DEPENS ON : CHARACTER CREATION") + // } } Ok(()) } @@ -159,11 +157,11 @@ fn handle_blocker(args: &Qty) -> Result<(), EpochError> { fn handle_exotic(args: &Qty) -> Result<(), EpochError> { for _ in 0..args.number { let name = NAMING.generate_exotic_character_name(); - if args.name_only { - println!("{}", name); - } else { - unimplemented!("DEPENS ON : CHARACTER CREATION") - } + // if args.name_only { + println!("{}", name); + // } else { + // unimplemented!("DEPENS ON : CHARACTER CREATION") + // } } Ok(()) } @@ -172,11 +170,11 @@ fn handle_exotic(args: &Qty) -> Result<(), EpochError> { fn handle_town(args: &Qty) -> Result<(), EpochError> { for _ in 0..args.number { let name = NAMING.generate_town_name(); - if args.name_only { - println!("{}", name); - } else { - unimplemented!("DEPENS ON : TOWN CREATION") - } + // if args.name_only { + println!("{}", name); + // } else { + // unimplemented!("DEPENS ON : TOWN CREATION") + // } } Ok(()) } @@ -185,11 +183,11 @@ fn handle_town(args: &Qty) -> Result<(), EpochError> { fn handle_event(args: &Qty) -> Result<(), EpochError> { for _ in 0..args.number { let event = NAMING.random_event_idea()?; - if args.name_only { - println!("{}", event.name); - } else { - println!("{}", event.oneline_display()); - } + // if args.name_only { + // println!("{}", event.name); + // } else { + println!("{}", event.oneline_display()); + // } } Ok(()) } @@ -203,11 +201,11 @@ fn handle_chr(args: &Qty) -> Result<(), EpochError> { NAMING.generate_character_name() }; - if args.name_only { - println!("{}", name); - } else { - unimplemented!("DEPENS ON : CHARACTER CREATION") - } + // if args.name_only { + println!("{}", name); + // } else { + // unimplemented!("DEPENS ON : CHARACTER CREATION") + // } } Ok(()) } diff --git a/lib_efo/src/entity.rs b/lib_efo/src/entity.rs index ca0fcea..be7c9f9 100644 --- a/lib_efo/src/entity.rs +++ b/lib_efo/src/entity.rs @@ -33,6 +33,9 @@ pub struct Entity { /// The name of the entity pub name: String, + /// A short description of the entity + pub description: String, + /// The global identifier for the entity pub id: Uuid, diff --git a/lib_efo/src/entity/implementations.rs b/lib_efo/src/entity/implementations.rs index 7715044..cb359b5 100644 --- a/lib_efo/src/entity/implementations.rs +++ b/lib_efo/src/entity/implementations.rs @@ -265,6 +265,30 @@ impl Entity { overwrite_stat(&mut self.stats, pair); } + /// Change the entity's duration. + /// + /// This simply replaces the current `EntityDuration` with the one supplied. + /// No validation or transformation is performed; it is a direct overwrite. + /// + /// # Arguments + /// * `duration` - The new `EntityDuration` to assign to the entity. + /// + pub fn change_duration(&mut self, duration: EntityDuration) { + self.duration = duration + } + + /// Change the entity's description. + /// + /// Replaces the current description string with the new one supplied. + /// This method performs a direct overwrite; the previous description is dropped. + /// + /// # Arguments + /// * `descritption` - The new description string for the entity. + /// + pub fn change_description(&mut self, descritption: String) { + self.description = descritption + } + /// Apply a delta to all of the entity's statistics. /// /// The delta specified by `pair` is added to each of the statistics in @@ -306,6 +330,11 @@ impl Entity { } } +// impl Entity { +// /// Create a new Event +// fn new_event(name: String, description: String){} +// } + /// Replace a statistic in `stats` with the value from `pair`. /// /// This function performs a direct overwrite: the existing value is @@ -357,6 +386,7 @@ impl Diffable for Entity { effect_nature: other.effect_nature.clone(), effect_bounds: other.effect_bounds.clone(), id: Uuid::new_v4(), + description: other.description.clone(), } } } diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_delta_stat_positive.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_delta_stat_positive.snap index c0df3e1..ee4827b 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_delta_stat_positive.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_delta_stat_positive.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}\", e)" --- Entity { name: "", + description: "", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-2.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-2.snap index a813809..07a4d68 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-2.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-2.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}{}\", delta2, delta2.full_stats_to_table().unwrap()) --- Entity { name: "Bob", + description: "Ilo", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-3.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-3.snap index ec02a33..6f1174c 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-3.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-3.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}{}\", delta3, delta3.full_stats_to_table().unwrap()) --- Entity { name: "Bob->Alice", + description: "Ello", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta.snap index a688a9a..8b7671c 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}{}\", &delta, delta.full_stats_to_table().unwrap())" --- Entity { name: "Alice->Bob", + description: "Ilo", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_duration.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_duration.snap index 61f463d..f997384 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_duration.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_duration.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}\", e)" --- Entity { name: "", + description: "", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_application.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_application.snap index 3fffbfd..da16fa0 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_application.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_application.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}\", e)" --- Entity { name: "", + description: "", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_bounds.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_bounds.snap index 7ce3de6..3138636 100644 --- a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_bounds.snap +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_modify_effect_bounds.snap @@ -4,6 +4,7 @@ expression: "format!(\"{:#?}\", e)" --- Entity { name: "", + description: "", id: 00000000-0000-0000-0000-000000000000, stats: OverallStats { demographics: GenericStat( diff --git a/lib_efo/src/entity/test.rs b/lib_efo/src/entity/test.rs index a4ae504..d5c6f9e 100644 --- a/lib_efo/src/entity/test.rs +++ b/lib_efo/src/entity/test.rs @@ -244,6 +244,7 @@ fn full_entity() -> Entity { effect_bounds: EffectBounds::from((1, 5)), stats: stats::OverallStats::default(), temp_stats: Some(stats::OverallStats::default()), + description: String::from("Bob"), } } @@ -379,6 +380,7 @@ fn snapshot_entity_delta() { duration: EntityDuration::Permanent, effect_nature: EffectApplication::Recurring, effect_bounds: EffectBounds::from(0..33), + description: "Ello".to_string(), }; let e2 = Entity { @@ -398,6 +400,7 @@ fn snapshot_entity_delta() { duration: EntityDuration::Permanent, effect_nature: EffectApplication::Recurring, effect_bounds: EffectBounds::from(0..3), + description: "Ilo".to_string(), }; // Compute the delta diff --git a/lib_efo/src/naming.rs b/lib_efo/src/naming.rs index d2d2913..f972228 100644 --- a/lib_efo/src/naming.rs +++ b/lib_efo/src/naming.rs @@ -145,12 +145,18 @@ impl NamingData { #[allow(clippy::unwrap_used)] pub fn random_event_idea(&self) -> Result<&EventDescription, EpochError> { let mut rng = rand::rng(); - self.event_ideas + let event_desc = self + .event_ideas .choose(&mut rng) .ok_or(EpochError::RNGPickError { cause: "Picking a random event".into(), help: None, - }) + })?; + // let mut e = Entity::default(); + + // e.name = event_desc.name.clone(); + // e.change_description(event_desc.description.clone()); + Ok(event_desc) } /// Pick a random event name