mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Implement shop purchase limits
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user