Compare commits

...

2 Commits

Author SHA1 Message Date
Ponk
16b0a36c86 Merge pull request #238 from channarit1994/master #patch
Surprise Box Implementation
2024-06-14 21:33:08 +02:00
Channarit Sittiparat
db82cbcfae Surprise Box Implementation
- Added showCashInventory after a successful gachapon opening in the CashShopSurpriseHandler.
- Added getItemsSize() condition to check the inventory size before proceeding with the cash shop surprise opening
2024-06-13 20:02:40 +07:00
2 changed files with 17 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ public class CashShopSurpriseHandler extends AbstractPacketHandler {
if (cssResult != null) { if (cssResult != null) {
Item cssItem = cssResult.getLeft(), cssBox = cssResult.getRight(); Item cssItem = cssResult.getLeft(), cssBox = cssResult.getRight();
c.sendPacket(PacketCreator.onCashGachaponOpenSuccess(c.getAccID(), cssBox.getSN(), cssBox.getQuantity(), cssItem, cssItem.getItemId(), cssItem.getQuantity(), true)); c.sendPacket(PacketCreator.onCashGachaponOpenSuccess(c.getAccID(), cssBox.getSN(), cssBox.getQuantity(), cssItem, cssItem.getItemId(), cssItem.getQuantity(), true));
c.sendPacket(PacketCreator.showCashInventory(c));
} else { } else {
c.sendPacket(PacketCreator.onCashItemGachaponOpenFailed()); c.sendPacket(PacketCreator.onCashItemGachaponOpenFailed());
} }

View File

@@ -36,6 +36,7 @@ import provider.DataProviderFactory;
import provider.DataTool; import provider.DataTool;
import provider.wz.WZFiles; import provider.wz.WZFiles;
import tools.DatabaseConnection; import tools.DatabaseConnection;
import tools.PacketCreator;
import tools.Pair; import tools.Pair;
import java.sql.Connection; import java.sql.Connection;
@@ -407,6 +408,17 @@ public class CashShop {
} }
} }
public int getItemsSize() {
int size = 0;
lock.lock();
try {
size = inventory.size();
} finally {
lock.unlock();
}
return size;
}
public List<Integer> getWishList() { public List<Integer> getWishList() {
return wishList; return wishList;
} }
@@ -544,14 +556,14 @@ public class CashShop {
Item css = getCashShopItemByItemid(ItemId.CASH_SHOP_SURPRISE); Item css = getCashShopItemByItemid(ItemId.CASH_SHOP_SURPRISE);
if (css != null) { if (css != null) {
if (getItemsSize() >= 100) {
return null;
}
CashItem cItem = CashItemFactory.getRandomCashItem(); CashItem cItem = CashItemFactory.getRandomCashItem();
if (cItem != null) { if (cItem != null) {
if (css.getQuantity() > 1) { if (css.getQuantity() > 1) {
/* if(NOT ENOUGH SPACE) { looks like we're not dealing with cash inventory limit whatsoever, k then
return null;
} */
css.setQuantity((short) (css.getQuantity() - 1)); css.setQuantity((short) (css.getQuantity() - 1));
} else { } else {
removeFromInventory(css); removeFromInventory(css);