cleanup
This commit is contained in:
parent
03d2809295
commit
2c28394705
|
@ -246,13 +246,13 @@ impl ChatDB {
|
||||||
// - `"What's up?"`
|
// - `"What's up?"`
|
||||||
// - `{"goto": "foo"}`
|
// - `{"goto": "foo"}`
|
||||||
fn is_choice(&self, yaml: Option<&Value>) -> bool {
|
fn is_choice(&self, yaml: Option<&Value>) -> bool {
|
||||||
if let Some(data) = self.extract(yaml) {
|
if let Some(data) = self.extract_choice(yaml) {
|
||||||
return data.choice_text.is_some();
|
return data.choice_text.is_some();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract(&self, yaml: Option<&Value>) -> Option<Extracted> {
|
fn extract_choice(&self, yaml: Option<&Value>) -> Option<Extracted> {
|
||||||
let non_choice_tokens = NON_CHOICE_TOKENS.to_vec();
|
let non_choice_tokens = NON_CHOICE_TOKENS.to_vec();
|
||||||
if let Some(Value::Mapping(map)) = yaml {
|
if let Some(Value::Mapping(map)) = yaml {
|
||||||
let mut result: Extracted = Extracted::default();
|
let mut result: Extracted = Extracted::default();
|
||||||
|
@ -571,7 +571,7 @@ impl ChatDB {
|
||||||
// Spawn choices until we reach a non-choice item or the end of the branch
|
// Spawn choices until we reach a non-choice item or the end of the branch
|
||||||
let mut key: usize = 0;
|
let mut key: usize = 0;
|
||||||
let mut reached_end_of_branch = false;
|
let mut reached_end_of_branch = false;
|
||||||
while let Some(data) = self.extract(self.at(chat.internal_id, &chat.position).as_ref()) {
|
while let Some(data) = self.extract_choice(self.at(chat.internal_id, &chat.position).as_ref()) {
|
||||||
if let Some(choice_text) = data.choice_text {
|
if let Some(choice_text) = data.choice_text {
|
||||||
if reached_end_of_branch {
|
if reached_end_of_branch {
|
||||||
break;
|
break;
|
||||||
|
@ -697,7 +697,6 @@ pub fn handle_chat_events(
|
||||||
}
|
}
|
||||||
ChatEvent::SpawnChoice(replytext, key, goto, nowait, condition) => {
|
ChatEvent::SpawnChoice(replytext, key, goto, nowait, condition) => {
|
||||||
'out: {
|
'out: {
|
||||||
dbg!(condition);
|
|
||||||
if let Some(condition) = condition {
|
if let Some(condition) = condition {
|
||||||
if !vars.evaluate_condition(condition, &chat.talker.actor_id) {
|
if !vars.evaluate_condition(condition, &chat.talker.actor_id) {
|
||||||
break 'out;
|
break 'out;
|
||||||
|
|
Loading…
Reference in a new issue