This commit is contained in:
yuni 2024-04-14 21:14:46 +02:00
parent 03d2809295
commit 2c28394705

View file

@ -246,13 +246,13 @@ impl ChatDB {
// - `"What's up?"`
// - `{"goto": "foo"}`
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 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();
if let Some(Value::Mapping(map)) = yaml {
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
let mut key: usize = 0;
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 reached_end_of_branch {
break;
@ -697,7 +697,6 @@ pub fn handle_chat_events(
}
ChatEvent::SpawnChoice(replytext, key, goto, nowait, condition) => {
'out: {
dbg!(condition);
if let Some(condition) = condition {
if !vars.evaluate_condition(condition, &chat.talker.actor_id) {
break 'out;