Beispiel #1
0
        protected override ICollection <SimDescription> GetTargets(SimDescription sim)
        {
            List <SimDescription> results = new List <SimDescription>();

            foreach (SimDescription parent in Relationships.GetParents(sim))
            {
                foreach (Relationship relation in Relationship.Get(parent))
                {
                    if (!relation.AreEnemies())
                    {
                        continue;
                    }

                    SimDescription other = relation.GetOtherSimDescription(parent);
                    if (other == null)
                    {
                        continue;
                    }

                    foreach (SimDescription child in Relationships.GetChildren(other))
                    {
                        results.Add(child);
                    }
                }
            }

            return(Flirts.FindAnyFor(this, sim, true, Force, results));
        }
Beispiel #2
0
        protected override bool TargetAllow(SimDescription target)
        {
            if ((!IsFriendly) && (Sim.ToddlerOrBelow))
            {
                IncStat("Too Young");
                return(false);
            }
            else if ((IsRomantic) && (Sim.TeenOrAbove != target.TeenOrAbove))
            {
                IncStat("Wrong Age");
                return(false);
            }
            else if ((IsFriendly) && (TestRelationship) && (ManagerSim.GetLTR(Sim, Target) >= 100))
            {
                IncStat("Max Liking");
                return(false);
            }
            else if (Delta < 0)
            {
                if (target.ToddlerOrBelow)
                {
                    IncStat("Too Young");
                    return(false);
                }
                else if ((TestRelationship) && (ManagerSim.GetLTR(Sim, Target) <= -100))
                {
                    IncStat("Min Liking");
                    return(false);
                }
                else if (!Friends.AllowEnemy(this, Sim, Target, Managers.Manager.AllowCheck.None))
                {
                    return(false);
                }
                else if ((!GetValue <AllowEnemyFamilyOption, bool>()) &&
                         ((Sim.Partner == Target) || (Relationships.IsCloselyRelated(Sim, Target, false))))
                {
                    IncStat("Closely Related Denied");
                    return(false);
                }
            }
            else if (Delta > 0)
            {
                if ((TestRelationship) && (target.CreatedSim != null) && (SnubManager.IsSnubbing(target.CreatedSim, target)))
                {
                    IncStat("Snubbing");
                    return(false);
                }
                else if (!Friends.AllowFriend(this, Sim, Target, Managers.Manager.AllowCheck.None))
                {
                    return(false);
                }
                else if ((IsRomantic) && (!Flirts.Allow(this, Sim, Target)))
                {
                    return(false);
                }
            }

            return(base.TargetAllow(target));
        }
Beispiel #3
0
        protected bool DuoSameHouse(SimDescription a, SimDescription b)
        {
            if (Flirts.IsCloselyRelated(a, b))
            {
                return(true);
            }

            return(!mNewHouse);
        }
Beispiel #4
0
        public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if (Personalities.IsOpposing(stats, actor, target, true))
            {
                stats.IncStat("Opposing Clan");
                return(false);
            }
            else if (!Flirts.CanHaveAutonomousRomance(stats, actor, target, ((check & AllowCheck.Active) == AllowCheck.Active)))
            {
                return(false);
            }

            return(AllowPartner(stats, actor, target, check));
        }
Beispiel #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            if (Sim.Teen)
            {
                float gaySims      = 0;
                float straightSims = 0;
                Flirts.CalculateGayRatio(ref gaySims, ref straightSims);

                bool allowGay = ((gaySims / straightSims) * 100) < GetValue <ManagerFlirt.MaximumGayRatioOption, int>();

                Flirts.SetGenderPreference(Sim, allowGay);
            }
            return(true);
        }
Beispiel #6
0
        public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if (!Allow(stats, actor, check))
            {
                return(false);
            }

            if (!Allow(stats, target, check))
            {
                return(false);
            }

            if (!Flirts.CanHaveAutonomousRomance(stats, actor, target, ((check & AllowCheck.Active) == AllowCheck.Active)))
            {
                return(false);
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            if (!actorData.Allowed <AllowCasteCanBePregnantOption>(targetData, false))
            {
                stats.IncStat("Can Be Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCasteCanBePregnantOption>(targetData, false))
            {
                stats.IncStat("Can Be Caste Denied");
                return(false);
            }
            else if (!actorData.Allowed <AllowCastePregnancyOption>(targetData, true))
            {
                stats.IncStat("Participation Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCastePregnancyOption>(targetData, true))
            {
                stats.IncStat("Participation Caste Denied");
                return(false);
            }
            else if (!DualAllow(stats, actorData, targetData, check))
            {
                return(false);
            }

            return(true);
        }
Beispiel #7
0
        protected override bool CommonAllow(SimDescription sim)
        {
            if (!Flirts.Allow(this, sim))
            {
                IncStat("User Denied");
                return(false);
            }
            else if (AddScoring("Partner To Flirt Cooldown", TestElapsedTime <DayOfLastPartnerOption, MinTimeFromPartnerToFlirtOption>(sim)) < 0)
            {
                AddStat("Too Early", GetElapsedTime <DayOfLastPartnerOption>(sim));
                return(false);
            }
            else if ((TestFlirtCooldown) && (AddScoring("Flirt To Flirt Cooldown", TestElapsedTime <DayOfLastRomanceOption, MinTimeBetweenFlirtsOption>(sim)) < 0))
            {
                AddStat("Too Early", GetElapsedTime <DayOfLastRomanceOption>(sim));
                return(false);
            }
            else
            {
                int maximum = GetValue <ScheduledFlirtScenario.MaximumFlirtsOption, int>();
                if (maximum > 0)
                {
                    int totalFlirts = 0;
                    foreach (Relationship relation in Relationship.GetRelationships(sim))
                    {
                        if (relation.AreRomantic())
                        {
                            totalFlirts++;

                            if (totalFlirts >= maximum)
                            {
                                IncStat("Maximum Exceeded");
                                return(false);
                            }
                        }
                    }
                }
            }

            return(base.CommonAllow(sim));
        }
Beispiel #8
0
        protected override bool TargetAllow(SimDescription sim)
        {
            if (Sim.Age != Target.Age)
            {
                if ((Sim.ChildOrBelow) || (Target.ChildOrBelow))
                {
                    if (!Flirts.IsCloselyRelated(Sim, Target))
                    {
                        IncStat("Not Family");
                        return(false);
                    }
                }
            }
            else if (Sim.ToddlerOrBelow)
            {
                IncStat("Too Young");
                return(false);
            }

            return(base.TargetAllow(sim));
        }
Beispiel #9
0
        protected override bool Allow(SimDescription sim)
        {
            if (sim.CreatedSim == null)
            {
                IncStat("Hibernating");
                return(false);
            }
            else if (AddScoring("Stalking", sim) <= 0)
            {
                IncStat("Score Fail");
                return(false);
            }
            else
            {
                List <SimDescription> friends = Flirts.FindExistingFor(this, sim, true);
                if ((friends != null) && (friends.Count > 0))
                {
                    IncStat("Other Loves");
                    return(false);
                }
            }

            return(base.Allow(sim));
        }
Beispiel #10
0
 protected override ICollection <SimDescription> GetTargets(SimDescription sim)
 {
     return(Flirts.FindAnyFor(this, sim, false, false));
 }
Beispiel #11
0
        protected override bool Sort(List <Household> houses)
        {
            Dictionary <Household, int> candidates = new Dictionary <Household, int>();

            AddStat("Potentials", houses.Count);

            SimDescription oldestSim = Sim;

            foreach (SimDescription sim in Movers)
            {
                if ((oldestSim == null) || (SimTypes.IsOlderThan(sim, oldestSim)))
                {
                    oldestSim = sim;
                }
            }

            foreach (Household house in houses)
            {
                bool olderFound = false;

                foreach (SimDescription other in HouseholdsEx.All(house))
                {
                    if (Deaths.IsDying(other))
                    {
                        continue;
                    }

                    if (SimTypes.IsOlderThan(other, oldestSim))
                    {
                        olderFound = true;
                    }

                    int count = 0;

                    if (Flirts.IsCloselyRelated(Sim, other))
                    {
                        if (Sim.Genealogy.Parents.Contains(other.Genealogy))
                        {
                            count += 10;
                        }
                        else
                        {
                            count++;
                        }
                    }
                    else if (OnlyFamilyMoveIn)
                    {
                        continue;
                    }

                    bool checkRel = false;
                    if (other.YoungAdultOrAbove)
                    {
                        checkRel = true;
                    }
                    else if ((Households.AllowSoloMove(Sim)) && (other.TeenOrAbove))
                    {
                        checkRel = true;
                    }

                    if (checkRel)
                    {
                        int rel = 0;

                        Relationship relation = Relationship.Get(Sim, other, false);
                        if (relation != null)
                        {
                            rel = (int)(relation.LTR.Liking / 25);

                            if ((relation.AreRomantic()) && (rel > 0))
                            {
                                rel += 5;
                            }

                            count += rel;
                        }

                        if (Households.AllowSoloMove(Sim))
                        {
                            if (rel < 3)
                            {
                                continue;
                            }
                        }
                    }

                    if (Sim.Partner == other)
                    {
                        count += 10;
                    }

                    if (!candidates.ContainsKey(house))
                    {
                        candidates.Add(house, count);
                    }
                    else
                    {
                        candidates[house] += count;
                    }
                }

                if (!olderFound)
                {
                    candidates.Remove(house);
                }
            }

            houses.Clear();
            if (candidates.Count > 0)
            {
                ScoringList <Household> scoring = new ScoringList <Household>();
                foreach (KeyValuePair <Household, int> candidate in candidates)
                {
                    AddScoring("", candidate.Value);

                    scoring.Add(candidate.Key, candidate.Value);
                }

                houses.AddRange(scoring.GetBestByMinScore(1));
            }
            else
            {
                IncStat("No Candidates");
            }

            return(true);
        }
Beispiel #12
0
 protected override ICollection <SimDescription> GetTargets(SimDescription sim)
 {
     return(Flirts.FindExistingFor(this, sim, true));
 }
Beispiel #13
0
        public bool BumpToHigherState(Common.IStatGenerator stats, SimDescription a, SimDescription b)
        {
            Relationship relation = ManagerSim.GetRelationship(a, b);

            if (relation == null)
            {
                IncStat("BumpUp: Bad Relation");
                stats.IncStat("BumpUp: Bad Relation");
                return(false);
            }

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = ChangeRelationship.NextPositiveRomanceState(currentState, relation.IsPetToPetRelationship);

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                IncStat("BumpUp: No Next Level");
                stats.IncStat("BumpUp: No Next Level");
                return(false);
            }

            if (currentState == LongTermRelationshipTypes.RomanticInterest)
            {
                if (Flirts.IsCloselyRelated(a, b))
                {
                    IncStat("BumpUp: Related");
                    stats.IncStat("BumpUp: Related");
                    return(false);
                }

                if ((!GetValue <AllowSteadyOption, bool>(a)) || (!GetValue <AllowSteadyOption, bool>(b)))
                {
                    IncStat("BumpUp: Steady Denied");
                    stats.IncStat("BumpUp: Steady Denied");
                    return(false);
                }

                if (!DumpOtherRomances(stats, a, b))
                {
                    return(false);
                }
                if (!DumpOtherRomances(stats, b, a))
                {
                    return(false);
                }

                if ((a.Partner != b) || (b.Partner != a))
                {
                    try
                    {
                        a.SetPartner(b);

                        SetElapsedTime <DayOfLastPartnerOption>(a);
                        SetElapsedTime <DayOfLastPartnerOption>(b);

                        SetElapsedTime <DayOfLastRomanceOption>(a);
                        SetElapsedTime <DayOfLastRomanceOption>(b);
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(a, b, e);
                    }
                }
            }
            else if (currentState == LongTermRelationshipTypes.Partner)
            {
                if ((a.TeenOrBelow) || (b.TeenOrBelow))
                {
                    if ((!GetValue <AllowMarriageOption, bool>(a)) || (!GetValue <AllowMarriageOption, bool>(b)))
                    {
                        IncStat("BumpUp: Marriage Denied");
                        stats.IncStat("BumpUp: Marriage Denied");
                        return(false);
                    }
                    else if (GetValue <MarriageScenario.AllowTeenOnlyOnPregnancyOption, bool>())
                    {
                        if ((!a.IsPregnant) && (!b.IsPregnant))
                        {
                            IncStat("BumpUp: Non-Pregnant Marriage Denied");
                            stats.IncStat("BumpUp: Non-Pregnant Marriage Denied");
                            return(false);
                        }
                    }
                }

                relation.ProposerDesc = a;
            }

            float liking = relation.LTR.Liking;

            ForceChangeState(relation, nextState);

            if (liking > relation.LTR.Liking)
            {
                relation.LTR.SetLiking(liking);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                IncStat("Invalid: " + currentState);
                stats.IncStat("Invalid: " + currentState);
                return(false);
            }

            IncStat("BumpUp: " + currentState + " to " + relation.LTR.CurrentLTR);
            stats.IncStat("BumpUp: " + currentState + " to " + relation.LTR.CurrentLTR);
            return(true);
        }
Beispiel #14
0
 protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, AllowCheck check)
 {
     return(Flirts.Allow(stats, sim, check));
 }
Beispiel #15
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            ScoringList <SimDescription> scoring = new ScoringList <SimDescription>();

            SimDescription head = SimTypes.HeadOfFamily(House);

            foreach (SimDescription sim in House.AllSimDescriptions)
            {
                if ((sim == head) || (sim.Partner == head))
                {
                    continue;
                }

                // Don't move sims that can't move out
                if (!Households.AllowSoloMove(sim))
                {
                    continue;
                }

                // Don't move sims related to the head of family
                if (Flirts.IsCloselyRelated(sim, head))
                {
                    continue;
                }

                // Don't move sims that don't have partners
                if (sim.Partner == null)
                {
                    continue;
                }

                if (!House.AllSimDescriptions.Contains(sim.Partner))
                {
                    continue;
                }

                if (Flirts.IsCloselyRelated(sim.Partner, head))
                {
                    continue;
                }

                scoring.Add(sim, AddScoring("FindOwnHome", sim.Partner, sim));
            }

            ICollection <SimDescription> best = scoring.GetBestByPercent(100);

            if ((best == null) || (best.Count == 0))
            {
                IncStat("No Choices");
                return(false);
            }
            else
            {
                foreach (SimDescription sim in best)
                {
                    HouseholdBreakdown breakdown = new HouseholdBreakdown(Manager, this, UnlocalizedName, sim, HouseholdBreakdown.ChildrenMove.Scoring, false);

                    Add(frame, new StandardMoveInLotScenario(breakdown, 0), ScenarioResult.Failure);
                    Add(frame, new PostScenario(sim), ScenarioResult.Success);
                }
            }

            return(false);
        }