diff --git a/server/src/api.rs b/server/src/api.rs index 7efc52f..d142709 100644 --- a/server/src/api.rs +++ b/server/src/api.rs @@ -49,7 +49,7 @@ pub async fn api_process // Perform this code on a GET request .map(|state: Arc>, tx_handle: Sender<(bool,usize)>| { - info!("GET: {:?}", state); + debug!("GET: {:?}", state); let reply = state.as_ref(); let _ = tx_handle.send((true,0)); warp::reply::json(&reply) // Send the reply data (data_to_send formatted as JSON) diff --git a/server/src/main.rs b/server/src/main.rs index 3939e10..7313434 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -28,6 +28,7 @@ mod character; mod config; mod api; +#[warn(clippy::all, clippy::pedantic)] #[tokio::main] async fn main() { @@ -42,7 +43,7 @@ async fn main() error!("No filename specified"); std::process::exit(5); }); - let file = File::open(format!("stories/{}",file_name)) + let file = File::open(format!("../stories/{}",file_name)) .unwrap_or_else (|err| { error!("Failed to open file: {}", err); @@ -59,7 +60,7 @@ async fn main() { Ok(result) => { - info!("{:?}", result); + debug!("{:?}", result); result }, Err(error) => @@ -72,8 +73,8 @@ async fn main() let data_to_send = Arc::new(Mutex::new(api::DataToSend { action_type: "begin".to_string(), - content: "".to_string(), - character: "".to_string(), + content: String::new(), + character: String::new(), choices: vec![], })); diff --git a/server/src/parsing.rs b/server/src/parsing.rs index 682b884..3acfa8f 100644 --- a/server/src/parsing.rs +++ b/server/src/parsing.rs @@ -25,12 +25,14 @@ pub async fn token_parse( rx: &Receiver<(bool,usize)>, ) -> Result<(),String> { + info!("DSL parsing begun"); let mut index: usize = 0; if rx.recv().is_err() { warn!("Some issue with api"); // TOD eh? }; + info!("Client has connected"); // Run an infinite loop 'parse_loop: loop { @@ -43,7 +45,7 @@ pub async fn token_parse( if token.starts_with('@') { let character_name: String = token.chars().skip(1).collect(); - info!("Doing something with a character: {}", character_name); + debug!("Doing something with a character: {}", character_name); // The index is incremented to after the character's instructions index = match character_parse(index+1, tokens, character_name, &characters, &data_to_send).await { @@ -59,7 +61,7 @@ pub async fn token_parse( "end" => { info!("END command, exiting"); - return Ok(()) // quit + return Ok(()) // quit successfully }, "choice" => { @@ -69,14 +71,28 @@ pub async fn token_parse( Err(error) => return Err(error), }; if rx.recv().is_err() { warn!("Error sending choices to client"); }; - let (_, choice) = rx.recv().unwrap(); // TODO eh + let (_, choice) = match rx.recv() + { + Ok((_,choice)) => (None::, choice), + Err(err) => + { + warn!("Error receiving choice from client, defaulting to choice 0 {}", err); + (None::, 0) + } + }; index = jump_points[choice]; + info!("CHOICE command with {} choices", jump_points.len()); debug!("{:?} {} {}",jump_points, choice, index); continue 'parse_loop }, "or" => { - index += strings::closing_char(&tokens[index..], '{','}').unwrap(); // TODO eh + info!("OR command, jumping over"); + index += match strings::closing_char(&tokens[index..], '{','}') // TODO eh + { + Ok(index) => index, + Err(_) => return Err(String::from("Unable to find closing brace to OR command")), + }; continue }, "}" => diff --git a/server/stories/characters.json b/server/stories/characters.json deleted file mode 100644 index a5ec8d4..0000000 --- a/server/stories/characters.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "tim": { - "name": "Timothy Sharpshooter", - "gender": "", - "skin_color": "", - "eye_color": "", - "pronoun_subject": "", - "pronoun_object": "", - "pronoun_deppos": "", - "pronoun_indpos": "", - "pronoun_reflex": "", - "animation": "", - "head": "", - "hair": "", - "torso": "", - "arm": "", - "leg": "", - "hair_color": "", - "top_clothing": "", - "bottom_clothing": "", - "shoes": "" - } -} diff --git a/server/stories/no-characters.zip b/server/stories/no-characters.zip deleted file mode 100644 index dd9ff21..0000000 Binary files a/server/stories/no-characters.zip and /dev/null differ diff --git a/server/stories/no-story.zip b/server/stories/no-story.zip deleted file mode 100644 index 131cadc..0000000 Binary files a/server/stories/no-story.zip and /dev/null differ diff --git a/server/stories/nothing.zip b/server/stories/nothing.zip deleted file mode 100644 index 6703614..0000000 Binary files a/server/stories/nothing.zip and /dev/null differ diff --git a/server/stories/story.ha b/server/stories/story.ha deleted file mode 100644 index a8799fb..0000000 --- a/server/stories/story.ha +++ /dev/null @@ -1,8 +0,0 @@ -@tim says "hello world, it's a good day" -choice "choice numero uno" { - @tim says "super sad" -} -or "choice numero duo" { - @tim says "super unsad" -} -END diff --git a/server/stories/test.zip b/server/stories/test.zip deleted file mode 100644 index 3575183..0000000 Binary files a/server/stories/test.zip and /dev/null differ