Addition of purchase limit shop item result.
Contributed by Norvox.
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.model.holders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gustavo Fonseca
|
||||||
|
*/
|
||||||
|
public class LimitShopRandomCraftReward
|
||||||
|
{
|
||||||
|
private final int _itemId;
|
||||||
|
private final int _count;
|
||||||
|
private final int _rewardIndex;
|
||||||
|
|
||||||
|
public LimitShopRandomCraftReward(int itemId, int count, int rewardIndex)
|
||||||
|
{
|
||||||
|
_itemId = itemId;
|
||||||
|
_count = count;
|
||||||
|
_rewardIndex = rewardIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemId()
|
||||||
|
{
|
||||||
|
return _itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount()
|
||||||
|
{
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRewardIndex()
|
||||||
|
{
|
||||||
|
return _rewardIndex;
|
||||||
|
}
|
||||||
|
}
|
@@ -16,6 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets.limitshop;
|
package org.l2jmobius.gameserver.network.clientpackets.limitshop;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
@@ -24,11 +27,13 @@ import org.l2jmobius.gameserver.data.xml.LimitShopCraftData;
|
|||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
||||||
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
|
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.LimitShopRandomCraftReward;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.variables.AccountVariables;
|
import org.l2jmobius.gameserver.model.variables.AccountVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExPurchaseLimitShopItemResult;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
||||||
|
|
||||||
@@ -40,15 +45,16 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
private int _productId;
|
private int _productId;
|
||||||
private int _amount;
|
private int _amount;
|
||||||
private LimitShopProductHolder _product;
|
private LimitShopProductHolder _product;
|
||||||
|
private int _shopIndex;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int shopIndex = packet.readC(); // 3 Lcoin Store, 4 Special Craft
|
_shopIndex = packet.readC(); // 3 Lcoin Store, 4 Special Craft
|
||||||
_productId = packet.readD();
|
_productId = packet.readD();
|
||||||
_amount = packet.readD();
|
_amount = packet.readD();
|
||||||
|
|
||||||
switch (shopIndex)
|
switch (_shopIndex)
|
||||||
{
|
{
|
||||||
case 3: // Normal Lcoin Shop
|
case 3: // Normal Lcoin Shop
|
||||||
{
|
{
|
||||||
@@ -170,23 +176,31 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reward.
|
// Reward.
|
||||||
|
final List<LimitShopRandomCraftReward> rewards = new ArrayList<>();
|
||||||
if (_product.getProductionId2() > 0)
|
if (_product.getProductionId2() > 0)
|
||||||
{
|
{
|
||||||
if (Rnd.get(100) < _product.getChance())
|
for (int i = 0; i < _amount; i++)
|
||||||
{
|
{
|
||||||
player.addItem("LCoinShop", _product.getProductionId(), _product.getCount(), player, true);
|
if (Rnd.get(100) < _product.getChance())
|
||||||
}
|
{
|
||||||
else if (Rnd.get(100) < _product.getChance2())
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId(), (int) _product.getCount(), 0));
|
||||||
{
|
player.addItem("LCoinShop", _product.getProductionId(), _product.getCount(), player, true);
|
||||||
player.addItem("LCoinShop", _product.getProductionId2(), _product.getCount2(), player, true);
|
}
|
||||||
}
|
else if (Rnd.get(100) < _product.getChance2())
|
||||||
else if (_product.getProductionId3() > 0)
|
{
|
||||||
{
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId2(), (int) _product.getCount2(), 1));
|
||||||
player.addItem("LCoinShop", _product.getProductionId3(), _product.getCount3(), player, true);
|
player.addItem("LCoinShop", _product.getProductionId2(), _product.getCount2(), player, true);
|
||||||
|
}
|
||||||
|
else if (_product.getProductionId3() > 0)
|
||||||
|
{
|
||||||
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId3(), (int) _product.getCount3(), 2));
|
||||||
|
player.addItem("LCoinShop", _product.getProductionId3(), _product.getCount3(), player, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId(), _amount, 0));
|
||||||
player.addItem("LCoinShop", _product.getProductionId(), _amount, player, true);
|
player.addItem("LCoinShop", _product.getProductionId(), _amount, player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,6 +215,8 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.sendPacket(new ExPurchaseLimitShopItemResult(true, _shopIndex, _productId, rewards));
|
||||||
|
|
||||||
// Remove request.
|
// Remove request.
|
||||||
player.removeRequest(PrimeShopRequest.class);
|
player.removeRequest(PrimeShopRequest.class);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.network.serverpackets.limitshop;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.LimitShopCraftData;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.LimitShopData;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.LimitShopRandomCraftReward;
|
||||||
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gustavo Fonseca
|
||||||
|
*/
|
||||||
|
public class ExPurchaseLimitShopItemResult implements IClientOutgoingPacket
|
||||||
|
{
|
||||||
|
private final int _category, _productId;
|
||||||
|
private final boolean _isSuccess;
|
||||||
|
private final List<LimitShopRandomCraftReward> _rewards;
|
||||||
|
private final LimitShopProductHolder _product;
|
||||||
|
|
||||||
|
public ExPurchaseLimitShopItemResult(boolean isSuccess, int category, int productId, List<LimitShopRandomCraftReward> rewards)
|
||||||
|
{
|
||||||
|
_isSuccess = isSuccess;
|
||||||
|
_category = category;
|
||||||
|
_productId = productId;
|
||||||
|
_rewards = rewards;
|
||||||
|
|
||||||
|
switch (_category)
|
||||||
|
{
|
||||||
|
case 3: // Normal Lcoin Shop
|
||||||
|
{
|
||||||
|
_product = LimitShopData.getInstance().getProduct(_productId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: // Lcoin Special Craft
|
||||||
|
{
|
||||||
|
_product = LimitShopCraftData.getInstance().getProduct(_productId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
_product = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean write(PacketWriter packet)
|
||||||
|
{
|
||||||
|
OutgoingPackets.EX_PURCHASE_LIMIT_SHOP_ITEM_BUY.writeId(packet);
|
||||||
|
if ((_product == null) || !_isSuccess)
|
||||||
|
{
|
||||||
|
packet.writeC(1);
|
||||||
|
packet.writeC(_category);
|
||||||
|
packet.writeD(_productId);
|
||||||
|
packet.writeD(1);
|
||||||
|
packet.writeC(1);
|
||||||
|
packet.writeD(0);
|
||||||
|
packet.writeQ(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packet.writeC(0); // success
|
||||||
|
packet.writeC(_category);
|
||||||
|
packet.writeD(_productId);
|
||||||
|
packet.writeD(_rewards.size());
|
||||||
|
int counter = 0;
|
||||||
|
for (LimitShopRandomCraftReward entry : _rewards)
|
||||||
|
{
|
||||||
|
if (counter == _rewards.size())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
packet.writeC(entry.getRewardIndex());
|
||||||
|
packet.writeD(0);
|
||||||
|
packet.writeD(entry.getCount());
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.model.holders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gustavo Fonseca
|
||||||
|
*/
|
||||||
|
public class LimitShopRandomCraftReward
|
||||||
|
{
|
||||||
|
private final int _itemId;
|
||||||
|
private final int _count;
|
||||||
|
private final int _rewardIndex;
|
||||||
|
|
||||||
|
public LimitShopRandomCraftReward(int itemId, int count, int rewardIndex)
|
||||||
|
{
|
||||||
|
_itemId = itemId;
|
||||||
|
_count = count;
|
||||||
|
_rewardIndex = rewardIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemId()
|
||||||
|
{
|
||||||
|
return _itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount()
|
||||||
|
{
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRewardIndex()
|
||||||
|
{
|
||||||
|
return _rewardIndex;
|
||||||
|
}
|
||||||
|
}
|
@@ -16,6 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets.limitshop;
|
package org.l2jmobius.gameserver.network.clientpackets.limitshop;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
@@ -26,11 +29,13 @@ import org.l2jmobius.gameserver.enums.SpecialItemType;
|
|||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
||||||
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
|
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.LimitShopRandomCraftReward;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.variables.AccountVariables;
|
import org.l2jmobius.gameserver.model.variables.AccountVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExPurchaseLimitShopItemResult;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
||||||
|
|
||||||
@@ -42,15 +47,16 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
private int _productId;
|
private int _productId;
|
||||||
private int _amount;
|
private int _amount;
|
||||||
private LimitShopProductHolder _product;
|
private LimitShopProductHolder _product;
|
||||||
|
private int _shopIndex;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int shopIndex = packet.readC(); // 3 Lcoin Store, 4 Special Craft, 100 Clan Shop
|
_shopIndex = packet.readC(); // 3 Lcoin Store, 4 Special Craft, 100 Clan Shop
|
||||||
_productId = packet.readD();
|
_productId = packet.readD();
|
||||||
_amount = packet.readD();
|
_amount = packet.readD();
|
||||||
|
|
||||||
switch (shopIndex)
|
switch (_shopIndex)
|
||||||
{
|
{
|
||||||
case 3: // Normal Lcoin Shop
|
case 3: // Normal Lcoin Shop
|
||||||
{
|
{
|
||||||
@@ -190,23 +196,31 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reward.
|
// Reward.
|
||||||
|
final List<LimitShopRandomCraftReward> rewards = new ArrayList<>();
|
||||||
if (_product.getProductionId2() > 0)
|
if (_product.getProductionId2() > 0)
|
||||||
{
|
{
|
||||||
if (Rnd.get(100) < _product.getChance())
|
for (int i = 0; i < _amount; i++)
|
||||||
{
|
{
|
||||||
player.addItem("LCoinShop", _product.getProductionId(), _product.getCount(), player, true);
|
if (Rnd.get(100) < _product.getChance())
|
||||||
}
|
{
|
||||||
else if (Rnd.get(100) < _product.getChance2())
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId(), (int) _product.getCount(), 0));
|
||||||
{
|
player.addItem("LCoinShop", _product.getProductionId(), _product.getCount(), player, true);
|
||||||
player.addItem("LCoinShop", _product.getProductionId2(), _product.getCount2(), player, true);
|
}
|
||||||
}
|
else if (Rnd.get(100) < _product.getChance2())
|
||||||
else if (_product.getProductionId3() > 0)
|
{
|
||||||
{
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId2(), (int) _product.getCount2(), 1));
|
||||||
player.addItem("LCoinShop", _product.getProductionId3(), _product.getCount3(), player, true);
|
player.addItem("LCoinShop", _product.getProductionId2(), _product.getCount2(), player, true);
|
||||||
|
}
|
||||||
|
else if (_product.getProductionId3() > 0)
|
||||||
|
{
|
||||||
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId3(), (int) _product.getCount3(), 2));
|
||||||
|
player.addItem("LCoinShop", _product.getProductionId3(), _product.getCount3(), player, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
rewards.add(new LimitShopRandomCraftReward(_product.getProductionId(), _amount, 0));
|
||||||
player.addItem("LCoinShop", _product.getProductionId(), _amount, player, true);
|
player.addItem("LCoinShop", _product.getProductionId(), _amount, player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +235,8 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.sendPacket(new ExPurchaseLimitShopItemResult(true, _shopIndex, _productId, rewards));
|
||||||
|
|
||||||
// Remove request.
|
// Remove request.
|
||||||
player.removeRequest(PrimeShopRequest.class);
|
player.removeRequest(PrimeShopRequest.class);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.network.serverpackets.limitshop;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.LimitShopClanData;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.LimitShopCraftData;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.LimitShopData;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.LimitShopRandomCraftReward;
|
||||||
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gustavo Fonseca
|
||||||
|
*/
|
||||||
|
public class ExPurchaseLimitShopItemResult implements IClientOutgoingPacket
|
||||||
|
{
|
||||||
|
private final int _category, _productId;
|
||||||
|
private final boolean _isSuccess;
|
||||||
|
private final List<LimitShopRandomCraftReward> _rewards;
|
||||||
|
private final LimitShopProductHolder _product;
|
||||||
|
|
||||||
|
public ExPurchaseLimitShopItemResult(boolean isSuccess, int category, int productId, List<LimitShopRandomCraftReward> rewards)
|
||||||
|
{
|
||||||
|
_isSuccess = isSuccess;
|
||||||
|
_category = category;
|
||||||
|
_productId = productId;
|
||||||
|
_rewards = rewards;
|
||||||
|
|
||||||
|
switch (_category)
|
||||||
|
{
|
||||||
|
case 3: // Normal Lcoin Shop
|
||||||
|
{
|
||||||
|
_product = LimitShopData.getInstance().getProduct(_productId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: // Lcoin Special Craft
|
||||||
|
{
|
||||||
|
_product = LimitShopCraftData.getInstance().getProduct(_productId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 100: // Clan Shop
|
||||||
|
{
|
||||||
|
_product = LimitShopClanData.getInstance().getProduct(_productId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
_product = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean write(PacketWriter packet)
|
||||||
|
{
|
||||||
|
OutgoingPackets.EX_PURCHASE_LIMIT_SHOP_ITEM_BUY.writeId(packet);
|
||||||
|
if ((_product == null) || !_isSuccess)
|
||||||
|
{
|
||||||
|
packet.writeC(1);
|
||||||
|
packet.writeC(_category);
|
||||||
|
packet.writeD(_productId);
|
||||||
|
packet.writeD(1);
|
||||||
|
packet.writeC(1);
|
||||||
|
packet.writeD(0);
|
||||||
|
packet.writeQ(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packet.writeC(0); // success
|
||||||
|
packet.writeC(_category);
|
||||||
|
packet.writeD(_productId);
|
||||||
|
packet.writeD(_rewards.size());
|
||||||
|
int counter = 0;
|
||||||
|
for (LimitShopRandomCraftReward entry : _rewards)
|
||||||
|
{
|
||||||
|
if (counter == _rewards.size())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
packet.writeC(entry.getRewardIndex());
|
||||||
|
packet.writeD(0);
|
||||||
|
packet.writeD(entry.getCount());
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user