Package org.pokenet.server.battle.mechanics

Examples of org.pokenet.server.battle.mechanics.ValidationException


    for (int i = 0; i < m_move.length; ++i) {
      MoveListEntry move = m_move[i];
      if (move != null) {
        ++moveCount;
        String name = move.getName();
        if (set.contains(name)) { throw new ValidationException(
        "This pokemon learns two of the same move."); }
        set.add(name);
        if (!canLearn(speciesData, name)) { throw new ValidationException(
            "This pokemon cannot learn " + name + "."); }
        if ((m_ppUp[i] > 3) || (m_ppUp[i] < 0)) { throw new ValidationException(
            "Each move must have between zero and "
            + "three PP ups applied to it."); }
      }
    }
    if (moveCount == 0) {
      // Pokemon must have at least one move.
      throw new ValidationException("This pokemon learns no moves.");
    } else if (moveCount > 4) { throw new ValidationException(
    "This pokemon learns move than four moves."); }

    int genders = getPossibleGenders();
    if (((genders & m_gender) == 0) && ((genders != 0) || (m_gender != 0))) { throw new ValidationException(
    "This pokemon has an invalid gender."); }

    if (!canUseAbility(speciesData, m_abilityName)) {
      String[] possibilities = getPossibleAbilities(speciesData);
      if ((possibilities != null)) {
        m_abilityName = possibilities[0];
      }
    }

    if ((m_itemName != null)
        && !data.getHoldItemData().canUseItem(getSpeciesName(), m_itemName)) { throw new ValidationException(
        "This pokemon's item is invalid."); }
  }
View Full Code Here


    * Return whether a client's team is valid.
    */
   public void validateTeam(Pokemon[] team, int idx) throws ValidationException {
     final int length = team.length;
     if ((length < 1) || (length > 6)) {
       throw new ValidationException("The team is an invalid size.");
     }
     ModData data = ModData.getDefaultData();
     for (int i = 0; i < length; ++i) {
       team[i].validate(data);
     }

     // Check any clauses.
     Collections.sort(m_effects, new Comparator<Object>() {
       public int compare(Object o1, Object o2) {
         StatusEffect e1 = (StatusEffect)o1;
         StatusEffect e2 = (StatusEffect)o2;
         return e1.getTier() - e2.getTier();
       }
     });
     Iterator<FieldEffect> i = m_effects.iterator();
     while (i.hasNext()) {
       StatusEffect eff = (StatusEffect)i.next();
       if (eff instanceof Clause) {
         Clause clause = (Clause)eff;
         if (!clause.isTeamValid(this, team, idx)) {
           throw new ValidationException("The team violates "
               + clause.getClauseName() + ".");
         }
       }
     }
   }
View Full Code Here

TOP

Related Classes of org.pokenet.server.battle.mechanics.ValidationException

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.