public void ValidateDialogue(IWorld world, IHasStats recipient, DialogueInitiation dialogue, IRoom room) { if (dialogue.Next.HasValue) { var d = world.Dialogue.GetDialogue(dialogue.Next); if (d == null) { AddError($"Could not find Dialogue '{dialogue.Next}'"); } else { ValidateDialogue(world, recipient, dialogue, d, room); } } if (dialogue.Banter != null) { foreach (var guid in dialogue.Banter) { var d = world.Dialogue.GetDialogue(guid); if (d == null) { AddError($"Could not find Banter Dialogue '{dialogue.Next}'"); } else { ValidateDialogue(world, recipient, dialogue, d, room); } } } }
public void ValidateDialogue(IWorld world, IHasStats recipient, DialogueInitiation dialogue, DialogueNode node, IRoom room) { if (_alreadyValidated.Contains(node.Identifier)) { return; } _alreadyValidated.Add(node.Identifier); if (node.Body == null || node.Body.Count == 0 || node.Body.All(b => string.IsNullOrWhiteSpace(b.Text))) { AddError($"Dialogue '{node.Identifier}' has no Body Text"); } foreach (ICondition condition in node.Condition) { try { condition.IsMet(world, new SystemArgs(world, _ui, 0, GetTestActor(room), recipient, Guid.Empty)); } catch (Exception e) { AddWarning($"Error testing dialogue condition on '{node}' for test actor interacting with '{recipient}'", e); } } if (node.Body != null) { foreach (ICondition condition in node.Body.SelectMany(b => b.Condition)) { try { condition.IsMet(world, new SystemArgs(world, _ui, 0, GetTestActor(room), recipient, Guid.Empty)); } catch (Exception e) { AddWarning($"Error testing dialogue BodyText Condition on '{node}' for test actor interacting with '{recipient}'", e); } } } foreach (var option in node.Options) { Validate(world, recipient, dialogue, room, node, option); } }
public void Validate(IWorld world, IHasStats recipient, DialogueInitiation initiation, IRoom room, DialogueNode dialogue, DialogueOption option) { if (string.IsNullOrWhiteSpace(option.Text)) { AddError($"A Dialogue Option of Dialogue '{dialogue.Identifier}' has no Text"); } foreach (IEffect effect in option.Effect) { try { effect.Apply(new SystemArgs(world, _ui, 0, GetTestActor(room), recipient, Guid.Empty)); } catch (Exception e) { AddWarning($"Error testing EffectCode of Option '{option.Text}' of Dialogue '{dialogue.Identifier}' for test actor interacting with '{recipient}' Bad code was:{effect}", e); } } foreach (ICondition condition in option.Condition) { try { condition.IsMet(world, new SystemArgs(world, _ui, 0, GetTestActor(room), recipient, Guid.Empty)); } catch (Exception e) { AddWarning($"Error testing Condition Code of Option '{option.Text}' of Dialogue '{dialogue.Identifier}' for test actor interacting with '{recipient}'. Bad code was:{condition}", e); } } if (option.Destination != null) { initiation.Next = option.Destination; ValidateDialogue(world, recipient, initiation, room); } }