Package org.pokenet.server.battle

Examples of org.pokenet.server.battle.PokemonSpecies


          if (p.isBattling()) return false;
          /* Get the pokemon's evolution data */
          poke = p.getParty()[Integer.parseInt(data[0])];
          /* Ensure poke exists */
          if (poke == null) return false;
          PokemonSpecies pokeData = PokemonSpecies.getDefaultData().getPokemonByName(
              poke.getSpeciesName());
          for (int j = 0; j < pokeData.getEvolutions().length; j++) {
            PokemonEvolution evolution = pokeData.getEvolutions()[j];
            /*
             * Check if this pokemon evolves by item
             */
            if (evolution.getType() == EvolutionTypes.Item) {
              /*
 
View Full Code Here


  private Pokemon createStarter(int speciesIndex) throws Exception {
    /*
     * Get the Pokemon species. Use getPokemonByName as once the
     * species array gets to gen 3 it loses the pokedex numbering
     */
    PokemonSpecies species = null;
    switch(speciesIndex) {
    case 1:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Bulbasaur");
      break;
    case 4:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Charmander");
      break;
    case 7:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Squirtle");
      break;
    case 152:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Chikorita");
      break;
    case 155:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Cyndaquil");
      break;
    case 158:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Totodile");
      break;
    case 252:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Treecko");
      break;
    case 255:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Torchic");
      break;
    case 258:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Mudkip");
      break;
    case 387:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Turtwig");
      break;
    case 390:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Chimchar");
      break;
    case 393:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Piplup");
      break;
    default:
      species = PokemonSpecies.getDefaultData().getPokemonByName("Mudkip");
    }
       
        ArrayList<MoveListEntry> possibleMoves = new ArrayList<MoveListEntry>();
        MoveListEntry[] moves = new MoveListEntry[4];
        Random random = DataService.getBattleMechanics().getRandom();
        for (int i = 0; i < species.getStarterMoves().length; i++) {
                possibleMoves.add(DataService.getMovesList().getMove(
                    species.getStarterMoves()[i]));
        }
        for (int i = 1; i <= 5; i++) {
                if (species.getLevelMoves().containsKey(i)) {
                        possibleMoves.add(DataService.getMovesList().getMove(
                            species.getLevelMoves().get(i)));
                }
        }
        /*
         * possibleMoves sometimes has null moves stored in it, get rid of them
         */
        for(int i = 0; i < possibleMoves.size(); i++) {
          if(possibleMoves.get(i) == null)
            possibleMoves.remove(i);
        }
        /*
         * Now the store the final set of moves for the Pokemon
         */
        if (possibleMoves.size() <= 4) {
                for (int i = 0; i < possibleMoves.size(); i++) {
                        moves[i] = possibleMoves.get(i);
                }
        } else {
          MoveListEntry m = null;
                for (int i = 0; i < 4; i++) {
                        if (possibleMoves.size() == 0) {
                            moves[i] = null;
                        } else {
                          while(m == null) {
                            m = possibleMoves.get(random.nextInt(possibleMoves
                                        .size()));
                          }
                            moves[i] = m;
                            possibleMoves.remove(m);
                            m = null;
                        }
                }
        }
        /*
         * Get all possible abilities
         */
        String [] abilities = species.getAbilities();
        /* First select an ability randomly */
        String ab = abilities[random.nextInt(abilities.length)];
        /*
         * Unfortunately, all Pokemon have two possible ability slots but some only have one.
         * If the null slot was selected, select the other slot
         */
        while(ab == null || ab.equalsIgnoreCase("")) {
          ab = abilities[random.nextInt(abilities.length)];
        }
        /*
         * Create the Pokemon object
         */
        Pokemon starter = new Pokemon(
            DataService.getBattleMechanics(),
                        species,
                        PokemonNature.N_QUIRKY,
                                        ab,
                        null, (random.nextInt(100) > 87 ? Pokemon.GENDER_FEMALE
                                        : Pokemon.GENDER_MALE), 5, new int[] {
                                        random.nextInt(32), // IVs
                                        random.nextInt(32), random.nextInt(32),
                                        random.nextInt(32), random.nextInt(32),
                                        random.nextInt(32) }, new int[] { 0, 0, 0, 0, 0, 0 }, //EVs
                        moves, new int[] { 0, 0, 0, 0 });
        /* Attach their growth rate */
        starter.setExpType(species.getGrowthRate());
        /* Attach base experience */
        starter.setBaseExp(species.getBaseEXP());
        /* Set their current exp */
        starter.setExp(DataService.getBattleMechanics().getExpForLevel(starter, 5));
        /* Set their happiness */
        starter.setHappiness(species.getHappiness());
        /* Set their name as their species */
        starter.setName(starter.getSpeciesName());
        return starter;
  }
View Full Code Here

   */
  public MoveListEntry[] getBabyMoves(int species) {
    MoveListEntry[] moves = new MoveListEntry[4];
    MoveList moveList = MoveList.getDefaultData();
    ArrayList<MoveListEntry> possibleMoves = new ArrayList<MoveListEntry>();
    PokemonSpecies s = PokemonSpecies.getDefaultData().getSpecies(species);
    // List of moves by level 5
    for (int i = 1; i <= 5; i++) {
      if (s.getLevelMoves().containsKey(i)) {
        possibleMoves.add(moveList.getMove(s.getLevelMoves().get(i)));
      }
    }

    int moveNum = possibleMoves.size();
    if (possibleMoves.size() <= 4) {
      for (int i = 0; i < possibleMoves.size(); i++) {
        moves[i] = possibleMoves.get(i);
      }
    } else {
      for (int i = 0; i < moves.length; i++) {
        if (possibleMoves.size() == 0)
          moves[i] = null;
        moves[i] = possibleMoves.get(moveNum);
        moveNum--;
        if (moveNum == 0)
          break;
      }
    }

    // Moves that both parents know

    // List of egg moves
    possibleMoves.clear();
    for (int i = 0; i < s.getEggMoves().length; i++) {
      for (int x = 0; i < 4; i++) {
        if (malePoke.getMove(x) == moveList.getMove(s.getEggMoves()[i])) {
          possibleMoves.add(moveList.getMove(s.getEggMoves()[i]));
        }
      }
    }
    for (int i = 0; i < 4; i++) {
      if (moves[i] == null && possibleMoves.size() < i) {
View Full Code Here

   * @throws Exception
   */
  private Pokemon generateHatchling(int species) throws Exception{
    Pokemon hatchling;
    try{
    PokemonSpecies speciesData = PokemonSpecies.getDefaultData()
        .getSpecies(species);
    Random random = DataService.getBattleMechanics().getRandom();

    // get Nature if female or ditto is holding an everstone, 50% chance
    String nature = "";
    if (femalePoke.getItemName() == "Everstone") {
      if (random.nextInt(2) == 0) {
        nature = femalePoke.getNature().getName();
      }
    } else
      nature = PokemonNature.getNature(
          random.nextInt(PokemonNature.getNatureNames().length))
          .getName();

    int natureIndex = 0;
    for (String name : PokemonNature.getNatureNames()) {
      if (name == nature) {
        break;
      }
      natureIndex++;
    }

    // Get 3 random IVS from parents
    int[] ivs = new int[6];
    for (int iv : ivs) {
      ivs[iv] = speciesData.getBaseStats()[iv];
    }

    int[] attempt = new int[3];
    for (int i = 0; i < 3; i++) {
      int randomNum = DataService.getBattleMechanics().getRandom()
          .nextInt(2);
      attempt[i] = randomNum;
      if (i == 2) {
        if (attempt[0] == 0 && attempt[1] == 0) {
          randomNum = 1;
        } else if (attempt[0] == 1 && attempt[1] == 1) {
          randomNum = 0;
        }
      }
      int iv = DataService.getBattleMechanics().getRandom().nextInt(6);
      if (randomNum == 0) {
        ivs[iv] = malePoke.getBaseStats()[iv];
      } else {
        ivs[iv] = femalePoke.getBaseStats()[iv];
      }
    }

    hatchling = new Pokemon(DataService.getBattleMechanics(),
        PokemonSpecies.getDefaultData().getSpecies(species),
        PokemonNature.getNature(natureIndex),
        speciesData.getPossibleAbilities(PokemonSpecies.getDefaultData())[random
            .nextInt(speciesData.getPossibleAbilities(
                PokemonSpecies.getDefaultData()).length)], "", Pokemon
            .generateGender(speciesData.getPossibleGenders()), 5,
        ivs, new int[6], getBabyMoves(species), new int[4]);
    } catch (Exception e) {
      throw new Exception("BreedingException: Hatchling generation issue");
    }
    return hatchling;
View Full Code Here

        double levelExp = DataService.getBattleMechanics().getExpForLevel(p,
            p.getLevel() + 1)
            - p.getExp();
        if (levelExp <= 0) {
          PokemonSpecies pokeData = PokemonSpecies.getDefaultData().getPokemonByName(
              p.getSpeciesName());
          boolean evolve = false;
          /* Handle evolution */
          for (int i = 0; i < pokeData.getEvolutions().length; i++) {
            PokemonEvolution evolution = pokeData.getEvolutions()[i];
            if (evolution.getType() == EvolutionTypes.Level) {
              if (evolution.getLevel() <= p.getLevel() + 1) {
                p.setEvolution(evolution);
                m_player.getTcpSession().write("PE" + index);
                evolve = true;
                i = pokeData.getEvolutions().length;
              }
            } else if (evolution.getType() == EvolutionTypes.HappinessDay) {
              if (p.getHappiness() > 220 && !TimeService.isNight()) {
                p.setEvolution(evolution);
                m_player.getTcpSession().write("PE" + index);
                evolve = true;
                i = pokeData.getEvolutions().length;
              }
            } else if (evolution.getType() == EvolutionTypes.HappinessNight) {
              if (p.getHappiness() > 220 && TimeService.isNight()) {
                p.setEvolution(evolution);
                m_player.getTcpSession().write("PE" + index);
                evolve = true;
                i = pokeData.getEvolutions().length;
              }
            } else if (evolution.getType() == EvolutionTypes.Happiness) {
              if (p.getHappiness() > 220) {
                p.setEvolution(evolution);
                m_player.getTcpSession().write("PE" + index);
                evolve = true;
                i = pokeData.getEvolutions().length;
              }
            }
          }
          /* If the Pokemon is evolving, don't move learn just yet */
          if (evolve) continue;

          /* This Pokemon just levelled up! */
          p.setHappiness(p.getHappiness() + 2);
          p.calculateStats(false);

          int level = DataService.getBattleMechanics().calculateLevel(p);
          m_player.addTrainingExp(level * 5);
          int oldLevel = p.getLevel();
          String move = "";

          /* Move learning */
          p.getMovesLearning().clear();
          for (int i = oldLevel + 1; i <= level; i++) {
            if (pokeData.getLevelMoves().get(i) != null) {
              move = pokeData.getLevelMoves().get(i);
              p.getMovesLearning().add(move);
              m_player.getTcpSession().write("Pm" + index + move);
            }
          }

View Full Code Here

            p = (PlayerChar) player1;
          }
         
          int index = p.getPokemonIndex(curPokemon);
         
          PokemonSpecies pokeData = PokemonSpecies.getDefaultData().getPokemonByName(
              curPokemon.getSpeciesName());
         
          for (PokemonEvolution currentEvolution : pokeData.getEvolutions()) {
            System.out.println(curPokemon.getName() + " can evolve via " + currentEvolution.getType());
           
            if (currentEvolution.getType().equals(EvolutionTypes.Trade)){
              curPokemon.setEvolution(currentEvolution);
              p.getTcpSession().write("PE" + index);
View Full Code Here

TOP

Related Classes of org.pokenet.server.battle.PokemonSpecies

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.