Exemple #1
0
 public static bool TryParse(string input, IFormatProvider provider, out Parseable result)
 {
     result = new Parseable  {
         Value = 1
     };
     return(true);
 }
Exemple #2
0
 public static bool TryParse(string input, out Parseable result)
 {
     result = new Parseable {
         Value = 2
     };
     return(true);
 }
Exemple #3
0
        public DotAData(string itemLocation, string heroLocation, string abilityLocation, string saveLocation = null)
        {
            Items  = Parseable.ParseItems <Item>(File.ReadAllLines(itemLocation)).Where(i => i.Valid).ToList();
            Heroes = Parseable.ParseItems <Hero>(File.ReadAllLines(heroLocation)).Where(h => h.Valid).ToList();

            //get the abilities and try to assign them to the heroes
            var abilities = Parseable.ParseItems <Ability>(File.ReadAllLines(abilityLocation));

            Heroes.ForEach(h => {
                foreach (var abilityName in h.AbilityList)
                {
                    var abilityMatch = abilities.FirstOrDefault(a => a.Name == abilityName);
                    if (abilityMatch != null)
                    {
                        h.Abilities.Add(abilityMatch);
                    }
                }

                //Try to assign the talents as well
                if (h.TalentList.Count() != 8)
                {
                    return;                            // 8 is what it should be
                }
                h.Talents.Add(new Talent()
                {
                    Level   = 10,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[0])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[1])?.Effects.FirstOrDefault()
                });
                h.Talents.Add(new Talent()
                {
                    Level   = 15,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[2])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[3])?.Effects.FirstOrDefault()
                });
                h.Talents.Add(new Talent()
                {
                    Level   = 20,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[4])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[5])?.Effects.FirstOrDefault()
                });
                h.Talents.Add(new Talent()
                {
                    Level   = 25,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[6])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[7])?.Effects.FirstOrDefault()
                });
            });

            if (!string.IsNullOrEmpty(saveLocation))
            {
                Save(saveLocation);
            }
        }