andy vs. clippy round 4 and some cleanup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
andy 2021-07-24 01:32:58 +00:00
parent 7a1a20db53
commit 3faca14883
4 changed files with 29 additions and 18 deletions

View File

@ -324,14 +324,13 @@ impl MapEnemy {
} }
pub fn has_rare_appearance(self) -> bool { pub fn has_rare_appearance(self) -> bool {
match self.monster { matches!(self.monster,
MonsterType::RagRappy | MonsterType::Hildebear | MonsterType::RagRappy | MonsterType::Hildebear |
MonsterType::PoisonLily | MonsterType::PofuillySlime | MonsterType::PoisonLily | MonsterType::PofuillySlime |
MonsterType::SandRappyCrater | MonsterType::ZuCrater | MonsterType::Dorphon | MonsterType::SandRappyCrater | MonsterType::ZuCrater | MonsterType::Dorphon |
MonsterType::SandRappyDesert | MonsterType::ZuDesert | MonsterType::MerissaA | MonsterType::SandRappyDesert | MonsterType::ZuDesert | MonsterType::MerissaA |
MonsterType::SaintMillion | MonsterType::Shambertin => true, MonsterType::SaintMillion | MonsterType::Shambertin
_ => false )
}
} }
/* /*

View File

@ -33,8 +33,7 @@ fn parse_enemy(episode: &Episode, map_area: &MapArea, raw_enemy: RawMapEnemy) ->
enemy enemy
.map_or(vec![None], |monster| { .map_or(vec![None], |monster| {
let mut monsters = Vec::new(); let mut monsters = vec![Some(monster)];
monsters.push(Some(monster));
match monster.monster { match monster.monster {
MonsterType::Monest => { MonsterType::Monest => {
@ -333,9 +332,9 @@ impl Maps {
} }
}) })
.collect(); .collect();
for i in 0..shiny.len() { for monster in &shiny {
if let Some(j) = rare_monsters.iter().position(|&x| x == 0xFFFF) { if let Some(j) = rare_monsters.iter().position(|&x| x == 0xFFFF) {
rare_monsters[j] = shiny[i].0 as u16; rare_monsters[j] = monster.0 as u16;
} else { } else {
break break
} }
@ -346,11 +345,18 @@ impl Maps {
pub fn roll_monster_appearance(&mut self, rare_monster_table: &RareMonsterAppearTable) { pub fn roll_monster_appearance(&mut self, rare_monster_table: &RareMonsterAppearTable) {
self.enemy_data = self.enemy_data self.enemy_data = self.enemy_data
.iter() .iter()
.map(|&x| if x.is_some() && x.unwrap().has_rare_appearance() { // .map(|&x| if x.is_some() && x.unwrap().has_rare_appearance() {
Some(x.unwrap().roll_appearance_for_mission(&rare_monster_table)) .map(|&x|
} else { if let Some(monster) = x {
x if monster.has_rare_appearance() {
}) Some(monster.roll_appearance_for_mission(rare_monster_table))
} else {
Some(monster)
}
} else {
x
}
)
.collect(); .collect();
} }
} }

View File

@ -72,8 +72,8 @@ pub fn add_to_room(_id: ClientId,
}) })
} }
pub fn build_rare_monster_list(rare_monster_vec: Vec<u16>) -> Result<RareMonsterList, ShipError> { pub fn build_rare_monster_list(rare_monster_vec: Vec<u16>) -> RareMonsterList {
Ok(RareMonsterList { RareMonsterList {
ids: rare_monster_vec.try_into().unwrap_or([0xFFFFu16; 16]), ids: rare_monster_vec.try_into().unwrap_or([0xFFFFu16; 16]),
}) }
} }

View File

@ -130,9 +130,15 @@ pub fn done_bursting(id: ClientId,
.flatten() .flatten()
); );
// // TODO: check how often `done_bursting` is called. ie: make sure it's only used when joining a room and not each time a player warps in a pipe
// if rare_monster_list.is_some() {
// let rare_monster_packet = SendShipPacket::RareMonsterList(builder::room::build_rare_monster_list(rare_monster_list.unwrap()).unwrap()); // TODO: don't double unwrap
// result = Box::new(result.chain(vec![(id, rare_monster_packet)])); // TODO: make sure we arent clobbering `result` here
// }
// TODO: check how often `done_bursting` is called. ie: make sure it's only used when joining a room and not each time a player warps in a pipe // TODO: check how often `done_bursting` is called. ie: make sure it's only used when joining a room and not each time a player warps in a pipe
if rare_monster_list.is_some() { if let Some(rare_list) = rare_monster_list {
let rare_monster_packet = SendShipPacket::RareMonsterList(builder::room::build_rare_monster_list(rare_monster_list.unwrap()).unwrap()); // TODO: don't double unwrap let rare_monster_packet = SendShipPacket::RareMonsterList(builder::room::build_rare_monster_list(rare_list));
result = Box::new(result.chain(vec![(id, rare_monster_packet)])); // TODO: make sure we arent clobbering `result` here result = Box::new(result.chain(vec![(id, rare_monster_packet)])); // TODO: make sure we arent clobbering `result` here
} }