Example #1
0
        internal Pokemon(Controller controller, int id, Player owner, IPokemonData custom)
        {
            Controller = controller;
            Id         = id;
            Owner      = owner;
            TeamId     = owner.TeamId;

            Form         = custom.Form;
            Name         = custom.Name;
            Happiness    = custom.Happiness;
            Gender       = custom.Gender;
            Lv           = custom.Lv;
            Nature       = custom.Nature;
            AbilityIndex = custom.AbilityIndex;
            Moves        = new Move[custom.Moves.Count()];
            int i = 0;

            foreach (var m in custom.Moves)
            {
                Moves[i++] = new Move(m.Move, m.PP);
            }
            _item = custom.Item;
            Iv    = new ReadOnly6D(custom.Iv);
            Ev    = new ReadOnly6D(custom.Ev);
            _hp   = MaxHp = GetMaxHp;
        }
Example #2
0
    public static float GetNatureModifier(PokemonNature pokemonNature, Stat stat)
    {
        int row = (int)pokemonNature;
        int col = (int)stat;

        return(chart[row][col]);
    }
Example #3
0
        public string Nature(PokemonNature nature)
        {
            var i      = (int)nature;
            var backup = InnerBackup.Natures;

            return(Natures == null ? backup == null ? null : backup.ValueOrDefault(i) : Natures.ValueOrDefault(i));
        }
Example #4
0
    public static Flavor GetFavoriteFlavor(PokemonNature pNature)
    {
        int natureToInt = (int)pNature;

        if (natureToInt % 6 == 0)
        {
            return(Flavor.None);
        }

        int onFive = Mathf.FloorToInt(natureToInt / 5);

        switch (onFive)
        {
        case 0:
            return(Flavor.Spicy);

        case 1:
            return(Flavor.Sour);

        case 2:
            return(Flavor.Sweet);

        case 3:
            return(Flavor.Dry);

        case 4:
            return(Flavor.Bitter);
        }

        return(Flavor.None);
    }
Example #5
0
    /// <summary>
    /// Gets the stat's value according to the current level and nature with the current modifiers.
    /// </summary>
    /// <param name="pPokemonLevel"></param>
    /// <param name="pNature"></param>
    /// <returns></returns>
    public int GetCurrentValue(int pPokemonLevel, PokemonNature pNature)
    {
        int currentLevelValue = GetCurrentLevelValue(pPokemonLevel, pNature);

        foreach (var mod in Modifiers)
        {
            switch (mod.Type)
            {
            case PokemonStatModifierType.LostHP:
                // Current HP
                currentLevelValue -= mod.CurrentValue;
                break;

            case PokemonStatModifierType.Battle:
                // Battle modifiers for non HP stats.
                switch (Type)
                {
                case PokemonStatType.Attack:
                case PokemonStatType.Defence:
                case PokemonStatType.Speed:
                case PokemonStatType.SpecialAttack:
                case PokemonStatType.SpecialDefence:
                    if (mod.CurrentValue < 0)
                    {
                        currentLevelValue *= 2 / 2 - mod.CurrentValue;
                    }
                    else
                    {
                        currentLevelValue *= (2 + mod.CurrentValue) / 2;
                    }
                    break;

                case PokemonStatType.Evasion:
                case PokemonStatType.Accuracy:
                    if (mod.CurrentValue < 0)
                    {
                        currentLevelValue *= 3 / 3 - mod.CurrentValue;
                    }
                    else
                    {
                        currentLevelValue *= (3 + mod.CurrentValue) / 3;
                    }
                    break;
                }
                break;

            default:
                continue;
            }
        }

        return(currentLevelValue);
    }
Example #6
0
    public static string GetNatureName(PokemonNature pNature)
    {
        int natureToInt = (int)pNature;

        if (natureToInt < 0 ||
            natureToInt > 24)
        {
            throw new Exception("Invalid nature providen.");
        }

        return(POKEMON_NATURE_NAMES[natureToInt]);
    }
Example #7
0
    /// <summary>
    /// New Pokemon with: random IVS, Shininess, default moveset, and EVS (0)
    /// </summary>
    /// <param name="pPokemonID"></param>
    /// <param name="pGender"></param>
    /// <param name="pLevel"></param>
    /// <param name="pCaughtBall"></param>
    /// <param name="pHeldItem"></param>
    /// <param name="pOT"></param>
    /// <param name="pAbility"></param>
    public OwnedPokemon(string pPokemonID, PokemonGender pGender, int pLevel, string pCaughtBall, string pHeldItem, string pOT, int pAbility)
        : this(pPokemonID)
    {
        // Set status.
        CurrentStatus = PokemonStatus.NONE;

        // Set level and experience.
        CurrentLevel      = pLevel;
        CurrentExperience = PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(Species.LevelingRate, CurrentLevel);

        // Set friendship.
        CurrentFriendship = Species.BaseFriendship;

        // Set gender.
        generateGender(pGender);

        // Set rare value.
        generateRareValue();

        // Set met data.
        generateMetData(pLevel, pCaughtBall);

        // Set DO n°.
        generateDONumber();

        // Set IVs and EVs.
        generateIVsAndEVs();

        // Set nature.
        Nature = PokemonNatureHelper.GetRandomNature();

        // Set ability.
        generateAbility();

        // ToDo: Set default move set as 4 highest level learnable moves
        //Set moveset based off of the highest level moves possible.
        //_currentMoveset = thisPokemonData.GenerateMoveset(_currentLevel);
        _moveHistory = _currentMoveset;

        //set maxPP and PP to be the regular PP defined by the move in the database.
        PPups = new int[4];
        maxPP = new int[4];
        PP    = new int[4];
        for (int i = 0; i < 4; i++)
        {
            if (!string.IsNullOrEmpty(_currentMoveset[i]))
            {
                maxPP[i] = MoveDatabase.getMove(_currentMoveset[i]).getPP();
                PP[i]    = maxPP[i];
            }
        }
        packMoveset();
    }
Example #8
0
    /// <summary>
    /// Gets the stat's value according to the current level and nature.
    ///
    /// See http://bulbapedia.bulbagarden.net/wiki/Statistic for formula.
    /// </summary>
    /// <param name="pPokemonLevel"></param>
    /// <returns></returns>
    public int GetCurrentLevelValue(int pPokemonLevel, PokemonNature pNature)
    {
        if (BaseValue == 1)
        {
            return(1);
        }

        int currentValue = 1;

        switch (Type)
        {
        case PokemonStatType.HP:
        case PokemonStatType.Attack:
        case PokemonStatType.Defence:
        case PokemonStatType.SpecialAttack:
        case PokemonStatType.SpecialDefence:
        case PokemonStatType.Speed:
            currentValue  = Mathf.CeilToInt(Mathf.Sqrt(EV));
            currentValue  = Mathf.FloorToInt(currentValue * 0.25f);
            currentValue += (BaseValue + IV) * 2;
            currentValue *= pPokemonLevel;
            currentValue  = Mathf.FloorToInt(currentValue * 0.1f);
            currentValue += 5;

            if (Type == PokemonStatType.HP)
            {
                currentValue += pPokemonLevel + 5;
            }
            else
            {
                currentValue = Mathf.FloorToInt(currentValue * PokemonNatureHelper.GetStatFactorFromNature(Type, pNature));
            }

            break;

        case PokemonStatType.Evasion:
        case PokemonStatType.Accuracy:
            // Should be 100.
            currentValue = BaseValue;
            break;
        }

        if (currentValue < 1)
        {
            currentValue = 1;
        }

        return(currentValue);
    }
        internal SimPokemon(int id, SimPlayer owner, IPokemonData custom)
        {
            Id     = id;
            Owner  = owner;
            TeamId = owner.Team;

            Gender       = custom.Gender;
            Lv           = custom.Lv;
            nature       = custom.Nature;
            abilityIndex = custom.AbilityIndex;
            Moves        = custom.Moves.Select((m) => new Move(m.Move, m.PP)).ToArray();
            Item         = custom.Item;
            iv           = new ReadOnly6D(custom.Iv);
            ev           = new ReadOnly6D(custom.Ev);
            _hp          = new PairValue(GameHelper.GetHp(custom.Form.Data.Base.Hp, (byte)iv.Hp, (byte)ev.Hp, (byte)Lv));

            Form       = custom.Form;
            originForm = Form;
            Name       = custom.Name ?? GameString.Current.Pokemon(_form.Species.Number);
        }
Example #10
0
        internal SimPokemon(int id, SimPlayer owner, IPokemonData custom)
        {
            Id     = id;
            Owner  = owner;
            TeamId = owner.Team;

            Gender       = custom.Gender;
            Lv           = custom.Lv;
            nature       = custom.Nature;
            abilityIndex = custom.AbilityIndex;
            Moves        = custom.Moves.Select((m) => new Move(m.Move, m.PP)).ToArray();

            Item      = custom.Item;
            Happiness = custom.Happiness;

            iv  = new ReadOnly6D(custom.Iv);
            ev  = new ReadOnly6D(custom.Ev);
            _hp = new PairValue(GameHelper.GetHp(custom.Form.Data.Base.Hp, (byte)iv.Hp, (byte)ev.Hp, (byte)Lv));

            Form       = custom.Form;
            originForm = Form;
            Name       = custom.Name ?? GameString.Current.Pokemon(_form.Species.Number);

            HiddenPower = GameHelper.HiddenPower(iv);
            for (int i = 0; i < Moves.Length; ++i)
            {
                if (Moves[i].Type.Id == Ms.HIDDEN_POWER)
                {
                    Moves[i] = new Move(new MoveType(Moves[i].Type.Id, HiddenPower, Moves[i].Type.Category, Moves[i].Type.Power, Moves[i].Type.Accuracy, Moves[i].Type.PP, Moves[i].Type.Range), Moves[i].PP.Value);
                }
                if (Moves[i].Type.Id == Ms.NATURAL_GIFT)
                {
                    Moves[i] = new Move(new MoveType(Moves[i].Type.Id, GameHelper.NatureGift(Item), Moves[i].Type.Category, Moves[i].Type.Power, Moves[i].Type.Accuracy, Moves[i].Type.PP, Moves[i].Type.Range), Moves[i].PP.Value);
                }
            }
        }
Example #11
0
 public static bool DislikeTaste(this PokemonNature nature, StatType stat)
 {
     return(StatRevise(nature, stat) == 9);
 }
Example #12
0
        public static int StatRevise(this PokemonNature nature, StatType stat)
        {
            var s = (int)stat - 1;

            return(0 <= s && s < 5 ? REVISES[(int)nature, s] : 10);
        }
Example #13
0
 public static int Get5D(StatType statType, PokemonNature nature, int typeBase, int iv, int ev, int lv)
 {
     return((((typeBase << 1) + iv + (ev >> 2)) * lv / 100 + 5) * nature.StatRevise(statType) / 10);
 }
Example #14
0
 public static double GetNatureEffect(StatType statType, PokemonNature nature)
 {
     return NatureEffects[(int)nature, (int)statType - 1];
 }
Example #15
0
    public static float GetStatFactorFromNature(PokemonStatType pStatType, PokemonNature pNature)
    {
        float factor = 1.0f;

        int natureToInt = (int)pNature;

        if (natureToInt % 6 == 0)
        {
            return(factor);
        }

        switch (pStatType)
        {
        case PokemonStatType.Attack:
            if (Mathf.FloorToInt(natureToInt / 5) == 0)
            {
                factor = 1.1f;
            }
            else if (natureToInt % 5 == 0)
            {
                factor = 0.9f;
            }
            break;

        case PokemonStatType.Defence:
            if (Mathf.FloorToInt(natureToInt / 5) == 1)
            {
                factor = 1.1f;
            }
            else if (natureToInt % 5 == 1)
            {
                factor = 0.9f;
            }
            break;

        case PokemonStatType.Speed:
            if (Mathf.FloorToInt(natureToInt / 5) == 2)
            {
                factor = 1.1f;
            }
            else if (natureToInt % 5 == 2)
            {
                factor = 0.9f;
            }
            break;

        case PokemonStatType.SpecialAttack:
            if (Mathf.FloorToInt(natureToInt / 5) == 3)
            {
                factor = 1.1f;
            }
            else if (natureToInt % 5 == 3)
            {
                factor = 0.9f;
            }
            break;

        case PokemonStatType.SpecialDefence:
            if (Mathf.FloorToInt(natureToInt / 5) == 4)
            {
                factor = 1.1f;
            }
            else if (natureToInt % 5 == 4)
            {
                factor = 0.9f;
            }
            break;
        }

        return(factor);
    }
Example #16
0
    public static PokemonStatType GetDowngradedStat(PokemonNature pNature)
    {
        int natureToInt = (int)pNature;

        return(GetDowngradedStat(natureToInt));
    }
Example #17
0
    /// <summary>
    /// Adding a caught pokemon (only a few customizable details)
    /// </summary>
    /// <param name="pPokemon"></param>
    /// <param name="pNickname"></param>
    /// <param name="pCaughtBall"></param>
    public OwnedPokemon(OwnedPokemon pPokemon, string pNickname, string pCaughtBall)
        : this(pPokemon.Species.GameId)
    {
        Nickname = pNickname;

        // Set status.
        CurrentStatus = pPokemon.CurrentStatus;

        // Set level and experience.
        CurrentLevel      = pPokemon.CurrentLevel;
        CurrentExperience = pPokemon.CurrentExperience;

        // Set friendship.
        CurrentFriendship = pPokemon.Species.BaseFriendship;

        // Set gender.
        Gender = pPokemon.Gender;

        // Set rare value.
        RareValue = pPokemon.RareValue;

        // Set met data.
        MetData = pPokemon.MetData;

        // Set DO n°.
        generateDONumber();


        // Set nature.
        Nature = pPokemon.Nature;

        // Set ability.
        CurrentAbility = pPokemon.CurrentAbility;

        Stats = pPokemon.Stats;
        //// Copy IVs.
        //Stats[PokemonStatType.HP].IV = pPokemon.GetIV(PokemonStatType.HP);
        //Stats[PokemonStatType.Attack].IV = pPokemon.GetIV(PokemonStatType.Attack);
        //Stats[PokemonStatType.Defence].IV = pPokemon.GetIV(PokemonStatType.Defence);
        //Stats[PokemonStatType.SpecialAttack].IV = pPokemon.GetIV(PokemonStatType.SpecialAttack);
        //Stats[PokemonStatType.SpecialDefence].IV = pPokemon.GetIV(PokemonStatType.SpecialDefence);
        //Stats[PokemonStatType.Speed].IV = pPokemon.GetIV(PokemonStatType.Speed);

        //// Copy EVs.
        //Stats[PokemonStatType.HP].EV = pPokemon.GetEV(PokemonStatType.HP);
        //Stats[PokemonStatType.Attack].EV = pPokemon.GetEV(PokemonStatType.Attack);
        //Stats[PokemonStatType.Defence].EV = pPokemon.GetEV(PokemonStatType.Defence);
        //Stats[PokemonStatType.SpecialAttack].EV = pPokemon.GetEV(PokemonStatType.SpecialAttack);
        //Stats[PokemonStatType.SpecialDefence].EV = pPokemon.GetEV(PokemonStatType.SpecialDefence);
        //Stats[PokemonStatType.Speed].EV = pPokemon.GetEV(PokemonStatType.Speed);

        // MoveSet.
        _currentMoveset = pPokemon._currentMoveset;
        _moveHistory    = pPokemon._moveHistory;

        PPups = pPokemon.PPups;
        //set maxPP and PP to be the regular PP defined by the move in the database.
        maxPP = new int[4];
        PP    = new int[4];
        for (int i = 0; i < 4; i++)
        {
            if (!string.IsNullOrEmpty(_currentMoveset[i]))
            {
                maxPP[i] = Mathf.FloorToInt(MoveDatabase.getMove(_currentMoveset[i]).getPP() * ((PPups[i] * 0.2f) + 1));
                PP[i]    = maxPP[i];
            }
        }
        packMoveset();
    }
Example #18
0
 public static int GetStat(StatType statType, PokemonNature nature, int typeBase, byte iv, byte ev, byte lv)
 {
     if (statType == StatType.Hp)
       {
     return GetHp(typeBase, iv, ev, lv);
       }
       else
       {
     return GetStat(typeBase, iv, ev, lv, GetNatureEffect(statType, nature));
       }
 }