2022-06-16 15:59:33 +00:00
|
|
|
use crate::dynamic_data::choices::TurnChoice;
|
2022-06-11 15:22:46 +00:00
|
|
|
use crate::dynamic_data::models::pokemon::Pokemon;
|
|
|
|
|
2022-06-03 14:35:18 +00:00
|
|
|
#[derive(Debug)]
|
2022-06-16 15:59:33 +00:00
|
|
|
pub struct ChoiceQueue<'battle, 'library> {
|
2022-06-18 08:41:42 +00:00
|
|
|
queue: Vec<Option<TurnChoice<'battle, 'library>>>,
|
2022-06-11 15:22:46 +00:00
|
|
|
current: usize,
|
|
|
|
}
|
|
|
|
|
2022-06-16 15:59:33 +00:00
|
|
|
impl<'battle, 'library> ChoiceQueue<'battle, 'library> {
|
2022-06-18 08:41:42 +00:00
|
|
|
pub fn new(queue: Vec<Option<TurnChoice<'battle, 'library>>>) -> Self {
|
2022-06-11 15:22:46 +00:00
|
|
|
Self { queue, current: 0 }
|
|
|
|
}
|
|
|
|
|
2022-06-18 08:41:42 +00:00
|
|
|
pub fn dequeue<'b>(&'b mut self) -> TurnChoice<'battle, 'library> {
|
|
|
|
let c = self.queue[self.current].take();
|
2022-06-11 15:22:46 +00:00
|
|
|
self.current += 1;
|
2022-06-18 08:41:42 +00:00
|
|
|
c.unwrap()
|
2022-06-11 15:22:46 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 07:49:17 +00:00
|
|
|
pub fn peek(&mut self) -> &'battle TurnChoice {
|
2022-06-18 13:52:39 +00:00
|
|
|
self.queue[self.current].as_ref().unwrap()
|
2022-06-11 15:22:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_next(&self) -> bool {
|
|
|
|
self.current < self.queue.len()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn move_pokemon_choice_next(&mut self, _pokemon: &Pokemon) {
|
|
|
|
todo!()
|
|
|
|
}
|
2022-06-16 15:59:33 +00:00
|
|
|
|
2022-06-18 08:41:42 +00:00
|
|
|
pub(crate) fn get_queue(&self) -> &[Option<TurnChoice<'battle, 'library>>] {
|
|
|
|
&self.queue[self.current..self.queue.len()]
|
2022-06-16 15:59:33 +00:00
|
|
|
}
|
2022-06-11 15:22:46 +00:00
|
|
|
}
|