Here is the method responsible for leveling an NPC. For example, if we give him 100 xp for next level, it will get his level incremented. But for next levels, if xp needed for next level is equal to current amount of exp that NPC has, statement is ignored. But when I print it, it gives true. How come?
public void setExp(int exp) throws Exception {
if (exp >= 0) {
this.exp += exp;
if (this.exp > expForNextLvl) {
while (this.exp > expForNextLvl) {
setLvl(1);
setExpForNextLvl(Math.round(expForNextLvl * 1.2 + 5));
}
} else if (Double.valueOf(this.exp).equals(Double.valueOf(expForNextLvl))) {
setLvl(1);
setExpForNextLvl(Math.round(expForNextLvl * 1.2 + 5));
}
} else {
throw new Exception("exp less than 0");
}
}
Aucun commentaire:
Enregistrer un commentaire