version & fixed some clippy linting
This commit is contained in:
BIN
Binary file not shown.
Generated
+1
-1
@@ -457,7 +457,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "happening-server"
|
||||
version = "0.1.0"
|
||||
version = "0.0.2"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"log",
|
||||
|
||||
+8
-2
@@ -1,7 +1,13 @@
|
||||
[package]
|
||||
name = "happening-server"
|
||||
version = "0.1.0"
|
||||
version = "0.0.2"
|
||||
edition = "2024"
|
||||
license = "GPL-3"
|
||||
repository = "https://git.javalsai.tuxcord.net/deadvey/happening/"
|
||||
readme = "../README.md"
|
||||
keywords = ["interactive", "storytelling", "server"]
|
||||
categories = ["parsing", "games"]
|
||||
description = "Server for happening: an interactive storytelling game"
|
||||
|
||||
[lints.clippy]
|
||||
cargo = { level = "warn", priority = -1 }
|
||||
@@ -14,7 +20,7 @@ option_if_let_else = { level = "allow" }
|
||||
pedantic = { level = "deny", priority = -1 }
|
||||
perf = { level = "deny", priority = -1 }
|
||||
style = { level = "deny", priority = -1 }
|
||||
unwrap_used = "deny"
|
||||
unwrap_used = "warn"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.11.10"
|
||||
|
||||
+12
-8
@@ -62,17 +62,21 @@ pub async fn api_process
|
||||
.and(characters_filter)
|
||||
.map(|name: String, characters: Arc<Mutex<HashMap<String, character::Character>>>|
|
||||
{
|
||||
let characters = match characters.lock()
|
||||
let reply =
|
||||
{
|
||||
Ok(data) => data,
|
||||
Err(poisoned) =>
|
||||
let characters = match characters.lock()
|
||||
{
|
||||
warn!("Character Mutex is poisoned");
|
||||
poisoned.into_inner()
|
||||
},
|
||||
Ok(data) => data,
|
||||
Err(poisoned) =>
|
||||
{
|
||||
warn!("Character Mutex is poisoned");
|
||||
poisoned.into_inner()
|
||||
},
|
||||
};
|
||||
characters.get(&name).cloned()
|
||||
};
|
||||
let Some(reply) = characters.get(&name)
|
||||
else
|
||||
|
||||
let Some(reply) = reply else
|
||||
{
|
||||
warn!("Client requested character that does not exist");
|
||||
return warp::reply::json(&json!({"reply": "invalid character"}));
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
Mutex,
|
||||
Arc,
|
||||
};
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Character
|
||||
{
|
||||
name: String,
|
||||
@@ -20,7 +20,6 @@ pub struct Character
|
||||
pronoun_deppos: String,
|
||||
pronoun_indpos: String,
|
||||
pronoun_reflex: String,
|
||||
animation: String,
|
||||
head: String,
|
||||
hair: String,
|
||||
torso: String,
|
||||
@@ -42,7 +41,6 @@ impl Character {
|
||||
"pronoun_deppos" => self.pronoun_deppos = value.to_string(),
|
||||
"pronoun_indpos" => self.pronoun_indpos = value.to_string(),
|
||||
"pronoun_reflex" => self.pronoun_reflex = value.to_string(),
|
||||
"animation" => self.animation = value.to_string(),
|
||||
"head" => self.head = value.to_string(),
|
||||
"hair" => self.hair = value.to_string(),
|
||||
"torso" => self.torso = value.to_string(),
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ async fn main()
|
||||
let data_clone2 = Arc::clone(&data_to_send);
|
||||
let characters_clone2 = Arc::clone(&characters);
|
||||
// Run the parsing process for the DSL
|
||||
match parsing::token_parse(&tokens, characters_clone2, &data_clone2, &rx)
|
||||
match parsing::token_parse(&tokens, &characters_clone2, &data_clone2, &rx)
|
||||
{
|
||||
// Exit with error or success
|
||||
Ok(()) =>
|
||||
|
||||
@@ -21,7 +21,7 @@ mod character_parse;
|
||||
// Returns success or an error string
|
||||
pub fn token_parse(
|
||||
tokens: &Vec<&str>,
|
||||
characters: Arc<Mutex<HashMap::<String, character::Character>>>,
|
||||
characters: &Arc<Mutex<HashMap::<String, character::Character>>>,
|
||||
data_to_send: &Arc<Mutex<api::DataToSend>>,
|
||||
rx: &Receiver<(bool,usize)>,
|
||||
) -> Result<(),String>
|
||||
@@ -48,7 +48,7 @@ pub fn token_parse(
|
||||
let character_name: String = token.chars().skip(1).collect();
|
||||
debug!("Doing something with a character: {character_name}");
|
||||
// The index is incremented to after the character's instructions
|
||||
index = match character_parse::character_parse(index+1, tokens, character_name, &characters, &data_to_send)
|
||||
index = match character_parse::character_parse(index+1, tokens, character_name, characters, data_to_send)
|
||||
{
|
||||
Ok(increment) => increment,
|
||||
Err((err,increment)) =>
|
||||
@@ -70,12 +70,12 @@ pub fn token_parse(
|
||||
},
|
||||
"choice" =>
|
||||
{
|
||||
let (_,jump_points) = match choice_parse(index+1, tokens, &data_to_send)
|
||||
let (_,jump_points) = match choice_parse(index+1, tokens, data_to_send)
|
||||
{
|
||||
Ok((increment,jump_point)) => (increment,jump_point),
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
if rx.recv().is_err() { warn!("Error sending choices to client"); };
|
||||
if rx.recv().is_err() { warn!("Error sending choices to client"); }
|
||||
let (_, choice) = match rx.recv()
|
||||
{
|
||||
Ok((_,choice)) => (None::<bool>, choice),
|
||||
@@ -151,5 +151,6 @@ fn choice_parse
|
||||
data.content = String::new();
|
||||
data.character = String::new();
|
||||
data.choices = choices; //TODO
|
||||
drop(data);
|
||||
Ok((sum_index + 1, choice_indeces))
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ pub fn character_parse
|
||||
data.content = output_string;
|
||||
data.character = character_name;
|
||||
data.choices = vec![];
|
||||
drop(data);
|
||||
},
|
||||
None => return Err(("Unable to read output string".to_string(), sum_index)),
|
||||
}
|
||||
@@ -69,14 +70,14 @@ pub fn character_parse
|
||||
info!("CHANGE command with character {character_name} feature {feature}");
|
||||
let mut characters = characters.lock().expect("Data cannot be unlocked");
|
||||
if let Some(character) = characters.get_mut(&character_name)
|
||||
{
|
||||
if character.set_field(feature, &output_string)
|
||||
.is_err() { warn!("Feature {feature} does not exist") };
|
||||
}
|
||||
&& character.set_field(feature, &output_string)
|
||||
.is_err() { warn!("Feature {feature} does not exist") }
|
||||
drop(characters);
|
||||
let mut data = data_to_send.lock().unwrap(); // TODO eh?
|
||||
data.action_type = String::from("change");
|
||||
data.content = String::new();
|
||||
data.character = character_name;
|
||||
drop(data);
|
||||
},
|
||||
// Catch all condition, if the instruction is unrecognised as a
|
||||
// character command
|
||||
|
||||
@@ -23,10 +23,10 @@ pub fn extract_quoted(parts: &[&str])
|
||||
for part in parts
|
||||
{
|
||||
counter += 1;
|
||||
vec_string.push(*part);
|
||||
// End of the string
|
||||
if part.ends_with('\"') // TODO allow for backslashes and '
|
||||
{
|
||||
vec_string.push(*part);
|
||||
let final_string: String = vec_string.join(" ");
|
||||
let final_string: String = final_string
|
||||
.chars()
|
||||
@@ -37,11 +37,6 @@ pub fn extract_quoted(parts: &[&str])
|
||||
.collect();
|
||||
return Some((final_string, counter));
|
||||
}
|
||||
// Otherwise just add this to the list
|
||||
else
|
||||
{
|
||||
vec_string.push(*part);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"pronoun_deppos": "His",
|
||||
"pronoun_indpos": "His",
|
||||
"pronoun_reflex": "Himself",
|
||||
"animation": "",
|
||||
"head": "",
|
||||
"hair": "",
|
||||
"torso": "",
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user