Compare commits

...

4 Commits

Author SHA1 Message Date
Ponk
d22d9b603b Merge pull request #228 from HarkuLi/feat/fix-npc-gain-meso #patch
NPC: Fix type casting error for `gainMeso()` method
2024-06-14 21:44:10 +02:00
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
HarkuLi
0d684c1400 NPC: Fix type casting error for gainMeso() method
Number type values might be passed into the `gainMeso()` method in js
scripts, and thus it expects a `gainMeso(Double gain)` method in the
`NPCConversationManager` class.
2024-03-02 15:38:22 +08:00
3 changed files with 21 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ public class CashShopSurpriseHandler extends AbstractPacketHandler {
if (cssResult != null) {
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.showCashInventory(c));
} else {
c.sendPacket(PacketCreator.onCashItemGachaponOpenFailed());
}

View File

@@ -278,6 +278,10 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
getPlayer().gainMeso(gain);
}
public void gainMeso(Double gain) {
getPlayer().gainMeso(gain.intValue());
}
public void gainExp(int gain) {
getPlayer().gainExp(gain, true, true);
}

View File

@@ -36,6 +36,7 @@ import provider.DataProviderFactory;
import provider.DataTool;
import provider.wz.WZFiles;
import tools.DatabaseConnection;
import tools.PacketCreator;
import tools.Pair;
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() {
return wishList;
}
@@ -544,14 +556,14 @@ public class CashShop {
Item css = getCashShopItemByItemid(ItemId.CASH_SHOP_SURPRISE);
if (css != null) {
if (getItemsSize() >= 100) {
return null;
}
CashItem cItem = CashItemFactory.getRandomCashItem();
if (cItem != null) {
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));
} else {
removeFromInventory(css);