namespace AIStudio.Assistants.BeyondFactsLab; /// /// Whom the chat of the step "Test situation" of the BeyondFacts Lab actually plays: the mode and the people which /// count of what the person chose. /// /// /// A chosen person counts while they are a candidate, see BflSimulationCandidates, and only as many as the mode allows, /// in the order of the list of participants. When nobody of the chosen people counts, the chat plays generic /// counterparts, as it did before the person chose a mode. /// /// The mode in effect. /// The people the chat plays, in the order of the list; empty for generic counterparts. public sealed record BflEffectiveSimulation(BflSimulationMode Mode, IReadOnlyList People) { /// /// The simulation with generic counterparts, no specific person. /// public static readonly BflEffectiveSimulation GENERIC = new(BflSimulationMode.GENERIC, []); /// /// Gets whom the chat plays of what the person chose. /// /// What the person chose; null when they chose nothing. /// The people the chat may play, in the order of the list, see BflSimulationCandidates. /// The simulation in effect. public static BflEffectiveSimulation Of(BflSimulation? simulation, IReadOnlyList candidates) { if (simulation is null || !simulation.Mode.HasPeople) return GENERIC; var people = candidates.Where(candidate => simulation.HasChosen(candidate.Name)).Take(simulation.Mode.MaxPeople).ToList(); return people.Count is 0 ? GENERIC : new(simulation.Mode, people); } }