Examples of Pokemon


Examples of org.jpokemon.pokemon.Pokemon

    if (indexOld < 0 || indexNew < 0 || indexOld >= _amount || indexNew >= _amount)
      throw new IllegalArgumentException("Index out of bounds");
    if (indexOld == indexNew)
      throw new IllegalArgumentException("Arguments are equal");

    Pokemon swap = _data[indexOld];
    int loopUpdateDirection = (indexOld > indexNew) ? -1 : 1;
    for (int i = indexOld; i != indexNew; i = i + loopUpdateDirection) {
      _data[i] = _data[i + loopUpdateDirection];
    }
    _data[indexNew] = swap;
View Full Code Here

Examples of org.pokenet.client.backend.entity.Pokemon

    if (curHP != 0)
      m_timeLine.getBattleCanvas().setPokeballImage(index, "normal");
    else
      m_timeLine.getBattleCanvas().setPokeballImage(index, "fainted");
   
    m_enemyPokes[index] = new Pokemon();
    m_enemyPokes[index].setName(name);
    m_enemyPokes[index].setLevel(level);
    m_enemyPokes[index].setGender(gender);
    m_enemyPokes[index].setMaxHP(maxHP);
    m_enemyPokes[index].setCurHP(curHP);
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

   * @param p
   * @return
   */
  public Pokemon [] getParty(PlayerChar p) {
    Pokemon [] party = new Pokemon[6];
    Pokemon poke;
    int level;
    String name;
    Random r = DataService.getBattleMechanics().getRandom();
    if(isGymLeader()) {
      if(p.getBadgeCount() > 7) {
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

            return true;
        /** See if the opponent already has a pokemon with this effect and that
         *  that effect was induced by this enemy trainer. */
        Pokemon[] party = target.getTeammates();
        for (int i = 0; i < party.length; ++i) {
            Pokemon p = party[i];
            if (p.isFainted())
                continue;
            StatusEffect effect = p.getEffect(m_effect);
            if (effect != null) {
                Pokemon inducer = effect.getInducer();
                if ((inducer != null) &&
                    (inducer.getParty() == source.getParty()))
                    return false;
            }
        }
        return true;
    }
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

      int playerId = data.getInt("id");
      //Player's bag is now created "on the fly" as soon as player gets his first item.
      /*
       * Create the players party
       */
      Pokemon p = this.createStarter(s);
      p.setOriginalTrainer(info[0]);
      p.setDateCaught(new SimpleDateFormat("yyyy-MM-dd:HH-mm-ss").format(new Date()));
      this.saveNewPokemon(p, m_database);
     
      m_database.query("INSERT INTO pn_party (member, pokemon0, pokemon1, pokemon2, pokemon3, pokemon4, pokemon5) VALUES ('" +
          + playerId + "','" + p.getDatabaseID() + "','-1','-1','-1','-1','-1')");
      data = m_database.query("SELECT * FROM pn_party WHERE member='" + playerId + "'");
      data.first();
      /*
       * Attach pokemon to the player
       */
 
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

          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

Examples of org.pokenet.server.battle.Pokemon

    /* Check that the bag contains the item */
    if (p.getBag().containsItem(itemId) < 0) return false;
    /* We have the item, so let us use it */
    Item i = GameServer.getServiceManager().getItemDatabase().getItem(itemId);
    /* Pokemon object we might need */
    Pokemon poke = null;
    try {
      /* Check if the item is a rod */
      if (i.getName().equalsIgnoreCase("OLD ROD")) {
        if(!p.isBattling() && !p.isFishing()) {
          p.fish(0);
          return true;
        }
      } else if(i.getName().equalsIgnoreCase("GOOD ROD")) {
        if(!p.isBattling() && !p.isFishing()) {
          if(p.getFishingLevel() >= 15) {
            p.fish(15);
          } else {
            // Notify client that you need a fishing level of 15 or higher for this rod
            p.getTcpSession().write("FF15");
          }
          return true;
        }
      } else if(i.getName().equalsIgnoreCase("GREAT ROD")) {
        if(!p.isBattling() && !p.isFishing()) {
          if(p.getFishingLevel() >= 50) {
            p.fish(35);
          } else {
            // Notify client that you need a fishing level of 50 or higher for this rod
            p.getTcpSession().write("FF50");
          }
          return true;
        }
      } else if(i.getName().equalsIgnoreCase("ULTRA ROD")) {
        if(!p.isBattling() && !p.isFishing()) {
          if(p.getFishingLevel() >= 70) {
            p.fish(50);
          } else {
            // Notify client that you need a fishing level of 70 or higher for this rod
            p.getTcpSession().write("FF70");
          }
          return true;
        }
      }
      /* Check if the item is a repel or escape rope */
      else if (i.getName().equalsIgnoreCase("REPEL")) {
        p.setRepel(100);
        return true;
      } else if (i.getName().equalsIgnoreCase("SUPER REPEL")) {
        p.setRepel(200);
        return true;
      } else if (i.getName().equalsIgnoreCase("MAX REPEL")) {
        p.setRepel(250);
        return true;
      } else if (i.getName().equalsIgnoreCase("ESCAPE ROPE")) {
        if (p.isBattling()) return false;
        /* Warp the player to their last heal point */
        p.setX(p.getHealX());
        p.setY(p.getHealY());
        p.setMap(GameServer.getServiceManager().getMovementService()
            .getMapMatrix()
            .getMapByGamePosition(p.getHealMapX(), p.getHealMapY()), null);
        return true;
      }
      /* Else, determine what do to with the item */
      if (i.getAttributes().contains(ItemAttribute.MOVESLOT)) {
        /* TMs & HMs */
        try {
          /* Can't use a TM/HM during battle */
          if (p.isBattling()) return false;
          /* Player is not in battle, learn the move */
          poke = p.getParty()[Integer.parseInt(data[0])];
          if (poke == null) return false;
          String moveName = i.getName().substring(5);
          /* Ensure the Pokemon can learn this move */
          if (DataService.getMoveSetData().getMoveSet(poke.getSpeciesNumber())
              .canLearn(moveName)) {
            poke.getMovesLearning().add(moveName);
            m_player.getTcpSession().write("Pm" + data[0] + moveName);
            return true;
          }
        } catch (Exception e) {
          e.printStackTrace();
          return false;
        }
      } else if (i.getAttributes().contains(ItemAttribute.POKEMON)) {
        /* Status healers, hold items, etc. */
        if (i.getCategory().equalsIgnoreCase("POTIONS")) {
          /*
           * Potions
           */
          int hpBoost = 0;
          poke = p.getParty()[Integer.parseInt(data[0])];
          String message = "";
          if (poke == null) return false;
          if(i.getId() == 1) { //Potion
                        hpBoost = 20;
                        poke.changeHealth(hpBoost);
                        message = "You used Potion on "+poke.getName()+"/nThe Potion restored 20 HP";
                  } else if(i.getId()==2) {//Super Potion
                          hpBoost = 50;
                          poke.changeHealth(hpBoost);
                          message = "You used Super Potion on "+poke.getName()+"/nThe Super Potion restored 50 HP";
                  } else if(i.getId()==3) { //Hyper Potion
                          hpBoost = 200;
                          poke.changeHealth(hpBoost);
                          message = "You used Hyper Potion on "+poke.getName()+"/nThe Hyper Potion restored 200 HP";
                  } else if(i.getId()==4) {//Max Potion
                          poke.changeHealth(poke.getRawStat(0));
                          message = "You used Max Potion on "+poke.getName()+"/nThe Max Potion restored All HP";
                  } else {
                          return false;
                  }
          if (!p.isBattling()) {
            /* Update the client */
            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
            p.getTcpSession().write("Ii" + message);
          } else {
            /* Player is in battle, take a hit from enemy */
            p.getBattleField().forceExecuteTurn();
          }
          return true;
        } else if (i.getCategory().equalsIgnoreCase("EVOLUTION")) {
          /* Evolution items can't be used in battle */
          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) {
              /*
               * Check if the item is an evolution stone If so, evolve the
               * Pokemon
               */
              if (i.getName().equalsIgnoreCase("FIRE STONE")
                  && evolution.getAttribute().equalsIgnoreCase("FIRESTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("WATER STONE")
                  && evolution.getAttribute().equalsIgnoreCase("WATERSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("THUNDERSTONE")
                  && evolution.getAttribute().equalsIgnoreCase("THUNDERSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("LEAF STONE")
                  && evolution.getAttribute().equalsIgnoreCase("LEAFSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("MOON STONE")
                  && evolution.getAttribute().equalsIgnoreCase("MOONSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("SUN STONE")
                  && evolution.getAttribute().equalsIgnoreCase("SUNSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("SHINY STONE")
                  && evolution.getAttribute().equalsIgnoreCase("SHINYSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("DUSK STONE")
                  && evolution.getAttribute().equalsIgnoreCase("DUSKSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("DAWN STONE")
                  && evolution.getAttribute().equalsIgnoreCase("DAWNSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              } else if (i.getName().equalsIgnoreCase("OVAL STONE")
                  && evolution.getAttribute().equalsIgnoreCase("OVALSTONE")) {
                poke.setEvolution(evolution);
                poke.evolutionResponse(true, p);
                return true;
              }
            }
          }
        } else if (i.getCategory().equalsIgnoreCase("MEDICINE")) {
          poke = p.getParty()[Integer.parseInt(data[0])];
          if (poke == null) return false;
          if(i.getId() == 16) { //Antidote
                  String message = "You used Antidote on "+poke.getName()+"/nThe Antidote restored "+poke.getName()+" status to normal";
                  poke.removeStatus(PoisonEffect.class);
                  if(p.isBattling())
                    p.getBattleField().forceExecuteTurn();
                  else
                    p.getTcpSession().write("Ii" + message);
                  return true;
                    } else if(i.getId() == 17) { //Parlyz Heal
                      String message = "You used Parlyz Heal on "+poke.getName()+"/nThe Parlyz Heal restored "+poke.getName()+" status to normal";
                      poke.removeStatus(ParalysisEffect.class);
                      if(p.isBattling())
                        p.getBattleField().forceExecuteTurn();
                      else
                        p.getTcpSession().write("Ii" + message);
                      return true;
                    } else if(i.getId() == 18) { //Awakening
                      String message = "You used Awakening on "+poke.getName()+"/nThe Awakening restored "+poke.getName()+" status to normal";
                      poke.removeStatus(SleepEffect.class);
                      if(p.isBattling())
                        p.getBattleField().forceExecuteTurn();
                      else
                        p.getTcpSession().write("Ii" + message);
                      return true;
                    } else if(i.getId() == 19) { //Burn Heal
                      String message = "You used Burn Heal on "+poke.getName()+"/nThe Burn Heal restored "+poke.getName()+" status to normal";
                      poke.removeStatus(BurnEffect.class);
                      if(p.isBattling())
                        p.getBattleField().forceExecuteTurn();
                      else
                        p.getTcpSession().write("Ii" + message);
                      return true;
                    } else if(i.getId() == 20) { //Ice Heal
                      String message = "You used Ice Heal on "+poke.getName()+"/nThe Ice Heal restored "+poke.getName()+" status to normal";
                      poke.removeStatus(FreezeEffect.class);
                      if(p.isBattling())
                        p.getBattleField().forceExecuteTurn();
                      else
                        p.getTcpSession().write("Ii" + message);
                      return true;
                    } else if(i.getId() == 21) { //Full Heal
                      String message = "You used Full Heal on "+poke.getName()+"/nThe Full Heal restored "+poke.getName()+" status to normal";
                      poke.removeStatusEffects(true);
                      if(p.isBattling())
                        p.getBattleField().forceExecuteTurn();
                      else
                        p.getTcpSession().write("Ii" + message);
                      return true;
                    } else if (i.getName().equalsIgnoreCase("LAVA COOKIE")) {
            // just like a FULL HEAL
            poke.removeStatusEffects(true);
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }
            return true;
          } else if (i.getName().equalsIgnoreCase("OLD GATEAU")) {
            // just like a FULL HEAL
            poke.removeStatusEffects(true);
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }
            return true;
          }
        } else if (i.getCategory().equalsIgnoreCase("FOOD")) {
          poke = p.getParty()[Integer.parseInt(data[0])];
          Random rand = new Random();
          if (poke == null) return false;
          if(i.getId() == 200) { //Cheri Berry
                      String message = poke.getName()+" ate the Cheri Berry/nThe Cheri Berry restored "+poke.getName()+" status to normal";
                      poke.removeStatus(ParalysisEffect.class);
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 201) { //Chesto Berry
                      String message = poke.getName()+" ate the Chesto Berry/nThe Chesto Berry restored "+poke.getName()+" status to normal";
                      poke.removeStatus(SleepEffect.class);
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 202) { //Pecha Berry
                      String message = poke.getName()+" ate the Pecha Berry/nThe Pecha Berry restored "+poke.getName()+" status to normal";
                        poke.removeStatus(PoisonEffect.class);
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 203) { //Rawst Berry
                      String message = poke.getName()+" ate the Rawst Berry/nThe Rawst Berry restored "+poke.getName()+" status to normal";
                      poke.removeStatus(BurnEffect.class);
                      if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 204) { //Aspear Berry
                      String message = poke.getName()+" ate the Aspear Berry/nThe Aspear Berry restored "+poke.getName()+" status to normal";
                        poke.removeStatus(FreezeEffect.class);
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 205) { //Leppa Berry
                      String message = "Leppa Berry had no effect"; // Move selection not completed, temp message TODO. Add support for this
                        int ppSlot = Integer.parseInt(data[1]);
                        if(poke.getPp(ppSlot) + 10 <= poke.getMaxPp(ppSlot))
                          poke.setPp(ppSlot, poke.getPp(ppSlot) + 10);
                        else
                          poke.setPp(ppSlot, poke.getMaxPp(ppSlot));
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 206) { //Oran Berry
                      String message = poke.getName()+" ate the Oran Berry/nThe Oran Berry restored 10HP";
                      poke.changeHealth(10);
                        if(!p.isBattling()) {
                          p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                          p.getTcpSession().write("Ii" + message);
                        }
                        else
                          p.getBattleField().forceExecuteTurn();
                        return true;
                    } else if(i.getId() == 207) { //Persim Berry
                      String message = poke.getName()+" ate the Persim Berry/nThe Persim Berry restored "+poke.getName()+" status to normal";
                      poke.removeStatus(ConfuseEffect.class);
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                          p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 208) { //Lum Berry
                      String message = poke.getName()+" ate the Lum Berry/nThe Lum Berry restored "+poke.getName()+" status to normal";
                        poke.removeStatusEffects(true);
                        if(p.isBattling())
                          p.getBattleField().forceExecuteTurn();
                        else
                             p.getTcpSession().write("Ii" + message);
                        return true;
                    } else if(i.getId() == 209) { //Sitrus Berry
                      String message = poke.getName()+" ate the Sitrus Berry/nThe Sitrus Berry restored 30HP";
                        poke.changeHealth(30);
                        if(!p.isBattling()) {
                            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                          p.getTcpSession().write("Ii" + message);
                        }
                        else
                          p.getBattleField().forceExecuteTurn();
                        return true;
                    } else if(i.getId() == 210) { //Figy Berry
                      String message = poke.getName()+" ate the Figy Berry/nThe Figy Berry restored" +poke.getRawStat(0) / 8+" HP to " +poke.getName()+"!";
                        poke.changeHealth(poke.getRawStat(0) / 8);
                        if(!p.isBattling()) {
                            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                             p.getTcpSession().write("Ii" + message);
                        }
                        else
                             p.getBattleField().forceExecuteTurn();
                        return true;
                    } else if(i.getId() == 214) { //Wiki Berry
                      String message = poke.getName()+" ate the Wiki Berry/nThe Wiki Berry restored" +poke.getRawStat(0) / 8+" HP to " +poke.getName()+"!";
                        poke.changeHealth(poke.getRawStat(0) / 8);
                        if(!p.isBattling()) {
                            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                             p.getTcpSession().write("Ii" + message);
                        }
                        else
                             p.getBattleField().forceExecuteTurn();
                        return true;
                    } else if(i.getId() == 212) { //Mago Berry
                      String message = poke.getName()+" ate the Mago Berry/nThe Mago Berry restored" +poke.getRawStat(0) / 8+" HP to " +poke.getName()+"!";
                        poke.changeHealth(poke.getRawStat(0) / 8);
                        if(!p.isBattling()) {
                            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                             p.getTcpSession().write("Ii" + message);
                        }
                        else
                             p.getBattleField().forceExecuteTurn();
                        return true;
                    } else if(i.getId() == 213) { //Aguav Berry
                      String message = poke.getName()+" ate the Aguav Berry/nThe Aguav Berry restored" +poke.getRawStat(0) / 8+" HP to " +poke.getName()+"!";
                        poke.changeHealth(poke.getRawStat(0) / 8);
                        if(!p.isBattling()) {
                            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                             p.getTcpSession().write("Ii" + message);
                        }
                        else
                             p.getBattleField().forceExecuteTurn();
                        return true;
                    } else if(i.getId() == 214) { //Iapapa Berry
                      String message = poke.getName()+" ate the Iapapa Berry/nThe Iapapa Berry restored" +poke.getRawStat(0) / 8+" HP to " +poke.getName()+"!";
                        poke.changeHealth(poke.getRawStat(0) / 8);
                        if(!p.isBattling()) {
                            p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
                             p.getTcpSession().write("Ii" + message);
                        }
                        else
                             p.getBattleField().forceExecuteTurn();
                        return true;
                    }else if (i.getId() == 800) { //Voltorb Lollipop
            String message = poke.getName()+" ate the Voltorb Lollipop/nThe Lollipop restored 50 HP to " +poke.getName()+"!";
            poke.changeHealth(50);
            int random = rand.nextInt(10);
            if(random <3){
              poke.addStatus(new ParalysisEffect());
              message+="/n"+poke.getName()+" was Paralyzed from the Lollipop!";
            }
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }else{
              p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
              p.getTcpSession().write("Ii" + message);
            }
            return true;
          } else if (i.getId() == 801) { //Sweet Chills
            String message = poke.getName()+" ate the Sweet Chill/nThe Sweet Chill restored " +poke.getName()+"'s moves!";
            for(int ppSlot=0;ppSlot<4;ppSlot++){
              if (poke.getPp(ppSlot) + 5 <= poke.getMaxPp(ppSlot)) {
                poke.setPp(ppSlot, poke.getPp(ppSlot) + 5);
              } else {
                poke.setPp(ppSlot, poke.getMaxPp(ppSlot));
              }
            }
            int random = rand.nextInt(10);
            if(random <3){
              try{
              poke.addStatus(new FreezeEffect());
              message+="/n"+poke.getName()+" was frozen solid from the cold candy!";
              }catch(Exception e){}//Already under a status effect.
            }
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }else
              p.getTcpSession().write("Ii" + message);
            return true;
          }else if (i.getId() == 802) { //Cinnamon Candy
            String message = poke.getName()+" ate the Cinnamon Candy./nThe Cinnamon Candy restored " +poke.getName()+"'s status to normal!";
            poke.removeStatusEffects(true);
            int random = rand.nextInt(10);
            if(random <3){
              poke.addStatus(new BurnEffect());
              message+="/n"+poke.getName()+" was burned from the candy!";
            }
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }else{
              p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
              p.getTcpSession().write("Ii"+message);
            }
            return true;
          } else if (i.getId() == 803) { //Candy Corn
            String message = poke.getName()+" ate the Candy Corn./n" +poke.getName()+" is happier!";
            int happiness = poke.getHappiness()+15;
            if(happiness<=300)
              poke.setHappiness(happiness);
            else
              poke.setHappiness(300);
            int random = rand.nextInt(10);
            if(random <3){
              poke.addStatus(new PoisonEffect());
              message+="/n"+poke.getName()+" got Poisoned from the rotten candy!";
            }
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }else
              p.getTcpSession().write("Ii"+message);
            return true;
          } else if (i.getId() == 804) { //Poke'Choc
            String message = poke.getName()+" ate the Poke'Choc Bar!/n" +poke.getName()+" is happier!";
            int happiness = poke.getHappiness()+10;
            if(happiness<=300)
              poke.setHappiness(happiness);
            else
              poke.setHappiness(300);
            int random = rand.nextInt(10);
            if(random <=3){
              poke.changeHealth(30);
              message+="/n"+poke.getName()+" recovered 30HP.";
            }
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }else
              p.getTcpSession().write("Ii"+message);
            return true;
          } else if (i.getId() == 805) { //Gummilax
            String message = poke.getName()+" ate the Gummilax./n" +poke.getName()+" is happier!";
            int happiness = poke.getHappiness()+rand.nextInt(30);
            if(happiness<=255)
              poke.setHappiness(happiness);
            else
              poke.setHappiness(255);
            int random = rand.nextInt(10);
            if(random <3){
              poke.addStatus(new ParalysisEffect());
              message+="/nThe gummi was too sweet for "+poke.getName()+"./n"+poke.getName()+" fell asleep!";
            }
            if (p.isBattling()) {
              p.getBattleField().forceExecuteTurn();
            }else
              p.getTcpSession().write("Ii"+message);
            return true;
          } else if (i.getId() == 806) { //Gengum
            String message = poke.getName()+" ate the Gengum.";
            int randHealth = rand.nextInt(100);
            randHealth-=20;
            if(poke.getHealth()+randHealth<0)
              poke.setHealth(1);
            else
              poke.changeHealth(randHealth);
            if(randHealth>0)
              message+="/n"+poke.getName()+" healed "+randHealth+"HP";
            else
              message+="/n"+poke.getName()+" lost "+-randHealth+"HP";
            if (p.isBattling()) {
              p.getBattleField().queueMove(0,BattleTurn.getMoveTurn(-1));
            }else{
              p.getTcpSession().write("Ph" + data[0] + poke.getHealth());
              p.getTcpSession().write("Ii"+message);
            }
            return true;
          }
        }
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

            DataService.getMovesList().getMove(data.getString("move3")) :
              null);
        /*
         * Create the new Pokemon
         */
        Pokemon p = new Pokemon(
            DataService.getBattleMechanics(),
            PokemonSpecies.getDefaultData().getPokemonByName(data.getString("speciesName"))
            ,
            PokemonNature.getNatureByName(data.getString("nature")),
            data.getString("abilityName"),
            data.getString("itemName"),
            data.getInt("gender"),
            data.getInt("level"),
            new int[] {
              data.getInt("ivHP"),
              data.getInt("ivATK"),
              data.getInt("ivDEF"),
              data.getInt("ivSPD"),
              data.getInt("ivSPATK"),
              data.getInt("ivSPDEF")},
            new int[] {
              data.getInt("evHP"),
              data.getInt("evATK"),
              data.getInt("evDEF"),
              data.getInt("evSPD"),
              data.getInt("evSPATK"),
              data.getInt("evSPDEF")},
            moves,
            new int[] {
              data.getInt("ppUp0"),
              data.getInt("ppUp1"),
              data.getInt("ppUp2"),
              data.getInt("ppUp3")
            });
        p.reinitialise();
        /*
         * Set exp, nickname, isShiny and exp gain type
         */
        p.setBaseExp(data.getInt("baseExp"));
        p.setExp(Double.parseDouble(data.getString("exp")));
        p.setName(data.getString("name"));
        p.setHappiness(data.getInt("happiness"));
        p.setShiny(Boolean.parseBoolean(data.getString("isShiny")));
        p.setExpType(ExpTypes.valueOf(data.getString("expType")));
        p.setOriginalTrainer(data.getString("originalTrainerName"));
        p.setDatabaseID(data.getInt("id"));
        p.setDateCaught(data.getString("date"));
        p.setIsFainted(Boolean.parseBoolean(data.getString("isFainted")));
        /*
         * Contest stats (beauty, cute, etc.)
         */
        String [] cstats = data.getString("contestStats").split(",");
        p.setContestStat(0, Integer.parseInt(cstats[0]));
        p.setContestStat(1, Integer.parseInt(cstats[1]));
        p.setContestStat(2, Integer.parseInt(cstats[2]));
        p.setContestStat(3, Integer.parseInt(cstats[3]));
        p.setContestStat(4, Integer.parseInt(cstats[4]));
        /*
         * Sets the stats
         */
        p.calculateStats(true);
        p.setHealth(data.getInt("hp"));
        p.setRawStat(1, data.getInt("atk"));
        p.setRawStat(2, data.getInt("def"));
        p.setRawStat(3, data.getInt("speed"));
        p.setRawStat(4, data.getInt("spATK"));
        p.setRawStat(5, data.getInt("spDEF"));
        /*
         * Sets the pp information
         */
        p.setPp(0, data.getInt("pp0"));
        p.setPp(1, data.getInt("pp1"));
        p.setPp(2, data.getInt("pp2"));
        p.setPp(3, data.getInt("pp3"));
        p.setPpUp(0, data.getInt("ppUp0"));
        p.setPpUp(0, data.getInt("ppUp1"));
        p.setPpUp(0, data.getInt("ppUp2"));
        p.setPpUp(0, data.getInt("ppUp3"));
        return p;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

   * @param poke2
   * @return
   * @throws Exception
   */
  public PokemonEgg generateEgg(Pokemon poke1, Pokemon poke2) throws Exception{
    Pokemon poke = null;
    if (canBreed(poke1, poke2)) {
      try{
        poke = generateHatchling(generateEggSpecies());
        return new PokemonEgg(poke, 200);
      } catch (Exception e) {
View Full Code Here

Examples of org.pokenet.server.battle.Pokemon

   * @param species
   * @return
   * @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
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.