Exemplo n.º 1
0
        public override bool Parse(XmlDbRow row, ref string error)
        {
            mHit = new HitMissResult <T, HitMissSP>(row, "Hit", ref error);
            if (!string.IsNullOrEmpty(error))
            {
                return(false);
            }

            mMiss = new HitMissResult <T, HitMissSP>(row, "Miss", ref error);
            if (!string.IsNullOrEmpty(error))
            {
                return(false);
            }

            if (row.Exists("OnExpansionFail"))
            {
                if (!ParserFunctions.TryParseEnum <HitMissExpansionFail>(row.GetString("OnExpansionFail"), out mOnExpansionFail, HitMissExpansionFail.None))
                {
                    error = "OnExpansionFail unknown";
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public override bool Parse(XmlDbRow row, string prefix, bool firstPass, ref string error)
        {
            mDelta = row.GetInt(prefix + "PropagateDelta", -25);

            if (row.Exists(prefix + "PropagateEnemy"))
            {
                if (!ParserFunctions.TryParseEnum <WhichSim>(row.GetString(prefix + "PropagateEnemy"), out mEnemySim, WhichSim.Actor))
                {
                    error = prefix + "PropagateEnemy unknown";
                    return(false);
                }
            }

            SimScenarioFilter.RelationshipLevel relationLevel;
            if (ParserFunctions.TryParseEnum <SimScenarioFilter.RelationshipLevel>(row.GetString(prefix + "PropagateRelationshipGate"), out relationLevel, SimScenarioFilter.RelationshipLevel.Neutral))
            {
                mRelationshipGate = (int)relationLevel;
            }
            else
            {
                mRelationshipGate = row.GetInt(prefix + "PropagateRelationshipGate", mRelationshipGate);
            }

            return(base.Parse(row, prefix, firstPass, ref error));
        }
Exemplo n.º 3
0
        public override void SetImportValue(string value)
        {
            TType newValue;

            ParserFunctions.TryParseEnum <TType>(value, out newValue, Default);
            Value = newValue;
        }
Exemplo n.º 4
0
        public override bool Parse(XmlDbRow row, ref string error)
        {
            if (!base.Parse(row, ref error))
            {
                return(false);
            }

            if (!row.Exists("Type"))
            {
                error = "Type missing";
                return(false);
            }
            else if (!ParserFunctions.TryParseEnum <SimType>(row.GetString("Type"), out mType, SimType.None))
            {
                error = "Unknown Type " + row.GetString("Type");
                return(false);
            }

            if (!row.Exists("OtherType"))
            {
                error = "OtherType missing";
                return(false);
            }
            else if (!ParserFunctions.TryParseEnum <SimType>(row.GetString("OtherType"), out mOtherType, SimType.None))
            {
                error = "Unknown OtherType " + row.GetString("OtherType");
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        protected override TraitNames ConvertFromString(string value)
        {
            TraitNames result;

            ParserFunctions.TryParseEnum <TraitNames>(value, out result, TraitNames.Unknown);
            return(result);
        }
Exemplo n.º 6
0
        public override bool Parse(XmlDbRow row, SimPersonality personality, ref string error)
        {
            if (!base.Parse(row, personality, ref error))
            {
                return(false);
            }

            if (!row.Exists("Name"))
            {
                error = "Name missing";
                return(false);
            }
            else if (!row.Exists("Default"))
            {
                error = "Default missing";
                return(false);
            }
            else
            {
                CASAgeGenderFlags ageGender;
                if (!ParserFunctions.TryParseEnum <CASAgeGenderFlags>(row.GetString("AgeGender"), out ageGender, CASAgeGenderFlags.None))
                {
                    error = "Unknown AgeGender " + row.GetString("AgeGender");
                    return(false);
                }

                mAge = ageGender & CASAgeGenderFlags.AgeMask;

                if (mAge == CASAgeGenderFlags.None)
                {
                    mAge = CASAgeGenderFlags.AgeMask;
                }

                mGender = ageGender & CASAgeGenderFlags.GenderMask;

                if (mGender == CASAgeGenderFlags.None)
                {
                    mGender = CASAgeGenderFlags.GenderMask;
                }

                StringToSpeciesList converter = new StringToSpeciesList();
                mSpecies = converter.Convert(row.GetString("Species"));
                if (mSpecies == null)
                {
                    error = converter.mError;
                    return(false);
                }

                if (mSpecies.Count == 0)
                {
                    mSpecies.Add(CASAgeGenderFlags.Human);
                }
            }

            mName = row.GetString("Name");

            SetValue(row.GetBool("Default"));

            return(true);
        }
Exemplo n.º 7
0
        protected override Zodiac ConvertFromString(string value)
        {
            Zodiac result;

            ParserFunctions.TryParseEnum <Zodiac>(value, out result, Zodiac.Unset);
            return(result);
        }
Exemplo n.º 8
0
            protected override List <TraitNames> PrivateConvert(string value)
            {
                TraitNames trait;

                if (!ParserFunctions.TryParseEnum <TraitNames>(value, out trait, TraitNames.Unknown))
                {
                    mError = "Unknown Trait " + value;
                    return(null);
                }

                List <TraitNames> results = new List <TraitNames>();

                results.Add(trait);

                TraitNames[] petTraits = null;
                if (sPetEquivalents.TryGetValue(trait, out petTraits))
                {
                    results.AddRange(petTraits);
                }

                TraitNames robotTrait = TraitNames.Unknown;

                if (sPlumbotEquivalents.TryGetValue(trait, out robotTrait))
                {
                    results.Add(robotTrait);
                }

                return(results);
            }
Exemplo n.º 9
0
        public void Perform(BooterHelper.BootFile file, XmlDbRow row)
        {
            WorldName world;

            row.TryGetEnum <WorldName>("World", out world, WorldName.Undefined);

            List <DaysOfTheWeek> days = ParserFunctions.ParseDayList(row.GetString("Days"));

            if ((days == null) || (days.Count == 0))
            {
                days = ParserFunctions.ParseDayList("MTWRFSU");
            }

            int startHour = row.GetInt("StartHour");
            int endHour   = row.GetInt("EndHour");

            if (startHour > endHour)
            {
                return;
            }

            int speed = row.GetInt("Speed");

            if (speed <= 0)
            {
                speed = Relativity.sOneMinute;
            }

            mIntervals.Add(new SpeedInterval(world, days, startHour, endHour, speed));
        }
Exemplo n.º 10
0
        protected override SimType ConvertFromString(string value)
        {
            SimType result;

            ParserFunctions.TryParseEnum <SimType>(value, out result, SimType.None);
            return(result);
        }
Exemplo n.º 11
0
        protected override OccultTypes ConvertFromString(string value)
        {
            OccultTypes result;

            ParserFunctions.TryParseEnum <OccultTypes>(value, out result, OccultTypes.None);
            return(result);
        }
Exemplo n.º 12
0
        public OmniJournalData(XmlDbRow row, int rowIndex)
            : base(row, "OmniJournal", rowIndex)
        {
            mCareerName     = row.GetString("CareerName");
            mCareerLevel    = ParserFunctions.ParseInt(row.GetString("CareerLevel"), 0);
            mCurrentEdition = ParserFunctions.ParseInt(row.GetString("StartingEdition"), 1);

            mMaxEdition = ParserFunctions.ParseInt(row.GetString("MaxEdition"), 1);

            base.MyType = BookData.BookType.MedicalJournal;

            Dictionary <int, OmniJournalData> levels;

            if (!sJournalDataList.TryGetValue(mCareerName, out levels))
            {
                levels = new Dictionary <int, OmniJournalData>();

                sJournalDataList.Add(mCareerName, levels);
            }

            if (!levels.ContainsKey(mCareerLevel))
            {
                levels.Add(mCareerLevel, this);
            }
        }
Exemplo n.º 13
0
        public override bool Parse(XmlDbRow row, ref string error)
        {
            mName = new WeightOption.NameOption(row);

            mInjuredStory = row.GetString("InjuredStory");

            if (!ParserFunctions.TryParseEnum <SimDescription.DeathType>(row.GetString("Type"), out mType, SimDescription.DeathType.None))
            {
                error = "Type not valid";
                return(false);
            }

            if (mType == SimDescription.DeathType.None)
            {
                error = "Type cannot be None";
                return(false);
            }

            mSuccess = new WeightScenarioHelper(Origin.FromWatchingSimSuffer);
            if (!mSuccess.Parse(row, Manager, this, "Success", ref error))
            {
                return(false);
            }

            return(base.Parse(row, ref error));
        }
Exemplo n.º 14
0
        public static void InjectRealEstateData(string varname)
        {
            // temporary
            CommercialLotSubType type;

            if (ParserFunctions.TryParseEnum <CommercialLotSubType>(varname, out type, CommercialLotSubType.kCommercialUndefined))
            {
                RealEstateData.VenueData data = default(RealEstateData.VenueData);
                data.LotType  = type;
                data.BaseCost = 50000;

                List <int> list;
                List <int> list2;

                string weeklyIncomes = "5800,12750,25000";
                string upgradeValues = "50000,85000,155000";
                ParserFunctions.ParseCommaSeperatedInt(weeklyIncomes, out list);
                ParserFunctions.ParseCommaSeperatedInt(upgradeValues, out list2);
                data.WeeklyIncomes = list.ToArray();
                data.UpgradeValues = list2.ToArray();

                // needed because EA
                data.UpgradeObjects = new List <Pair <string, int> > [3];
                for (int i = 0; i < 3; i++)
                {
                    data.UpgradeObjects[i] = new List <Pair <string, int> >();
                }

                RealEstateData.sDictionary.Add(type, data);
            }
        }
Exemplo n.º 15
0
        protected override CASAgeGenderFlags ConvertFromString(string value)
        {
            CASAgeGenderFlags result;

            ParserFunctions.TryParseEnum <CASAgeGenderFlags>(value, out result, CASAgeGenderFlags.None);
            return(result);
        }
Exemplo n.º 16
0
        public override bool Parse(XmlDbRow row, ref string error)
        {
            if (!row.Exists("AgeGender"))
            {
                error = "AgeGender Missing";
            }
            else
            {
                if (!ParserFunctions.TryParseEnum <CASAgeGenderFlags>(row.GetString("AgeGender"), out mAgeGender, CASAgeGenderFlags.None))
                {
                    error = "Unknown AgeGender " + row.GetString("AgeGender");
                    return(false);
                }
            }

            StringToSpeciesList converter = new StringToSpeciesList();

            mSpecies = converter.Convert(row.GetString("Species"));
            if (mSpecies == null)
            {
                error = converter.mError;
                return(false);
            }

            return(base.Parse(row, ref error));
        }
Exemplo n.º 17
0
 public void Import(Persistence.Lookup settings)
 {
     mWorld     = settings.GetEnum <WorldName>("World", GameUtils.GetCurrentWorld());
     mDays      = ParserFunctions.ParseDayList(settings.GetString("Days"));
     mStartHour = settings.GetInt("StartHour", 0);
     mEndHour   = settings.GetInt("EndHour", 24);
     mSpeed     = settings.GetInt("Speed", Relativity.sOneMinute);
 }
Exemplo n.º 18
0
            protected override bool PrivateConvert(string value, out OccupationNames result)
            {
                if (ParserFunctions.TryParseEnum <OccupationNames>(value.Trim(), out result, OccupationNames.Any))
                {
                    return(true);
                }

                mError = "Unknown Occupation " + value;
                return(false);
            }
Exemplo n.º 19
0
            protected override bool PrivateConvert(string value, out CASAgeGenderFlags result)
            {
                if (ParserFunctions.TryParseEnum <CASAgeGenderFlags>(value, out result, CASAgeGenderFlags.None))
                {
                    return(true);
                }

                mError = "Unknown Species: " + value;
                return(false);
            }
Exemplo n.º 20
0
            public void Parse(string key, OnPopulate populate)
            {
                XmlDbData careerFile = XmlDbData.ReadData(key);

                if ((careerFile != null) && (careerFile.Tables != null) && (careerFile.Tables.ContainsKey("CareerData")))
                {
                    XmlDbTable table = careerFile.Tables["CareerData"];

                    foreach (XmlDbRow row in table.Rows)
                    {
                        string guid = row.GetString("Career");

                        string branch = row.GetString("Branch");
                        if (string.IsNullOrEmpty(branch))
                        {
                            branch = "Base";
                        }

                        int level = row.GetInt("Level");
                        if (level == 1)
                        {
                            continue;
                        }

                        OccupationNames careerGuid = OccupationNames.Undefined;
                        ParserFunctions.TryParseEnum <OccupationNames>(guid, out careerGuid, OccupationNames.Undefined);

                        if (careerGuid == OccupationNames.Undefined)
                        {
                            careerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(guid));
                        }

                        Dictionary <int, Dictionary <string, TData> > levels;
                        if (!mLevels.TryGetValue(careerGuid, out levels))
                        {
                            levels = new Dictionary <int, Dictionary <string, TData> >();
                            mLevels.Add(careerGuid, levels);
                        }

                        Dictionary <string, TData> branches;
                        if (!levels.TryGetValue(level, out branches))
                        {
                            branches = new Dictionary <string, TData>();
                            levels.Add(level, branches);
                        }

                        if (branches.ContainsKey(branch))
                        {
                            continue;
                        }

                        branches.Add(branch, populate(row));
                    }
                }
            }
Exemplo n.º 21
0
        public List <RequirementInfoEx> GetTargetRequirements()
        {
            List <RequirementInfoEx> list = new List <RequirementInfoEx>();

            foreach (Opportunity.OpportunitySharedData.RequirementInfo info in mSharedData.mRequirementList)
            {
                if (info.mType == RequirementType.Undefined)
                {
                    List <string> entry = new List <string>(info.mData.Split(new char[] { ',' }));

                    List <RequirementTypeEx> types = new List <RequirementTypeEx>();

                    if (entry.Count > 0)
                    {
                        RequirementTypeEx type;
                        ParserFunctions.TryParseEnum <RequirementTypeEx>(entry[0], out type, RequirementTypeEx.Undefined);

                        RequirementInfoEx data = null;

                        if (type != RequirementTypeEx.Undefined)
                        {
                            switch (type)
                            {
                            case RequirementTypeEx.TargetCareer:
                                data = new CareerRequirementInfo(entry);
                                break;

                            case RequirementTypeEx.TargetAge:
                                data = new AgeRequirementInfo(entry);
                                break;

                            case RequirementTypeEx.TargetGender:
                                data = new GenderRequirementInfo(entry);
                                break;

                            case RequirementTypeEx.TargetService:
                                data = new ServiceRequirementInfo(entry);
                                break;

                            default:
                                data = new GenericRequirementInfo(type);
                                break;
                            }
                        }

                        if (data != null)
                        {
                            list.Add(data);
                        }
                    }
                }
            }

            return(list);
        }
Exemplo n.º 22
0
        protected void AddSummary(StoryProgressionObject spObject, string name, string msg, string[] extended, bool notify, StoryLogging logging)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            Manager manager = null;

            if (spObject is SimPersonality)
            {
                manager = Personalities;
            }
            else
            {
                manager = spObject as Manager;
            }

            if (manager != null)
            {
                manager.IncStat("Summary: " + msg);
            }

            string translated = msg;

            if (spObject != null)
            {
                ulong key = ParserFunctions.ParseUlong(msg, 0);

                if (key != 0)
                {
                    translated = Localization.LocalizeString(key);
                }
                else
                {
                    translated = spObject.Localize(msg);
                }

                if (string.IsNullOrEmpty(translated))
                {
                    translated = "(D) " + spObject.UnlocalizedName + "." + msg;
                }
            }

            if ((notify) && ((logging & StoryLogging.Summary) == StoryLogging.Summary) && (GetValue <ShowSummaryOption, int>() > 0))
            {
                mSummary.Add(translated + ": " + name);
            }

            if (((logging & StoryLogging.Log) == StoryLogging.Log) && ((notify) || (GetValue <FullStoryLogOption, bool>())))
            {
                AddSummaryToLog(translated + ": " + name, extended);
            }
        }
Exemplo n.º 23
0
            public ServiceRequirementInfo(List <string> list)
                : base(RequirementTypeEx.TargetCareer)
            {
                for (int i = 1; i < list.Count; i++)
                {
                    ServiceType serviceType;
                    ParserFunctions.TryParseEnum <ServiceType>(list[0], out serviceType, ServiceType.None);

                    mServices.Add(serviceType);
                }
            }
Exemplo n.º 24
0
 protected override OptionResult Convert(string value, out object result)
 {
     if (ParserFunctions.TryParseEnumType(FieldType, value, out result, true))
     {
         return(OptionResult.SuccessClose);
     }
     else
     {
         result = null;
         return(OptionResult.Failure);
     }
 }
Exemplo n.º 25
0
        protected static bool LoadSocialData(BooterHelper.DocumentBootFile socialData)
        {
            if (!socialData.IsValid)
            {
                BooterLogger.AddError(socialData + ": Unknown SocialData File");
                return(false);
            }

            XmlElementLookup  lookup  = new XmlElementLookup(socialData.Document);
            List <XmlElement> actions = lookup["Action"];

            if ((actions == null) || (actions.Count == 0))
            {
                BooterLogger.AddError(socialData + ": No Action");
                return(false);
            }

            bool isEp5Installed = GameUtils.IsInstalled(ProductVersion.EP5);

            foreach (XmlElement element in actions)
            {
                XmlElementLookup table = new XmlElementLookup(element);

                CommodityTypes types;
                ParserFunctions.TryParseEnum <CommodityTypes>(element.GetAttribute("com"), out types, CommodityTypes.Undefined);

                ProductVersion version;
                ParserFunctions.TryParseEnum <ProductVersion>(element.GetAttribute("ver"), out version, ProductVersion.BaseGame);

                ActionData data = new ActionData(element.GetAttribute("key"), types, version, table, isEp5Installed);

                List <XmlElement> list = table["LHS"];
                if (list.Count > 0x0)
                {
                    SocialRuleLHS.sDictionary.Remove(data.Key);

                    foreach (XmlElement element3 in list)
                    {
                        SocialRuleLHS lhs = new SocialRuleLHS(data.Key, data.IntendedCommodityString, element3);
                        lhs.ProceduralPrecondition = FindMethod(element3.GetAttribute("ProcTest"));
                    }

                    SocialRuleLHS.Get(data.Key).Sort(new Comparison <SocialRuleLHS>(SocialRuleLHS.SortSocialRules));
                }

                ActionData.Add(data);

                BooterLogger.AddTrace(" " + data.Key + " Added");
            }

            return(true);
        }
Exemplo n.º 26
0
        public static void Reduce(ref Stack <Term> SS, ref Stack <Term> ST)
        {
            var  rightOperand = ST.Pop();
            var  operatorTerm = SS.Pop();
            Term leftOperand  = null;

            if (ST.Count > 0 && (operatorTerm.Type != TermType.dec && operatorTerm.Type != TermType.inc &&
                                 operatorTerm.Type != TermType.compl && operatorTerm.Type != TermType.reference &&
                                 operatorTerm.Type != TermType.dereference && operatorTerm.Type != TermType.not))
            {
                leftOperand = ST.Pop();
            }

            ADExpression expression = new ADExpression();

            if (rightOperand.Expression != null)
            {
                expression.Right = rightOperand.Expression;
            }
            else
            {
                expression.Right = GetExpression(rightOperand.STRecord);
            }

            expression.Operator = operatorTerm.Type;


            if (leftOperand != null)
            {
                if (leftOperand.Expression != null)
                {
                    expression.Left = leftOperand.Expression;
                }
                else
                {
                    expression.Left = GetExpression(leftOperand.STRecord);
                }
            }

            if (expression.Operator == TermType.asgn)
            {
                if (leftOperand.STRecord.Type != STType.variable && leftOperand.STRecord.Type != STType.array)
                {
                    ParserFunctions.SyntaxError("Na leve strane operace prirazeni musi byt promenna.");
                }
            }

            ST.Push(new Term()
            {
                Type = TermType.id, Expression = expression
            });
        }
Exemplo n.º 27
0
 protected override OptionResult Convert(string value, out bool result)
 {
     try
     {
         result = ParserFunctions.ParseBool(value);
         return(OptionResult.SuccessClose);
     }
     catch
     {
         result = false;
         return(OptionResult.Failure);
     }
 }
Exemplo n.º 28
0
        protected bool ParseBuffs(XmlDbRow row, string prefix1, string prefix2, Dictionary <BuffNames, Origin> buffs, ref string error)
        {
            if ((!string.IsNullOrEmpty(prefix2)) && (!ParseBuffs(row, prefix1, null, buffs, ref error)))
            {
                return(false);
            }

            string prefix = prefix1 + prefix2;

            int index = 0;

            while (true)
            {
                if (!row.Exists(prefix + "Buff" + index))
                {
                    break;
                }

                BuffNames buff;
                if (!ParserFunctions.TryParseEnum <BuffNames>(row.GetString(prefix + "Buff" + index), out buff, BuffNames.Undefined))
                {
                    error = prefix + "Buff" + index + " unknown";
                    return(false);
                }

                if (buffs.ContainsKey(buff))
                {
                    error = prefix + "Buff " + buff + " already found";
                    return(false);
                }

                if (!row.Exists(prefix + "Origin" + index))
                {
                    error = prefix + "Origin" + index + " missing";
                    return(false);
                }

                Origin origin;
                if (!ParserFunctions.TryParseEnum <Origin>(row.GetString(prefix + "Origin" + index), out origin, Origin.None))
                {
                    error = prefix + "Origin" + index + " unknown";
                    return(false);
                }

                buffs.Add(buff, origin);

                index++;
            }

            return(true);
        }
Exemplo n.º 29
0
        protected override void Perform(BooterHelper.BootFile file, XmlDbRow row)
        {
            SkillNames skill;

            if (!ParserFunctions.TryParseEnum <SkillNames>(row.GetString("Skill"), out skill, SkillNames.None))
            {
                BooterLogger.AddError("Invalid Skill: " + row.GetString("Skill"));
                return;
            }

            sData.Add(skill, true);

            BooterLogger.AddTrace(" Child Skill: " + row.GetString("Skill"));
        }
Exemplo n.º 30
0
        protected override void Perform(BooterHelper.BootFile file, XmlDbRow row)
        {
            BuffNames buff;

            if (!ParserFunctions.TryParseEnum <BuffNames>(row.GetString("Moodlet"), out buff, BuffNames.Undefined))
            {
                BooterLogger.AddError("Invalid Moodlet: " + row.GetString("Moodlet"));
                return;
            }

            sData.Add(buff, true);

            BooterLogger.AddTrace(" Bad Lot Moodlet: " + row.GetString("Moodlet"));
        }