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));
        }
Exemplo n.º 2
0
        public void SetToneRandomly(Random rng)
        {
            if (rng == null)
            {
                rng = new Random();
            }

            var possibilities = IncidentEnumExtensions.GetPossibleTones(TheEnergyVariation, TheStressVariation);
            var diceRoll      = rng.Next(0, possibilities.Count);

            theTone = possibilities[diceRoll];
        }
Exemplo n.º 3
0
        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];
        }