make ChoiceQueue::move_pokemon_choice_next return a bool for success
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-08-28 15:50:39 +02:00
parent 4c06dc17e2
commit f9761f61da
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 4 additions and 3 deletions

View File

@ -50,7 +50,7 @@ impl ChoiceQueue {
} }
/// This moves the choice of a specific Pokemon up to the next choice to be executed. /// This moves the choice of a specific Pokemon up to the next choice to be executed.
pub fn move_pokemon_choice_next(&mut self, pokemon: &Pokemon) { pub fn move_pokemon_choice_next(&mut self, pokemon: &Pokemon) -> bool {
let mut desired_index = None; let mut desired_index = None;
// Find the index for the choice we want to move up. // Find the index for the choice we want to move up.
for index in self.current..self.queue.len() { for index in self.current..self.queue.len() {
@ -63,12 +63,12 @@ impl ChoiceQueue {
} }
// If we couldn't find a choice, we can't execute, return. // If we couldn't find a choice, we can't execute, return.
if desired_index.is_none() { if desired_index.is_none() {
return; return false;
} }
let desired_index = desired_index.unwrap(); let desired_index = desired_index.unwrap();
// If the choice we want to move up is already the next choice, just return. // If the choice we want to move up is already the next choice, just return.
if desired_index == self.current { if desired_index == self.current {
return; return true;
} }
// Take the choice we want to move forward out of it's place. // Take the choice we want to move forward out of it's place.
@ -80,6 +80,7 @@ impl ChoiceQueue {
} }
// Place the choice that needs to be next in the next to be executed position. // Place the choice that needs to be next in the next to be executed position.
let _ = self.queue[self.current].insert(choice); let _ = self.queue[self.current].insert(choice);
true
} }
/// Internal helper function to be easily able to iterate over the yet to be executed choices. /// Internal helper function to be easily able to iterate over the yet to be executed choices.