public void receiveXP(int experience) { DisplayText.add("", String.format("%s fikk %d studiepoeng!", this.getName(), experience)); this.experience += experience; this.experienceTotal += experience; if (this.experienceTotal >= XPNextLevel(level)) { levelUp(); } }
public void levelUp() { experience = experience - XPNextLevel(level) + XPNextLevel(level - 1); setLevel(level + 1); DisplayText.add("", String.format("%s er nå level %d!", this.getName(), level)); owner.levelUp(this); DisplayText.add("", String.format("Du ble litt bedre i %s", this.getName())); if (this.experienceTotal >= XPNextLevel(level)) { levelUp(); } }