Example #1
0
        protected string GetDetails(List <IMiniSimDescription> sims)
        {
            long lUnemployed = 0, lRetired = 0, lWorkingPension = 0, lTotalWorking = 0;
            long lDemotionPerf = 0;
            long lPositivePerf = 0;

            Dictionary <OccupationNames, long> list = new Dictionary <OccupationNames, long>();

            foreach (IMiniSimDescription miniSim in sims)
            {
                SimDescription member = miniSim as SimDescription;
                if (member == null)
                {
                    continue;
                }

                try
                {
                    if (member.Occupation == null)
                    {
                        if ((!member.TeenOrAbove) || (!member.IsHuman))
                        {
                            continue;
                        }

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

                        if ((member.CareerManager != null) && (member.CareerManager.RetiredCareer != null))
                        {
                            lRetired++;
                        }
                        else
                        {
                            lUnemployed++;
                        }
                    }
                    else
                    {
                        if (list.ContainsKey(member.Occupation.Guid))
                        {
                            list[member.Occupation.Guid]++;
                        }
                        else
                        {
                            list.Add(member.Occupation.Guid, 1);
                        }

                        float performance = StatusJobPerformance.GetPerformance(member);
                        if (performance >= 0.0)
                        {
                            lPositivePerf++;
                        }
                        else if (performance < Sims3.Gameplay.Careers.Career.kDemotionThreshold)
                        {
                            lDemotionPerf++;
                        }
                        if (member.CareerManager.RetiredCareer != null)
                        {
                            lWorkingPension++;
                        }
                        lTotalWorking++;
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(member, e);
                }
            }

            List <string> sorted = new List <string>();

            foreach (KeyValuePair <OccupationNames, long> value in list)
            {
                Occupation career = CareerManager.GetStaticOccupation(value.Key);
                if (career == null)
                {
                    continue;
                }

                sorted.Add(Common.Localize("JobsByCareerSummary:Element", false, new object[] { career.CareerName, value.Value }));
            }

            sorted.Sort(StringComparer.CurrentCulture);

            string body = null;

            foreach (string value in sorted)
            {
                body += value;
            }

            return(Common.Localize("JobsByCareerSummary:Body", false, new object[] { lUnemployed, lRetired, lWorkingPension, body, lTotalWorking, lPositivePerf, lDemotionPerf }));
        }
Example #2
0
        protected string GetDetails(List <IMiniSimDescription> sims)
        {
            long lUnemployed = 0, lRetired = 0, lWorkingPension = 0, lTotalWorking = 0;
            long lDemotionPerf = 0;
            long lPositivePerf = 0;

            List <TallyElement> levels = new List <TallyElement>();

            for (int level = 0; level < 10; level++)
            {
                levels.Add(new TallyElement(level + 1));
            }

            foreach (IMiniSimDescription miniSim in sims)
            {
                SimDescription member = miniSim as SimDescription;
                if (member == null)
                {
                    continue;
                }

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

                if (!member.YoungAdultOrAbove)
                {
                    continue;
                }

                if (member.Occupation == null)
                {
                    if ((member.CareerManager != null) && (member.CareerManager.RetiredCareer != null))
                    {
                        lRetired++;
                    }
                    else
                    {
                        lUnemployed++;
                    }
                }
                else
                {
                    Career career = member.Occupation as Career;
                    if ((career != null) && (career.CareerLevel == 1) && (career.CurLevel != null) && (career.CurLevel.DayLength == 0))
                    {
                        lRetired++;
                    }
                    else
                    {
                        float performance = StatusJobPerformance.GetPerformance(member);

                        levels[member.Occupation.CareerLevel - 1].Add(performance);

                        if (performance >= 0.0)
                        {
                            lPositivePerf++;
                        }
                        else if (performance < Sims3.Gameplay.Careers.Career.kDemotionThreshold)
                        {
                            lDemotionPerf++;
                        }

                        if (member.CareerManager.RetiredCareer != null)
                        {
                            lWorkingPension++;
                        }
                        lTotalWorking++;
                    }
                }
            }

            string body = null;

            for (int level = 0; level < levels.Count; level++)
            {
                body += levels[level].ToString();
            }

            return(Common.Localize("JobsByLevel:Body", false, new object[] { lUnemployed, lRetired, lWorkingPension, body, lTotalWorking, lPositivePerf, lDemotionPerf }));
        }
Example #3
0
 protected override float GetValue(SimDescription me)
 {
     return(StatusJobPerformance.GetPerformance(me));
 }
Example #4
0
        protected string GetDetails(List <IMiniSimDescription> sims)
        {
            long lUnemployed = 0, lRetired = 0, lTotalWorking = 0, lNoPerfCount = 0, lNoPerfLevel = 0;

            List <long> negPerfLevel = new List <long>();
            List <long> posPerfLevel = new List <long>();

            List <long> negPerfCount = new List <long>();
            List <long> posPerfCount = new List <long>();

            for (int perf = 0; perf < 10; perf++)
            {
                negPerfLevel.Add(0);
                posPerfLevel.Add(0);

                negPerfCount.Add(0);
                posPerfCount.Add(0);
            }

            foreach (IMiniSimDescription miniSim in sims)
            {
                SimDescription member = miniSim as SimDescription;
                if (member == null)
                {
                    continue;
                }

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

                if (!member.TeenOrAbove)
                {
                    continue;
                }

                if (member.Occupation == null)
                {
                    if (member.CareerManager.RetiredCareer != null)
                    {
                        lRetired++;
                    }
                    else if (!member.IsPet)
                    {
                        lUnemployed++;
                    }
                }
                else
                {
                    Career career = member.Occupation as Career;
                    if ((career != null) && (career.CareerLevel == 1) && (career.CurLevel != null) && (career.CurLevel.DayLength == 0))
                    {
                        lRetired++;
                    }
                    else
                    {
                        float perf = StatusJobPerformance.GetPerformance(member);
                        if (perf == 0)
                        {
                            lNoPerfCount++;

                            lNoPerfLevel += member.Occupation.CareerLevel;
                        }
                        else if (perf > 0)
                        {
                            int iPerf = (int)Math.Ceiling(perf / 10f);
                            if (iPerf > 9)
                            {
                                iPerf = 9;
                            }
                            posPerfCount[iPerf]++;

                            posPerfLevel[iPerf] += member.Occupation.CareerLevel;
                        }
                        else
                        {
                            int iPerf = (int)Math.Ceiling(-perf / 10f);
                            if (iPerf > 9)
                            {
                                iPerf = 9;
                            }
                            negPerfCount[iPerf]++;

                            negPerfLevel[iPerf] += member.Occupation.CareerLevel;
                        }

                        lTotalWorking++;
                    }
                }
            }

            string posBody = null, negBody = null;

            for (int perf = negPerfCount.Count - 1; perf >= 1; perf--)
            {
                negBody += Common.Localize("JobsByPerf:Element1", false, new object[] { (perf * 10) });
                if (negPerfCount[perf] == 0)
                {
                    negBody += "-";
                }
                else
                {
                    negBody += Common.Localize("JobsByPerf:Element2", false, new object[] { negPerfCount[perf], (((float)negPerfLevel[perf]) / negPerfCount[perf]) });
                }
            }

            if (lNoPerfCount == 0)
            {
                posBody += "-";
            }
            else
            {
                posBody += Common.Localize("JobsByPerf:Element2", false, new object[] { lNoPerfCount, (((float)lNoPerfLevel) / lNoPerfCount) });
            }

            for (int perf = 1; perf < posPerfCount.Count; perf++)
            {
                posBody += Common.Localize("JobsByPerf:Element3", false, new object[] { (perf * 10) });
                if (posPerfCount[perf] == 0)
                {
                    posBody += "-";
                }
                else
                {
                    posBody += Common.Localize("JobsByPerf:Element2", false, new object[] { posPerfCount[perf], (((float)posPerfLevel[perf]) / posPerfCount[perf]) });
                }
            }

            return(Common.Localize("JobsByPerf:Body", false, new object[] { lUnemployed, lRetired, negBody, posBody, lTotalWorking }));
        }
Example #5
0
        protected override OptionResult RunAll(List <IMiniSimDescription> sims)
        {
            Dictionary <OccupationNames, Item> lookup = new Dictionary <OccupationNames, Item>();

            foreach (IMiniSimDescription miniSim in sims)
            {
                SimDescription member = miniSim as SimDescription;
                if (member == null)
                {
                    continue;
                }

                if (member.Occupation == null)
                {
                    continue;
                }

                Item item;
                if (!lookup.TryGetValue(member.Occupation.Guid, out item))
                {
                    item = new Item(member.Occupation.Guid);
                    lookup.Add(member.Occupation.Guid, item);
                }

                item.IncCount();
                item.mSims.Add(new CareerElement(member.Occupation.CareerLevel, member, member.Occupation.Boss, StatusJobPerformance.GetPerformance(member)));
            }

            Item choice = new CommonSelection <Item>(Name, lookup.Values).SelectSingle();

            if (choice == null)
            {
                return(OptionResult.Failure);
            }

            List <CareerElement> list = choice.mSims;

            list.Sort(new CareerElement.CompareByLevel());

            string msg = null;

            foreach (CareerElement element in list)
            {
                if (msg != null)
                {
                    msg += Common.NewLine;
                }
                msg += Common.Localize("JobsByCareer:Employee", element.mSim.IsFemale, new object[] { element.mLevel, element.mSim, element.mPerf });

                if (element.mBoss != null)
                {
                    msg += Common.NewLine + Common.Localize("JobsByCareer:Boss", element.mBoss.IsFemale, new object[] { element.mBoss });
                }
            }

            string careerName = null;

            Occupation career = CareerManager.GetStaticOccupation(choice.Value);

            if (career != null)
            {
                careerName = career.CareerName;
            }

            Sims3.UI.SimpleMessageDialog.Show(careerName, msg);
            return(OptionResult.SuccessRetain);
        }
Example #6
0
        protected static string GetJob(SimDescription me)
        {
            bool bSeparator = true;

            string msg = null;

            try
            {
                if (me.AssignedRole != null)
                {
                    msg += Common.Localize("Status:Role", me.IsFemale, new object[] { Roles.GetLocalizedName(me.AssignedRole) });

                    DateAndTime start = DateAndTime.Invalid;
                    DateAndTime end   = DateAndTime.Invalid;
                    if (Roles.GetRoleHours(me, ref start, ref end))
                    {
                        msg += Common.Localize("Status:CareerHours", me.IsFemale, new object[] { start.ToString(), end.ToString() });
                    }
                }

                if (SimTypes.InServicePool(me))
                {
                    msg += Common.Localize("Status:TypeService", me.IsFemale, new object[] { Common.LocalizeEAString("Ui/Caption/Services/Service:" + me.CreatedByService.ServiceType.ToString()) });
                }

                NpcDriversManager.NpcDrivers driverType;
                if (SimTypes.InCarPool(me, out driverType))
                {
                    msg += Common.Localize("Status:TypeService", me.IsFemale, new object[] { Common.Localize("CarpoolType:" + driverType.ToString()) });
                }

                PetPoolType pool = SimTypes.GetPetPool(me);
                if (pool != PetPoolType.None)
                {
                    msg += Common.NewLine + Common.Localize("Status:PetPool", me.IsFemale, new object[] { Common.Localize("PetPool:" + pool) });
                }

                if (me.Occupation != null)
                {
                    msg       += Common.Localize("Status:Career", me.IsFemale, new object[] { me.Occupation.CareerName });
                    bSeparator = false;

                    msg += Common.Localize("Status:CareerLevel", me.IsFemale, new object[] { me.Occupation.CurLevelJobTitle, me.Occupation.CareerLevel });

                    int payPerHourBase  = 0;
                    int payPerHourExtra = 0;

                    Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career;
                    if (career != null)
                    {
                        if (career.CurLevel != null)
                        {
                            payPerHourBase = (int)career.CurLevel.PayPerHourBase;
                        }
                        payPerHourExtra = (int)(career.mPayPerHourExtra + career.mBonusPayFromDegreePerHour);
                    }
                    else
                    {
                        payPerHourBase = (int)me.Occupation.PayPerHourOrStipend;
                    }

                    msg += Common.Localize("Status:CareerExtra", me.IsFemale, new object[] { payPerHourBase, payPerHourExtra, me.Occupation.AverageTimeToReachWork });

                    string days = DaysToString(me.Occupation.DaysOfWeekToWork);

                    msg += Common.Localize("Status:CareerDays", me.IsFemale, new object[] { days });

                    msg += Common.Localize("Status:CareerHours", me.IsFemale, new object[] { me.Occupation.StartTimeText, me.Occupation.FinishTimeText });

                    msg += Common.Localize("Status:CareerDaysOff", me.IsFemale, new object[] { me.Occupation.PaidDaysOff, me.Occupation.mUnpaidDaysOff });

                    float performance = StatusJobPerformance.GetPerformance(me);
                    if (performance != 0f)
                    {
                        msg += Common.Localize("Status:Performance", me.IsFemale, new object[] { (int)performance });
                    }

                    if (me.Occupation.Boss != null)
                    {
                        msg += Common.Localize("Status:Boss", me.IsFemale, new object[] { me.Occupation.Boss });
                    }

                    if (me.Occupation.Coworkers != null)
                    {
                        msg += Common.Localize("Status:Coworkers", me.IsFemale, new object[] { me.Occupation.Coworkers.Count });
                        foreach (SimDescription sim in me.Occupation.Coworkers)
                        {
                            if (sim == null)
                            {
                                continue;
                            }

                            msg += Common.NewLine + sim.FullName;
                        }
                    }
                }
                else if (me.TeenOrAbove)
                {
                    msg       += Common.Localize("Status:Career", me.IsFemale, new object[] { Common.Localize("Status:Notemployed") });
                    bSeparator = false;
                }

                if (me.CareerManager != null)
                {
                    if (me.CareerManager.RetiredCareer != null)
                    {
                        if (bSeparator)
                        {
                            msg += Common.NewLine;
                        }

                        msg += Common.Localize("Status:Retired", me.IsFemale, new object[] { me.CareerManager.RetiredCareer.CurLevelJobTitle });
                        msg += Common.Localize("Status:Pension", me.IsFemale, new object[] { me.CareerManager.RetiredCareer.PensionAmount() });
                    }
                }
            }
            catch (Exception e)
            {
                msg += "EXCEPTION";

                Common.Exception(me, null, msg, e);
            }

            return(msg);
        }