Ejemplo n.º 1
0
    private void generateAbility()
    {
        int randomIndex = Random.Range(0, Species.PossibleAbilities.Count);

        CurrentAbility = Species.PossibleAbilities[randomIndex];
    }
        public JsonResult NewPokemon(Models.Pokemon pokemon, int[] typeIDs, int[] weaknessIDs, int[] abilityIDs, List <Models.PokemonStat> pokemonStats)
        {
            List <string> errorMessages = new List <string>();
            int           lastID        = 0;


            try
            {
                c.POKEMON.Add(pokemon);
                c.SaveChanges();
                lastID = pokemon.POKEMON_ID;

                foreach (int typeID in typeIDs)
                {
                    PokemonType pokemonType = new PokemonType();
                    pokemonType.POKEMON_ID = lastID;
                    pokemonType.TYPE_ID    = typeID;

                    try
                    {
                        c.POKEMON_TYPE.Add(pokemonType);
                        c.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        errorMessages.Add(e.Message);
                    }
                }



                foreach (int weaknessID in weaknessIDs)
                {
                    PokemonWeakness pokemonWeakness = new PokemonWeakness();
                    pokemonWeakness.WEAKNESS_ID = weaknessID;
                    pokemonWeakness.POKEMON_ID  = lastID;
                    try
                    {
                        c.POKEMON_WEAKNESS.Add(pokemonWeakness);
                        c.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        errorMessages.Add(e.Message);
                    }
                }


                foreach (int abilityID in abilityIDs)
                {
                    PokemonAbility pokemonAbility = new PokemonAbility();
                    pokemonAbility.POKEMON_ID = lastID;
                    pokemonAbility.ABILITY_ID = abilityID;
                    try
                    {
                        c.POKEMON_ABILITY.Add(pokemonAbility);
                        c.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        errorMessages.Add(e.Message);
                    }
                }



                foreach (var pokemonStat in pokemonStats)
                {
                    pokemonStat.POKEMON_ID = lastID;
                    try
                    {
                        c.POKEMON_STAT.Add(pokemonStat);
                        c.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        errorMessages.Add(e.Message);
                    }
                }

                c.SaveChanges();
            }
            catch (Exception e)
            {
                errorMessages.Add(e.Message);
            }

            if (errorMessages.Count == 0)
            {
                return(Json("başarılı"));
            }
            else
            {
                return(Json(errorMessages));
            }
        }
Ejemplo n.º 3
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();
    }