Skip to content

Commit

Permalink
Return the proper retcode when doing gacha with a full light cone inv…
Browse files Browse the repository at this point in the history
…entory
  • Loading branch information
Melledy committed Dec 11, 2023
1 parent f3c2840 commit 6c9f674
Show file tree
Hide file tree
Showing 3 changed files with 525 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/emu/lunarcore/game/gacha/GachaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import emu.lunarcore.proto.ItemOuterClass.Item;
import emu.lunarcore.server.game.BaseGameService;
import emu.lunarcore.server.game.GameServer;
import emu.lunarcore.server.packet.Retcode;
import emu.lunarcore.server.packet.send.PacketDoGachaScRsp;
import emu.lunarcore.util.JsonUtils;
import emu.lunarcore.util.Utils;
Expand Down Expand Up @@ -75,21 +76,22 @@ public synchronized void doPulls(Player player, int gachaId, int times) {

// Prevent player from using gacha if they are at max light cones
if (player.getInventory().getTabByItemType(ItemMainType.Equipment).getSize() >= player.getInventory().getTabByItemType(ItemMainType.Equipment).getMaxCapacity()) {
player.sendPacket(new PacketDoGachaScRsp());
player.sendPacket(new PacketDoGachaScRsp(Retcode.EQUIPMENT_EXCEED_LIMIT));
return;
}

// Get banner
GachaBanner banner = this.getGachaBanners().get(gachaId);
if (banner == null) {
player.sendPacket(new PacketDoGachaScRsp());
player.sendPacket(new PacketDoGachaScRsp(Retcode.GACHA_ID_NOT_EXIST));
return;
}

// Spend currency
if (banner.getGachaType().getCostItem() > 0) {
GameItem costItem = player.getInventory().getMaterialByItemId(banner.getGachaType().getCostItem());
if (costItem == null || costItem.getCount() < times) {
player.sendPacket(new PacketDoGachaScRsp(Retcode.FAIL));
return;
}

Expand Down
Loading

0 comments on commit 6c9f674

Please sign in to comment.