Skip to content

Commit 50a99e1

Browse files
committed
Complete changes for #13.
Update version number. RUSTFMT --ALL.
1 parent de8536d commit 50a99e1

File tree

17 files changed

+160
-93
lines changed

17 files changed

+160
-93
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fantasy-tavern-maker-tui"
3-
version = "0.13.1-191"
3+
version = "0.13.2-195"
44
edition = "2024"
55

66
[dev-dependencies]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
## Current Version
77

8-
0.13.1-191
8+
0.13.2-195
99

1010
[![forthebadge made-with-rust](http://ForTheBadge.com/images/badges/made-with-rust.svg)](https://www.rust-lang.org/)
1111
[![made-with-Markdown](https://img.shields.io/badge/Made%20with-Markdown-1f425f.svg)](http://commonmark.org)

src/dice_bag/tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
mod suite {
44
use crate::dice_bag::tower::{DiceResult, RollDice};
5-
use tracing::{Level, event};
65
use pretty_assertions::{assert_eq, assert_ne};
6+
use tracing::{Level, event};
77

88
#[test]
99
fn does_flip_coin() {
1010
let request: &str = "1d2";
1111
let valid_scope = (1..=2);
1212

13-
for _ in (0..valid_scope.len() as i16*2) {
13+
for _ in (0..valid_scope.len() as i16 * 2) {
1414
let resulting_roll = <DiceResult as RollDice>::from_string(request);
1515
let roll_value = resulting_roll.get_total();
1616
event!(Level::INFO, "roll_value[{}]", roll_value);
@@ -23,7 +23,7 @@ mod suite {
2323
let request: &str = "1d4";
2424
let valid_scope = (1..=4);
2525

26-
for _ in (0..valid_scope.len() as i16*2) {
26+
for _ in (0..valid_scope.len() as i16 * 2) {
2727
let resulting_roll = <DiceResult as RollDice>::from_string(request);
2828
let roll_value = resulting_roll.get_total();
2929
event!(Level::INFO, "roll_value[{}]", roll_value);
@@ -36,7 +36,7 @@ mod suite {
3636
let request: &str = "4d8";
3737
let valid_scope = (4..=32);
3838

39-
for _ in (0..valid_scope.len() as i16*2) {
39+
for _ in (0..valid_scope.len() as i16 * 2) {
4040
let resulting_roll = <DiceResult as RollDice>::from_string(request);
4141
let roll_value = resulting_roll.get_total();
4242
event!(Level::INFO, "roll_value[{}]", roll_value);
@@ -49,25 +49,25 @@ mod suite {
4949
let request: &str = "1d6+3";
5050
let valid_scope = (4..=9);
5151

52-
for _ in (0..valid_scope.len() as i16*2) {
52+
for _ in (0..valid_scope.len() as i16 * 2) {
5353
let resulting_roll = <DiceResult as RollDice>::from_string(request);
5454
let roll_value = resulting_roll.get_total();
5555
event!(Level::INFO, "roll_value[{}]", roll_value);
5656
assert!(valid_scope.contains(&roll_value));
57-
}
57+
}
5858
}
5959

6060
#[test]
6161
fn rolls_respect_neg_modifiers() {
6262
let request: &str = "1d6-3";
6363
let valid_scope = (-2..=3);
6464

65-
for _ in (0..valid_scope.len() as i16*2) {
65+
for _ in (0..valid_scope.len() as i16 * 2) {
6666
let resulting_roll = <DiceResult as RollDice>::from_string(request);
6767
let roll_value = resulting_roll.get_total();
6868
event!(Level::INFO, "roll_value[{}]", roll_value);
6969
assert!(valid_scope.contains(&roll_value));
70-
}
70+
}
7171
}
7272

7373
#[test]

src/fn_make_pbhouse.rs

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@ use cursive::views::LinearLayout;
77
use cursive::views::TextView;
88

99
// --- my stuff ---
10-
use dice_bag::tower::DiceResult;
11-
use dice_bag::tower::RollDice;
12-
use npc::build::NpcTypeCode;
13-
use npc::build::Profile as npc_Profile;
14-
use tavern::enums::list::EstablishmentQualityLevel;
15-
use tavern::enums::list::SizeList;
16-
use text_postproc::tpp::l1_heading;
17-
18-
use crate::dice_bag;
10+
use crate::dice_bag::tower::{DiceResult, RollDice};
1911
use crate::fn_save_pbhouse_to_file::save_pbhouse_to_file;
2012
use crate::fn_view_npc_block::view_npc_block;
2113
use crate::npc;
2214
use crate::tavern;
2315
use crate::tavern::structs::list::App;
2416
use crate::tavern::structs::list::PBHouse;
2517
use crate::text_postproc;
18+
use npc::build::NpcTypeCode;
19+
use npc::build::Profile as npc_Profile;
20+
use tavern::enums::list::EstablishmentQualityLevel;
21+
use tavern::enums::list::SizeList;
22+
use text_postproc::tpp::l1_heading;
2623

2724
pub fn make_pbhouse(s: &mut Cursive, app: App) {
2825
let pbh = PBHouse::new();
@@ -84,7 +81,6 @@ pub fn make_pbhouse(s: &mut Cursive, app: App) {
8481
let mut npc_bouncer: npc_Profile = npc_Profile::new();
8582
npc_bouncer.task_description = "Bouncer".into();
8683
npc_bouncer.npc_type = NpcTypeCode::Staff;
87-
8884
}
8985
}
9086
}
@@ -128,7 +124,6 @@ pub fn make_pbhouse(s: &mut Cursive, app: App) {
128124

129125
let npc_notable_patrons_count: i16 =
130126
<DiceResult as RollDice>::from_string(&roll_string).get_total();
131-
//println!("npc_notable_patrons_count [{npc_notable_patrons_count}]");
132127

133128
for _c in 1..npc_notable_patrons_count {
134129
let mut npc_patron: npc_Profile = npc_Profile::new();
@@ -141,6 +136,39 @@ pub fn make_pbhouse(s: &mut Cursive, app: App) {
141136
npc_notable_patrons_list.push(npc_patron);
142137
}
143138

139+
if pbh.establishment_quality.level == EstablishmentQualityLevel::Wealthy {
140+
for np in &mut npc_notable_patrons_list {
141+
if np.task_description.contains("Farmer") || np.task_description.contains("Commonfolk")
142+
{
143+
np.task_description = match <DiceResult as RollDice>::from_string("1d4").get_total()
144+
{
145+
1 => "Merchant accompanied by [1d4+1] guards".into(),
146+
2 => "Entertainer accompanied by [1d4+1] carousers".into(),
147+
3 => "Courtesan accompanied by [1d4] entourage".into(),
148+
_ => "Farmer or Fisher accompanied by [1d4-1] workers".into(),
149+
}
150+
}
151+
}
152+
};
153+
154+
if pbh.establishment_quality.level == EstablishmentQualityLevel::Aristocratic {
155+
for np in &mut npc_notable_patrons_list {
156+
if np.task_description.contains("Farmer") || np.task_description.contains("Commonfolk")
157+
{
158+
np.task_description = match <DiceResult as RollDice>::from_string("1d4").get_total()
159+
{
160+
1 => "Merchant accompanied by [1d4+1] guards".into(),
161+
2 => "Entertainer accompanied by [1d4+1] carousers".into(),
162+
3 => "Courtesan accompanied by [1d4] entourage".into(),
163+
_ => {
164+
"Noble accompanied by [1d4+1] entourage and [1d4+] henchmen ([1d4+1] level)"
165+
.into()
166+
}
167+
}
168+
}
169+
}
170+
};
171+
144172
//todo!("redlight_services ?? \"specific\" NPCs such as extra bouncer, wealthy gladiator, cardshark, healer ??")
145173
use crate::npc::build::Profile;
146174
let mut npc_select = cursive::views::SelectView::new();
@@ -177,10 +205,10 @@ pub fn make_pbhouse(s: &mut Cursive, app: App) {
177205
LinearLayout::horizontal()
178206
.child(
179207
Dialog::text(gm_text)
180-
.title("GM Notes")
181-
.fixed_width(32)
182-
.scrollable()
183-
.scroll_y(true),
208+
.title("GM Notes")
209+
.fixed_width(32)
210+
.scrollable()
211+
.scroll_y(true),
184212
)
185213
.child(
186214
Dialog::text(player_text)

src/fn_view_npc_block.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::{npc::build::Profile, text_postproc::tpp::l2_heading};
21
use crate::npc::build::NpcTypeCode;
2+
use crate::{npc::build::Profile, text_postproc::tpp::l2_heading};
33

44
pub fn view_npc_block(npc_data: &Profile) -> String {
55
let npc_type = &npc_data.npc_type;
@@ -19,7 +19,7 @@ pub fn view_npc_block(npc_data: &Profile) -> String {
1919
let mut text_block = l2_heading(format!("{npc_type} {task}"));
2020

2121
let ects = &npc_data.encounter_slots;
22-
22+
2323
let encounter_text: String = match npc_data.npc_type {
2424
NpcTypeCode::StoryCharacter | NpcTypeCode::Patron => {
2525
let temp_text: String = format!(
@@ -29,21 +29,25 @@ pub fn view_npc_block(npc_data: &Profile) -> String {
2929
ects[2].name.to_string(),
3030
);
3131
temp_text.to_string()
32-
},
32+
}
3333
NpcTypeCode::Staff => {
3434
let mut temp_text: String = "".into();
3535
for ts in ects {
36-
temp_text = temp_text + &format!(" {} 8+ |", ts.name.to_string());
36+
temp_text = temp_text + &format!(" {} 8+ |", ts.name.to_string());
3737
}
3838
temp_text.trim_end_matches("|").to_string()
39-
},
39+
}
4040
};
41-
42-
text_block += &format!("\n\n _[chance of being currently present (2d6): {:?}]_", encounter_text);
41+
42+
text_block += &format!(
43+
"\n\n _[chance of being currently present (2d6): {:?}]_",
44+
encounter_text
45+
);
4346
text_block += &format!(
4447
"\n\n {species:?} with {eye_color} eyes and {hair_color} hair in {hair_style} style."
4548
);
46-
text_block += &format!("\n They are {height_desc} with a {build_desc}, and present as {gender}.");
49+
text_block +=
50+
&format!("\n They are {height_desc} with a {build_desc}, and present as {gender}.");
4751

4852
text_block += "\n\n Quirks:";
4953
if quirk_emotional.is_empty() && quirk_physical.is_empty() {

src/main.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ use tavern::traits::list::AppFn;
2323
fn main() {
2424
let mut app: App = App::new();
2525
app.name = "fantasy-tavern-maker-tui".into();
26-
app.version_major = 0; //0.13.1-191
26+
app.version_major = 0; //0.13.2-195
2727
app.version_minor = 13;
28-
app.version_fix = 01;
29-
app.version_build = 191;
28+
app.version_fix = 02;
29+
app.version_build = 195;
3030

3131
let mut siv = cursive::default();
3232

@@ -38,7 +38,9 @@ fn main() {
3838
})
3939
.button("Quit", |s| s.quit()),
4040
);
41-
siv.add_global_callback(Key::Esc , |s|{ s.pop_layer(); });
41+
siv.add_global_callback(Key::Esc, |s| {
42+
s.pop_layer();
43+
});
4244

4345
siv.run()
4446
}

src/narrative_time_manager/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ pub mod ntm {
77
use rand::Rng;
88
use rand::distr::{Distribution, StandardUniform};
99

10-
#[derive(Clone, Copy, PartialEq)]
11-
#[derive(Debug)]
12-
pub enum Hour {
10+
#[derive(Clone, Copy, PartialEq, Debug)]
11+
pub enum Hour {
1312
H00,
1413
H01,
1514
H02,

src/narrative_time_manager/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ mod suite {
44
narrative_time_manager::ntm::{self, SlotNames},
55
npc::build::Profile,
66
};
7-
use std::mem;
87
use pretty_assertions::{assert_eq, assert_ne};
8+
use std::mem;
99

1010
#[test]
1111
fn number_of_timeslots() {

src/npc/impls.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ impl Profile {
5858
let resulting_roll = <DiceResult as RollDice>::from_string(request);
5959

6060
let slot_list: Vec<i8> = match resulting_roll.get_total() {
61-
1 => [1, 2, 3, 4, 5].to_vec(),
62-
2 => [4, 5, 6, 7, 8].to_vec(),
63-
3 => [7, 8, 9, 10, 11].to_vec(),
64-
4 => [10, 11, 12, 13, 14].to_vec(),
65-
5 => [13, 14, 15, 16, 17].to_vec(),
66-
6 => [3, 4, 5, 8, 9].to_vec(),
67-
_ => [3, 4, 5, 6, 7].to_vec(),
61+
1 => [1, 2, 3, 4, 5].to_vec(),
62+
2 => [4, 5, 6, 7, 8].to_vec(),
63+
3 => [7, 8, 9, 10, 11].to_vec(),
64+
4 => [10, 11, 12, 13, 14].to_vec(),
65+
5 => [13, 14, 15, 16, 17].to_vec(),
66+
6 => [3, 4, 5, 8, 9].to_vec(),
67+
_ => [3, 4, 5, 6, 7].to_vec(),
6868
};
6969

7070
for this_slot in slot_list.iter() {

src/npc/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ mod suite {
1212
},
1313
tavern::structs::list::App,
1414
};
15-
use tracing::{Level, event};
1615
use pretty_assertions::{assert_eq, assert_ne};
16+
use tracing::{Level, event};
1717

1818
#[test]
1919
fn profile_new() {

src/tavern/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub mod list {
109109
OilLamps,
110110
}
111111

112-
#[derive(Debug, Display, Clone, Copy)]
112+
#[derive(Debug, Display, Clone, Copy, PartialEq)]
113113
pub enum EstablishmentQualityLevel {
114114
Aristocratic,
115115
Comfortable,

src/tavern/functions.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use inflector::string::singularize::to_singular;
2-
use rand::{random_range, SeedableRng};
32
use rand::distr::Distribution;
43
use rand::distr::weighted::WeightedIndex;
54
use rand::seq::IndexedRandom;
5+
use rand::{SeedableRng, random_range};
66
use rand_chacha::ChaCha20Rng;
77
use std::cmp::*;
88
use strum::IntoEnumIterator;
@@ -19,7 +19,9 @@ use super::enums::list::{
1919
HouseDishWhatCooked, HouseDishWhatSide, LightingAdjectives, LightingSources, LightingVerb,
2020
MoodData, PostedSignLocation, PostedSignMessage, SecondSmell, SizeList,
2121
};
22-
use super::structs::list::{EstablishmentQuality, HouseDish, HouseDrink, PBHouseSize, RedlightService};
22+
use super::structs::list::{
23+
EstablishmentQuality, HouseDish, HouseDrink, PBHouseSize, RedlightService,
24+
};
2325

2426
// ---
2527
pub fn get_name() -> String {
@@ -397,13 +399,13 @@ pub fn get_establishment_reputation() -> String {
397399
result.into()
398400
}
399401

400-
pub fn get_red_light_services_list(size_code: SizeList ) -> Option<Vec<RedlightService>> {
402+
pub fn get_red_light_services_list(size_code: SizeList) -> Option<Vec<RedlightService>> {
401403
if tower::DiceResult::from_string("flip coin").get_total() == 2 {
402404
return None;
403405
}
404-
let mut red_light_services_list:Vec<RedlightService > = vec![];
405-
let max_range:i16 = (RSLCode::VARIANT_COUNT as f64 * 2.5) as i16;
406-
let mut current_roll_chance:i16 = (RSLCode::VARIANT_COUNT as f64 * 2.0) as i16;
406+
let mut red_light_services_list: Vec<RedlightService> = vec![];
407+
let max_range: i16 = (RSLCode::VARIANT_COUNT as f64 * 2.5) as i16;
408+
let mut current_roll_chance: i16 = (RSLCode::VARIANT_COUNT as f64 * 2.0) as i16;
407409

408410
let roll_chance_delta = match size_code {
409411
SizeList::Massive => 1,
@@ -415,10 +417,13 @@ pub fn get_red_light_services_list(size_code: SizeList ) -> Option<Vec<Redlight
415417

416418
RSLCode::iter().for_each(|rsl_code| {
417419
let test_roll = random_range(1..=max_range);
418-
let mut rl_service: RedlightService = RedlightService { service: RSLCode::None, dc:0 };
420+
let mut rl_service: RedlightService = RedlightService {
421+
service: RSLCode::None,
422+
dc: 0,
423+
};
419424

420425
match rsl_code {
421-
RSLCode::None => {},
426+
RSLCode::None => {}
422427
_ => {
423428
if test_roll <= current_roll_chance {
424429
current_roll_chance -= roll_chance_delta;

0 commit comments

Comments
 (0)