diff --git a/src/bot_worker.rs b/src/bot_worker.rs index 6a42915..efdad78 100644 --- a/src/bot_worker.rs +++ b/src/bot_worker.rs @@ -1,8 +1,9 @@ -use strafesnet_snf::bot::BotInstructions; +use strafesnet_snf::bot::BotDebug; pub enum Instruction{ //TODO: pass map id Create, + Delete, Push{ ins:strafesnet_common::instruction::TimedInstruction, }, @@ -13,7 +14,7 @@ pub enum Instruction{ //push pushes an instruction to the file pub struct Worker{ - file:Option, + file:Option, } pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a,Instruction>{ @@ -23,14 +24,18 @@ pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a, crate::worker::QNWorker::new(scope,move|instruction|{ match instruction{ Instruction::Create=>{ - worker.file=Some(BotIntructions::new("hi.snfb")) + worker.file=Some(BotDebug::new().unwrap()) }, + Instruction::Delete=>{ + match worker.file.take(){ + Some(file)=>file.delete().unwrap(), + None=>println!("no file created!"), + } + } Instruction::Push{ins}=>{ match &worker.file{ - Some(file)=>file.push(ins), - None=>{ - println!("no file created!"), - } + Some(file)=>file.push(ins).unwrap(), + None=>println!("no file created!"), } }, }