Ejemplo n.º 1
0
        public MonsterStaticData(short id)
        {
            var pokemon        = DataFetcher.GetApiObject <Pokemon>(id).Result;
            var pokemonSpecies = DataFetcher.GetApiObject <PokemonSpecies>(id).Result;


            ID   = id;
            Name = pokemonSpecies.Names.Single(GetLocalizedName).Name;

            Types     = new Types(pokemon.Types.Select(type => Cached <MonsterTypeStaticData> .Get((byte)type.Type.ID)).ToArray <ITypeStaticData>());
            Abilities = new Abilities(pokemon.Abilities.Select(ability => new Ability((short)ability.Ability.ID, ability.IsHidden)).ToArray <BaseAbility>());
            EggGroups = new EggGroups(pokemonSpecies.EggGroups.Select(eggGroup => Cached <EggGroupStaticData> .Get((byte)eggGroup.ID)).ToArray <IEggGroupStaticData>());
            HeldItems = pokemon.HeldItems.Select(heldItem => Cached <ItemStaticData> .Get(heldItem.Item.ID)).ToList <IItemStaticData>();

            Height = pokemon.Height;
            Weight = pokemon.Mass;

            BaseStats = new Stats(
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.HP).BaseValue,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.Attack).BaseValue,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.Defense).BaseValue,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.SpecialAttack).BaseValue,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.SpecialDefense).BaseValue,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.Speed).BaseValue);
            BaseHappiness = (byte)pokemonSpecies.BaseHappiness;

            CatchRate = (byte)pokemonSpecies.CaptureRate;

            MaleRatio = 1.0f - pokemonSpecies.FemaleToMaleRate ?? -1.0f;

            HatchCycles = (byte)pokemonSpecies.HatchCounter;

            IsBaby = pokemonSpecies.IsBaby;

            HasGenderDifferences = pokemonSpecies.HasGenderDifferences;

            ExperienceType = (ExperienceType)pokemonSpecies.GrowthRate.ID;

            RewardExperience = (short)pokemon.BaseExperience;
            RewardStats      = new Stats(
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.HP).Effort,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.Attack).Effort,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.Defense).Effort,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.SpecialAttack).Effort,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.SpecialDefense).Effort,
                (short)pokemon.Stats.Single(stat => stat.Stat.ID == (int)StatType.Speed).Effort);
        }
Ejemplo n.º 2
0
        public AttackStaticData(short id)
        {
            var move = DataFetcher.GetApiObject <Move>(id).Result;

            ID   = id;
            Name = move.Names.Single(MonsterStaticData.GetLocalizedName).Name;
            Type = Cached <MonsterTypeStaticData> .Get((byte)move.Type.ID);

            Target = (Target)move.Target.ID;

            DamageClass = (DamageClass)move.DamageClass.ID;

            Power    = (byte)(move.Power ?? 0);
            Accuracy = (byte)(move.Accuracy ?? 0);
            Priority = (byte)move.Priority;

            PP = (byte)(move.PP ?? 0);
        }
Ejemplo n.º 3
0
 public Trainer(int id) : base(Cached <TrainerStaticData> .Get(id))
 {
 }
Ejemplo n.º 4
0
 public Item(int id) : base(Cached <ItemStaticData> .Get(id))
 {
 }
Ejemplo n.º 5
0
 public Monster(short species, Gender gender, bool isShiny, short ability, byte nature) : base(Cached <MonsterStaticData> .Get(species))
 {
     PersonalityValue = StaticData.Abilities.Contains(ability) ? GenerateRandom(gender, isShiny, ability) : 0;
     Nature           = nature;
 }
Ejemplo n.º 6
0
        public Monster(short species, ushort secretID, uint personalityValue, byte nature) : base(Cached <MonsterStaticData> .Get(species))
        {
            SecretID         = secretID;
            PersonalityValue = personalityValue;

            Nature = nature;
        }
Ejemplo n.º 7
0
        public Monster(DataItems dataItems) : this(GetID(dataItems), GetGender(dataItems), GetIsShiny(dataItems), GetAbility(dataItems), GetNature(dataItems))
        {
            var dict = dataItems.ToDictionary();


            Experience = int.Parse(dict["Experience"]);
            Friendship = byte.Parse(dict["Friendship"]);
            EggSteps   = int.Parse(dict["EggSteps"]);
            CatchInfo  = new CatchInfo()
            {
                Nickname    = string.IsNullOrEmpty(dict["NickName"]) ? string.Empty : dict["NickName"],
                PokeballID  = byte.Parse(dict["CatchBall"]),
                Method      = dict["CatchMethod"],
                Location    = dict["CatchLocation"],
                TrainerName = dict["CatchTrainer"],
                TrainerID   = (ushort)int.Parse(dict["OT"]).BitsGet(0, 16) == ushort.MaxValue ? (ushort)int.Parse(dict["OT"]).BitsGet(16, 32) : (ushort)int.Parse(dict["OT"]).BitsGet(0, 16)
            };

            if (short.TryParse(dict["Item"], out var item) && item != 0)
            {
                HeldItem = new Item(item);
            }

            var move0 = dict["Attack1"].Split(',');
            var move1 = dict["Attack2"].Split(',');
            var move2 = dict["Attack3"].Split(',');
            var move3 = dict["Attack4"].Split(',');

            Moves = new List <BaseAttackInstance>();
            if (move0.Length != 1)
            {
                var dat = Cached <AttackStaticData> .Get(short.Parse(move0[0]));

                var ppUps = (byte)Math.Round((double)(byte.Parse(move0[1]) - dat.PP) / dat.PP / 0.2D);
                Moves.Add(new Attack(dat, byte.Parse(move0[2]), ppUps));
            }
            if (move1.Length != 1)
            {
                var dat = Cached <AttackStaticData> .Get(short.Parse(move1[0]));

                var ppUps = (byte)Math.Round((double)(byte.Parse(move1[1]) - dat.PP) / dat.PP / 0.2D);
                Moves.Add(new Attack(dat, byte.Parse(move1[2]), ppUps));
            }
            if (move2.Length != 1)
            {
                var dat = Cached <AttackStaticData> .Get(short.Parse(move2[0]));

                var ppUps = (byte)Math.Round((double)(byte.Parse(move2[1]) - dat.PP) / dat.PP / 0.2D);
                Moves.Add(new Attack(dat, byte.Parse(move2[2]), ppUps));
            }
            if (move3.Length != 1)
            {
                var dat = Cached <AttackStaticData> .Get(short.Parse(move3[0]));

                var ppUps = (byte)Math.Round((double)(byte.Parse(move3[1]) - dat.PP) / dat.PP / 0.2D);
                Moves.Add(new Attack(dat, byte.Parse(move3[2]), ppUps));
            }

            CurrentHP = short.Parse(dict["HP"]);

            var ev  = dict["EVs"].Split(',');
            var ev0 = short.Parse(ev[0]);
            var ev1 = short.Parse(ev[1]);
            var ev2 = short.Parse(ev[2]);
            var ev3 = short.Parse(ev[3]);
            var ev4 = short.Parse(ev[4]);
            var ev5 = short.Parse(ev[5]);

            EV = new Stats(ev0, ev1, ev2, ev3, ev4, ev5);

            var iv  = dict["IVs"].Split(',');
            var iv0 = short.Parse(iv[0]);
            var iv1 = short.Parse(iv[1]);
            var iv2 = short.Parse(iv[2]);
            var iv3 = short.Parse(iv[3]);
            var iv4 = short.Parse(iv[4]);
            var iv5 = short.Parse(iv[5]);

            IV = new Stats(iv0, iv1, iv2, iv3, iv4, iv5);
        }
Ejemplo n.º 8
0
        private IReadOnlyList <EvolvesTo> GetEvolutions()
        {
            var evolvesToList  = new List <EvolvesTo>();
            var evolutionChain = DataFetcher.GetApiObject <PokemonSpecies>(ID).Result.EvolutionChain.GetObject().Result;

            if (evolutionChain.Chain.EvolvesTo.Any())
            {
                var chains = GetChains(evolutionChain.Chain);
                var chain  = chains.FirstOrDefault(c => ID == c.Species.ID);
                foreach (var evolvesTo in chain.EvolvesTo)
                {
                    var list = new List <EvolvesTo.IEvolutionCondition>();
                    foreach (var evolutionDetail in evolvesTo.Details)
                    {
                        var evolutionConditions = new List <EvolvesTo.ISubEvolutionCondition>();

                        if (evolutionDetail.MinLevel != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByLevel((byte)evolutionDetail.MinLevel));
                        }

                        if (evolutionDetail.MinHappiness != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByHappiness((byte)evolutionDetail.MinHappiness.Value));
                        }

                        if (evolutionDetail.MinAffection != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByAffection((byte)evolutionDetail.MinAffection.Value));
                        }

                        if (evolutionDetail.MinBeauty != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByBeauty((byte)evolutionDetail.MinBeauty));
                        }

                        if (evolutionDetail.KnownMove != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByAttack(Cached <AttackStaticData> .Get((short)evolutionDetail.KnownMove.ID)));
                        }

                        if (evolutionDetail.KnownMoveType != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByKnownAttackType(Cached <MonsterTypeStaticData> .Get((byte)evolutionDetail.KnownMoveType.ID)));
                        }

                        if (evolutionDetail.Item != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByItem(Cached <ItemStaticData> .Get(evolutionDetail.Item.ID)));
                        }

                        if (evolutionDetail.HeldItem != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByHeldItem(Cached <ItemStaticData> .Get(evolutionDetail.HeldItem.ID)));
                        }

                        if (evolutionDetail.Gender != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByGender((BattleEngine.Monster.Enums.Gender)evolutionDetail.Gender));
                        }

                        if (evolutionDetail.Location != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByArea(null));
                        }

                        if (evolutionDetail.NeedsOverworldRain)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByWeather(Weather.Rain));
                        }

                        if (evolutionDetail.PartySpecies != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByMonsterInTeam((short)evolutionDetail.PartySpecies.ID));
                        }

                        if (evolutionDetail.PartyType != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByMonsterTypeInTeam(Cached <MonsterTypeStaticData> .Get((byte)evolutionDetail.PartySpecies.ID)));
                        }

                        if (evolutionDetail.TradeSpecies != null)
                        {
                            evolutionConditions.Add(new EvolvesTo.ByTradeMonster((short)evolutionDetail.TradeSpecies.ID));
                        }

                        if (evolutionDetail.TurnUpsideDown)
                        {
                            evolutionConditions.Add(new ByTurnUpsideDown());
                        }

                        if (!string.IsNullOrEmpty(evolutionDetail.TimeOfDay))
                        {
                            if (Enum.TryParse(evolutionDetail.TimeOfDay, true, out EvolvesTo.ByTimeOfDay.TimeOfDay @enum))
                            {
                                evolutionConditions.Add(new EvolvesTo.ByTimeOfDay(@enum));
                            }
                            else
                            {
                                throw new Exception();
                            }
                        }

                        switch (evolutionDetail.Trigger.ID)
                        {
                        case 1:
                            list.Add(new EvolvesTo.ByLevelUp(evolutionConditions));
                            break;

                        case 2:
                            list.Add(new EvolvesTo.ByTrade(evolutionConditions));
                            break;

                        case 3:
                            list.Add(new EvolvesTo.ByItemUse(evolutionConditions));
                            break;

                        case 4:
                            list.Add(new ByShed());
                            break;

                        default:
                            break;
                        }
                    }

                    evolvesToList.Add(new EvolvesTo(Cached <MonsterStaticData> .Get((short)evolvesTo.Species.ID), list));
                }
            }
            return(evolvesToList);
        }
Ejemplo n.º 9
0
 public Attack(short id) : base(Cached <AttackStaticData> .Get(id))
 {
 }
Ejemplo n.º 10
0
 public Attack(short id, byte ppCurrent, byte ppUps) : base(Cached <AttackStaticData> .Get(id), ppCurrent, ppUps)
 {
 }
Ejemplo n.º 11
0
 public Ability(short id, bool isHidden) : base(Cached <AbilityStaticData> .Get(id), isHidden)
 {
 }