Exemplo n.º 1
0
        /// <summary>
        /// Does parsing stuff in the derived class.
        /// </summary>
        /// <param name="source">The JSON data to parse.</param>
        protected override void Create(JsonData source)
        {
            Power = source.AsInt(POW);
            PP    = source.AsInt(PP_C);

            Description = source[DESC].ToString();
            Accurracy   = Double.Parse(source[ACC].ToString(), CultureInfo.InvariantCulture) * 0.01d;

            MoveCategory cat;

            Enum.TryParse(source[CAT].ToString(), true, out cat);

            Category = cat;
        }
Exemplo n.º 2
0
        internal static bool Get(this JsonData data, ref int val)
        {
            bool ret = false;

            if (null != data && (data.IsDouble || data.IsInt || data.IsLong))
            {
                ret = true;
                val = data.AsInt();
            }
            return(ret);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
 internal static uint AsUint(this JsonData data)
 {
     return((uint)data.AsInt());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Does parsing stuff in the derived class.
 /// </summary>
 /// <param name="source">The JSON data to parse.</param>
 protected override void Create(JsonData source)
 {
     ReleaseYear = source.AsInt(R_Y);
     Generation  = source.AsInt(GEN);
 }