fixed a bug with single word strings and multiple choice blocks side by side
This commit is contained in:
+1
-1
@@ -126,7 +126,7 @@ pub fn modify_data
|
||||
choices: Vec<String>,
|
||||
)
|
||||
{
|
||||
let mut data = data_to_send.lock().unwrap_or_exit("Data to send Mutex was poisoned",2); // TODO eh?
|
||||
let mut data = data_to_send.lock().unwrap_or_exit("Data to send Mutex was poisoned",2);
|
||||
data.id += 1;
|
||||
data.action_type = action_type;
|
||||
data.content = content;
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ async fn main()
|
||||
{
|
||||
id: 0,
|
||||
action_type: "begin".to_owned(),
|
||||
content: String::new(),
|
||||
content: String::new(), // TODO send title and description
|
||||
character: String::new(),
|
||||
choices: vec![],
|
||||
}));
|
||||
|
||||
@@ -65,6 +65,7 @@ pub fn token_parse(
|
||||
increment
|
||||
},
|
||||
};
|
||||
if rx.recv().is_err() { warn!("Some issue with api"); }
|
||||
continue 'parse_loop
|
||||
}
|
||||
Some(_) =>
|
||||
@@ -129,20 +130,17 @@ pub fn token_parse(
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
if rx.recv().is_err()
|
||||
{
|
||||
warn!("Some issue with api");
|
||||
}
|
||||
if rx.recv().is_err() { warn!("Some issue with api"); }
|
||||
}
|
||||
}
|
||||
|
||||
fn choice_parse(tokens: &[tokenise::Token], mut index: usize, data_to_send: &Arc<Mutex<api::DataToSend>>,)
|
||||
-> Result<Vec<usize>, String>
|
||||
{
|
||||
let mut next_token: String = "choice".to_string();
|
||||
let mut next_token: String = "or".to_string();
|
||||
let mut choices: Vec<String> = Vec::new();
|
||||
let mut choice_indeces: Vec<usize> = Vec::new();
|
||||
while next_token == "or" || next_token == "choice"
|
||||
while next_token == "or"
|
||||
{
|
||||
index += 1;
|
||||
choices.push
|
||||
|
||||
@@ -27,6 +27,12 @@ pub fn character_parse
|
||||
) -> Result<usize,(String,usize)>
|
||||
{
|
||||
let mut sum_index: usize = index;
|
||||
let characters_hashmap = characters.lock().unwrap_or_exit("Characters Mutex was poisoned",2);
|
||||
if character_name.to_lowercase() != "narrator" && ! characters_hashmap.contains_key(&character_name)
|
||||
{
|
||||
return Err((format!("Character {character_name} does not exist"),sum_index + 1));
|
||||
}
|
||||
drop(characters_hashmap);
|
||||
// Ensure the index is valid (the index is not beyond the vector)
|
||||
let keyword = tokenise::get_keyword_token(tokens, sum_index)
|
||||
.map_err(|err| (err, sum_index))?;
|
||||
|
||||
+10
-2
@@ -91,7 +91,6 @@ pub fn tokenise(file_contents: &str)
|
||||
tokenised_data.len(),
|
||||
);
|
||||
}
|
||||
// On a new indentation level, do a recursive call
|
||||
else if item == "{"
|
||||
{
|
||||
bracket_stack.push(tokenised_data.len());
|
||||
@@ -115,7 +114,16 @@ fn tokenise_string(space_seperated: &[&str], mut index: usize)
|
||||
-> Option<(usize, String)>
|
||||
{
|
||||
let mut string = String::new();
|
||||
let mut chars = space_seperated[index].chars();
|
||||
let first_word = space_seperated[index];
|
||||
if first_word.ends_with('"') // One word string edge case
|
||||
{
|
||||
let mut chars = first_word.chars();
|
||||
chars.next();
|
||||
chars.next_back();
|
||||
string += chars.as_str();
|
||||
return Some((index,string));
|
||||
}
|
||||
let mut chars = first_word.chars();
|
||||
chars.next();
|
||||
string += chars.as_str();
|
||||
for item in &space_seperated[index+1..]
|
||||
|
||||
Reference in New Issue
Block a user