Exemple #1
0
        protected bool DuoSameHouse(SimDescription a, SimDescription b)
        {
            if (Flirts.IsCloselyRelated(a, b))
            {
                return(true);
            }

            return(!mNewHouse);
        }
Exemple #2
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));
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }