public Incident CreateIncident(Random rng, Pleasantness forced_P, EnergyLevel forced_E) { var theI = CreateIncident(rng); theI.SetToneRandomly_WithLimits(rng, forced_P, forced_E); return(theI); }
public Incident GetRandomIncident(Random rng, Pleasantness reqd_p, EnergyLevel reqd_e, Frequency min_f) { //First, exclude by Rarity var matchRarity = IncidentEnumExtensions.GetRandomFrequency_Weighted(rng); if (matchRarity < min_f) { matchRarity = min_f; } var possibleTemplates = this.TheTemplates.Where(t => t.TheFrequency == matchRarity).ToList(); //Next, exclude by EnergyLevel if (reqd_e != EnergyLevel.EitherLowOrHigh) { possibleTemplates = possibleTemplates.Where(t => t.IsHighEnergy == EnergyLevel.EitherLowOrHigh || t.IsHighEnergy == reqd_e).ToList(); } //Finally, exclude by Pleasantness if (reqd_p != Pleasantness.EitherPleasantOrNot)//#TODO - need to add more rare incidents that are pleasant to the default library { possibleTemplates = possibleTemplates.Where(t => t.IsPleasant == Pleasantness.EitherPleasantOrNot || t.IsPleasant == reqd_p).ToList(); } if (false == possibleTemplates.Any()) { return(null); } var diceRoll = rng.Next(0, possibleTemplates.Count); return(possibleTemplates[diceRoll].CreateIncident(rng, reqd_p, reqd_e)); }
public void SetToneRandomly_WithLimits(Random rng, Pleasantness p, EnergyLevel e) { if (rng == null) { rng = new Random(); } var finalEnergy = e == EnergyLevel.EitherLowOrHigh ? TheEnergyVariation : e; var finalStress = p == Pleasantness.EitherPleasantOrNot ? TheStressVariation : p; var possibilities = IncidentEnumExtensions.GetPossibleTones(finalEnergy, finalStress); var diceRoll = rng.Next(0, possibilities.Count); theTone = possibilities[diceRoll]; }
public static List <Tone> GetPossibleTones(EnergyLevel energy, Pleasantness stress) { var possibleTones = new List <Tone>(); if (energy != EnergyLevel.AlwaysHighEnergy) { if (stress != Pleasantness.NeverPleasant) { possibleTones.Add(Tone.Calm); possibleTones.Add(Tone.Empathy); } if (stress != Pleasantness.AlwaysPleasant) { possibleTones.Add(Tone.Sadness); possibleTones.Add(Tone.Shame); possibleTones.Add(Tone.Confusion); possibleTones.Add(Tone.Apathy); } } if (energy != EnergyLevel.AlwaysLowEnergy) { if (stress != Pleasantness.NeverPleasant) { possibleTones.Add(Tone.Curiousity); possibleTones.Add(Tone.Joy); possibleTones.Add(Tone.Confidence); } if (stress != Pleasantness.AlwaysPleasant) { possibleTones.Add(Tone.Shock); possibleTones.Add(Tone.Anger); possibleTones.Add(Tone.Fear); } } return(possibleTones); }
protected void GetAllowedEnergyAndPleasantness(ref Pleasantness p, ref EnergyLevel e, bool isFinalEvent) { if (isFinalEvent) { //Final event has opposite energy of the one before it if (fromPriorRound.TheTone.IsHighEnergy()) { e = EnergyLevel.AlwaysLowEnergy; } else { e = EnergyLevel.AlwaysHighEnergy; } } else if (consecutive_HighEnergy >= MAX_CONSECUTIVE_HIGH_ENERGY) { e = EnergyLevel.AlwaysLowEnergy; } else if (consecutive_LowEnergy >= MAX_CONSECUTIVE_LOW_ENERGY) { e = EnergyLevel.AlwaysHighEnergy; } if (consecutive_Pleasant >= MAX_CONSECUTIVE_PLEASANT) { p = Pleasantness.NeverPleasant; } else if (consecutive_Unpleasant >= MAX_CONSECUTIVE_UNPLEASANT) { p = Pleasantness.AlwaysPleasant; } //Future: // Toggle to allow hook for follow-up story. If true, // allow high energy unpleasant as final event. If false, // 50% chance to have happy ending vs 50% chance to cut final event short and have tragedy }
protected IIncident GetNextEvent(Random rng, bool isJustBeforeEnding, bool isFinalEvent) { var chosenCollection = this.possibleIncidents.ChooseRandomCollection(rng); Pleasantness allowedPleasantness = Pleasantness.EitherPleasantOrNot; EnergyLevel allowedEnergy = EnergyLevel.EitherLowOrHigh; GetAllowedEnergyAndPleasantness(ref allowedPleasantness, ref allowedEnergy, isFinalEvent); Frequency minFrequency = GetMinFrequency(isJustBeforeEnding); var chosenIncident = chosenCollection.GetRandomIncident(rng, allowedPleasantness, allowedEnergy, minFrequency); var popluatedSucessfully = chosenIncident?.TryToPopulateIncident(this.currentCast, rng) ?? false; if (popluatedSucessfully == false) { return(null); } else { UpdatePatternTracking(chosenIncident); return(chosenIncident); } }