예제 #1
0
        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);
        }
예제 #2
0
        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;
        }