Fixing Sell/Buy Signs which use EXP as a currency.

This commit is contained in:
KHobbits 2011-12-13 04:29:16 +00:00
parent a00f070400
commit d3dd8208ef
4 changed files with 36 additions and 6 deletions

View file

@ -65,7 +65,7 @@ public interface IUser
void setJail(String jail); void setJail(String jail);
public int getTotalExperience(); public int getXP();
public void setTotalExperience(int l); public void setXP(int l);
} }

View file

@ -80,7 +80,7 @@ public class Trade
} }
if (exp != null && exp > 0 if (exp != null && exp > 0
&& user.getTotalExperience() < exp) { && user.getXP() < exp) {
throw new ChargeException(_("notEnoughExperience")); throw new ChargeException(_("notEnoughExperience"));
} }
} }
@ -115,7 +115,7 @@ public class Trade
} }
if (getExperience() != null) if (getExperience() != null)
{ {
user.setTotalExperience(user.getTotalExperience() + getExperience()); user.setXP(user.getXP() + getExperience());
} }
return success; return success;
} }
@ -154,12 +154,12 @@ public class Trade
} }
if (getExperience() != null) if (getExperience() != null)
{ {
final int experience = user.getTotalExperience(); final int experience = user.getXP();
if (experience < getExperience() && getExperience() > 0) if (experience < getExperience() && getExperience() > 0)
{ {
throw new ChargeException(_("notEnoughExperience")); throw new ChargeException(_("notEnoughExperience"));
} }
user.setTotalExperience(experience - getExperience()); user.setXP(experience - getExperience());
} }
} }

View file

@ -544,4 +544,21 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{ {
return teleportRequestTime; return teleportRequestTime;
} }
@Override
public int getXP() {
return base.getTotalExperience();
}
@Override
public void setXP(int l) {
base.setExp(0);
base.setLevel(0);
base.setTotalExperience(0);
for(int i=0;i<l; ++i) {
base.giveExp(1);
}
this.sendMessage("new exp: " + base.getExp() + " total exp: " + base.getTotalExperience());
}
} }

View file

@ -196,4 +196,17 @@ public class User extends UserBase implements IUser
unlock(); unlock();
} }
} }
@Override
public int getXP()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setXP(int l)
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }