Esempio n. 1
0
        private static short CalculateHP(MonsterInstanceData instanceData)
        {
            // HP = 
            // (floor((2 * Base + IV + floor(EV / 4)) * Level) + Level + 10)

            return (short) (Math.Floor(((2 * instanceData.StaticData.BaseStats.HP + instanceData.IV.HP + Math.Floor((double) instanceData.EV.HP / 4)) * instanceData.Level) / 100) + instanceData.Level + 10);
        }
Esempio n. 2
0
        public override ProtobufPacket ReadPacket(ProtobufDataReader reader)
        {
            DestinationId = reader.Read(DestinationId);
            MonsterData = reader.Read(MonsterData);

            return this;
        }
Esempio n. 3
0
        public static MonsterStats CalculateStats(MonsterInstanceData instanceData)
        {
            var hp = CalculateStat(instanceData, MonsterStatType.HP);
            var attack = CalculateStat(instanceData, MonsterStatType.Attack);
            var defence = CalculateStat(instanceData, MonsterStatType.Defense);
            var spAttack = CalculateStat(instanceData, MonsterStatType.SpecialAttack);
            var spDefence = CalculateStat(instanceData, MonsterStatType.SpecialDefense);
            var speed = CalculateStat(instanceData, MonsterStatType.Speed);

            return new MonsterStats(hp, attack, defence, spAttack, spDefence, speed);
        }
Esempio n. 4
0
        public static short CalculateStat(MonsterInstanceData instanceData, MonsterStatType statType)
        {
            if (statType == MonsterStatType.HP)
                return CalculateHP(instanceData);

            // Stat = 
            // floor((floor(((2 * base + IV + floor(EV / 4)) * level) / 100) + 5) * nature)

            int IV = instanceData.IV.GetStat(statType);
            int EV = instanceData.EV.GetStat(statType);
            int baseStat = instanceData.StaticData.BaseStats.GetStat(statType);

            double nature = 1.0d;

            //if (Monster.Nature.StatIncrease.Contains(statType))
            //    nature = 1.1d;
            //else if (Monster.Nature.StatDecrease.Contains(statType))
            //    nature = 0.9d;

            return (short) ((Math.Floor((Math.Floor(2 * baseStat + IV + Math.Floor((double) EV / 4)) * instanceData.Level) / 100) + 5) * nature);
        }
Esempio n. 5
0
        //public int EncounterType => Data.EncounterType;
        //public int Version => Data.Version;
        //public int Country => Data.Country;
        //public int Region => Data.Region;
        //public int ConsoleRegion => Data.ConsoleRegion;
        //public int Language => Data.Language;


        public MonsterInstanceData ConvertToMonsterInstanceData()
        {
            Data.FixMoves();
            Data.FixMemories();
            Data.FixRelearn();
            Data.RefreshChecksum();

            var data = new MonsterInstanceData(Species, SId, PId, Nature)
            {
                Affection = OT_Affection,
                CatchInfo = new MonsterCatchInfo()
                {
                    Method = "converted from a Pokémon Game",// "converted from Pokémon Game",// EncounterType.ToString(),
                    Location = $"on {MetLocationTypes.MetLocation[Met_Location]}",//"at PokéD's Server",//Met_Location.ToString(),
                    TrainerName = OT_Name,
                    TrainerId = OT_Id,
                    PokeballId = Ball,
                    Nickname = IsNicknamed ? Nickname : string.Empty
                },
                CurrentHP = HPCurrent,
                EV = new MonsterStats(EVs[0], EVs[1], EVs[2], EVs[3], EVs[4], EVs[5]),
                EggSteps = IsEgg ? 0 : 0,
                Experience = EXP,
                Friendship = CurrentFriendship,
                HeldItem = HeldItem,
                IV = new MonsterStats(IVs[0], IVs[1], IVs[2], IVs[3], IVs[4], IVs[5]),
                Moves = new MonsterMoves(
                    new MonsterMove(Move1, Move1_PPUps),
                    new MonsterMove(Move2, Move2_PPUps),
                    new MonsterMove(Move3, Move3_PPUps),
                    new MonsterMove(Move4, Move4_PPUps))
            };

            // HT_Affection?
            //data.HiddenEV = new MonsterStats();

            return data;
        }
Esempio n. 6
0
        public static Monster ToMonster(this DataItems data)
        {
            var dict = data.ToDictionary();

            var id = short.Parse(dict["Pokemon"]);
            var gender = (MonsterGender) int.Parse(dict["Gender"]);
            if(gender == MonsterGender.Female)
                gender = MonsterGender.Male;
            else if (gender == MonsterGender.Male)
                gender = MonsterGender.Female;

            var isShiny = int.Parse(dict["isShiny"]) != 0;
            var ability = short.Parse(dict["Ability"]);
            var nature = byte.Parse(dict["Nature"]);

            var dat = new MonsterInstanceData(id, gender, isShiny, ability, nature)
            {
                Experience = int.Parse(dict["Experience"]),
                Friendship = byte.Parse(dict["Friendship"]),
                CatchInfo = new MonsterCatchInfo()
                {
                    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)
                }
            };

            dat.HeldItem = short.Parse(dict["Item"]);

            var move0 = dict["Attack1"].Split(',');
            var move1 = dict["Attack2"].Split(',');
            var move2 = dict["Attack3"].Split(',');
            var move3 = dict["Attack4"].Split(',');
            dat.Moves = new MonsterMoves(
                move0.Length != 1 ? new MonsterMove(int.Parse(move0[0]), int.Parse(move0[2]) - int.Parse(move0[1])) : MonsterMove.Empty,
                move1.Length != 1 ? new MonsterMove(int.Parse(move1[0]), int.Parse(move1[2]) - int.Parse(move1[1])) : MonsterMove.Empty,
                move2.Length != 1 ? new MonsterMove(int.Parse(move2[0]), int.Parse(move2[2]) - int.Parse(move2[1])) : MonsterMove.Empty,
                move3.Length != 1 ? new MonsterMove(int.Parse(move3[0]), int.Parse(move3[2]) - int.Parse(move3[1])) : MonsterMove.Empty);

            dat.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]);
            dat.EV = new MonsterStats(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]);
            dat.IV = new MonsterStats(iv0, iv1, iv2, iv3, iv4, iv5);

            return new Monster(dat);
        }
Esempio n. 7
0
 public Monster(MonsterInstanceData instanceData) { InstanceData = instanceData; }
Esempio n. 8
0
 public Monster(short id) { InstanceData = new MonsterInstanceData(id); }