public int getCP(string name, int iv_atk, int iv_def, int iv_hp, float level) { Poke foundPoke = null; foreach (var poke in _pokes) { if (poke.Name == name) { foundPoke = poke; break; } } if (foundPoke == null) { throw new Exception("not found"); } IV iv = foundPoke.IV; iv.Attack = iv_atk; iv.Defense = iv_def; iv.HP = iv_hp; iv.Level = level; var cp = iv.CP; return(cp); }
public List <Poke> JSONParsePoke(string jsonText) { JObject jResults = JObject.Parse(jsonText); List <Poke> counties = new List <Poke>(); foreach (var county in jResults["pokemon"]) { var name = (string)county["speciesName"]; var stats = county["baseStats"]; var atk = int.Parse((string)stats["atk"]); var def = int.Parse((string)stats["def"]); var hp = int.Parse((string)stats["hp"]); Poke move = new Poke(); move.Name = name; IV iv = new IV(atk, def, hp); move.IV = iv; counties.Add(move); } return(counties); }