Skip to content

Instantly share code, notes, and snippets.

@stanleykerr
Created August 6, 2016 01:51
Show Gist options
  • Save stanleykerr/4c53121df6e38946973a497eee0ec63c to your computer and use it in GitHub Desktop.
Save stanleykerr/4c53121df6e38946973a497eee0ec63c to your computer and use it in GitHub Desktop.
package xyz.saboteur.pokemongo;
import java.util.HashMap;
import java.util.Map;
import com.pokegoapi.api.pokemon.PokemonType;
public enum Type {
NORMAL(PokemonType.ROCK, 0.5,
PokemonType.GHOST, 0.5,
PokemonType.STEEL, 0.5),
FIRE(PokemonType.FIRE, 0.5,
PokemonType.WATER, 0.5,
PokemonType.GRASS, 2.0,
PokemonType.ICE, 2.0,
PokemonType.BUG, 2.0,
PokemonType.ROCK, 0.5,
PokemonType.DRAGON, 0.5,
PokemonType.STEEL, 2.0),
WATER(PokemonType.FIRE, 2.0,
PokemonType.WATER, 0.5,
PokemonType.GRASS, 0.5,
PokemonType.GROUND, 2.0,
PokemonType.ROCK, 2.0,
PokemonType.DRAGON, 0.5),
GRASS(PokemonType.FIRE, 0.5,
PokemonType.WATER, 2.0,
PokemonType.GRASS, 0.5,
PokemonType.POISON, 0.5,
PokemonType.GROUND, 2.0,
PokemonType.FLYING, 0.5,
PokemonType.BUG, 0.5,
PokemonType.ROCK, 2.0,
PokemonType.DRAGON, 0.5,
PokemonType.STEEL, 0.5),
ELECTRIC(PokemonType.WATER, 2.0,
PokemonType.GRASS, 0.5,
PokemonType.ELECTRIC, 0.5,
PokemonType.GROUND, 0.5,
PokemonType.FLYING, 2.0,
PokemonType.DRAGON, 0.5),
ICE(PokemonType.FIRE, 0.5,
PokemonType.WATER, 0.5,
PokemonType.GRASS, 2.0,
PokemonType.ICE, 0.5,
PokemonType.GROUND, 2.0,
PokemonType.FLYING, 2.0,
PokemonType.DRAGON, 2.0,
PokemonType.STEEL, 0.5),
FIGHTING(PokemonType.NORMAL, 2.0,
PokemonType.ICE, 2.0,
PokemonType.POISON, 0.5,
PokemonType.FLYING, 0.5,
PokemonType.PSYCHIC, 0.5,
PokemonType.BUG, 0.5,
PokemonType.ROCK, 2.0,
PokemonType.GHOST, 0.5,
PokemonType.DARK, 2.0,
PokemonType.STEEL, 2.0,
PokemonType.FAIRY, 0.5),
POISON(PokemonType.GRASS, 2.0,
PokemonType.POISON, 0.5,
PokemonType.GROUND, 0.5,
PokemonType.ROCK, 0.5,
PokemonType.GHOST, 0.5,
PokemonType.STEEL, 0.5,
PokemonType.FAIRY, 2.0),
GROUND(PokemonType.FIRE, 2.0,
PokemonType.GRASS, 0.5,
PokemonType.ELECTRIC, 2.0,
PokemonType.POISON, 2.0,
PokemonType.FLYING, 0.5,
PokemonType.BUG, 0.5,
PokemonType.ROCK, 2.0,
PokemonType.STEEL, 2.0),
FLYING(PokemonType.GRASS, 2.0,
PokemonType.ELECTRIC, 0.5,
PokemonType.FIGHTING, 2.0,
PokemonType.BUG, 2.0,
PokemonType.ROCK, 0.5,
PokemonType.STEEL, 0.5),
PSYCHIC(PokemonType.FIGHTING, 2.0,
PokemonType.POISON, 2.0,
PokemonType.PSYCHIC, 0.5,
PokemonType.DARK, 0.5,
PokemonType.STEEL, 0.5),
BUG(PokemonType.FIRE, 0.5,
PokemonType.GRASS, 2.0,
PokemonType.FIGHTING, 0.5,
PokemonType.POISON, 0.5,
PokemonType.FLYING, 0.5,
PokemonType.PSYCHIC, 2.0,
PokemonType.ROCK, 0.5,
PokemonType.DARK, 2.0,
PokemonType.STEEL, 0.5,
PokemonType.FAIRY, 0.5),
ROCK(PokemonType.FIRE, 2.0,
PokemonType.ICE, 2.0,
PokemonType.FIGHTING, 0.5,
PokemonType.GROUND, 0.5,
PokemonType.FLYING, 2.0,
PokemonType.BUG, 2.0,
PokemonType.STEEL, 0.5),
GHOST(PokemonType.NORMAL, 0.5,
PokemonType.PSYCHIC, 2.0,
PokemonType.GHOST, 2.0,
PokemonType.DARK, 0.5),
DRAGON(PokemonType.DRAGON, 2.0,
PokemonType.STEEL, 0.5,
PokemonType.FAIRY, 0.5),
DARK(PokemonType.FIGHTING, 0.5,
PokemonType.FLYING, 2.0,
PokemonType.GHOST, 2.0,
PokemonType.DRAGON, 0.5,
PokemonType.FAIRY, 0.5),
STEEL(PokemonType.FIRE, 0.5,
PokemonType.WATER, 0.5,
PokemonType.ELECTRIC, 0.5,
PokemonType.ICE, 2.0,
PokemonType.BUG, 2.0,
PokemonType.STEEL, 0.5,
PokemonType.FAIRY, 2.0),
FAIRY(PokemonType.FIRE, 0.5,
PokemonType.FIGHTING, 2.0,
PokemonType.POISON, 0.5,
PokemonType.DRAGON, 2.0,
PokemonType.DARK, 2.0,
PokemonType.STEEL, 0.5)
;
private Map<PokemonType, Double> damageModifiers;
private Type(Object... objects) {
this.damageModifiers = new HashMap<>();
for(int i = 0; i < objects.length; i+=2)
this.damageModifiers.put((PokemonType) objects[i], (Double) objects[i+1]);
for(PokemonType pt : PokemonType.values())
if(pt != PokemonType.NONE && !this.damageModifiers.containsKey(pt))
this.damageModifiers.put(pt, 1.0);
}
public Map<PokemonType, Double> getModifiers() {
return damageModifiers;
}
public double getModifier(PokemonType type) {
return damageModifiers.get(type);
}
public static Type valueOf(PokemonType type) {
return Type.valueOf(type.name());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment