private bool AssessPreconditions(DialogueElement d) { bool pass = true; if (d.getPrecondition() == null) { return(true); } foreach (KeyValuePair <PreconditionOperators, string[]> set in d.getPrecondition().GetPreconditions()) { foreach (string operand in set.Value) { if (!set.Key.Assess(operand, this)) { pass = false; break; } } if (!pass) { break; } } return(pass); }
private void RunPostconditions(DialogueElement d) { if (d.getPostcondition() == null) { return; } foreach (KeyValuePair <PostconditionOperators, string[]> set in d.getPostcondition().GetPostconditions()) { foreach (string operand in set.Value) { set.Key.Update(operand, this); } } }
public ConversationTransaction GetNext(string id) { DialogueElement d = dialogueElements[id]; Dictionary <string, string> idOptionLabelPairs = new Dictionary <string, string>(); if (d.getOptions() != null) { foreach (DialogueElement option in d.getOptions()) { if (AssessPreconditions(option)) { idOptionLabelPairs.Add(option.getId(), option.getOptionText()); } } } RunPostconditions(d); return(new ConversationTransaction(d.getBody(), idOptionLabelPairs)); }