diff --git a/.run_status.toml b/.run_status.toml index b4e5585..0f10435 100644 --- a/.run_status.toml +++ b/.run_status.toml @@ -1,8 +1,8 @@ [last_run_clean] run_status = "Success" -lines_parsed = 59 -coverage = 14.8 +lines_parsed = 76 +coverage = 38.61 [last_run_clean.run_duration] -secs = 23 -nanos = 833334374 +secs = 24 +nanos = 391618885 diff --git a/badges/coverage.svg b/badges/coverage.svg index e11fa6b..41d0854 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -test-coverage: 15%test-coverage15% +test-coverage: 39%test-coverage39% \ No newline at end of file diff --git a/badges/test.svg b/badges/test.svg index a7859aa..382bf2f 100644 --- a/badges/test.svg +++ b/badges/test.svg @@ -1 +1 @@ -test: passingtestpassing +test: passingtestpassing \ No newline at end of file diff --git a/badges/version.svg b/badges/version.svg index e154d66..c835340 100644 --- a/badges/version.svg +++ b/badges/version.svg @@ -1 +1 @@ -version: 0.1version0.1 +version: 0.1version0.1 \ No newline at end of file diff --git a/lib_efo/src/entity/implementations.rs b/lib_efo/src/entity/implementations.rs index 5d5c10d..c87d3fd 100644 --- a/lib_efo/src/entity/implementations.rs +++ b/lib_efo/src/entity/implementations.rs @@ -371,10 +371,10 @@ impl Diffable for Entity { stats: self.stats.clone() - other.stats.clone(), temp_stats: self.temp_stats.delta(&other.temp_stats), metadata: self.metadata.delta(&other.metadata), - entity_type: self.entity_type.clone(), - duration: self.duration.clone(), - effect_nature: self.effect_nature.clone(), - effect_bounds: self.effect_bounds.clone() - other.effect_bounds.clone(), + entity_type: other.entity_type.clone(), + duration: other.duration.clone(), + effect_nature: other.effect_nature.clone(), + effect_bounds: other.effect_bounds.clone(), id: Uuid::new_v4(), } } 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 51b4cdc..58a59f3 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 @@ -1,6 +1,6 @@ --- source: lib_efo/src/entity/test.rs -expression: "format!(\"{:#?}\", delta2)" +expression: "format!(\"{:#?}{}\", delta2, delta2.full_stats_to_table().unwrap())" --- Entity { name: "Bob", @@ -157,6 +157,13 @@ Entity { effect_nature: Recurring, effect_bounds: EffectBounds { min: 0, - max: 0, + max: 3, }, -} +}┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ DEM │ POP │ GRW │ CRM │ HPY │ ECO │ FOD │ IND │ SCI │ TRD │ MIL │ ARM │ STR │ FRT │ THR │ IFR │ BUR │ TRP │ SPR │ HLT │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ 0  │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + 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 new file mode 100644 index 0000000..548c7f5 --- /dev/null +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_entity_delta-3.snap @@ -0,0 +1,173 @@ +--- +source: lib_efo/src/entity/test.rs +expression: "format!(\"{:#?}{}\", delta3, delta3.full_stats_to_table().unwrap())" +--- +Entity { + name: "Bob->Alice", + id: 00000000-0000-0000-0000-000000000000, + stats: OverallStats { + demographics: GenericStat( + 42, + ), + population: GenericStat( + 42, + ), + growth_rate: GenericStat( + 42, + ), + crime: GenericStat( + 42, + ), + happiness: GenericStat( + 42, + ), + economy: GenericStat( + 42, + ), + food: GenericStat( + 42, + ), + industry: GenericStat( + 42, + ), + science: GenericStat( + 42, + ), + trade: GenericStat( + 42, + ), + military: GenericStat( + 42, + ), + army: GenericStat( + 42, + ), + strength: GenericStat( + 42, + ), + fortification: GenericStat( + 42, + ), + threat: GenericStat( + 42, + ), + infrastructure: GenericStat( + 42, + ), + bureaucracy: GenericStat( + 42, + ), + transportation: GenericStat( + 42, + ), + sprawl: GenericStat( + 42, + ), + health: GenericStat( + 42, + ), + }, + temp_stats: Some( + OverallStats { + demographics: GenericStat( + 5, + ), + population: GenericStat( + 6, + ), + growth_rate: GenericStat( + 7, + ), + crime: GenericStat( + 8, + ), + happiness: GenericStat( + 9, + ), + economy: GenericStat( + 10, + ), + food: GenericStat( + 11, + ), + industry: GenericStat( + 12, + ), + science: GenericStat( + 13, + ), + trade: GenericStat( + 14, + ), + military: GenericStat( + 15, + ), + army: GenericStat( + 16, + ), + strength: GenericStat( + 17, + ), + fortification: GenericStat( + 18, + ), + threat: GenericStat( + 19, + ), + infrastructure: GenericStat( + 20, + ), + bureaucracy: GenericStat( + 21, + ), + transportation: GenericStat( + 22, + ), + sprawl: GenericStat( + 23, + ), + health: GenericStat( + 24, + ), + }, + ), + metadata: MetaStats { + position: Position( + -11, + -662, + ), + capital: Some( + TownId( + 5000, + ), + ), + governor: Some( + CharacterId( + 2000, + ), + ), + faction: Some( + FactionId( + 44, + ), + ), + links: [], + prestige: GenericStat( + 2, + ), + }, + entity_type: Monster, + duration: Permanent, + effect_nature: Recurring, + effect_bounds: EffectBounds { + min: 0, + max: 33, + }, +}┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ DEM │ POP │ GRW │ CRM │ HPY │ ECO │ FOD │ IND │ SCI │ TRD │ MIL │ ARM │ STR │ FRT │ THR │ IFR │ BUR │ TRP │ SPR │ HLT │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ 42  │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ 5  │ 6  │ 7  │ 8  │ 9  │ 10  │ 11  │ 12  │ 13  │ 14  │ 15  │ 16  │ 17  │ 18  │ 19  │ 20  │ 21  │ 22  │ 23  │ 24  │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + 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 1486567..bfc612a 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 @@ -1,6 +1,6 @@ --- source: lib_efo/src/entity/test.rs -expression: "format!(\"{:#?}\", delta)" +expression: "format!(\"{:#?}{}\", &delta, delta.full_stats_to_table().unwrap())" --- Entity { name: "Alice->Bob", @@ -156,11 +156,18 @@ Entity { -2, ), }, - entity_type: Monster, + entity_type: Town, duration: Permanent, effect_nature: Recurring, effect_bounds: EffectBounds { min: 0, - max: 30, + max: 3, }, -} +}┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ DEM │ POP │ GRW │ CRM │ HPY │ ECO │ FOD │ IND │ SCI │ TRD │ MIL │ ARM │ STR │ FRT │ THR │ IFR │ BUR │ TRP │ SPR │ HLT │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ -42 │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ 5  │ 6  │ 7  │ 8  │ 9  │ 10  │ 11  │ 12  │ 13  │ 14  │ 15  │ 16  │ 17  │ 18  │ 19  │ 20  │ 21  │ 22  │ 23  │ 24  │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-2.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-2.snap new file mode 100644 index 0000000..0979c2d --- /dev/null +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-2.snap @@ -0,0 +1,68 @@ +--- +source: lib_efo/src/entity/test.rs +expression: "format!(\"{:#?}\", delta2)" +--- +Some( + OverallStats { + demographics: GenericStat( + 23, + ), + population: GenericStat( + 24, + ), + growth_rate: GenericStat( + 25, + ), + crime: GenericStat( + 26, + ), + happiness: GenericStat( + 27, + ), + economy: GenericStat( + 28, + ), + food: GenericStat( + 29, + ), + industry: GenericStat( + 30, + ), + science: GenericStat( + 31, + ), + trade: GenericStat( + 32, + ), + military: GenericStat( + 33, + ), + army: GenericStat( + 34, + ), + strength: GenericStat( + 35, + ), + fortification: GenericStat( + 36, + ), + threat: GenericStat( + 37, + ), + infrastructure: GenericStat( + 38, + ), + bureaucracy: GenericStat( + 39, + ), + transportation: GenericStat( + 40, + ), + sprawl: GenericStat( + 41, + ), + health: GenericStat( + 42, + ), + }, +) diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-3.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-3.snap new file mode 100644 index 0000000..81d4653 --- /dev/null +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-3.snap @@ -0,0 +1,68 @@ +--- +source: lib_efo/src/entity/test.rs +expression: "format!(\"{:#?}\", delta3)" +--- +Some( + OverallStats { + demographics: GenericStat( + 33, + ), + population: GenericStat( + 34, + ), + growth_rate: GenericStat( + 35, + ), + crime: GenericStat( + 36, + ), + happiness: GenericStat( + 37, + ), + economy: GenericStat( + 38, + ), + food: GenericStat( + 39, + ), + industry: GenericStat( + 40, + ), + science: GenericStat( + 41, + ), + trade: GenericStat( + 42, + ), + military: GenericStat( + 43, + ), + army: GenericStat( + 44, + ), + strength: GenericStat( + 45, + ), + fortification: GenericStat( + 46, + ), + threat: GenericStat( + 47, + ), + infrastructure: GenericStat( + 48, + ), + bureaucracy: GenericStat( + 49, + ), + transportation: GenericStat( + 50, + ), + sprawl: GenericStat( + 51, + ), + health: GenericStat( + 52, + ), + }, +) diff --git a/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-4.snap b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-4.snap new file mode 100644 index 0000000..7e98cf8 --- /dev/null +++ b/lib_efo/src/entity/snapshots/lib_efo__entity__test__snapshot_option_stats_delta-4.snap @@ -0,0 +1,5 @@ +--- +source: lib_efo/src/entity/test.rs +expression: "format!(\"{:#?}\", delta4)" +--- +None diff --git a/lib_efo/src/entity/test.rs b/lib_efo/src/entity/test.rs index a1a9258..22fc8bd 100644 --- a/lib_efo/src/entity/test.rs +++ b/lib_efo/src/entity/test.rs @@ -403,10 +403,25 @@ fn snapshot_entity_delta() { // Compute the delta let mut delta = e1.delta(&e2); let mut delta2 = e2.delta(&e2); + let mut delta3 = e2.delta(&e1); delta.id = Uuid::nil(); delta2.id = Uuid::nil(); - assert_snapshot!(format!("{:#?}", delta)); - assert_snapshot!(format!("{:#?}", delta2)); + delta3.id = Uuid::nil(); + assert_snapshot!(format!( + "{:#?}{}", + &delta, + delta.full_stats_to_table().unwrap() + )); + assert_snapshot!(format!( + "{:#?}{}", + delta2, + delta2.full_stats_to_table().unwrap() + )); + assert_snapshot!(format!( + "{:#?}{}", + delta3, + delta3.full_stats_to_table().unwrap() + )); } #[test] @@ -421,8 +436,14 @@ fn snapshot_option_stats_delta() { // `delta` is commutative for the purpose of the snapshot let delta = opt_a.delta(&opt_b); + let delta2 = None.delta(&opt_b); + let delta3 = opt_a.delta(&None); + let delta4 = None::.delta(&None); assert_snapshot!(format!("{:#?}", delta)); + assert_snapshot!(format!("{:#?}", delta2)); + assert_snapshot!(format!("{:#?}", delta3)); + assert_snapshot!(format!("{:#?}", delta4)); } #[test] @@ -507,3 +528,14 @@ fn snapshot_modify_effect_bounds() { assert_snapshot!(format!("{:#?}", e)); } + +#[test] +fn test_rng() { + Entity::create_rng(&EntityType::Character, &crate::utils::RngLevel::Zero).unwrap(); + Entity::create_rng(&EntityType::Player, &crate::utils::RngLevel::Low).unwrap(); + Entity::create_rng(&EntityType::Town, &crate::utils::RngLevel::Med).unwrap(); + Entity::create_rng(&EntityType::Monster, &crate::utils::RngLevel::High).unwrap(); + Entity::create_rng(&EntityType::Blocker, &crate::utils::RngLevel::Legendary).unwrap(); + Entity::create_rng(&EntityType::Event, &crate::utils::RngLevel::Mixed).unwrap(); + Entity::create_rng(&EntityType::Event, &crate::utils::RngLevel::Flawed).unwrap(); +} diff --git a/lib_efo/src/naming.rs b/lib_efo/src/naming.rs index 7275388..d2d2913 100644 --- a/lib_efo/src/naming.rs +++ b/lib_efo/src/naming.rs @@ -368,4 +368,21 @@ mod tests { println!("{values:#?}"); // panic!() } + #[test] + fn test_most_naming() { + let _ = NAMING.generate_character_name(); + let _ = NAMING.generate_town_name(); + let _ = NAMING.random_event_idea().expect("Couldn't generate event"); + let _ = NAMING.random_event_name(); + let _ = NAMING.generate_blocker_name(); + let _ = NAMING.generate_calamity_name(); + let _ = NAMING.generate_long_character_name(); + let _ = NAMING.generate_exotic_character_name(); + } + + #[test] + fn event_description() { + let event = NAMING.random_event_idea().expect("Generating event"); + let _ = event.oneline_display(); + } }