Exemplo n.º 1
0
        public bool Test(Parameters parameters, string name, SimDescription sim, SimDescription potential, bool testScore, out int score)
        {
            score = 0;

            if (SimTypes.IsDead(potential))
            {
                parameters.IncStat(name + " Dead Fail");
                return false;
            }

            if (!parameters.CustomTestAllow (potential))
            {
                parameters.IncStat(name + " Custom Fail");
                return false;
            }

            if ((mCustomTest.Valid) && (!mCustomTest.Invoke<bool>(new object[] { parameters, sim, potential })))
            {
                parameters.IncStat(name + " Custom Test Fail");
                return false;
            }

            parameters.IncStat("Testing " + potential.FullName, Common.DebugLevel.Logging);

            CASAgeGenderFlags age = (mAgeGender & CASAgeGenderFlags.AgeMask);

            if ((age == CASAgeGenderFlags.None) && (potential.ToddlerOrBelow))
            {
                parameters.IncStat(name + " Too Young");
                return false;
            }
            else if ((age != CASAgeGenderFlags.None) && ((mAgeGender & potential.Age) != potential.Age))
            {
                parameters.IncStat(name + " Age Fail");
                return false;
            }
            else if (((mAgeGender & CASAgeGenderFlags.GenderMask) != CASAgeGenderFlags.None) && ((mAgeGender & potential.Gender) != potential.Gender))
            {
                parameters.IncStat(name + " Gender Fail");
                return false;
            }
            else if (!mSpecies.Contains(potential.Species))
            {
                parameters.IncStat(name + " Species Fail");
                return false;
            }

            if ((!mAllowAffair) && (parameters.mIsRomantic) && (sim != null))
            {
                if (((potential.Partner != null) || (sim.Partner != null)) && (potential.Partner != sim))
                {
                    parameters.IncStat(name + " Affair Denied");
                    return false;
                }
            }

            if ((sim != null) && (sim != potential))
            {
                if ((mStandardDisallowPartner) && (sim.Partner == potential))
                {
                    parameters.IncStat(name + " Partner Fail");
                    return false;
                }

                if ((!mAllowOpposing) && (StoryProgression.Main.Personalities.IsOpposing(parameters, sim, potential, false)))
                {
                    parameters.IncStat(name + " Clan Opposing Fail");
                    return false;
                }

                if (!parameters.mIsFriendly)
                {
                    if (StoryProgression.Main.Personalities.IsFriendly(parameters, sim, potential))
                    {
                        parameters.IncStat(name + " Clan Friendly Denied");
                        return false;
                    }
                }

                int liking = 0;

                Relationship relation = Relationship.Get(sim, potential, false);
                if (relation != null)
                {
                    liking = (int)relation.LTR.Liking;
                }

                if (liking < mRelationshipMinimum)
                {
                    parameters.IncStat(name + " Relationship Underscore");
                    return false;
                }
                else if (liking > mRelationshipMaximum)
                {
                    parameters.IncStat(name + " Relationship Overscore");
                    return false;
                }
            }

            foreach (IValueTestOption value in mValueTestOptions)
            {
                if (!value.Satisfies())
                {
                    parameters.IncStat(name + " " + value.ToString() + " Value Fail");
                    return false;
                }
            }

            foreach (AgeGenderOption ageGender in mAgeGenderOptions)
            {
                if (!ageGender.Satisfies(potential.Age, potential.Gender, potential.Species))
                {
                    parameters.IncStat(name + " " + ageGender.Name + " User Fail");
                    return false;
                }
            }

            if (mDisallowRelated)
            {
                if (parameters.mManager.Flirts.IsCloselyRelated(sim, potential))
                {
                    parameters.IncStat(name + " Closely Related");
                    return false;
                }
            }

            if ((testScore) && (Score(potential, sim, parameters.mAbsoluteScoring, out score)))
            {
                int scoringMinimum = mScoringMinimum + parameters.mScoreDelta;
                int scoringMaximum = mScoringMaximum + parameters.mScoreDelta;

                if (score < scoringMinimum)
                {
                    parameters.AddScoring(name + " Under Scoring Fail", score);
                    return false;
                }
                else if (score > scoringMaximum)
                {
                    parameters.AddScoring(name + " Over Scoring Fail", score);
                    return false;
                }

                parameters.AddStat(name + " Score Success", score);
                return true;
            }
            else
            {
                parameters.IncStat(name + " No Scoring");
                return true;
            }
        }
Exemplo n.º 2
0
        public bool Test(Parameters parameters, string name, SimDescription sim, SimDescription potential, bool testScore, out int score)
        {
            score = 0;

            if (SimTypes.IsDead(potential))
            {
                parameters.IncStat(name + " Dead Fail");
                return(false);
            }

            if (!parameters.CustomTestAllow(potential))
            {
                parameters.IncStat(name + " Custom Fail");
                return(false);
            }

            if ((mCustomTest.Valid) && (!mCustomTest.Invoke <bool>(new object[] { parameters, sim, potential })))
            {
                parameters.IncStat(name + " Custom Test Fail");
                return(false);
            }

            parameters.IncStat("Testing " + potential.FullName, Common.DebugLevel.Logging);

            CASAgeGenderFlags age = (mAgeGender & CASAgeGenderFlags.AgeMask);

            if ((age == CASAgeGenderFlags.None) && (potential.ToddlerOrBelow))
            {
                parameters.IncStat(name + " Too Young");
                return(false);
            }
            else if ((age != CASAgeGenderFlags.None) && ((mAgeGender & potential.Age) != potential.Age))
            {
                parameters.IncStat(name + " Age Fail");
                return(false);
            }
            else if (((mAgeGender & CASAgeGenderFlags.GenderMask) != CASAgeGenderFlags.None) && ((mAgeGender & potential.Gender) != potential.Gender))
            {
                parameters.IncStat(name + " Gender Fail");
                return(false);
            }
            else if (!mSpecies.Contains(potential.Species))
            {
                parameters.IncStat(name + " Species Fail");
                return(false);
            }

            if ((!mAllowAffair) && (parameters.mIsRomantic) && (sim != null))
            {
                if (((potential.Partner != null) || (sim.Partner != null)) && (potential.Partner != sim))
                {
                    parameters.IncStat(name + " Affair Denied");
                    return(false);
                }
            }

            if ((sim != null) && (sim != potential))
            {
                if ((mStandardDisallowPartner) && (sim.Partner == potential))
                {
                    parameters.IncStat(name + " Partner Fail");
                    return(false);
                }

                if ((!mAllowOpposing) && (StoryProgression.Main.Personalities.IsOpposing(parameters, sim, potential, false)))
                {
                    parameters.IncStat(name + " Clan Opposing Fail");
                    return(false);
                }

                if (!parameters.mIsFriendly)
                {
                    if (StoryProgression.Main.Personalities.IsFriendly(parameters, sim, potential))
                    {
                        parameters.IncStat(name + " Clan Friendly Denied");
                        return(false);
                    }
                }

                int liking = 0;

                Relationship relation = Relationship.Get(sim, potential, false);
                if (relation != null)
                {
                    liking = (int)relation.LTR.Liking;
                }

                if (liking < mRelationshipMinimum)
                {
                    parameters.IncStat(name + " Relationship Underscore");
                    return(false);
                }
                else if (liking > mRelationshipMaximum)
                {
                    parameters.IncStat(name + " Relationship Overscore");
                    return(false);
                }
            }

            foreach (IValueTestOption value in mValueTestOptions)
            {
                if (!value.Satisfies())
                {
                    parameters.IncStat(name + " " + value.ToString() + " Value Fail");
                    return(false);
                }
            }

            foreach (AgeGenderOption ageGender in mAgeGenderOptions)
            {
                if (!ageGender.Satisfies(potential.Age, potential.Gender, potential.Species))
                {
                    parameters.IncStat(name + " " + ageGender.Name + " User Fail");
                    return(false);
                }
            }

            if (mDisallowRelated)
            {
                if (parameters.mManager.Flirts.IsCloselyRelated(sim, potential))
                {
                    parameters.IncStat(name + " Closely Related");
                    return(false);
                }
            }

            if ((testScore) && (Score(potential, sim, parameters.mAbsoluteScoring, out score)))
            {
                int scoringMinimum = mScoringMinimum + parameters.mScoreDelta;
                int scoringMaximum = mScoringMaximum + parameters.mScoreDelta;

                if (score < scoringMinimum)
                {
                    parameters.AddScoring(name + " Under Scoring Fail", score);
                    return(false);
                }
                else if (score > scoringMaximum)
                {
                    parameters.AddScoring(name + " Over Scoring Fail", score);
                    return(false);
                }

                parameters.AddStat(name + " Score Success", score);
                return(true);
            }
            else
            {
                parameters.IncStat(name + " No Scoring");
                return(true);
            }
        }