public void ProcessPokemonDataCSV(string embeddedResourceFileName) { pokemonData.Clear(); var assembly = Assembly.GetExecutingAssembly(); string resourceName = assembly.GetManifestResourceNames() .Single(str => str.EndsWith(embeddedResourceFileName)); using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); string[] rows = result.Split(new Char[] { '\n', '\r' }); for (int x = 1; x < rows.Length; x++) { string[] columnData = rows[x].Split(','); if (columnData.Length > 1) { PokeData pd = new PokeData(); pd.PokemonName = columnData[0]; pd.HP = Int32.Parse(columnData[1]); pd.Atk = Int32.Parse(columnData[2]); pd.Def = Int32.Parse(columnData[3]); pd.PokemonNumber = Int32.Parse(columnData[4]); pd.Gen = columnData[5]; pokemonData.Add(pd); } } } }
public void PopulatePokemonStats() { if (cbPokemon.SelectedIndex != -1) { PokeData pd = Pokemon.pokemonData[cbPokemon.SelectedIndex]; lblPokeGen.Content = pd.Gen; lblPokeNum.Content = pd.PokemonNumber; lblBaseStam.Content = pd.HP; baseStam = pd.HP; lblBaseAtk.Content = pd.Atk; baseAtk = pd.Atk; lblBaseDef.Content = pd.Def; baseDef = pd.Def; } }