public int Score(SP parameters) { IScoringMethod <T, SP> scoring = Scoring; if (scoring != null) { return(scoring.Score(parameters)); } else if (mMinimum == mMaximum) { return(mMinimum); } else if (!parameters.IsAbsolute) { return(RandomUtil.GetInt(mMinimum, mMaximum)); } else { return(mMaximum); } }
// the caste cache seems to be invalided too rapidly for my taste, something to look into... public bool Matches(SimDescription sim, int netWorth) { CASAgeGenderFlags ageGender = sim.mSimFlags & sAgeGenderMask; if ((mAgeGender & ageGender) != ageGender) { return(false); } if (mSpecies.Count > 0) { if (!mSpecies.ContainsKey(sim.Species)) { return(false); } } if (mMatchAll) { if (!SimTypes.MatchesAll(sim, mTypes)) { return(false); } if (mCareer.Count > 0) { if (!HasAllCareers(sim, mCareer)) { return(false); } } if (mCareerLevel.Count > 0) { if (!HasAllCareersOfLevel(sim, mCareerLevel)) { return(false); } } if (mSkill.Count > 0) { if (!HasAllSkills(sim, mSkill)) { return(false); } } if (mSkillLevel.Count > 0) { if (!HasAllSkillsOfLevel(sim, mSkillLevel)) { return(false); } } if (mZodiac.Count > 0) { if (!HasAllZodiacs(sim, mZodiac)) { return(false); } } if (mDegree.Count > 0) { if (!HasAllDegrees(sim, mDegree)) { return(false); } } } else { if (!SimTypes.MatchesAny(sim, mTypes, true)) { return(false); } if (mCareer.Count > 0) { if (!HasAnyCareer(sim, mCareer)) { return(false); } } if (mCareerLevel.Count > 0) { if (!HasAnyCareerOfLevel(sim, mCareerLevel)) { return(false); } } if (mSkill.Count > 0) { if (!HasAnySkill(sim, mSkill)) { return(false); } } if (mSkillLevel.Count > 0) { if (!HasAnySkillOfLevel(sim, mSkillLevel)) { return(false); } } if (mZodiac.Count > 0) { if (!HasAnyZodiac(sim, mZodiac)) { return(false); } } if (mDegree.Count > 0) { if (!HasAnyDegree(sim, mDegree)) { return(false); } } } if (netWorth < mMinNetWorth) { return(false); } if (netWorth > mMaxNetWorth) { return(false); } if (mScoring != null) { if (mScoring.Score(new SimScoringParameters(sim)) <= 0) { return(false); } } if (mPersonalityLeaders.Count > 0) { bool found = false; foreach (SimPersonality personality in StoryProgression.Main.Personalities.GetClanLeadership(sim)) { if (mPersonalityLeaders.ContainsKey(personality.UnlocalizedName)) { found = true; } } if (!found) { return(false); } } if (mPersonalityMembers.Count > 0) { bool found = false; foreach (SimPersonality personality in StoryProgression.Main.Personalities.GetClanMembership(sim, false)) { if (mPersonalityMembers.ContainsKey(personality.UnlocalizedName)) { found = true; } } if (!found) { return(false); } } if (mRequiredTraits.Count > 0) { bool found = false; foreach (Trait trait in sim.TraitManager.List) { if (mRequiredTraits.ContainsKey(trait.Guid)) { found = true; break; } } if (!found) { return(false); } } if (mDeniedTraits.Count > 0) { foreach (Trait trait in sim.TraitManager.List) { if (mDeniedTraits.ContainsKey(trait.Guid)) { return(false); } } } return(true); }