Exemplo n.º 1
0
        private List <Digimon> LoadFromFile(string listFilePath)
        {
            var digimonList = new List <Digimon>();
            var digimon     = new Digimon();

            foreach (var line in File.ReadAllLines(listFilePath))
            {
                if (line.StartsWith("|n="))
                {
                    digimon.Name = line.Replace("|n=", string.Empty);
                }
                if (line.StartsWith("|yr=") && int.TryParse(line.Replace("|yr=", string.Empty), out int debutYear))
                {
                    digimon.DebutYear = debutYear;
                }
                if (line.StartsWith("|d="))
                {
                    digimon.DebutedIn = line.Replace("|d=", string.Empty);
                }
                if (line.StartsWith("}}"))
                {
                    if (digimon.DebutYear == 0)
                    {
                        digimon.DebutYear = 2099;
                    }
                    digimonList.Add(digimon);
                    digimon = new Digimon();
                }
            }
            return(digimonList.Where(x => IsValidDigimon(x)).ToList());
        }
Exemplo n.º 2
0
 public EditForm(DigimonList digimonList, Digimon currentDigimon)
 {
     InitializeComponent();
     _currentDigimon = currentDigimon;
     _digimonList = digimonList;
     SetText();
 }
 private bool IsValidDigimon(Digimon digimon)
 {
     return(!string.Equals("[[C'mon Digimon]]", digimon.DebutedIn) &&
            !string.Equals("[[Digimon Universe Appli Monsters]]", digimon.DebutedIn) &&
            digimon.Name.IndexOf("Mon", StringComparison.OrdinalIgnoreCase) >= 0 &&
            !digimon.Name.StartsWith("Bio", StringComparison.OrdinalIgnoreCase) &&
            !_InvalidMonsters.Contains(digimon.Name, StringComparer.OrdinalIgnoreCase));
 }
Exemplo n.º 4
0
 private void prevButton_Click(object sender, EventArgs e)
 {
     if (_digimonList.DigimonCollection.Any(x => x.Number < _currentDigimon?.Number))
     {
         _currentDigimon = _digimonList.DigimonCollection.OrderByDescending(z => z.Number).FirstOrDefault(x => x.Number < _currentDigimon.Number);
         SetDigimon(_currentDigimon);
     }
     _justChanged = false;
 }
Exemplo n.º 5
0
 private void GoToPreviousMon()
 {
     var nextDigimon = _digimonList.DigimonCollection.OrderByDescending(z => z.Number).FirstOrDefault(x => x.Number < _currentDigimon.Number);
     if (nextDigimon != null)
     {
         _currentDigimon = nextDigimon;
         SetText();
     }
 }
Exemplo n.º 6
0
 private void GoToNextMon()
 {
     var nextDigimon = _digimonList.DigimonCollection.OrderBy(z => z.Number).FirstOrDefault(x => x.Number > _currentDigimon.Number);
     if (nextDigimon != null)
     {
         _currentDigimon = nextDigimon;
         SetText();
     }
 }
Exemplo n.º 7
0
        private void ChangeCurrentDigimon(string digimon)
        {
            var nextDigimon = _digimonList.DigimonCollection.FirstOrDefault(x => x.NameCheck(digimon));

            if (nextDigimon != null)
            {
                _currentDigimon = nextDigimon;
                SetDigimon(_currentDigimon);
            }
        }
        private List <Digimon> LoadFromJsonFile(string listFilePath)
        {
            var digimonList = new List <Digimon>();
            var digimon     = new Digimon();

            digimonList = new JavaScriptSerializer().Deserialize <List <Digimon> >(File.ReadAllText(listFilePath));
            var validDigimon = digimonList.Where(x => IsValidDigimon(x)).ToList();

            SetNumbers(validDigimon);
            return(validDigimon);
        }
Exemplo n.º 9
0
 private bool TryArmourEvolve(Digimon digimon)
 {
     if (_armourChart.Any(x => string.Equals(x.Digimon, digimon.Name, StringComparison.OrdinalIgnoreCase)))
     {
         var armourForm = new ArmourEvolver();
         armourForm.ArmourEvolved   += ArmourCynka;
         armourForm.NormalEvolution += NormalCynka;
         armourForm.ShowDialog();
         return(true);
     }
     return(false);
 }
Exemplo n.º 10
0
        private void NumberEntered(object sender, EventArgs e)
        {
            var digimonNumber = textBox2.Text;

            if (int.TryParse(digimonNumber, out int digimonInteger) && digimonInteger > 0 &&
                _digimonList.DigimonCollection.Any(x => x.Number == digimonInteger))
            {
                _currentDigimon = _digimonList.DigimonCollection.FirstOrDefault(x => x.Number == digimonInteger);
                SetDigimon(_currentDigimon);
            }
            _justChanged = false;
        }
Exemplo n.º 11
0
 private static void GetEvolutions(Digimon digimon, string downloadString)
 {
     if (Regex.IsMatch(downloadString, "==Evolves To==(.{1,})=Appearances", RegexOptions.Singleline))
     {
         var possibleDigivolutions = new List <string>();
         var digivolutionText      = Regex.Match(downloadString, "==Evolves To==(.{1,})=Appearances", RegexOptions.Singleline).Value.Replace("==Evolves To==", string.Empty).Replace("=Appearances", string.Empty);
         foreach (var match in Regex.Matches(digivolutionText, "\\*([^\\]]{1,})]", RegexOptions.Singleline))
         {
             possibleDigivolutions.Add(match.ToString().Replace("* ", string.Empty).Replace("*", string.Empty).Replace("'''", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty));
         }
         digimon.Digivolutions = possibleDigivolutions;
     }
 }
Exemplo n.º 12
0
 private void DigimonEntered(object sender, EventArgs e)
 {
     if (!_justChanged)
     {
         var digimonName = textBox1.Text;
         if (_digimonList.DigimonCollection.Any(x => x.NameCheck(digimonName)))
         {
             _currentDigimon = _digimonList.DigimonCollection.FirstOrDefault(x => x.NameCheck(digimonName));
             SetDigimon(_currentDigimon);
         }
         _justChanged = false;
     }
 }
Exemplo n.º 13
0
 private bool FilterList(DigimonFilter digimonFilter, Digimon x)
 {
     return((string.IsNullOrWhiteSpace(digimonFilter.AppearanceFilter) ||
             x.Appearances.Any(
                 y => (y.AppearanceCategory == digimonFilter.AppearanceTypeFilter ||
                       digimonFilter.AppearanceTypeFilter == Appearance.AppearanceType.Any) &&
                 Regex.IsMatch(y.AppearanceNameConvert(), digimonFilter.AppearanceFilter, RegexOptions.IgnoreCase))) &&
            (string.IsNullOrWhiteSpace(digimonFilter.LevelFilter) || Regex.IsMatch(x.DubLevel ?? string.Empty, digimonFilter.LevelFilter, RegexOptions.IgnoreCase)) &&
            (string.IsNullOrWhiteSpace(digimonFilter.NameFilter) || Regex.IsMatch(x.Name, digimonFilter.NameFilter, RegexOptions.IgnoreCase) || Regex.IsMatch(x.DisplayName, digimonFilter.NameFilter, RegexOptions.IgnoreCase)) &&
            (string.IsNullOrWhiteSpace(digimonFilter.TypeFilter) || Regex.IsMatch(x.Type ?? string.Empty, digimonFilter.TypeFilter, RegexOptions.IgnoreCase)) &&
            (digimonFilter.NumberFilter <= 0 || x.Number <= digimonFilter.NumberFilter) &&
            (digimonFilter.YearFilter <= 0 || x.DebutYear >= digimonFilter.YearFilter) &&
            (digimonFilter.YearEndFilter <= 0 || x.DebutYear <= digimonFilter.YearEndFilter));
 }
Exemplo n.º 14
0
        private bool TryArmourDevolve(Digimon digimon, out string digimonToDevolve)
        {
            var devolutionFound = false;

            digimonToDevolve = string.Empty;
            var devolveTo = _armourChart.FirstOrDefault(x => x.DigimentalDigivolution.Values.Any(y => string.Equals(y, digimon.Name, StringComparison.OrdinalIgnoreCase)));

            if (devolveTo != null)
            {
                digimonToDevolve = devolveTo.Digimon;
                devolutionFound  = true;
            }
            return(devolutionFound);
        }
Exemplo n.º 15
0
 private static void GetMangaAppearances(Digimon digimon, string downloadString)
 {
     if (Regex.IsMatch(downloadString, "=Appearances=(.{1,})==Manga==(.*?)[^=]==[^=]", RegexOptions.Singleline))
     {
         var appearances     = new List <Appearance>();
         var appearancesText = Regex.Match(downloadString, "=Appearances=(.{1,})==Manga==(.*?)[^=]==[^=]", RegexOptions.Singleline).Value;
         foreach (var match in Regex.Matches(appearancesText, "===(.*?)===", RegexOptions.Singleline))
         {
             appearances.Add(new Appearance
             {
                 Name = match.ToString().Replace("=", string.Empty).Replace("{", string.Empty).Replace("hdr|", string.Empty).Replace("}", string.Empty),
                 AppearanceCategory = Appearance.AppearanceType.Manga
             });
         }
         digimon.Appearances = appearances;
     }
 }
Exemplo n.º 16
0
 public bool TryAddDigimon(Digimon digimon)
 {
     if (!DigimonAlreadyExists(digimon.Name))
     {
         var webloader = new DigimonWebLoader(new List <string>());
         webloader.LoadImage(digimon);
         if (!string.IsNullOrEmpty(digimon.ImageUrl))
         {
             DigimonCollection.Add(digimon);
             UnfilteredDigimonCollection.Add(digimon);
             return(true);
         }
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 17
0
 private void SetDigimon(Digimon digimon)
 {
     _justChanged = true;
     if (digimon != null)
     {
         pictureBox2.Visible  = true;
         pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
         ThreadPool.QueueUserWorkItem(x =>
         {
             try
             {
                 if (digimon.ImageUrl != null && string.Equals(_currentDigimon.Name, digimon.Name))
                 {
                     pictureBox2.LoadAsync(digimon.ImageUrl);
                 }
             }
             catch (Exception ex)
             {
             }
         });
         textBox2.Text  = digimon.Number.ToString();
         textBox1.Text  = digimon.DisplayName;
         textBox3.Lines = new string[3] {
             digimon.DubLevel, digimon.Attribute, digimon.Type
         };
         if (digimon.Appearances != null)
         {
             textBox4.Lines = digimon.Appearances.Where(y => y.AppearanceValue() < 100).OrderBy(x => x.AppearanceValue()).Select(y => y.AppearanceNameConvert()).ToArray();
             if (textBox4.Lines.Count() > 3)
             {
                 textBox4.ScrollBars = ScrollBars.Vertical;
             }
             else
             {
                 textBox4.ScrollBars = ScrollBars.None;
             }
         }
     }
 }
Exemplo n.º 18
0
 private static void GetVirutalPetAppearances(Digimon digimon, string downloadString)
 {
     if (Regex.IsMatch(downloadString, "==Virtual Pets==(.*?)[^=]==[^=]", RegexOptions.Singleline))
     {
         var appearances     = new List <Appearance>();
         var appearancesText = Regex.Match(downloadString, "==Virtual Pets==(.*?)[^=]==[^=]", RegexOptions.Singleline).Value.Replace("==Evolves To==", string.Empty).Replace("=Appearances", string.Empty);
         foreach (var match in Regex.Matches(appearancesText, "===(.*?)===", RegexOptions.Singleline))
         {
             appearances.Add(new Appearance
             {
                 Name = match.ToString().Replace("=", string.Empty).Replace("{", string.Empty).Replace("hdr|", string.Empty).Replace("}", string.Empty),
                 AppearanceCategory = Appearance.AppearanceType.VirtualPet
             });
         }
         if (digimon.Appearances == null)
         {
             digimon.Appearances = appearances;
         }
         else
         {
             digimon.Appearances.AddRange(appearances);
         }
     }
 }
Exemplo n.º 19
0
        public void UpdateDigimon(Digimon digimon)
        {
            var webloader = new DigimonWebLoader(new List <string>());

            webloader.LoadImage(digimon);
        }
Exemplo n.º 20
0
 private bool IsValidDigimon(Digimon digimon)
 {
     return(digimon.DebutYear > 2005 &&
            !string.Equals("[[C'mon Digimon]]", digimon.DebutedIn) &&
            !_InvalidMonsters.Contains(digimon.Name, StringComparer.OrdinalIgnoreCase));
 }
Exemplo n.º 21
0
        private void MakeWebRequest(Digimon digimon, bool retry = false)
        {
            try
            {
                var urlToLoad      = string.Format("https://wikimon.net/index.php?title={0}&action=edit", digimon.Name.Replace(" ", "_"));
                var client         = new WebClient();
                var downloadString = client.DownloadString(urlToLoad);
                if (Regex.IsMatch(downloadString, "\\|dub=[A-z]{1,}\\n"))
                {
                    digimon.DubName = Regex.Match(downloadString, "\\|dub=[A-z]{1,}\\n").Value.Replace("|dub=", string.Empty).Replace("\n", string.Empty);
                }
                if (Regex.IsMatch(downloadString, "\\|l1=[A-z\\s]{1,}\\n"))
                {
                    digimon.Level = Regex.Match(downloadString, "\\|l1=[A-z\\s]{1,}\\n").Value.Replace("|l1=", string.Empty).Replace("\n", string.Empty);
                    if (string.Equals(digimon.Level, "No Level", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Regex.IsMatch(downloadString, "\\|l2=[A-z\\s]{1,}\\n"))
                        {
                            digimon.Level = Regex.Match(downloadString, "\\|l2=[A-z\\s]{1,}\\n").Value.Replace("|l2=", string.Empty).Replace("\n", string.Empty);
                        }
                    }
                }
                if (Regex.IsMatch(downloadString, "\\|yd=[0-9\\s]{1,}\\n"))
                {
                    var yearString = Regex.Match(downloadString, "\\|yd=[0-9\\s]{1,}\\n").Value.Replace("|yd=", string.Empty).Replace("\n", string.Empty);
                    if (int.TryParse(yearString, out int year))
                    {
                        digimon.DebutYear = year;
                    }
                }
                if (Regex.IsMatch(downloadString, "\\|t1=[A-z\\s]{1,}\\n"))
                {
                    digimon.Type = Regex.Match(downloadString, "\\|t1=[A-z\\s]{1,}\\n").Value.Replace("|t1=", string.Empty).Replace("\n", string.Empty);
                }
                if (Regex.IsMatch(downloadString, "\\|a1=[A-z\\s]{1,}\\n"))
                {
                    digimon.Attribute = Regex.Match(downloadString, "\\|a1=[A-z\\s]{1,}\\n").Value.Replace("|a1=", string.Empty).Replace("\n", string.Empty);
                }
                //if (Regex.IsMatch(downloadString, "\\|pe=[A-z\\s]{1,}\\n"))
                //{
                //    digimon.Description = Regex.Match(downloadString, "\\|pe=[A-z\\s]{1,}\\n").Value.Replace("|pe=", string.Empty).Replace("\n", string.Empty);
                //}

                GetEvolutions(digimon, downloadString);
                GetAnimeAppearances(digimon, downloadString);
                GetMangaAppearances(digimon, downloadString);
                GetVideoGameAppearances(digimon, downloadString);
                GetVirutalPetAppearances(digimon, downloadString);

                if (Regex.IsMatch(downloadString, "\\|image=.{1,}\\n"))
                {
                    var imageDownloadString = client.DownloadString(string.Concat("https://wikimon.net/File:",
                                                                                  Regex.Match(downloadString, "\\|image=.{1,}\\n").Value.Replace("|image=", string.Empty).Replace("\n", string.Empty).Replace(" ", "_")));
                    var imageUrl = string.Concat("https://wikimon.net",
                                                 Regex.Match(Regex.Match(imageDownloadString, "<img.{1,}src=\"[^ \"]{1,}\"").Value,
                                                             "src=\"[^ \"]{1,}\"").Value.Replace("src=", string.Empty).Replace("\"", string.Empty));
                    digimon.ImageUrl = imageUrl;
                }
                else if (Regex.IsMatch(downloadString, "#REDIRECT\\s\\[\\[.{1,}]]") && !retry)
                {
                    var newName = Regex.Match(downloadString, "#REDIRECT\\s\\[\\[.{1,}]]").Value.Replace("#REDIRECT [[", string.Empty).Replace("]]", string.Empty);
                    digimon.Name = newName;
                    MakeWebRequest(digimon, true);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 22
0
 public void LoadImage(Digimon digimon)
 {
     MakeWebRequest(digimon);
 }