예제 #1
0
 @Override
 public boolean equals(Object o) {
   if (this == o) return true;
   if (!(o instanceof PokemonData)) return false;
   PokemonData pkm = (PokemonData) o;
   return this.hashCode() == pkm.hashCode();
 }
예제 #2
0
 public static PokemonData create(
     int id,
     String name,
     int baseHp,
     int baseAtt,
     int baseDef,
     int baseSpecialAtt,
     int baseSpecialDef,
     int baseSpeed,
     ExperienceCalculator expCalc) {
   if (POKEDEX.containsKey(id)) {
     PokemonData cachedPkm = POKEDEX.get(id).get();
     if (cachedPkm != null) {
       return cachedPkm;
     }
   }
   PokemonData pkm =
       new PokemonData(
           id, name, baseHp, baseAtt, baseDef, baseSpecialAtt, baseSpecialDef, baseSpeed, expCalc);
   POKEDEX.put(pkm.getId(), new WeakReference<>(pkm));
   return pkm;
 }
예제 #3
0
 private Object readResolve() {
   return PokemonData.create(
       id, name, baseHp, baseAtt, baseDef, baseSpecialAtt, baseSpecialDef, baseSpeed, expCalc);
 }