Implement shop purchase limits

This commit is contained in:
Melledy
2025-11-14 08:08:02 -08:00
parent 484ca84e00
commit c4d564abb6
10 changed files with 176 additions and 28 deletions
@@ -5,6 +5,7 @@ import com.google.gson.annotations.SerializedName;
import emu.nebula.data.BaseDef;
import emu.nebula.data.ResourceType;
import emu.nebula.game.inventory.ItemParamMap;
import emu.nebula.game.player.Player;
import lombok.Getter;
@Getter
@@ -27,6 +28,10 @@ public class MallShopDef extends BaseDef {
return IdString.hashCode();
}
public int getStock(Player player) {
return Math.max(this.getStock() - player.getInventory().getMallBuyCount().get(this.getIdString()), 0);
}
@Override
public void onLoad() {
this.products = new ItemParamMap();
@@ -3,6 +3,7 @@ package emu.nebula.data.resources;
import emu.nebula.data.BaseDef;
import emu.nebula.data.ResourceType;
import emu.nebula.game.inventory.ItemParamMap;
import emu.nebula.game.player.Player;
import lombok.Getter;
@Getter
@@ -24,6 +25,10 @@ public class ResidentGoodsDef extends BaseDef {
public int getId() {
return Id;
}
public int getStock(Player player) {
return Math.max(this.getMaximumLimit() - player.getInventory().getMallBuyCount().getInt(this.getId()), 0);
}
@Override
public void onLoad() {