Fix buying energy with gems not giving the correct amount

This commit is contained in:
Melledy
2025-11-20 05:37:21 -08:00
parent 480d0d60b3
commit 6289e3f1b6
2 changed files with 16 additions and 5 deletions

View File

@@ -635,20 +635,27 @@ public class Inventory extends PlayerManager implements GameDatabaseObject {
return change.setSuccess(true);
}
public PlayerChangeInfo buyEnergy() {
public PlayerChangeInfo buyEnergy(int count) {
// Validate count
if (count <= 0 || count > 6) {
return null;
}
// Create change info
var change = new PlayerChangeInfo();
// Make sure we have the gems
if (!this.hasItem(GameConstants.ENERGY_BUY_ITEM_ID, 30)) {
int cost = 30 * count;
if (!this.hasItem(GameConstants.ENERGY_BUY_ITEM_ID, cost)) {
return change;
}
// Remove gems
this.removeItem(GameConstants.ENERGY_BUY_ITEM_ID, 30, change);
this.removeItem(GameConstants.ENERGY_BUY_ITEM_ID, cost, change);
// Add energy
this.getPlayer().addEnergy(60, change);
this.getPlayer().addEnergy(60 * count, change);
// Success
return change;