private void tblDigimon_Select() { if (tblDigimon.SelectedCells.Count == 0) { return; } int rowIndex = tblDigimon.SelectedCells[0].RowIndex; int colIndex = tblDigimon.SelectedCells[0].ColumnIndex; if (rowIndex < 0) { return; } string name = tblDigimon[colIndex, rowIndex].Value.ToString(); SelectedDigimon = Dex.GetDigimonByName(name); FillDigimonDetails(); }
private void ParseFile(string path) { /*File Format: * LEVEL: Rookie * (Digimon A): (Digimon X, Y, Z that evolve from Digimon A) * (Stats required to evolve into Digimon A) * (Digimon B): (Digimon X, Y, Z that evolve from Digimon B) * (Stats required to evolve into Digimon B) * ... * * LEVEL: Champion * (Digimon C): (Digimon X, Y, Z that evolve from Digimon C) * (Stats required to evolve into Digimon C) */ if (!File.Exists(path)) { return; } using (StreamReader file = new StreamReader(path)) { int counter = 1; string line; string currentDigiLevel = ""; Digimon currDigimon = null; while ((line = file.ReadLine()) != null) { if (line.Trim() == "") { continue; } if (line.StartsWith("LEVEL: ")) { //change the current level string[] strSplit = line.Split(':'); currentDigiLevel = strSplit[1].Trim(); } else if (line.StartsWith("(")) { //this will be a digivolve req string req = line.Substring(1, line.Length - 2); if (currDigimon != null) { currDigimon.Requirements = req; } } else { //got a digimon! string[] nameSplit = line.Split(':'); string name = nameSplit[0].Trim(); currDigimon = new Digimon(); currDigimon.Name = name; currDigimon.Level = currentDigiLevel; Dex.AllDigimon.Add(currDigimon); if (nameSplit.Length > 1) { //digimon can digivolve string[] digivolveSplit = nameSplit[1].Split(','); foreach (string digi in digivolveSplit) { string digivolvesTo = digi.Trim(); Digivolution digivolution = new Digivolution(name, digivolvesTo); Dex.AllDigivolutions.Add(digivolution); } } } counter++; } //end file read while loop } Dex.WriteXML(); }