Beispiel #1
0
        protected void Tally(IScoringGenerator stats, string tag, bool ignoreHead)
        {
            if (!Common.kDebugging)
            {
                return;
            }

            string prefix = tag + " Break";

            if (ignoreHead)
            {
                prefix += " Ignore";
            }

            int humans = 0, pets = 0, plumbots = 0;

            stats.AddStat(prefix + ": Sims", mSims.Count);
            stats.AddStat(prefix + ": Going", GetGoingCount(ref humans, ref pets, ref plumbots));
            stats.AddStat(prefix + ": Going Human", humans);
            stats.AddStat(prefix + ": Going Pets", pets);
            stats.AddStat(prefix + ": Going Plumbots", plumbots);
            stats.AddStat(prefix + ": Staying", GetStayingCount(ref humans, ref pets, ref plumbots));
            stats.AddStat(prefix + ": Staying Human", humans);
            stats.AddStat(prefix + ": Staying Pets", pets);
            stats.AddStat(prefix + ": Staying Plumbots", plumbots);

            if (SimGoing)
            {
                stats.IncStat(prefix + ": SimGoing");
            }
        }
Beispiel #2
0
        public List <SimDescription> FindAnyFor(IScoringGenerator stats, SimDescription sim, bool allowAffair, bool force, ICollection <SimDescription> pool)
        {
            if ((sim == null) || (sim.Household == null))
            {
                stats.IncStat("Invalid Sim");
                return(new List <SimDescription>());
            }

            stats.AddStat("Pool", pool.Count);

            SimScoringList scoring = new SimScoringList("NewFlirt");

            foreach (SimDescription potential in pool)
            {
                stats.IncStat("FindAnyFor " + potential.FullName, Common.DebugLevel.Logging);

                if (IsValidLover(stats, sim, potential, allowAffair, force))
                {
                    scoring.Add(stats, "Single", potential, sim);
                }

                Main.Sleep("ManagerFlirt:FindAnyFor");
            }

            if (force)
            {
                return(scoring.GetBestByPercent(50f));
            }
            else
            {
                return(scoring.GetBestByMinScore(0));
            }
        }
        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;
        }
Beispiel #4
0
        public static bool PushForRepairman(IScoringGenerator stats, StoryProgressionObject manager, Household house)
        {
            List <SimDescription> choices = manager.Situations.GetFree(stats, new SimScoringList(stats, "Handiness", manager.Sims.TeensAndAdults, false).GetBestByMinScore(1), true);

            Dictionary <Household, List <GameObject> > repairs = new Dictionary <Household, List <GameObject> >();

            foreach (Lot lot in ManagerLot.GetOwnedLots(house))
            {
                GetRepairs(manager, lot.GetObjects <GameObject>(), repairs);
            }

            stats.AddStat("Residents", choices.Count);

            while (choices.Count > 0)
            {
                SimDescription choice = RandomUtil.GetRandomObjectFromList(choices);
                choices.Remove(choice);

                if (choice.CreatedSim == null)
                {
                    continue;
                }

                List <GameObject> repairWork = null;
                if (repairs.TryGetValue(house, out repairWork))
                {
                    if (PushInteractions(manager, choice, repairWork))
                    {
                        stats.IncStat("Resident Repairman");
                        return(true);
                    }
                    else
                    {
                        stats.IncStat("Push Fail");
                    }
                }
                else
                {
                    stats.IncStat("No Repairs Fonud");
                }
            }

            stats.IncStat("Service Repairman");

            Repairman instance = Repairman.Instance;

            if (instance != null)
            {
                instance.MakeServiceRequest(house.LotHome, true, ObjectGuid.InvalidObjectGuid);
            }
            return(true);
        }
Beispiel #5
0
        public List <SimDescription> FindExistingFriendFor(IScoringGenerator stats, SimDescription sim, int minLiking, bool ignoreBusy)
        {
            List <SimDescription> choices = new List <SimDescription>();

            List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(sim));

            if (relations.Count == 0)
            {
                stats.IncStat("Friend: None");
                return(choices);
            }

            stats.AddStat("Friend: Relations", relations.Count);

            foreach (Relationship relation in relations)
            {
                SimDescription other = relation.GetOtherSimDescription(sim);
                if (other == null)
                {
                    stats.IncStat("Friend: Bad Link");
                    continue;
                }

                stats.IncStat(other.FullName, Common.DebugLevel.Logging);

                if (relation.LTR.Liking <= minLiking)
                {
                    stats.IncStat("Friend: Unliked");
                }
                else if (SimTypes.IsDead(other))
                {
                    stats.IncStat("Friend: Dead");
                }
                else if ((!ignoreBusy) && (Situations.IsBusy(stats, other, true)))
                {
                    stats.IncStat("Friend: Busy");
                }
                else if (!Allow(stats, other))
                {
                    stats.IncStat("Friend: User Denied");
                }
                else
                {
                    choices.Add(other);
                }

                Main.Sleep("ManagerFriendship:FindExistingFriendFor");
            }

            return(choices);
        }
Beispiel #6
0
        public List <SimDescription> FindNemesisFor(IScoringGenerator stats, SimDescription sim, bool ignoreBusy)
        {
            List <SimDescription> choices = new List <SimDescription>();

            List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(sim));

            if (relations.Count == 0)
            {
                stats.IncStat("Nemesis: None");
                return(choices);
            }

            stats.AddStat("Nemesis: Relations", relations.Count);

            foreach (Relationship relation in relations)
            {
                SimDescription other = relation.GetOtherSimDescription(sim);
                if (other == null)
                {
                    stats.IncStat("Nemesis: Bad Link");
                    continue;
                }

                stats.IncStat(other.FullName, Common.DebugLevel.Logging);

                if (!relation.HasInteractionBitSet(LongTermRelationship.InteractionBits.MakeEnemy))
                {
                    stats.IncStat("Nemesis: Not");
                }
                else if (SimTypes.IsDead(other))
                {
                    stats.IncStat("Nemesis: Dead");
                }
                else if ((!ignoreBusy) && (Situations.IsBusy(stats, other, true)))
                {
                    stats.IncStat("Nemesis: Busy");
                }
                else if (!Allow(stats, other))
                {
                    stats.IncStat("Nemesis: User Denied");
                }
                else
                {
                    choices.Add(other);
                }

                Main.Sleep("ManagerFriendship:FindNemesisFor");
            }

            return(choices);
        }
        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);
        }
Beispiel #8
0
        protected void Perform(StoryProgressionObject manager, IScoringGenerator stats, string tag, List <SimDescription> movers, ChildrenMove children, bool ignoreHead)
        {
            if (movers.Count == 0)
            {
                return;
            }

            SimDescription focus = movers[0];

            if (focus.Household == null)
            {
                stats.IncStat(tag + " Break: No Home");

                mGoing.AddRange(movers);
                return;
            }
            else if (SimTypes.IsSpecial(focus))
            {
                stats.IncStat(tag + " Break: Special");

                mGoing.AddRange(movers);
                return;
            }
            else
            {
                bool adult = false;
                foreach (SimDescription sim in movers)
                {
                    if (manager.Households.AllowGuardian(sim))
                    {
                        adult = true;
                        break;
                    }
                }

                if (!adult)
                {
                    stats.IncStat(tag + " Break: Child Transfer");

                    mStaying.AddRange(Households.All(focus.Household));

                    foreach (SimDescription sim in movers)
                    {
                        if (SimTypes.IsSelectable(sim))
                        {
                            continue;
                        }

                        mStaying.Remove(sim);

                        mGoing.Add(sim);
                    }

                    return;
                }

                List <SimDescription> going   = new List <SimDescription>();
                List <SimDescription> staying = new List <SimDescription>();
                List <SimDescription> houseChildrenPetsPlumbots = new List <SimDescription>();

                bool ancestral = manager.GetValue <IsAncestralOption, bool>(focus.Household);

                SimDescription head = null;
                if (!ignoreHead)
                {
                    head = SimTypes.HeadOfFamily(focus.Household);
                }
                else if (ancestral)
                {
                    stats.IncStat(tag + " Break: Ancestral Head Denied");

                    mStaying.AddRange(Households.All(focus.Household));
                    return;
                }

                foreach (SimDescription sim in Households.All(focus.Household))
                {
                    stats.IncStat(sim.FullName, Common.DebugLevel.Logging);

                    SimDescription partner = null;
                    if (SimTypes.IsSelectable(sim))
                    {
                        stats.IncStat(tag + " Break: Active");

                        staying.Add(sim);
                    }
                    else if (!manager.Households.Allow(stats, sim, 0))
                    {
                        stats.IncStat(tag + " Break: User Denied");

                        staying.Add(sim);
                    }
                    else if (IsPartner(sim, staying, out partner))
                    {
                        stats.IncStat(tag + " Break: Partner Stay");

                        staying.Add(sim);
                    }
                    else if ((IsPartner(sim, movers, out partner)) || (IsPartner(sim, going, out partner)))
                    {
                        if ((head == sim) && (Households.NumHumans(focus.Household) != 1))
                        {
                            stats.IncStat(tag + " Break: Partner Go Denied");

                            going.Remove(partner);

                            staying.Add(sim);

                            if (!staying.Contains(partner))
                            {
                                staying.Add(partner);
                            }
                        }
                        else
                        {
                            stats.IncStat(tag + " Break: Partner Go");

                            going.Add(sim);
                        }
                    }
                    else if (movers.Contains(sim))
                    {
                        if ((head == sim) && (Households.NumHumans(focus.Household) != 1))
                        {
                            stats.IncStat(tag + " Break: Go Denied");

                            staying.Add(sim);
                        }
                        else
                        {
                            stats.IncStat(tag + " Break: Go");

                            going.Add(sim);
                        }
                    }
                    else if (head == sim)
                    {
                        stats.IncStat(tag + " Break: Head Stay");

                        staying.Add(sim);
                    }
                    else if ((sim.YoungAdultOrAbove) && (!sim.IsPet) && (!sim.IsEP11Bot))
                    {
                        stats.IncStat(tag + " Break: Stay");

                        staying.Add(sim);
                    }
                    else
                    {
                        houseChildrenPetsPlumbots.Add(sim);
                    }
                }

                List <SimDescription> extraChildrenPets = new List <SimDescription>();
                foreach (SimDescription child in houseChildrenPetsPlumbots)
                {
                    bool bGoing = false;
                    bool bMatch = false;

                    if (child.IsPet)
                    {
                        int goingLiking = int.MinValue;
                        foreach (SimDescription foci in going)
                        {
                            if (child.LastName == foci.LastName)
                            {
                                bMatch = true;

                                int liking = ManagerSim.GetLTR(child, foci);
                                if (goingLiking < liking)
                                {
                                    goingLiking = liking;
                                }
                            }
                        }

                        int stayingLiking = int.MinValue;
                        foreach (SimDescription foci in staying)
                        {
                            if (child.LastName == foci.LastName)
                            {
                                bMatch = true;

                                int liking = ManagerSim.GetLTR(child, foci);
                                if (stayingLiking < liking)
                                {
                                    stayingLiking = liking;
                                }
                            }
                        }

                        if (goingLiking > stayingLiking)
                        {
                            bGoing = true;
                        }
                    }
                    else
                    {
                        // this will handle plumbots that are related to the family (i.e. creation)
                        if (children == ChildrenMove.RelatedStay)
                        {
                            foreach (SimDescription parent in Relationships.GetParents(child))
                            {
                                if (staying.Contains(parent))
                                {
                                    bMatch = true;
                                }
                            }
                        }
                        else if (children == ChildrenMove.RelatedGo)
                        {
                            foreach (SimDescription parent in Relationships.GetParents(child))
                            {
                                if (going.Contains(parent))
                                {
                                    bMatch = true;
                                }
                            }
                        }
                        else if (children != ChildrenMove.Stay)
                        {
                            foreach (SimDescription foci in going)
                            {
                                if (Relationships.GetChildren(foci).Contains(child))
                                {
                                    bMatch = true;
                                    if ((children != ChildrenMove.Scoring) || (ScoreChildMove(stats, tag, child, going)))
                                    {
                                        bGoing = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (child.IsEP11Bot && !bGoing)
                    {
                        // test the liking for Plumbots without the HumanEmotion chip
                        if (!manager.Households.AllowGuardian(child))
                        {
                            bMatch = true;
                            int goingLiking = int.MinValue;
                            foreach (SimDescription foci in going)
                            {
                                int liking = ManagerSim.GetLTR(child, foci);
                                if (goingLiking < liking)
                                {
                                    goingLiking = liking;
                                }
                            }

                            int stayingLiking = int.MinValue;
                            foreach (SimDescription foci in staying)
                            {
                                int liking = ManagerSim.GetLTR(child, foci);
                                if (stayingLiking < liking)
                                {
                                    stayingLiking = liking;
                                }
                            }

                            if (goingLiking > stayingLiking)
                            {
                                bGoing = true;
                            }
                        }
                    }

                    stats.IncStat(child.FullName, Common.DebugLevel.Logging);

                    if ((!bMatch) && (manager.Households.AllowSoloMove(child)))
                    {
                        stats.IncStat(tag + " Break: Teen Stay");

                        staying.Add(child);
                    }
                    else if (bGoing)
                    {
                        if (children == ChildrenMove.Go)
                        {
                            stats.IncStat(tag + " Break: Child Go");
                        }
                        else
                        {
                            stats.IncStat(tag + " Break: Child Scoring Go");
                        }

                        going.Add(child);
                    }
                    else
                    {
                        if (children == ChildrenMove.Stay)
                        {
                            stats.IncStat(tag + " Break: Child Stay");
                        }
                        else if (bMatch)
                        {
                            stats.IncStat(tag + " Break: Child Scoring Stay");
                        }

                        extraChildrenPets.Add(child);
                    }
                }

                bool foundAdult = false, foundBlood = false;
                foreach (SimDescription sim in staying)
                {
                    if (manager.Deaths.IsDying(sim))
                    {
                        continue;
                    }

                    if (!manager.Households.AllowGuardian(sim))
                    {
                        continue;
                    }

                    if (ancestral)
                    {
                        if (Relationships.IsCloselyRelated(head, sim, false))
                        {
                            foundBlood = true;
                        }
                    }

                    foundAdult = true;
                }

                if ((!foundAdult) || ((ancestral) && (!foundBlood)))
                {
                    stats.AddStat(tag + " Break: Extra", extraChildrenPets.Count);

                    going.AddRange(extraChildrenPets);

                    if (ancestral)
                    {
                        stats.IncStat(tag + " Break: Ancestral");

                        mStaying.AddRange(going);
                        return;
                    }
                }

                mStaying.AddRange(staying);

                foreach (SimDescription sim in mStaying)
                {
                    going.Remove(sim);
                }

                mGoing.AddRange(going);
            }
        }
Beispiel #9
0
        public Lot FindLot(IScoringGenerator stats, ICollection <SimDescription> sims, int maximumLoan, FindLotFlags flags, LotPriceCheck inPriceRange)
        {
            stats.IncStat("FindLot");

            Dictionary <SimDescription, bool> lookup = new Dictionary <SimDescription, bool> ();

            Dictionary <Household, bool> homes = new Dictionary <Household, bool>();

            Dictionary <ulong, int> castes = new Dictionary <ulong, int>();
            int simCount = 0;

            bool allowRentable = true;

            if (sims != null)
            {
                foreach (SimDescription sim in sims)
                {
                    if (lookup.ContainsKey(sim))
                    {
                        continue;
                    }
                    lookup.Add(sim, true);

                    if (!Money.AllowRent(stats, sim))
                    {
                        allowRentable = false;
                    }

                    simCount++;

                    foreach (CasteOptions caste in GetData(sim).Castes)
                    {
                        int count;
                        if (castes.TryGetValue(caste.ID, out count))
                        {
                            castes[caste.ID] = count + 1;
                        }
                        else
                        {
                            castes[caste.ID] = 1;
                        }
                    }

                    if (SimTypes.IsSpecial(sim))
                    {
                        continue;
                    }

                    if (sim.Household == null)
                    {
                        continue;
                    }

                    homes[sim.Household] = true;
                }
            }

            int currentLotCost = 0;

            int availableFunds = maximumLoan;

            foreach (Household home in homes.Keys)
            {
                bool allMoving = true;
                foreach (SimDescription sim in home.AllSimDescriptions)
                {
                    if (!lookup.ContainsKey(sim))
                    {
                        allMoving = false;
                        break;
                    }
                }

                if (allMoving)
                {
                    if (home.LotHome == null)
                    {
                        availableFunds += home.NetWorth();
                    }
                    else if (GetValue <IsAncestralOption, bool>(home))
                    {
                        stats.IncStat("FindLot: Ancestral Fail");
                        return(null);
                    }
                    else
                    {
                        currentLotCost += GetLotCost(home.LotHome);

                        availableFunds += home.FamilyFunds + GetLotCost(home.LotHome);

                        availableFunds -= CalculateVehicleCost(home.LotHome);
                    }
                }
                else
                {
                    availableFunds += home.FamilyFunds;
                }
            }

            flags |= FindLotFlags.InspectCareerItems;

            stats.AddStat("Available Funds", availableFunds);

            List <Lot> choices = new List <Lot>();

            foreach (Lot lot in LotManager.AllLots)
            {
                string reason = HouseholdsEx.IsValidResidentialLot(lot);
                if (!string.IsNullOrEmpty(reason))
                {
                    stats.IncStat("Find Lot: " + reason);
                }
                else if (!Allow(stats, lot, sims, flags, allowRentable))
                {
                    continue;
                }
                else
                {
                    stats.AddStat("Lot Cost", GetLotCost(lot));

                    if ((inPriceRange == null) || (inPriceRange(stats, lot, currentLotCost, availableFunds) != CheckResult.Failure))
                    {
                        choices.Add(lot);
                    }
                }
            }

            if (choices.Count == 0)
            {
                stats.IncStat("Find Lot: Failure");
                return(null);
            }
            else if ((flags & FindLotFlags.CheapestHome) == FindLotFlags.CheapestHome)
            {
                choices.Sort(new Comparison <Lot>(HouseholdsEx.SortByCost));

                return(choices[0]);
            }
            else
            {
                return(RandomUtil.GetRandomObjectFromList(choices));
            }
        }
Beispiel #10
0
        protected void Perform(StoryProgressionObject manager, IScoringGenerator stats, string tag, List<SimDescription> movers, ChildrenMove children, bool ignoreHead)
        {
            if (movers.Count == 0) return;

            SimDescription focus = movers[0];

            if (focus.Household == null)
            {
                stats.IncStat(tag + " Break: No Home");

                mGoing.AddRange(movers);
                return;
            }
            else if (SimTypes.IsSpecial(focus))
            {
                stats.IncStat(tag + " Break: Special");

                mGoing.AddRange(movers);
                return;
            }
            else
            {
                bool adult = false;
                foreach (SimDescription sim in movers)
                {
                    if (manager.Households.AllowGuardian(sim))
                    {
                        adult = true;
                        break;
                    }
                }

                if (!adult)
                {
                    stats.IncStat(tag + " Break: Child Transfer");

                    mStaying.AddRange(Households.All(focus.Household));

                    foreach (SimDescription sim in movers)
                    {
                        if (SimTypes.IsSelectable(sim)) continue;

                        mStaying.Remove(sim);

                        mGoing.Add(sim);
                    }

                    return;
                }

                List<SimDescription> going = new List<SimDescription>();
                List<SimDescription> staying = new List<SimDescription>();
                List<SimDescription> houseChildrenPetsPlumbots = new List<SimDescription>();                

                bool ancestral = manager.GetValue<IsAncestralOption, bool>(focus.Household);

                SimDescription head = null;
                if (!ignoreHead)
                {
                    head = SimTypes.HeadOfFamily(focus.Household);
                }
                else if (ancestral)
                {
                    stats.IncStat(tag + " Break: Ancestral Head Denied");

                    mStaying.AddRange(Households.All(focus.Household));
                    return;
                }

                foreach (SimDescription sim in Households.All(focus.Household))
                {
                    stats.IncStat(sim.FullName, Common.DebugLevel.Logging);

                    SimDescription partner = null;
                    if (SimTypes.IsSelectable(sim))
                    {
                        stats.IncStat(tag + " Break: Active");

                        staying.Add(sim);
                    }
                    else if (!manager.Households.Allow(stats, sim, 0))
                    {
                        stats.IncStat(tag + " Break: User Denied");

                        staying.Add(sim);
                    }
                    else if (IsPartner(sim, staying, out partner))
                    {
                        stats.IncStat(tag + " Break: Partner Stay");

                        staying.Add(sim);
                    }
                    else if ((IsPartner(sim, movers, out partner)) || (IsPartner(sim, going, out partner)))
                    {
                        if ((head == sim) && (Households.NumHumans(focus.Household) != 1))
                        {
                            stats.IncStat(tag + " Break: Partner Go Denied");

                            going.Remove(partner);

                            staying.Add(sim);

                            if (!staying.Contains(partner))
                            {
                                staying.Add(partner);
                            }
                        }
                        else
                        {
                            stats.IncStat(tag + " Break: Partner Go");

                            going.Add(sim);
                        }
                    }
                    else if (movers.Contains(sim))
                    {
                        if ((head == sim) && (Households.NumHumans(focus.Household) != 1))
                        {
                            stats.IncStat(tag + " Break: Go Denied");

                            staying.Add(sim);
                        }
                        else
                        {
                            stats.IncStat(tag + " Break: Go");

                            going.Add(sim);
                        }
                    }
                    else if (head == sim)
                    {
                        stats.IncStat(tag + " Break: Head Stay");

                        staying.Add(sim);
                    }
                    else if ((sim.YoungAdultOrAbove) && (!sim.IsPet) && (!sim.IsEP11Bot))
                    {
                        stats.IncStat(tag + " Break: Stay");

                        staying.Add(sim);
                    }
                    else
                    {
                        houseChildrenPetsPlumbots.Add(sim);
                    }
                }

                List<SimDescription> extraChildrenPets = new List<SimDescription>();
                foreach (SimDescription child in houseChildrenPetsPlumbots)
                {
                    bool bGoing = false;
                    bool bMatch = false;

                    if (child.IsPet)
                    {
                        int goingLiking = int.MinValue;
                        foreach (SimDescription foci in going)
                        {
                            if (child.LastName == foci.LastName)
                            {
                                bMatch = true;

                                int liking = ManagerSim.GetLTR(child, foci);
                                if (goingLiking < liking)
                                {
                                    goingLiking = liking;
                                }
                            }
                        }

                        int stayingLiking = int.MinValue;
                        foreach (SimDescription foci in staying)
                        {
                            if (child.LastName == foci.LastName)
                            {
                                bMatch = true;

                                int liking = ManagerSim.GetLTR(child, foci);
                                if (stayingLiking < liking)
                                {
                                    stayingLiking = liking;
                                }
                            }
                        }

                        if (goingLiking > stayingLiking)
                        {
                            bGoing = true;
                        }
                    }
                    else
                    {
                        // this will handle plumbots that are related to the family (i.e. creation)
                        if (children == ChildrenMove.RelatedStay)
                        {
                            foreach (SimDescription parent in Relationships.GetParents(child))
                            {
                                if (staying.Contains(parent))
                                {
                                    bMatch = true;
                                }
                            }
                        }
                        else if (children == ChildrenMove.RelatedGo)
                        {
                            foreach (SimDescription parent in Relationships.GetParents(child))
                            {
                                if (going.Contains(parent))
                                {
                                    bMatch = true;
                                }
                            }
                        }
                        else if (children != ChildrenMove.Stay)
                        {
                            foreach (SimDescription foci in going)
                            {
                                if (Relationships.GetChildren(foci).Contains(child))
                                {
                                    bMatch = true;
                                    if ((children != ChildrenMove.Scoring) || (ScoreChildMove(stats, tag, child, going)))
                                    {
                                        bGoing = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (child.IsEP11Bot && !bGoing)
                    {
                        // test the liking for Plumbots without the HumanEmotion chip
                        if (!manager.Households.AllowGuardian(child))
                        {
                            bMatch = true;
                            int goingLiking = int.MinValue;
                            foreach (SimDescription foci in going)
                            {
                                int liking = ManagerSim.GetLTR(child, foci);
                                if (goingLiking < liking)
                                {
                                    goingLiking = liking;
                                }
                            }

                            int stayingLiking = int.MinValue;
                            foreach (SimDescription foci in staying)
                            {
                                int liking = ManagerSim.GetLTR(child, foci);
                                if (stayingLiking < liking)
                                {
                                    stayingLiking = liking;
                                }
                            }

                            if (goingLiking > stayingLiking)
                            {
                                bGoing = true;
                            }
                        }
                    }

                    stats.IncStat(child.FullName, Common.DebugLevel.Logging);

                    if ((!bMatch) && (manager.Households.AllowSoloMove(child)))
                    {
                        stats.IncStat(tag + " Break: Teen Stay");

                        staying.Add(child);
                    }
                    else if (bGoing)
                    {
                        if (children == ChildrenMove.Go)
                        {
                            stats.IncStat(tag + " Break: Child Go");
                        }
                        else
                        {
                            stats.IncStat(tag + " Break: Child Scoring Go");
                        }

                        going.Add(child);
                    }
                    else
                    {
                        if (children == ChildrenMove.Stay)
                        {
                            stats.IncStat(tag + " Break: Child Stay");
                        }
                        else if (bMatch)
                        {
                            stats.IncStat(tag + " Break: Child Scoring Stay");
                        }

                        extraChildrenPets.Add(child);
                    }
                }

                bool foundAdult = false, foundBlood = false;
                foreach (SimDescription sim in staying)
                {
                    if (manager.Deaths.IsDying(sim)) continue;

                    if (!manager.Households.AllowGuardian(sim)) continue;

                    if (ancestral)
                    {
                        if (Relationships.IsCloselyRelated(head, sim, false))
                        {
                            foundBlood = true;
                        }
                    }

                    foundAdult = true;
                }

                if ((!foundAdult) || ((ancestral) && (!foundBlood)))
                {
                    stats.AddStat(tag + " Break: Extra", extraChildrenPets.Count);

                    going.AddRange(extraChildrenPets);

                    if (ancestral)
                    {
                        stats.IncStat(tag + " Break: Ancestral");

                        mStaying.AddRange(going);
                        return;
                    }
                }

                mStaying.AddRange(staying);

                foreach (SimDescription sim in mStaying)
                {
                    going.Remove(sim);
                }

                mGoing.AddRange(going);
            }
        }
Beispiel #11
0
        protected void Tally(IScoringGenerator stats, string tag, bool ignoreHead)
        {
            if (!Common.kDebugging) return;

            string prefix = tag + " Break";
            if (ignoreHead)
            {
                prefix += " Ignore";
            }

            int humans = 0, pets = 0, plumbots = 0;

            stats.AddStat(prefix + ": Sims", mSims.Count);
            stats.AddStat(prefix + ": Going", GetGoingCount(ref humans, ref pets, ref plumbots));
            stats.AddStat(prefix + ": Going Human", humans);
            stats.AddStat(prefix + ": Going Pets", pets);
            stats.AddStat(prefix + ": Going Plumbots", plumbots);
            stats.AddStat(prefix + ": Staying", GetStayingCount(ref humans, ref pets, ref plumbots));
            stats.AddStat(prefix + ": Staying Human", humans);
            stats.AddStat(prefix + ": Staying Pets", pets);
            stats.AddStat(prefix + ": Staying Plumbots", plumbots);

            if (SimGoing)
            {
                stats.IncStat(prefix + ": SimGoing");
            }
        }
Beispiel #12
0
        public List <SimDescription> FindExistingFor(IScoringGenerator stats, SimDescription sim, bool disallowPartner)
        {
            if ((sim == null) || (sim.Household == null))
            {
                stats.IncStat("Invalid Sim");
                return(new List <SimDescription>());
            }

            List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(sim));

            if (relations.Count == 0)
            {
                stats.IncStat("None");
                return(new List <SimDescription>());
            }

            List <SimDescription> list = new List <SimDescription>();

            stats.AddStat("Relations", relations.Count);

            foreach (Relationship relation in relations)
            {
                SimDescription other = relation.GetOtherSimDescription(sim);
                if (other == null)
                {
                    stats.IncStat("Bad Link");
                    continue;
                }

                stats.IncStat(other.FullName, Common.DebugLevel.Logging);

                if (relation.LTR.Liking <= 0)
                {
                    stats.AddStat("Unliked", relation.LTR.Liking);
                }
                else if (!relation.AreRomantic())
                {
                    stats.IncStat("No Romantic");
                }
                else if ((disallowPartner) && (sim.Partner == other))
                {
                    stats.IncStat("Partner");
                }
                else if (SimTypes.IsDead(other))
                {
                    stats.IncStat("Dead");
                }
                else if (Situations.IsBusy(stats, other, true))
                {
                    stats.IncStat("Other Busy");
                }
                else if (!mFlirtPool.Contains(other))
                {
                    stats.IncStat("Not Pool");
                }
                else if (!Allow(stats, sim, other))
                {
                    stats.IncStat("User Denied");
                }
                else if (other.Household == null)
                {
                    stats.IncStat("Invalid Sim");
                }
                else if ((SimTypes.IsSpecial(sim)) && (SimTypes.IsSpecial(other)))
                {
                    stats.IncStat("Both Special");
                }
                else if (IsActiveInvolved(other))
                {
                    stats.IncStat("Other Active Involved");
                }
                else
                {
                    list.Add(other);
                }

                Main.Sleep("ManagerFlirt:FindExistingFor");
            }

            return(list);
        }