Esempio n. 1
0
    public PokemonStat(PokemonStatType pStatType, int pBaseValue)
    {
        Type      = pStatType;
        BaseValue = pBaseValue;

        Modifiers = new PokemonStatModifierList();
    }
Esempio n. 2
0
    public PokemonStat this[PokemonStatType pStatType]
    {
        get
        {
            // We get the 1st occurence of the desired PokemonStatType.
            foreach (var item in this)
            {
                if (item.Type == pStatType)
                {
                    return(item);
                }
            }

            // No occurence found.
            return(null);
        }
        set
        {
            var statToSet = this[pStatType];

            if (statToSet != null)
            {
                statToSet = value;
            }
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Returns the stat of this stat set defined in the stat type.
        /// </summary>
        public int GetStat(PokemonStatType statType)
        {
            switch (statType)
            {
            case PokemonStatType.HP:
                return(HP);

            case PokemonStatType.Attack:
                return(Atk);

            case PokemonStatType.Defense:
                return(Def);

            case PokemonStatType.SpecialAttack:
                return(SpAtk);

            case PokemonStatType.SpecialDefense:
                return(SpDef);

            case PokemonStatType.Speed:
                return(Speed);
            }
            // should not happen, as all cases are covered above
            return(0);
        }
Esempio n. 4
0
    public int GetEV(PokemonStatType pStatType)
    {
        switch (pStatType)
        {
        case PokemonStatType.HP:
        case PokemonStatType.Attack:
        case PokemonStatType.Defence:
        case PokemonStatType.Speed:
        case PokemonStatType.SpecialAttack:
        case PokemonStatType.SpecialDefence:
            return(Stats[pStatType].EV);

        default:
            return(-1);
        }
    }
Esempio n. 5
0
        private static int InternalCalculateStat(Pokemon pokemon, PokemonStatType statType)
        {
            // Stat = 
            // floor((floor(((2 * base + IV + floor(EV / 4)) * level) / 100) + 5) * nature)

            int IV = pokemon.EVs.GetStat(statType);
            int EV = pokemon.IVs.GetStat(statType);
            int baseStat = pokemon.BaseStats.GetStat(statType);

            double nature = 1.0d;

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

            return (int)((Floor((Floor(2 * baseStat + IV + Floor((double)EV / 4)) * pokemon.Level) / 100) + 5) * nature);
        }
Esempio n. 6
0
        private static int InternalCalculateStat(Pokemon pokemon, PokemonStatType statType)
        {
            // Stat =
            // floor((floor(((2 * base + IV + floor(EV / 4)) * level) / 100) + 5) * nature)

            int IV       = pokemon.EVs.GetStat(statType);
            int EV       = pokemon.IVs.GetStat(statType);
            int baseStat = pokemon.BaseStats.GetStat(statType);

            double nature = 1.0d;

            if (pokemon.Nature.StatIncrease.Contains(statType))
            {
                nature = 1.1d;
            }
            else if (pokemon.Nature.StatDecrease.Contains(statType))
            {
                nature = 0.9d;
            }

            return((int)((Floor((Floor(2 * baseStat + IV + Floor((double)EV / 4)) * pokemon.Level) / 100) + 5) * nature));
        }
Esempio n. 7
0
 /// <summary>
 /// Returns a specific stat for a Pokémon.
 /// </summary>
 public static int CalculateStat(Pokemon pokemon, PokemonStatType statType)
 {
     return(statType == PokemonStatType.HP ?
            CalculateHP(pokemon) :
            InternalCalculateStat(pokemon, statType));
 }
Esempio n. 8
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);
    }
Esempio n. 9
0
    public bool TryAddEV(PokemonStatType pStatType, int pAmount)
    {
        int hpEV   = GetEV(PokemonStatType.HP);
        int atkEV  = GetEV(PokemonStatType.Attack);
        int defEV  = GetEV(PokemonStatType.Defence);
        int sAtkEV = GetEV(PokemonStatType.SpecialAttack);
        int sDefEV = GetEV(PokemonStatType.SpecialDefence);
        int spdEV  = GetEV(PokemonStatType.Speed);

        int currentEV = 0;

        switch (pStatType)
        {
        case PokemonStatType.HP:
            currentEV = hpEV;
            break;

        case PokemonStatType.Attack:
            currentEV = atkEV;
            break;

        case PokemonStatType.Defence:
            currentEV = defEV;
            break;

        case PokemonStatType.Speed:
            currentEV = sAtkEV;
            break;

        case PokemonStatType.SpecialAttack:
            currentEV = sDefEV;
            break;

        case PokemonStatType.SpecialDefence:
            currentEV = spdEV;
            break;

        default:
            // Non EV stat.
            return(false);
        }

        int evTotal = hpEV + atkEV + defEV + sAtkEV + sDefEV + spdEV;

        if (evTotal >= MAX_SUMMED_EV ||
            currentEV >= MAX_EV)
        {
            // EV cap reached.
            return(false);
        }

        // We check if we will pass the max total amount.
        if (evTotal + pAmount > MAX_SUMMED_EV)
        {
            // If we do, we clamp.
            pAmount = MAX_SUMMED_EV - evTotal;
        }

        // We check if we will pass the max single amount.
        if (currentEV + pAmount > MAX_EV)
        {
            // If we do, we clamp.
            pAmount = MAX_EV - currentEV;
        }

        // We add the EV.
        Stats[pStatType].EV += pAmount;

        return(true);
    }
Esempio n. 10
0
 public int GetCurrentStatValue(PokemonStatType pStatType)
 {
     return(Stats[pStatType].GetCurrentValue(CurrentLevel, Nature));
 }
Esempio n. 11
0
 /// <summary>
 /// Returns a specific stat for a Pokémon.
 /// </summary>
 public static int CalculateStat(Pokemon pokemon, PokemonStatType statType)
 {
     return statType == PokemonStatType.HP ? 
         CalculateHP(pokemon) :
         InternalCalculateStat(pokemon, statType);
 }