Loads more work on battling, initial stretch to run a turn done.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-06-16 17:59:33 +02:00
parent a33369afcc
commit ff541b0696
50 changed files with 105871 additions and 497 deletions

View File

@@ -1,24 +1,26 @@
use crate::dynamic_data::choices::TurnChoice;
use crate::dynamic_data::models::pokemon::Pokemon;
use parking_lot::RwLock;
use std::sync::Arc;
#[derive(Debug)]
pub struct ChoiceQueue {
queue: Vec<Arc<ChoiceQueue>>,
pub struct ChoiceQueue<'battle, 'library> {
queue: Vec<Arc<RwLock<TurnChoice<'battle, 'library>>>>,
current: usize,
}
impl ChoiceQueue {
pub fn new(queue: Vec<Arc<ChoiceQueue>>) -> Self {
impl<'battle, 'library> ChoiceQueue<'battle, 'library> {
pub fn new(queue: Vec<Arc<RwLock<TurnChoice<'battle, 'library>>>>) -> Self {
Self { queue, current: 0 }
}
pub fn dequeue(&mut self) -> &Arc<ChoiceQueue> {
pub fn dequeue<'b>(&'b mut self) -> &'b Arc<RwLock<TurnChoice<'battle, 'library>>> {
let c = &self.queue[self.current];
self.current += 1;
c
}
pub fn peek(&mut self) -> &Arc<ChoiceQueue> {
pub fn peek(&mut self) -> &'battle Arc<RwLock<TurnChoice>> {
&self.queue[self.current]
}
@@ -29,4 +31,8 @@ impl ChoiceQueue {
pub fn move_pokemon_choice_next(&mut self, _pokemon: &Pokemon) {
todo!()
}
pub(crate) fn get_queue(&self) -> &Vec<Arc<RwLock<TurnChoice<'battle, 'library>>>> {
&self.queue
}
}