Added blacksmith

This commit is contained in:
Joshua Barretto 2022-08-14 16:18:47 +01:00
parent afd9ea5462
commit e08f7d4fa9
3 changed files with 13 additions and 3 deletions

View File

@ -106,6 +106,8 @@ pub enum Profession {
Guard,
#[serde(rename = "4")]
Adventurer(u32),
#[serde(rename = "5")]
Blacksmith,
}
impl Profession {
@ -116,6 +118,7 @@ impl Profession {
Self::Merchant => "Merchant".to_string(),
Self::Guard => "Guard".to_string(),
Self::Adventurer(_) => "Adventurer".to_string(),
Self::Blacksmith => "Blacksmith".to_string(),
}
}
}

View File

@ -46,11 +46,12 @@ impl Data {
wpos2d.map(|e| e as f32 + 0.5)
.with_z(world.sim().get_alt_approx(wpos2d).unwrap_or(0.0))
};
for _ in 0..10 {
for _ in 0..20 {
this.npcs.create(Npc::new(rng.gen(), rand_wpos(&mut rng)).with_home(site_id).with_profession(match rng.gen_range(0..10) {
0 => Profession::Hunter,
1..=4 => Profession::Farmer,
1 => Profession::Blacksmith,
2..=4 => Profession::Farmer,
_ => Profession::Guard,
}));
}

View File

@ -105,6 +105,12 @@ impl<'a> System<'a> for Sys {
economy.as_ref(),
|good| matches!(good, Good::Food),
),
Profession::Blacksmith => trader_loadout(
loadout_builder
.with_asset_expect("common.loadout.village.blacksmith", &mut rng),
economy.as_ref(),
|good| matches!(good, Good::Tools | Good::Armor),
),
Profession::Hunter => loadout_builder
.with_asset_expect("common.loadout.village.villager", &mut rng),
@ -114,7 +120,7 @@ impl<'a> System<'a> for Sys {
let can_speak = npc.profession.is_some(); // TODO: not this
let trade_for_site = if let Some(Profession::Merchant | Profession::Farmer) = npc.profession {
let trade_for_site = if let Some(Profession::Merchant | Profession::Farmer | Profession::Blacksmith) = npc.profession {
npc.home.and_then(|home| Some(data.sites.get(home)?.world_site?.id()))
} else {
None