public CompetitionLevel Update(CompetitionLevel entity)
        {
            var obj = FindById(entity.IdLevel);

            if (obj != null)
            {
                obj = entity;
            }
            _context.SaveChanges();
            return(obj);
        }
 private CompetitionLevel SetEnumValue(CompetitionLevel source, CompetitionLevel value, bool reset = false)
 {
     if (reset)
     {
         return(source & ~(value));
     }
     else
     {
         return(source | value);
     }
 }
 private static bool CheckEnumValue(CompetitionLevel source, CompetitionLevel check)
 {
     return((source & check) == check);
 }
Пример #4
0
            protected override bool PrivateUpdate(ScenarioFrame frame)
            {
                mPushes++;

                if (Sim.CreatedSim == null)
                {
                    IncStat("Hibernating");
                    return false;
                }
                else if (Sim.CreatedSim.InteractionQueue == null)
                {
                    IncStat("No Queue");
                    return false;
                }

                if (mPushes <= 1)
                {
                    Sim.CreatedSim.InteractionQueue.CancelAllInteractions();
                }

                bool maxSkill = true;

                List<SkillNames> practiceSkills = new List<SkillNames>();

                RidingSkill riding = Sim.SkillManager.GetSkill<RidingSkill>(SkillNames.Riding);
                if ((riding == null) || (!riding.ReachedMaxLevel()))
                {
                    maxSkill = false;

                    practiceSkills.Add(SkillNames.Riding);
                }

                Racing racing = mHorse.SkillManager.GetSkill<Racing>(SkillNames.Racing);
                if ((racing == null) || (!racing.ReachedMaxLevel()))
                {
                    maxSkill = false;

                    practiceSkills.Add(SkillNames.Racing);
                }

                Jumping jumping = mHorse.SkillManager.GetSkill<Jumping>(SkillNames.Jumping);
                if ((jumping == null) || (!jumping.ReachedMaxLevel()))
                {
                    maxSkill = false;

                    practiceSkills.Add(SkillNames.Jumping);
                }

                List<EquestrianCenter> lotCenters = new List<EquestrianCenter>();
                List<EquestrianCenter> centers = new List<EquestrianCenter>();
                foreach (EquestrianCenter hole in Sims3.Gameplay.Queries.GetObjects<EquestrianCenter>())
                {
                    if (Sim.CreatedSim.LotCurrent == hole.LotCurrent)
                    {
                        lotCenters.Add(hole);
                    }

                    centers.Add(hole);
                }

                if (lotCenters.Count > 0)
                {
                    centers = lotCenters;
                }

                EquestrianCenter center = null;

                if (centers.Count > 0)
                {
                    center = RandomUtil.GetRandomObjectFromList(centers);
                }
                else
                {
                    IncStat("No Centers");
                }

                if (center != null)
                {
                    CompetitionType type = CompetitionType.Racing;

                    bool canCompete = (maxSkill) || (RandomUtil.CoinFlip());

                    if (canCompete)
                    {
                        List<CompetitionType> types = new List<CompetitionType>(sTypes);

                        while (types.Count > 0)
                        {
                            type = RandomUtil.GetRandomObjectFromList(types);
                            types.Remove(type);

                            canCompete = false;

                            switch (type)
                            {
                                case CompetitionType.CrossCountry:
                                    if (RidingSkill.CanEnterCrossCountryCompetition(Sim))
                                    {
                                        canCompete = true;
                                    }
                                    break;
                                case CompetitionType.Jumping:
                                    if (!RidingSkill.CanEnterJumpingCompetition(Sim))
                                    {
                                        canCompete = true;
                                    }
                                    break;
                                case CompetitionType.Racing:
                                    if (!RidingSkill.CanEnterRacingCompetition(Sim))
                                    {
                                        canCompete = true;
                                    }
                                    break;
                            }

                            if (canCompete)
                            {
                                break;
                            }
                        }
                    }

                    if (canCompete)
                    {
                        List<CompetitionLevel> levels = new List<CompetitionLevel>();

                        foreach (CompetitionLevel level in sLevels)
                        {
                            GreyedOutTooltipCallback callback = null;
                            if (EquestrianCenter.EnterEquestrianCompetition.CanEnterCompetition(type, level, Sim.CreatedSim, false, ref callback))
                            {
                                levels.Add(level);
                            }
                        }

                        if (levels.Count == 0)
                        {
                            IncStat("No Levels");
                        }
                        else
                        {
                            CompetitionLevel level = RandomUtil.GetRandomObjectFromList(levels);

                            if (Common.kDebugging)
                            {
                                Common.DebugNotify("Compete " + type + " " + level, Sim.CreatedSim);
                            }

                            if (!Situations.PushVisit(this, Sim, center.LotCurrent))
                            {
                                IncStat("Visit Fail");
                                return false;
                            }
                            else if (Situations.PushInteraction<EquestrianCenter>(this, Sim, center, new EnterEquestrianCompetitionEx.Definition(type, level)))
                            {
                                return true;
                            }
                            else
                            {
                                IncStat("Competition Fail");
                            }
                        }
                    }
                }

                if (practiceSkills.Count == 0)
                {
                    IncStat("No Practice Skills");
                    return false;
                }

                bool practiceJumping = true;

                if ((riding != null) & (riding.SkillLevel >= RidingSkill.kLevelForTrainForRacing))
                {
                    switch (RandomUtil.GetRandomObjectFromList(practiceSkills))
                    {
                        case SkillNames.Riding:
                            practiceJumping = RandomUtil.CoinFlip();
                            break;
                        case SkillNames.Racing:
                            practiceJumping = false;
                            break;
                    }
                }

                if (!practiceJumping)
                {
                    List<TrainingPosts> lotPosts = new List<TrainingPosts>();
                    List<TrainingPosts> posts = new List<TrainingPosts>();
                    foreach(TrainingPosts post in Sims3.Gameplay.Queries.GetObjects<TrainingPosts>())
                    {
                        if (Sim.CreatedSim.LotCurrent == post.LotCurrent)
                        {
                            lotPosts.Add(post);
                        }

                        posts.Add(post);
                    }

                    if (lotPosts.Count > 0)
                    {
                        posts = lotPosts;
                    }

                    if (posts.Count > 0)
                    {
                        TrainingPosts choice = RandomUtil.GetRandomObjectFromList(posts);

                        if (!Situations.PushVisit(this, Sim, choice.LotCurrent))
                        {
                            IncStat("Visit Fail");
                            return false;
                        }
                        else if (Situations.PushInteraction<TrainingPosts>(this, Sim, choice, new ManagerSituation.WithCallbackPush(Manager, TrainingPosts.RiderTrainForRacing.Singleton, null, null, new MountScenario(Sim, mPushes))))
                        {
                            return true;
                        }
                        else
                        {
                            IncStat("Traning Fail");
                        }
                    }
                }

                int ridingSkill = 0;
                if (riding != null)
                {
                    ridingSkill = riding.SkillLevel;
                }

                List<HorseJump> lotJumps = new List<HorseJump>();
                List<HorseJump> jumps = new List<HorseJump>();
                foreach (HorseJump jump in Sims3.Gameplay.Queries.GetObjects<HorseJump>())
                {
                    if (jump.LotCurrent == null) continue;

                    if (!jump.LotCurrent.IsCommunityLot)
                    {
                        if (!jump.LotCurrent.CanSimTreatAsHome(Sim.CreatedSim)) continue;
                    }

                    if (jump.JumpTuning == null) continue;

                    if (jump.JumpTuning.HighSuccessChances[ridingSkill] < 0.75) continue;

                    if (Sim.CreatedSim.LotCurrent == jump.LotCurrent)
                    {
                        lotJumps.Add(jump);
                    }

                    jumps.Add(jump);
                }

                if (lotJumps.Count > 0)
                {
                    jumps = lotJumps;
                }

                if (jumps.Count > 0)
                {
                    HorseJump choice = RandomUtil.GetRandomObjectFromList(jumps);

                    if (!Situations.PushVisit(this, Sim, choice.LotCurrent))
                    {
                        IncStat("Visit Fail");
                        return false;
                    }
                    else if (Situations.PushInteraction<HorseJump>(this, Sim, choice, new ManagerSituation.WithCallbackPush(Manager, HorseJump.Jump.Singleton, null, null, new MountScenario(Sim, mPushes))))
                    {
                        return true;
                    }
                    else
                    {
                        IncStat("Jump Fail");
                        return false;
                    }
                }
                else
                {
                    IncStat("No Jump Choices");
                    return false;
                }
            }
        private void ShowCompetitionEndScoreEx(CompetitionType type, CompetitionLevel level, string competitionName)
        {
            mCurrentScore += mMoodScoreBonus;
            int currentMoneyReward = 0x0;
            List<EquestrianCenter.PositionScoring> positionScoringTuning = EquestrianCenter.PositionScoringTuning;
            if (mCompetitionType == CompetitionType.Racing)
            {
                RaceShuffle();
            }
            mCurrentPosition = GetPlaceInRace(type, level, EquestrianCenter.kNumberOfCompetitors, mCurrentScore, out currentMoneyReward);
            Responder.Instance.HudModel.UpdateCompetitionStanding(this);
            FinishType poorFinish = FinishType.PoorFinish;
            if ((mCurrentPosition >= EquestrianCenter.kPositionsForFinishTypes[0x1]) && (mCurrentPosition < EquestrianCenter.kPositionsForFinishTypes[0x0]))
            {
                poorFinish = FinishType.StandardFinish;
            }
            else if (mCurrentPosition == EquestrianCenter.kPositionsForFinishTypes[0x2])
            {
                poorFinish = FinishType.Victory;
            }
            RidingSkill skill = Actor.SimDescription.SkillManager.GetSkill<RidingSkill>(SkillNames.Riding);
            skill.AddPoints(EquestrianCenter.kSkillPointsAdded[0x0]);
            bool flag = type == CompetitionType.CrossCountry;
            if ((flag || (type == CompetitionType.Racing)) && !Horse.BuffManager.HasElement(BuffNames.PetSkillFatigue))
            {
                Horse.SimDescription.SkillManager.GetSkill<Racing>(SkillNames.Racing).AddPoints(EquestrianCenter.kSkillPointsAdded[0x1]);
            }
            if ((flag || (type == CompetitionType.Jumping)) && !Horse.BuffManager.HasElement(BuffNames.PetSkillFatigue))
            {
                Horse.SimDescription.SkillManager.GetSkill<Jumping>(SkillNames.Jumping).AddPoints(EquestrianCenter.kSkillPointsAdded[0x2]);
            }
            if (currentMoneyReward != 0x0)
            {
                if (skill.IsEquestrianChampion())
                {
                    currentMoneyReward = (int)(currentMoneyReward * RidingSkill.EquestrianChampionPrizeMultiplier);
                }
                Actor.ModifyFunds(currentMoneyReward);
                skill.UpdateXpForEarningMoney(currentMoneyReward);
                EventTracker.SendEvent(new JockeyEvent(EventTypeId.kJockeyEvent, Actor, currentMoneyReward));
            }

            string str = Localization.LocalizeString(false, "UI/Caption/HudCompetitionPanel/Place:Position" + mCurrentPosition, new object[0x0]);
            switch (poorFinish)
            {
                case FinishType.PoorFinish:
                    if (Actor.IsActiveSim)
                    {
                        Audio.StartSound("sting_eques_poor_finish");
                    }

                    if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse)))
                    {
                        Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterPoorFinish, null, Actor, new object[] { Horse, Actor, str, competitionName });
                    }
                    return;

                case FinishType.StandardFinish:
                    if (Actor.IsActiveSim)
                    {
                        Audio.StartSound("sting_eques_standard_finish");
                    }

                    if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse)))
                    {
                        Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterStandardFinish, null, Actor, new object[] { Horse, Actor, str, competitionName });
                    }
                    return;

                case FinishType.Victory:
                    RidingSkill.WonCompetition(Actor.SimDescription, Horse.SimDescription, type, level);
                    if (Actor.IsActiveSim)
                    {
                        Audio.StartSound("sting_eques_victory_finish");
                    }
                    if (!Target.mPlayerHasParticipatedAndWon)
                    {
                        Target.mPlayerHasParticipatedAndWon = true;
                        EventTracker.SendEvent(new EquestrianCompetitionEvent(EventTypeId.kEquestrianCompetition, Actor.FirstName, Actor.IsFemale, Horse.FirstName, Horse.IsFemale, competitionName));
                    }

                    if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse)))
                    {
                        Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterVictory, null, Actor, new object[] { Horse, Actor, competitionName });
                    }
                    AddCompetitionTrophy(type, level);
                    return;
            }
        }
 public Definition(CompetitionType type, CompetitionLevel level)
     : base(type, level)
 { }
 public CompetitionLevel Add(CompetitionLevel entity)
 {
     _context.CompetitionLevel.Add(entity);
     _context.SaveChanges();
     return(entity);
 }
Пример #8
0
        private void ShowCompetitionEndScoreEx(CompetitionType type, CompetitionLevel level, string competitionName)
        {
            mCurrentScore += mMoodScoreBonus;
            int currentMoneyReward = 0x0;
            List <EquestrianCenter.PositionScoring> positionScoringTuning = EquestrianCenter.PositionScoringTuning;

            if (mCompetitionType == CompetitionType.Racing)
            {
                RaceShuffle();
            }
            mCurrentPosition = GetPlaceInRace(type, level, EquestrianCenter.kNumberOfCompetitors, mCurrentScore, out currentMoneyReward);
            Responder.Instance.HudModel.UpdateCompetitionStanding(this);
            FinishType poorFinish = FinishType.PoorFinish;

            if ((mCurrentPosition >= EquestrianCenter.kPositionsForFinishTypes[0x1]) && (mCurrentPosition < EquestrianCenter.kPositionsForFinishTypes[0x0]))
            {
                poorFinish = FinishType.StandardFinish;
            }
            else if (mCurrentPosition == EquestrianCenter.kPositionsForFinishTypes[0x2])
            {
                poorFinish = FinishType.Victory;
            }
            RidingSkill skill = Actor.SimDescription.SkillManager.GetSkill <RidingSkill>(SkillNames.Riding);

            skill.AddPoints(EquestrianCenter.kSkillPointsAdded[0x0]);
            bool flag = type == CompetitionType.CrossCountry;

            if ((flag || (type == CompetitionType.Racing)) && !Horse.BuffManager.HasElement(BuffNames.PetSkillFatigue))
            {
                Horse.SimDescription.SkillManager.GetSkill <Racing>(SkillNames.Racing).AddPoints(EquestrianCenter.kSkillPointsAdded[0x1]);
            }
            if ((flag || (type == CompetitionType.Jumping)) && !Horse.BuffManager.HasElement(BuffNames.PetSkillFatigue))
            {
                Horse.SimDescription.SkillManager.GetSkill <Jumping>(SkillNames.Jumping).AddPoints(EquestrianCenter.kSkillPointsAdded[0x2]);
            }
            if (currentMoneyReward != 0x0)
            {
                if (skill.IsEquestrianChampion())
                {
                    currentMoneyReward = (int)(currentMoneyReward * RidingSkill.EquestrianChampionPrizeMultiplier);
                }
                Actor.ModifyFunds(currentMoneyReward);
                skill.UpdateXpForEarningMoney(currentMoneyReward);
                EventTracker.SendEvent(new JockeyEvent(EventTypeId.kJockeyEvent, Actor, currentMoneyReward));
            }

            string str = Localization.LocalizeString(false, "UI/Caption/HudCompetitionPanel/Place:Position" + mCurrentPosition, new object[0x0]);

            switch (poorFinish)
            {
            case FinishType.PoorFinish:
                if (Actor.IsActiveSim)
                {
                    Audio.StartSound("sting_eques_poor_finish");
                }

                if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse)))
                {
                    Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterPoorFinish, null, Actor, new object[] { Horse, Actor, str, competitionName });
                }
                return;

            case FinishType.StandardFinish:
                if (Actor.IsActiveSim)
                {
                    Audio.StartSound("sting_eques_standard_finish");
                }

                if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse)))
                {
                    Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterStandardFinish, null, Actor, new object[] { Horse, Actor, str, competitionName });
                }
                return;

            case FinishType.Victory:
                RidingSkill.WonCompetition(Actor.SimDescription, Horse.SimDescription, type, level);
                if (Actor.IsActiveSim)
                {
                    Audio.StartSound("sting_eques_victory_finish");
                }
                if (!Target.mPlayerHasParticipatedAndWon)
                {
                    Target.mPlayerHasParticipatedAndWon = true;
                    EventTracker.SendEvent(new EquestrianCompetitionEvent(EventTypeId.kEquestrianCompetition, Actor.FirstName, Actor.IsFemale, Horse.FirstName, Horse.IsFemale, competitionName));
                }

                if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse)))
                {
                    Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterVictory, null, Actor, new object[] { Horse, Actor, competitionName });
                }
                AddCompetitionTrophy(type, level);
                return;
            }
        }
Пример #9
0
 public Definition(CompetitionType type, CompetitionLevel level)
     : base(type, level)
 {
 }