|
|
@ -87,10 +87,9 @@ impl RareMonsterAppearTable { |
|
|
|
|
|
|
|
let appear_rates: HashMap<MonsterType, f32> = cfg
|
|
|
|
.into_iter()
|
|
|
|
.map(|(monster, rate)| {
|
|
|
|
let monster: MonsterType = monster.parse().unwrap(); // TODO: don't unwrap!
|
|
|
|
let appear_rate = rate;
|
|
|
|
(monster, appear_rate)
|
|
|
|
.filter_map(|(monster, rate)| {
|
|
|
|
let monster: MonsterType = monster.parse().ok()?;
|
|
|
|
Some((monster, rate))
|
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
|
|
|
@ -99,7 +98,7 @@ impl RareMonsterAppearTable { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn roll_appearance(&self, monster: &MonsterType) -> bool {
|
|
|
|
pub fn roll_is_rare(&self, monster: &MonsterType) -> bool {
|
|
|
|
if rand_chacha::ChaChaRng::from_entropy().gen::<f32>() < *self.appear_rate.get(monster).unwrap_or(&0.0f32) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
@ -324,7 +323,7 @@ impl MapEnemy { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_rare_appearance(self) -> bool {
|
|
|
|
pub fn can_be_rare(&self) -> bool {
|
|
|
|
matches!(self.monster,
|
|
|
|
MonsterType::RagRappy | MonsterType::Hildebear |
|
|
|
|
MonsterType::PoisonLily | MonsterType::PofuillySlime |
|
|
|
@ -339,10 +338,10 @@ impl MapEnemy { |
|
|
|
guaranteed rare monsters don't count towards the limit
|
|
|
|
*/
|
|
|
|
#[must_use]
|
|
|
|
pub fn set_rare_appearance(self) -> MapEnemy {
|
|
|
|
pub fn into_rare(self) -> MapEnemy {
|
|
|
|
match (self.monster, self.map_area.to_episode()) {
|
|
|
|
(MonsterType::RagRappy, Episode::One) => {MapEnemy {monster: MonsterType::AlRappy, shiny:true, ..self}},
|
|
|
|
(MonsterType::RagRappy, Episode::Two) => {MapEnemy {monster: MonsterType::EventRappy, shiny:true, ..self}},
|
|
|
|
(MonsterType::RagRappy, Episode::Two) => {MapEnemy {monster: MonsterType::LoveRappy, shiny:true, ..self}},
|
|
|
|
(MonsterType::Hildebear, _) => {MapEnemy {monster: MonsterType::Hildeblue, shiny:true, ..self}},
|
|
|
|
(MonsterType::PoisonLily, _) => {MapEnemy {monster: MonsterType::NarLily, shiny:true, ..self}},
|
|
|
|
(MonsterType::PofuillySlime, _) => {MapEnemy {monster: MonsterType::PouillySlime, shiny:true, ..self}},
|
|
|
@ -357,14 +356,5 @@ impl MapEnemy { |
|
|
|
_ => {self},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// in theory this should only be called on monsters we know can have rare types
|
|
|
|
#[must_use]
|
|
|
|
pub fn roll_appearance_for_mission(self, rare_monster_table: &RareMonsterAppearTable) -> MapEnemy {
|
|
|
|
if rare_monster_table.roll_appearance(&self.monster) {
|
|
|
|
return self.set_rare_appearance()
|
|
|
|
}
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|