/// <summary>
            /// Adds a proficiency to the List of proficiencies for this object.
            /// </summary>
            /// <param name="proficiency"></param>
            public void AddProficiency(string proficiency)
            {
                if (!string.IsNullOrEmpty(proficiency) && Proficiencies != null)
                {
                    Proficiencies.Add(proficiency);

                    return;
                }

                throw new ArgumentNullException(nameof(proficiency),
                                                $"{nameof(Proficiencies)} cannot have an empty or null value assigned to it. Alternatively, " +
                                                $"{nameof(Proficiencies)} itself cannot be null when assigning a value to it.");
            }
示例#2
0
        public Background(
            string Name,

            string proficiency1 = null,
            string proficiency2 = null,

            Tool tool1 = null,
            Tool tool2 = null,

            Language language1 = null,
            Language language2 = null)
        {
            this.Name = Name;

            if (proficiency1 != null)
            {
                Proficiencies.Add(proficiency1);
            }
            if (proficiency2 != null)
            {
                Proficiencies.Add(proficiency2);
            }

            if (tool1 != null)
            {
                Tools.Add(tool1);
            }
            if (tool2 != null)
            {
                Tools.Add(tool2);
            }

            if (language1 != null)
            {
                Languages.Add(language1);
            }
            if (language2 != null)
            {
                Languages.Add(language2);
            }
        }
        public Unit(int id, string[] txtUnitData)
        {
            ID = id;
            List <string[]> fs = new List <string[]>();

            foreach (var line in txtUnitData)
            {
                fs.Add(line.Replace("\r\n", "").Split(' '));
            }
            TroopID         = fs[0][0];
            EngSingleName   = fs[0][1].Replace('_', ' ');
            EngMultiplyName = fs[0][2].Replace('_', ' ');
            //Flags
            var flagsNum = Convert.ToInt32(fs[0][4]);

            foreach (var df in dividendsFlags)
            {
                var dr = App.GetDivRsltAndRest(flagsNum, df.Value);
                flagsNum = dr[1];
                Flags.Add(df.Key, (byte)dr[0]);
            }
            FactionID      = Convert.ToInt32(fs[0][7]);
            UpgradePath[0] = Convert.ToInt32(fs[0][8]);
            UpgradePath[1] = Convert.ToInt32(fs[0][9]);
            //Items
            List <int> itms = new List <int>();

            foreach (var it in fs[1])
            {
                if (it.Equals("0") || it.Equals(""))
                {
                    continue;
                }
                if (it.Equals("-1"))
                {
                    break;
                }
                itms.Add(Convert.ToInt32(it));
            }
            ItemsIDs = itms.ToArray();
            //Attributes
            var attrs  = Enum.GetValues(typeof(Attribute));
            int iattrs = 2;

            foreach (var attr in attrs)
            {
                Attributes.Add((Attribute)attr, (byte)Convert.ToInt16(fs[2][iattrs++]));
            }
            //Level
            Level = (byte)Convert.ToInt16(fs[2][6]);
            //Proficiencies
            var prfs  = Enum.GetValues(typeof(Proficiency));
            int iprfs = 1;

            foreach (var prf in prfs)
            {
                Proficiencies.Add((Proficiency)prf, (byte)Convert.ToInt32(fs[3][iprfs++]));
            }
            //Skills
            for (int i = 0; i < dividendsSkills.Length; i++)
            {
                var dividend = Convert.ToInt64(fs[4][i]);
                foreach (var sk in dividendsSkills[i])
                {
                    var rd = App.GetDivRsltAndRest(dividend, sk.Value);
                    dividend = rd[1];
                    Skills.Add(sk.Key, (byte)rd[0]);
                }
            }
        }