コード例 #1
0
ファイル: BoardTest.java プロジェクト: huangzhn/Shuffle-Move
 public static Species getRandomSpecies() {
   PkmType t = PkmType.values()[rand.nextInt(PkmType.values().length)];
   Predicate<Species> filter = species -> species.getType().equals(t);
   List<Species> options = new ArrayList<Species>(mngr.getSpeciesByFilters(Arrays.asList(filter)));
   if (options.isEmpty()) {
     options = Arrays.asList(Species.AIR);
   }
   return options.get(rand.nextInt(options.size()));
 }
コード例 #2
0
 public List<Stage> getDefaultStages() {
   if (typeStages == null) {
     PkmType[] types = PkmType.values();
     typeStages = new ArrayList<Stage>(types.length);
     for (PkmType type : types) {
       if (!type.isSpecial()) {
         typeStages.add(new Stage(type));
       }
     }
   }
   return typeStages;
 }
コード例 #3
0
 /**
  * Gets a filtered view of all stages.
  *
  * @param t If not null, filters to only allow stages with this type.
  * @param contains If not null, filters to only allow stages whose name (ignoring case) contains
  *     this String.
  * @return The filtered view as an unmodifiable list. Note: this list has no duplicates.
  */
 public List<Stage> getAllStagesFilteredBy(PkmType t, String contains) {
   LinkedHashSet<Stage> retStages = new LinkedHashSet<Stage>();
   String containsUpper = contains == null ? null : contains.toUpperCase();
   for (Stage s : getAllStages()) {
     PkmType thisType = s.getType();
     String thisNameUpper = s.getName().toUpperCase();
     if ((t == null || thisType.equals(t))
         && (containsUpper == null || thisNameUpper.contains(containsUpper))) {
       retStages.add(s);
     }
   }
   return Collections.unmodifiableList(new ArrayList<Stage>(retStages));
 }