public SocialSymptom(XmlDbRow row) : base(row) { if (BooterLogger.Exists(row, "Social", Guid)) { mSocial = row.GetString("Social"); if (mSocial != "Braaaiiins") { if (ActionData.Get(mSocial) == null) { BooterLogger.AddError(Guid + " Invalid Social: " + mSocial); } } } if (BooterLogger.Exists(row, "RoomOnly", Guid)) { mRoomOnly = row.GetBool("RoomOnly"); } mScoring = row.GetString("Scoring"); if (!string.IsNullOrEmpty(mScoring)) { if (ScoringLookup.GetScoring(mScoring) == null) { BooterLogger.AddError(Guid + " Invalid Scoring: " + mScoring); } mMinimum = row.GetInt("Minimum", 0); } }
public ScoringStage(XmlDbRow row) : base(row) { if (BooterLogger.Exists(row, "Scoring", Name)) { mScoring = row.GetString("Scoring"); if (string.IsNullOrEmpty(mScoring)) { BooterLogger.AddError(Name + " Empty Scoring"); } else if (ScoringLookup.GetScoring(mScoring) == null) { BooterLogger.AddError(Name + " Invalid Scoring: " + mScoring); } } if (row.GetString("Minimum") == "Strength") { mMinimum = int.MinValue; } else { mMinimum = row.GetInt("Minimum", int.MinValue); } mMinMutation = row.GetString("MinMutation"); }
public override bool Parse(XmlDbRow row, ref string error) { if (!row.Exists("Method")) { error = "Method missing"; return(false); } else if (!row.Exists("Gate")) { error = "Gate missing"; return(false); } mMethod = row.GetString("Method"); if (ScoringLookup.GetScoring(mMethod) == null) { error = mMethod + " not found"; return(false); } mGate = new HitMissResult <T, SP>(row, "Gate", ref error); if (!string.IsNullOrEmpty(error)) { return(false); } return(base.Parse(row, ref error)); }
protected override bool Allow(GameHitParameters <GameObject> parameters) { if (ScoringLookup.GetScoring("InterestInCommon", false) == null) { return(false); } return(true); }
public static int GetScoring(Sim actor, Sim target, string scoringName, bool checkAffair, bool absolute) { if (actor == target) { return(0); } int score = 0; if (scoringName == "Attraction") { score = (int)RelationshipEx.GetAttractionScore(actor.SimDescription, target.SimDescription, false); } else { IListedScoringMethod scoring = null; if (checkAffair) { if ((actor.Partner != null) && ((target == null) || (actor.Partner != target.SimDescription))) { scoring = ScoringLookup.GetScoring(scoringName + "Affair"); } else { scoring = ScoringLookup.GetScoring(scoringName + "Single"); } } else { scoring = ScoringLookup.GetScoring(scoringName); } if (scoring == null) { return(1); } if (scoring is DualSimListedScoringMethod) { score = scoring.IScore(new DualSimScoringParameters(target.SimDescription, actor.SimDescription, absolute)); } else { score = scoring.IScore(new SimScoringParameters(actor.SimDescription, absolute)); } } return(score); }
protected void Collect(SimDescription sim) { if (string.IsNullOrEmpty(mScoring)) { return; } SimListedScoringMethod scoring = ScoringLookup.GetScoring(mScoring) as SimListedScoringMethod; if (scoring == null) { return; } scoring.Collect(sim); }
public FindSimSymptom(XmlDbRow row) : base(row) { mScoring = row.GetString("Scoring"); if (!string.IsNullOrEmpty(mScoring)) { if (ScoringLookup.GetScoring(mScoring) == null) { BooterLogger.AddError(Guid + " Invalid Scoring: " + mScoring); } mMinimum = row.GetInt("Minimum", 0); } mAllowActive = row.GetBool("AllowActive"); }
public override bool IsHit(SP parameters) { if (mScoring == null) { if (string.IsNullOrEmpty(mMethod)) { return(false); } mScoring = ScoringLookup.GetScoring(mMethod); mMethod = null; // Stop the system from checking again if (mScoring == null) { return(false); } } return(mScoring.IScore(parameters) >= mGate.Score(parameters)); }
protected bool Score(string scoringName, SimDescription potential, SimDescription other, bool absolute, out int score) { if (string.IsNullOrEmpty(scoringName)) { score = 0; return(false); } else { IListedScoringMethod scoring = ScoringLookup.GetScoring(scoringName); if (scoring == null) { score = 0; return(false); } score = scoring.IScore(new ManagerScoringParameters(mManager, potential, other, absolute)); return(true); } }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } bool success = false; mIndex++; try { string methodName = row.GetString("Name"); if (string.IsNullOrEmpty(methodName)) { BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed"); } else if (ScoringLookup.GetScoring(methodName, false) != null) { BooterLogger.AddError(methodName + " Name already in use"); return; } else { Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(methodName + " Unknown FullClassName: " + row.GetString("FullClassName")); } else { IListedScoringMethod scoring = null; try { scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IListedScoringMethod; } catch { } if (scoring == null) { BooterLogger.AddError(methodName + ": Constructor Fail " + row.GetString("FullClassName")); } else { XmlDbTable scoringTable = dataFile.GetTable(methodName); if (scoringTable == null) { BooterLogger.AddError(methodName + ": Table Missing"); } else { if (scoring.Parse(row, scoringTable)) { BooterLogger.AddTrace("Added Scoring : " + methodName); ScoringLookup.AddScoring(methodName, scoring); success = true; } else { BooterLogger.AddError(methodName + ": Parsing Fail"); } } } } } } finally { if (!success) { foreach (string column in row.ColumnNames) { BooterLogger.AddError(column + "= " + row[column]); } } } }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { List <Item> options = new List <Item>(); foreach (string name in ScoringLookup.ScoringKeys) { options.Add(new Item(name)); } CommonSelection <Item> .Results choices = new CommonSelection <Item>(Name, options).SelectMultiple(); if (choices.Count == 0) { return(OptionResult.SuccessClose); } StringBuilder msg = new StringBuilder(); foreach (Item item in choices) { IListedScoringMethod scoring = ScoringLookup.GetScoring(item.Name); if (scoring == null) { continue; } msg.Append(Common.NewLine + "Scoring: " + scoring.Name); Selection.Results allSims = new Selection(Household.EverySimDescription(), item.Name).SelectMultiple(); float totalNegScore = 0, totalPosScore = 0; int totalNegCount = 0, totalPosCount = 0; foreach (SimDescription sim in allSims) { msg.Append(Common.NewLine + "Actor: " + sim.FullName); if (scoring is DualSimListedScoringMethod) { SimDescription other = Sim.ActiveActor.SimDescription; msg.Append(Common.NewLine + "Other: " + other.FullName); int score = scoring.IScore(new DualSimScoringParameters(sim, other, true)); if (score > 0) { totalPosScore += score; totalPosCount++; } else { totalNegScore += score; totalNegCount++; } msg.Append(Common.NewLine + "Score: " + score); } else { int score = scoring.IScore(new SimScoringParameters(sim, true)); if (score > 0) { totalPosScore += score; totalPosCount++; } else { totalNegScore += score; totalNegCount++; } msg.Append(Common.NewLine + "Score: " + score); } msg.Append(Common.NewLine); } msg.Append(Common.NewLine + "Average Scoring: " + scoring.Name); msg.Append(Common.NewLine + "Pos: " + totalPosCount + " " + (totalPosScore / totalPosCount)); msg.Append(Common.NewLine + "Neg: " + totalNegCount + " " + (totalNegScore / totalNegCount)); } Common.WriteLog(msg.ToString()); return(OptionResult.SuccessRetain); }
public CasteFilter(CasteOptions options) { mPriority = options.GetValue <CastePriorityOption, int>(); mAutomatic = options.GetValue <CasteAutoOption, bool>(); foreach (CASAgeGenderFlags flag in options.GetValue <CasteAgeOption, List <CASAgeGenderFlags> >()) { mAgeGender |= flag; } foreach (CASAgeGenderFlags flag in options.GetValue <CasteGenderOption, List <CASAgeGenderFlags> >()) { mAgeGender |= flag; } mSpecies = new Dictionary <CASAgeGenderFlags, bool>(); foreach (CASAgeGenderFlags flag in options.GetValue <CasteSpeciesOption, List <CASAgeGenderFlags> >()) { mSpecies.Add(flag, true); } mTypes = new List <SimType>(options.GetValue <CasteTypeOption, List <SimType> >()); mMatchAll = options.GetValue <CasteMatchAllTypeOption, bool>(); mMinNetWorth = options.GetValue <CasteFundsMinOption, int>(); mMaxNetWorth = options.GetValue <CasteFundsMaxOption, int>(); string scoring = options.GetValue <CasteScoringOption, string>(); if (!string.IsNullOrEmpty(scoring)) { mScoring = ScoringLookup.GetScoring(scoring) as IScoringMethod <SimDescription, SimScoringParameters>; } mPersonalityLeaders = new Dictionary <string, bool>(); foreach (string personality in options.GetValue <CastePersonalityLeaderOption, List <string> >()) { mPersonalityLeaders[personality] = true; } mPersonalityMembers = new Dictionary <string, bool>(); foreach (string personality in options.GetValue <CastePersonalityMemberOption, List <string> >()) { mPersonalityMembers[personality] = true; } mRequiredTraits = new Dictionary <TraitNames, bool>(); foreach (TraitNames trait in options.GetValue <CasteTraitRequireOption, List <TraitNames> >()) { mRequiredTraits[trait] = true; } mDeniedTraits = new Dictionary <TraitNames, bool>(); foreach (TraitNames trait in options.GetValue <CasteTraitDenyOption, List <TraitNames> >()) { mDeniedTraits[trait] = true; } // I need to refactor this but she works for now mSkill = new List <SkillNames>(); foreach (string skill in options.GetValue <CasteSkillFilterOption, List <string> >()) { // we aren't storing this as skillnames cause twallan didn't for some reason. // I assume changing it will wipe existing DisallowSkill settings SkillNames skillName; if (ParserFunctions.TryParseEnum <SkillNames>(skill, out skillName, SkillNames.None)) { mSkill.Add(skillName); } } mSkillLevel = new Dictionary <SkillNames, List <int> >(); foreach (string skillLevel in options.GetValue <CasteSkillLevelFilterOption, List <string> >()) { string[] split = skillLevel.Split('-'); if (split.Length == 2) { SkillNames skillName; if (ParserFunctions.TryParseEnum <SkillNames>(split[0], out skillName, SkillNames.None)) { if (!mSkillLevel.ContainsKey(skillName)) { mSkillLevel.Add(skillName, new List <int>()); } int result; if (int.TryParse(split[1], out result)) { if (skillName != SkillNames.None && result > 0) { mSkillLevel[skillName].Add(result); } } } } } mCareer = new List <OccupationNames>(); foreach (OccupationNames career in options.GetValue <CasteCareerFilterOption, List <OccupationNames> >()) { mCareer.Add(career); } mCareerLevel = new Dictionary <OccupationNames, List <int> >(); foreach (string careerLevel in options.GetValue <CasteCareerLevelFilterOption, List <string> >()) { string[] split = careerLevel.Split('-'); if (split.Length == 2) { OccupationNames careerName; if (ParserFunctions.TryParseEnum <OccupationNames>(split[0], out careerName, OccupationNames.Undefined)) { if (!mCareerLevel.ContainsKey(careerName)) { mCareerLevel.Add(careerName, new List <int>()); } int result; if (int.TryParse(split[1], out result)) { if (careerName != OccupationNames.Undefined && result > 0) { mCareerLevel[careerName].Add(result); } } } } } mZodiac = new List <Zodiac>(); foreach (Zodiac zodiac in options.GetValue <CasteZodiacFilterOption, List <Zodiac> >()) { mZodiac.Add(zodiac); } mDegree = new List <AcademicDegreeNames>(); foreach (AcademicDegreeNames degree in options.GetValue <CasteDegreeFilterOption, List <AcademicDegreeNames> >()) { mDegree.Add(degree); } }
public Data(string guid, BooterHelper.BootFile file, XmlDbRow row) { mGuid = guid; if (BooterLogger.Exists(row, "InitialStrength", guid)) { mInitialStrength = row.GetInt("InitialStrength", 0); } mInfectionScoring = row.GetString("InfectionScoring"); if (string.IsNullOrEmpty(mInfectionScoring)) { BooterLogger.AddError(Guid + " Missing InfectionScoring: " + mInfectionScoring); } else if (ScoringLookup.GetScoring(mInfectionScoring) == null) { BooterLogger.AddError(Guid + " Missing InfectionScoring: " + mInfectionScoring); } mInfectionMinimum = row.GetInt("InfectionMinimum", 0); VectorStageTable table = new VectorStageTable(file as BooterHelper.DataBootFile, guid); if (!table.IsValid) { BooterLogger.AddError(Guid + " Missing Stages: " + guid); } else { Dictionary <string, int> namesToStages = new Dictionary <string, int>(); for (int i = 0; i < table.Stages.Count; i++) { if (namesToStages.ContainsKey(table.Stages[i].Name)) { BooterLogger.AddError(Guid + " Stage " + i + ": Duplicate Name " + table.Stages[i].Name); continue; } namesToStages.Add(table.Stages[i].Name, i); } for (int i = 0; i < table.Stages.Count; i++) { BooterLogger.AddTrace("Stage " + i); table.Stages[i].ValidateStages(namesToStages); } } mStages = table.Stages; mInoculationRating = row.GetInt("InoculationRating", 10); mInoculationCost = row.GetInt("InoculationCost", 0); mResistanceCost = row.GetInt("ResistanceCost", 0); mCanOutbreak = row.GetBool("CanOutbreak"); mHighProtectionCost = row.GetInt("HighProtectionCost", 0); mLowProtectionCost = row.GetInt("LowProtectionCost", 0); mMinimumStrainDifference = row.GetInt("MinimumStrainDifference", 0); mStrainMutationRate = row.GetInt("StrainMutationRate", -1); int numInstigators = row.GetInt("NumInstigators", 0) + 1; for (int i = 1; i <= numInstigators; i++) { if (i == numInstigators) { if (row.Exists("Instigator" + i)) { BooterLogger.AddError(Guid + " More Instigator then NumInstigators"); } break; } mInstigators.Add(InstigatorBooter.GetInstigator(row.GetString("Instigator" + i))); } }
public bool Parse(XmlDbRow row, StoryProgressionObject manager, IUpdateManager updater, string prefix, bool errorIfNone, ref string error) { mDisallowRelated = row.GetBool(prefix + "DisallowRelated"); if (row.Exists(prefix + "StandardFilter")) { mEnabled = true; if (!ParserFunctions.TryParseEnum <StandardFilter>(row.GetString(prefix + "StandardFilter"), out mStandardFilter, StandardFilter.None)) { error = prefix + "StandardFilter invalid"; return(false); } } string customTest = row.GetString(prefix + "CustomTest"); mCustomTest = new Common.MethodStore(customTest, new Type[] { typeof(Parameters), typeof(SimDescription), typeof(SimDescription) }); if ((mCustomTest == null) && (!string.IsNullOrEmpty(customTest))) { error = prefix + "CustomTest Invalid"; return(false); } switch (mStandardFilter) { case StandardFilter.ExistingFriend: case StandardFilter.ExistingEnemy: case StandardFilter.Nemesis: if (!row.Exists(prefix + "StandardIgnoreBusy")) { error = prefix + "StandardIgnoreBusy missing"; return(false); } mStandardIgnoreBusy = row.GetBool(prefix + "StandardIgnoreBusy"); break; } switch (mStandardFilter) { case StandardFilter.ExistingFriend: case StandardFilter.ExistingEnemy: RelationshipLevel standardLevel; if (ParserFunctions.TryParseEnum <RelationshipLevel>(row.GetString(prefix + "StandardGate"), out standardLevel, RelationshipLevel.Neutral)) { mStandardGate = (int)standardLevel; } else { RelationshipLevel defGate = RelationshipLevel.Neutral; if (mStandardFilter == StandardFilter.ExistingFriend) { defGate = RelationshipLevel.Friend; } else { defGate = RelationshipLevel.Enemy; } mStandardGate = row.GetInt(prefix + "StandardGate", (int)defGate); } break; case StandardFilter.ExistingFlirt: case StandardFilter.ExistingOrAnyFlirt: if (!row.Exists(prefix + "StandardDisallowPartner")) { error = prefix + "StandardDisallowPartner missing"; return(false); } break; } // The default for DisallowPartner can be altered by the calling system, don't overwrite it if (row.Exists(prefix + "StandardDisallowPartner")) { mStandardDisallowPartner = row.GetBool(prefix + "StandardDisallowPartner"); } switch (mStandardFilter) { case StandardFilter.AnyFlirt: case StandardFilter.ExistingOrAnyFlirt: if (!row.Exists(prefix + "AllowAffair")) { error = prefix + "AllowAffair missing"; return(false); } break; } if (row.Exists(prefix + "AllowOpposing")) { mAllowOpposing = row.GetBool(prefix + "AllowOpposing"); } else { mAllowOpposing = true; } if (row.Exists("AllowAffair")) { error = prefix + "AllowAffair misdefined"; return(false); } else if (row.Exists(prefix + "AllowAffair")) { mAllowAffair = row.GetBool(prefix + "AllowAffair"); } else { mAllowAffair = false; } if (row.Exists(prefix + "ThirdPartyFilter")) { mEnabled = true; if (!ParserFunctions.TryParseEnum <ThirdPartyFilter>(row.GetString(prefix + "ThirdPartyFilter"), out mThirdPartyFilter, ThirdPartyFilter.None)) { error = prefix + "ThirdPartyFilter invalid"; return(false); } } mScoring = row.GetString(prefix + "Scoring"); if (!string.IsNullOrEmpty(mScoring)) { mEnabled = true; if (ScoringLookup.GetScoring(mScoring) == null) { error = mScoring + " missing"; return(false); } if ((!row.Exists(prefix + "ScoringMinimum")) && (!row.Exists(prefix + "ScoringMaximum"))) { error = prefix + "ScoringMinimum missing"; return(false); } } mScoringMaximum = row.GetInt(prefix + "ScoringMaximum", int.MaxValue); mScoringMinimum = row.GetInt(prefix + "ScoringMinimum", int.MinValue); if (mScoringMinimum > mScoringMaximum) { int scoring = mScoringMinimum; mScoringMinimum = mScoringMaximum; mScoringMaximum = scoring; } if ((row.Exists(prefix + "RelationshipMinimum")) || (row.Exists(prefix + "RelationshipMaximum"))) { mEnabled = true; } RelationshipLevel relationLevel; if (ParserFunctions.TryParseEnum <RelationshipLevel>(row.GetString(prefix + "RelationshipMaximum"), out relationLevel, RelationshipLevel.Neutral)) { mRelationshipMaximum = (int)relationLevel; } else { mRelationshipMaximum = row.GetInt(prefix + "RelationshipMaximum", 101); } if (ParserFunctions.TryParseEnum <RelationshipLevel>(row.GetString(prefix + "RelationshipMinimum"), out relationLevel, RelationshipLevel.Neutral)) { mRelationshipMinimum = (int)relationLevel; } else { mRelationshipMinimum = row.GetInt(prefix + "RelationshipMinimum", -101); } if (mRelationshipMinimum > mRelationshipMaximum) { int scoring = mRelationshipMinimum; mRelationshipMinimum = mRelationshipMaximum; mRelationshipMaximum = scoring; } mClan = row.GetString(prefix + "Clan"); if (!string.IsNullOrEmpty(mClan)) { mEnabled = true; } if (row.Exists(prefix + "ClanLeader")) { mEnabled = true; } mClanLeader = row.GetBool(prefix + "ClanLeader"); if (row.Exists(prefix + "ClanMembers")) { mEnabled = true; } mClanMembers = row.GetBool(prefix + "ClanMembers"); string ageGender = row.GetString(prefix + "AgeGender"); if (!string.IsNullOrEmpty(ageGender)) { mEnabled = true; if (!ParserFunctions.TryParseEnum <CASAgeGenderFlags>(ageGender, out mAgeGender, CASAgeGenderFlags.None)) { error = "Unknown AgeGender " + ageGender; return(false); } } StringToSpeciesList converter = new StringToSpeciesList(); mSpecies = converter.Convert(row.GetString(prefix + "Species")); if (mSpecies == null) { error = converter.mError; return(false); } if (mSpecies.Count == 0) { mSpecies.Add(CASAgeGenderFlags.Human); } for (int i = 0; i < 10; i++) { string key = prefix + "UserAgeGender" + i; if (!row.Exists(key)) { break; } mEnabled = true; string name = row.GetString(key); AgeGenderOption option = manager.GetOption <AgeGenderOption>(name); if (option == null) { error = prefix + "UserAgeGender" + i + " " + name + " missing"; return(false); } mUserAgeGenders.Add(name); } for (int i = 0; i < 10; i++) { string key = prefix + "ValueTest" + i; if (!row.Exists(key)) { break; } mEnabled = true; string name = row.GetString(key); int min = row.GetInt(key + "Minimum", int.MinValue); int max = row.GetInt(key + "Maximum", int.MaxValue); bool match = true; if (row.Exists(key + "Match")) { match = row.GetBool(key + "Match"); } mValueTestLoads.Add(new ValueTestLoadStore(name, min, max, match)); } if ((!mEnabled) && (errorIfNone)) { error = prefix + " Filter missing"; return(false); } updater.AddUpdater(this); return(true); }