public void Test_AdvancedSubstitution() { TwoInARoomWithRelationship(-50, false, out You you, out IActor npc, out IWorld world); you.Name = "Flash"; npc.Dialogue.Next = new Guid("339271e0-7b11-4aba-a9e2-2776f6c5a197"); var yaml = @"- Identifier: 339271e0-7b11-4aba-a9e2-2776f6c5a197 Body: - Text: ""I really hate {Recipient:WorstEnemy(false,-10)}"""; var dlg = new DialogueSystem { AllDialogues = Compiler.Instance.Deserializer.Deserialize <List <DialogueNode> >(yaml) }; var ui = GetUI(); dlg.Apply(new SystemArgs(world, ui, 0, you, npc, Guid.Empty)); Assert.Contains("I really hate Flash", ui.MessagesShown); }
public void Test_Substitutions(bool areFriends) { TwoInARoomWithRelationship(areFriends ? 10:-10, false, out You you, out IActor them, out IWorld world); them.Name = "Space Crab"; them.Dialogue.Next = new Guid("339271e0-7b11-4aba-a9e2-2776f6c5a197"); var yaml = @"- Identifier: 339271e0-7b11-4aba-a9e2-2776f6c5a197 Body: - Text: Screeeee (this creature seems friendly) Condition: - Lua: return Recipient:AttitudeTo(AggressorIfAny) > 0 - Text: Screeeee (this creature seems hostile) Condition: - Lua: return Recipient:AttitudeTo(AggressorIfAny) < 0 - Text: Screeeee (this creature seems indifferent) Condition: - Lua: return Recipient:AttitudeTo(AggressorIfAny) == 0"; var blueprints = Compiler.Instance.Deserializer.Deserialize <List <DialogueNodeBlueprint> >(yaml); var dialogueFactory = new DialogueNodeFactory(); var dlg = new DialogueSystem { AllDialogues = blueprints.Select(b => dialogueFactory.Create(b)).ToList() }; var ui = GetUI(); dlg.Apply(new SystemArgs(world, ui, 0, you, them, Guid.Empty)); if (areFriends) { Assert.Contains("Screeeee (this creature seems friendly)", ui.MessagesShown); } else { Assert.Contains("Screeeee (this creature seems hostile)", ui.MessagesShown); } }
public void Test_SimpleSubstitution() { var you = YouInARoom(out IWorld world); you.Name = "Flash"; var npc = new Npc("Space Crab", you.CurrentLocation); npc.Dialogue.Next = new Guid("339271e0-7b11-4aba-a9e2-2776f6c5a197"); var yaml = @"- Identifier: 339271e0-7b11-4aba-a9e2-2776f6c5a197 Body: - Text: ""Greetings {AggressorIfAny} I am {Recipient}"""; var dlg = new DialogueSystem { AllDialogues = Compiler.Instance.Deserializer.Deserialize <List <DialogueNode> >(yaml) }; var ui = GetUI(); dlg.Apply(new SystemArgs(world, ui, 0, you, npc, Guid.Empty)); Assert.Contains("Greetings Flash I am Space Crab", ui.MessagesShown); }