/// <summary> /// Does parsing stuff in the derived class. /// </summary> /// <param name="source">The JSON data to parse.</param> protected override void Create(JsonData source) { Id = (int)source[NID]; Abilities = source[ABS].Map <JsonData, ApiResource>(ParseResource).ToArray(); EggGroups = source[EGS].Map <JsonData, ApiResource>(ParseResource).ToArray(); Descriptions = source[DSS].Map <JsonData, ApiResource>(ParseResource).ToArray(); Moves = source[MVS].Map <JsonData, LearnableMove>(LearnableMove.Parse).OrderBy(t => t.Level).ToArray(); Evolutions = source.Keys.Contains(EVS) ? source[EVS].Map <JsonData, Evolution>(data => new Evolution(data)).ToArray() : EmptyEvoArr; Type = source[TPS].Map <JsonData, ApiResource>(ParseResource).Select(r => (TypeFlags)(1 << r.Id - 1)).Aggregate((a, b) => a | b); Species = source[SCS].ToString(); CatchRate = source.AsInt(CRT); HP = source.AsInt(HP_); Attack = source.AsInt(ATK); Defense = source.AsInt(DEF); SpecialAttack = source.AsInt(SAT); SpecialDefense = source.AsInt(SDF); Speed = source.AsInt(SPD); EggCycles = source.AsInt(EGC); Height = source.AsInt(HT); Mass = source.AsInt(MS); EvYield = EvYield.Parse(source); ExpYield = source.AsNullInt(EXP); GrowthRate = source[GRT].ToString(); BaseHappiness = (int)source[BHP]; var mfr = source[MFR].ToString(); var split = mfr.Split('/'); MaleFemaleRatio = String.IsNullOrEmpty(mfr) ? NanPair : Tuple.Create(Double.Parse(split[0], CultureInfo.InvariantCulture) / 100d, Double.Parse(split[1], CultureInfo.InvariantCulture) / 100d); }