public bool Parse(XmlDbRow row, string name, StoryProgressionObject manager, IUpdateManager updater, ref string error) { string value = row.GetString(name); if (string.IsNullOrEmpty(value)) { error = "AgeGenderOption " + name + " missing"; return(false); } if (!bool.TryParse(value, out mValue)) { mOption = manager.GetOption <AgeGenderOption>(value); if (mOption == null) { error = "AgeGenderOption " + value + " missing"; return(false); } } updater.AddUpdater(this); return(true); }
public bool Parse(XmlDbRow row, string name, StoryProgressionObject manager, IUpdateManager updater, ref string error) { string value = row.GetString(name); if (string.IsNullOrEmpty(value)) { error = "AgeGenderOption " + name + " missing"; return false; } if (!bool.TryParse(value, out mValue)) { mOption = manager.GetOption<AgeGenderOption>(value); if (mOption == null) { error = "AgeGenderOption " + value + " missing"; return false; } } updater.AddUpdater(this); return true; }
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; }
public bool Parse(XmlDbRow row, StoryProgressionObject manager, IUpdateManager updater, string prefix, ref string error) { if (!string.IsNullOrEmpty(prefix)) { if (!Parse(row, manager, updater, null, ref error)) { return(false); } mTestBeforehand = row.GetBool(prefix + "TestBeforehand"); mDelta = new HitMissResult <SimDescription, SimScoringParameters>(row, prefix + "Delta", ref error); bool deltaSet = string.IsNullOrEmpty(error); if (!deltaSet) { error = null; } string scenario = row.GetString(prefix + "Scenario"); if (!string.IsNullOrEmpty(scenario)) { WeightOption scenarioWeight = manager.GetOption <WeightOption>(scenario); if (scenarioWeight == null) { error = prefix + "Scenario weight " + scenario + " missing"; return(false); } mScenario = scenarioWeight.GetScenario(); if (mScenario == null) { error = prefix + "Scenario " + scenario + " invalid"; return(false); } if (deltaSet) { IDeltaScenario deltaScenario = mScenario as IDeltaScenario; if (deltaScenario != null) { deltaScenario.IDelta = mDelta; } } } mRecruit = new SimRecruitFilter(); if (!mRecruit.Parse(row, manager, updater, prefix, ref error)) { return(false); } mPropagate = new PropagationScenarioHelper(); if (!mPropagate.Parse(row, mOrigin, prefix, ref error)) { return(false); } mActorBuffs = new Dictionary <BuffNames, Origin>(); if (!ParseBuffs(row, prefix, "Actor", mActorBuffs, ref error)) { return(false); } mTargetBuffs = new Dictionary <BuffNames, Origin>(); if (!ParseBuffs(row, prefix, "Target", mTargetBuffs, ref error)) { return(false); } } if (row.Exists(prefix + "ScenarioActor")) { if (!row.TryGetEnum <PropagateBuffScenario.WhichSim>(prefix + "ScenarioActor", out mScenarioActor, PropagateBuffScenario.WhichSim.Unset)) { error = prefix + "ScenarioActor Unknown " + row.GetString(prefix + "ScenarioActor"); return(false); } } if (row.Exists(prefix + "ScenarioTarget")) { if (!row.TryGetEnum <PropagateBuffScenario.WhichSim>(prefix + "ScenarioTarget", out mScenarioTarget, PropagateBuffScenario.WhichSim.Unset)) { error = prefix + "ScenarioTarget Unknown " + row.GetString(prefix + "ScenarioTarget"); return(false); } } mActorCelebrity = row.GetInt(prefix + "ActorCelebrity", mActorCelebrity); mTargetCelebrity = row.GetInt(prefix + "TargetCelebrity", mTargetCelebrity); if (!ParseAccumulator(row, prefix + "AccumulateValue", mAccumulators, ref error)) { return(false); } if (!ParseAccumulator(row, prefix + "GatheringFailureValue", mGatheringFailAccumulators, ref error)) { return(false); } updater.AddUpdater(this); return(true); }
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); }
public bool Parse(XmlDbRow row, StoryProgressionObject manager, IUpdateManager updater, string prefix, ref string error) { if (!string.IsNullOrEmpty(prefix)) { if (!Parse(row, manager, updater, null, ref error)) { return false; } mTestBeforehand = row.GetBool(prefix + "TestBeforehand"); mDelta = new HitMissResult<SimDescription, SimScoringParameters>(row, prefix + "Delta", ref error); bool deltaSet = string.IsNullOrEmpty(error); if (!deltaSet) { error = null; } string scenario = row.GetString(prefix + "Scenario"); if (!string.IsNullOrEmpty(scenario)) { WeightOption scenarioWeight = manager.GetOption<WeightOption>(scenario); if (scenarioWeight == null) { error = prefix + "Scenario weight " + scenario + " missing"; return false; } mScenario = scenarioWeight.GetScenario(); if (mScenario == null) { error = prefix + "Scenario " + scenario + " invalid"; return false; } if (deltaSet) { IDeltaScenario deltaScenario = mScenario as IDeltaScenario; if (deltaScenario != null) { deltaScenario.IDelta = mDelta; } } } mRecruit = new SimRecruitFilter(); if (!mRecruit.Parse(row, manager, updater, prefix, ref error)) { return false; } mPropagate = new PropagationScenarioHelper(); if (!mPropagate.Parse(row, mOrigin, prefix, ref error)) { return false; } mActorBuffs = new Dictionary<BuffNames, Origin>(); if (!ParseBuffs(row, prefix, "Actor", mActorBuffs, ref error)) { return false; } mTargetBuffs = new Dictionary<BuffNames, Origin>(); if (!ParseBuffs(row, prefix, "Target", mTargetBuffs, ref error)) { return false; } } if (row.Exists(prefix + "ScenarioActor")) { if (!row.TryGetEnum<PropagateBuffScenario.WhichSim>(prefix + "ScenarioActor", out mScenarioActor, PropagateBuffScenario.WhichSim.Unset)) { error = prefix + "ScenarioActor Unknown " + row.GetString(prefix + "ScenarioActor"); return false; } } if (row.Exists(prefix + "ScenarioTarget")) { if (!row.TryGetEnum<PropagateBuffScenario.WhichSim>(prefix + "ScenarioTarget", out mScenarioTarget, PropagateBuffScenario.WhichSim.Unset)) { error = prefix + "ScenarioTarget Unknown " + row.GetString(prefix + "ScenarioTarget"); return false; } } mActorCelebrity = row.GetInt(prefix + "ActorCelebrity", mActorCelebrity); mTargetCelebrity = row.GetInt(prefix + "TargetCelebrity", mTargetCelebrity); if (!ParseAccumulator(row, prefix + "AccumulateValue", mAccumulators, ref error)) { return false; } if (!ParseAccumulator(row, prefix + "GatheringFailureValue", mGatheringFailAccumulators, ref error)) { return false; } updater.AddUpdater(this); return true; }