Пример #1
0
            protected static bool Test(IScoringGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check)
            {
                SimDescription actor  = actorData.SimDescription;
                SimDescription target = targetData.SimDescription;

                if (actor.Partner != null)
                {
                    int chance = actorData.GetValue <ChanceOfAdulteryOption, int>();
                    if (chance == 0)
                    {
                        stats.IncStat("Adultery Denied");
                        return(false);
                    }
                    else if (stats.AddScoring("FlirtyPartner", chance, ScoringLookup.OptionType.Chance, actor) <= 0)
                    {
                        stats.IncStat("Adultery Scoring Fail");
                        return(false);
                    }

                    chance = targetData.GetValue <ChanceOfLiaisonOption, int>();
                    if (chance == 0)
                    {
                        stats.IncStat("Liaison Denied");
                        return(false);
                    }
                    if (stats.AddScoring("FlirtyPartner", chance, ScoringLookup.OptionType.Chance, target) <= 0)
                    {
                        stats.IncStat("Liaison Scoring Fail");
                        return(false);
                    }
                }

                return(true);
            }
Пример #2
0
        protected bool ScoreChildMove(IScoringGenerator stats, string tag, SimDescription child, List <SimDescription> movingSims)
        {
            if (child.Genealogy.Parents.Count == 0)
            {
                stats.IncStat(tag + " ChildMove: No Parents");
                return(false);
            }

            int  firstScore  = 0;
            bool firstMoving = false;

            SimDescription mom = null, dad = null;

            Relationships.GetParents(child, out mom, out dad);

            if (mom != null)
            {
                firstMoving = movingSims.Contains(mom);

                if ((firstMoving) || (mom.Household == child.Household))
                {
                    firstScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, mom));
                }
                else
                {
                    return(true);
                }
            }

            int  secondScore  = 0;
            bool secondMoving = false;

            if (dad != null)
            {
                secondMoving = movingSims.Contains(dad);

                if ((secondMoving) || (dad.Household == child.Household))
                {
                    secondScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, dad));
                }
                else
                {
                    return(true);
                }
            }

            if (firstScore > secondScore)
            {
                return(firstMoving);
            }
            else
            {
                return(secondMoving);
            }
        }
        public static bool TestPreferredBaby(IScoringGenerator stats, SimDescription sim, int additionalBabyCount)
        {
            int simPreferredBabies = stats.AddScoring("PreferredBabyCount", sim);

            if (sim.Genealogy == null)
            {
                stats.IncStat("No Genealogy");
                return(false);
            }
            else if ((simPreferredBabies + additionalBabyCount) <= GetNumLiveChildren(sim))
            {
                stats.AddStat("Additional Children", additionalBabyCount);
                stats.AddStat("Preferred Children", (simPreferredBabies + additionalBabyCount));
                stats.AddStat("Actual Children", GetNumLiveChildren(sim));
                stats.AddStat("Enough Children", GetNumLiveChildren(sim) - simPreferredBabies);
                return(false);
            }

            if (sim.Partner == null)
            {
                return(!sim.IsHuman);
            }
            else
            {
                int partnerPreferredBabies = stats.AddScoring("PreferredBabyCount", sim.Partner);

                if (sim.Partner.Genealogy == null)
                {
                    stats.IncStat("No Genealogy");
                    return(false);
                }

                if ((partnerPreferredBabies + additionalBabyCount) <= GetNumLiveChildren(sim.Partner))
                {
                    stats.AddStat("Additional Children", additionalBabyCount);
                    stats.AddStat("Prefered Children", (partnerPreferredBabies + additionalBabyCount));
                    stats.AddStat("Actual Children", GetNumLiveChildren(sim.Partner));
                    stats.AddStat("Enough Children", GetNumLiveChildren(sim.Partner) - partnerPreferredBabies);
                    return(false);
                }
            }
            return(true);
        }
        public static bool TestPreferredBaby(IScoringGenerator stats, SimDescription sim, int additionalBabyCount)
        {
            int simPreferredBabies = stats.AddScoring("PreferredBabyCount", sim);

            if (sim.Genealogy == null)
            {
                stats.IncStat("No Genealogy");
                return false;
            }
            else if ((simPreferredBabies + additionalBabyCount) <= GetNumLiveChildren(sim))
            {
                stats.AddStat("Additional Children", additionalBabyCount);
                stats.AddStat("Preferred Children", (simPreferredBabies + additionalBabyCount));
                stats.AddStat("Actual Children", GetNumLiveChildren(sim));
                stats.AddStat("Enough Children", GetNumLiveChildren(sim) - simPreferredBabies);
                return false;
            }

            if (sim.Partner == null)
            {
                return (!sim.IsHuman);
            }
            else
            {
                int partnerPreferredBabies = stats.AddScoring("PreferredBabyCount", sim.Partner);

                if (sim.Partner.Genealogy == null)
                {
                    stats.IncStat("No Genealogy");
                    return false;
                }

                if ((partnerPreferredBabies + additionalBabyCount) <= GetNumLiveChildren(sim.Partner))
                {
                    stats.AddStat("Additional Children", additionalBabyCount);
                    stats.AddStat("Prefered Children", (partnerPreferredBabies + additionalBabyCount));
                    stats.AddStat("Actual Children", GetNumLiveChildren(sim.Partner));
                    stats.AddStat("Enough Children", GetNumLiveChildren(sim.Partner) - partnerPreferredBabies);
                    return false;
                }
            }
            return true;
        }
Пример #5
0
        public bool Allow(IScoringGenerator stats, SimDescription sim, int moveCooldown)
        {
            if (!Allow(stats, sim, AllowCheck.Active))
            {
                return(false);
            }

            if (sim.LotHome == null)
            {
                return(true);
            }

            if (stats.AddScoring("Allow: Move Cooldown", GetElapsedTime <DayOfLastMoveOption>(sim) - moveCooldown) < 0)
            {
                stats.IncStat("Allow: Cooldown Denied");
                return(false);
            }

            return(true);
        }
Пример #6
0
        protected static bool IsWitnessed(ManagerProgressionBase manager, IScoringGenerator stats, SimDescription sim, int baseChance)
        {
            if (sim.CreatedSim == null)
            {
                stats.IncStat("Hibernating");
                return(false);
            }

            Lot lot = sim.CreatedSim.LotCurrent;

            if (lot == null)
            {
                return(false);
            }

            if (lot.IsWorldLot)
            {
                return(false);
            }

            if (lot.CanSimTreatAsHome(sim.CreatedSim))
            {
                stats.IncStat("At Home");
                return(false);
            }

            /*
             * if (lot.IsResidentialLot)
             * {
             *  stats.IncStat("Residential");
             *  return false;
             * }
             */

            foreach (Sim witness in lot.GetAllActors())
            {
                if (!witness.IsHuman)
                {
                    continue;
                }

                if (witness.SimDescription.ChildOrBelow)
                {
                    continue;
                }

                if (stats.AddScoring("IgnoreCurfew", witness.SimDescription) > 0)
                {
                    continue;
                }

                if (!RandomUtil.RandomChance(stats.AddScoring("CurfewWitness", witness.SimDescription) + baseChance))
                {
                    continue;
                }

                bool forceCurfew;
                if (IsUnderCurfew(manager, stats, witness.SimDescription, out forceCurfew))
                {
                    continue;
                }

                stats.IncStat("Witnessed");
                return(true);
            }

            return(false);
        }
Пример #7
0
        protected bool ScoreChildMove(IScoringGenerator stats, string tag, SimDescription child, List<SimDescription> movingSims)
        {
            if (child.Genealogy.Parents.Count == 0)
            {
                stats.IncStat(tag + " ChildMove: No Parents");
                return false;
            }

            int firstScore = 0;
            bool firstMoving = false;

            SimDescription mom = null, dad = null;
            Relationships.GetParents(child, out mom, out dad);

            if (mom != null)
            {
                firstMoving = movingSims.Contains(mom);

                if ((firstMoving) || (mom.Household == child.Household))
                {
                    firstScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, mom));
                }
                else
                {
                    return true;
                }
            }

            int secondScore = 0;
            bool secondMoving = false;

            if (dad != null)
            {
                secondMoving = movingSims.Contains(dad);

                if ((secondMoving) || (dad.Household == child.Household))
                {
                    secondScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, dad));
                }
                else
                {
                    return true;
                }
            }

            if (firstScore > secondScore)
            {
                return firstMoving;
            }
            else
            {
                return secondMoving;
            }
        }