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-16 15:59:33 +00:00
|
|
|
use parking_lot::RwLock;
|
2022-06-11 15:22:46 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2022-06-03 14:35:18 +00:00
|
|
|
#[derive(Debug)]
|
2022-06-16 15:59:33 +00:00
|
|
|
pub struct ChoiceQueue<'battle, 'library> {
|
|
|
|
queue: Vec<Arc<RwLock<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> {
|
|
|
|
pub fn new(queue: Vec<Arc<RwLock<TurnChoice<'battle, 'library>>>>) -> Self {
|
2022-06-11 15:22:46 +00:00
|
|
|
Self { queue, current: 0 }
|
|
|
|
}
|
|
|
|
|
2022-06-16 15:59:33 +00:00
|
|
|
pub fn dequeue<'b>(&'b mut self) -> &'b Arc<RwLock<TurnChoice<'battle, 'library>>> {
|
2022-06-11 15:22:46 +00:00
|
|
|
let c = &self.queue[self.current];
|
|
|
|
self.current += 1;
|
|
|
|
c
|
|
|
|
}
|
|
|
|
|
2022-06-16 15:59:33 +00:00
|
|
|
pub fn peek(&mut self) -> &'battle Arc<RwLock<TurnChoice>> {
|
2022-06-11 15:22:46 +00:00
|
|
|
&self.queue[self.current]
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
pub(crate) fn get_queue(&self) -> &Vec<Arc<RwLock<TurnChoice<'battle, 'library>>>> {
|
|
|
|
&self.queue
|
|
|
|
}
|
2022-06-11 15:22:46 +00:00
|
|
|
}
|