Support for LCoin player level and buy limit.
This commit is contained in:
@@ -20,7 +20,8 @@
|
|||||||
<xs:simpleContent>
|
<xs:simpleContent>
|
||||||
<xs:extension base="xs:string">
|
<xs:extension base="xs:string">
|
||||||
<xs:attribute type="xs:int" name="id" use="optional"/>
|
<xs:attribute type="xs:int" name="id" use="optional"/>
|
||||||
<xs:attribute type="xs:long" name="accountDailyLimit" use="optional"/>
|
<xs:attribute type="xs:int" name="accountDailyLimit" use="optional"/>
|
||||||
|
<xs:attribute type="xs:int" name="accountBuyLimit" use="optional"/>
|
||||||
</xs:extension>
|
</xs:extension>
|
||||||
</xs:simpleContent>
|
</xs:simpleContent>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
@@ -28,6 +29,8 @@
|
|||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute type="xs:int" name="id" use="optional"/>
|
<xs:attribute type="xs:int" name="id" use="optional"/>
|
||||||
<xs:attribute type="xs:byte" name="category" use="optional"/>
|
<xs:attribute type="xs:byte" name="category" use="optional"/>
|
||||||
|
<xs:attribute type="xs:int" name="minLevel" use="optional"/>
|
||||||
|
<xs:attribute type="xs:int" name="maxLevel" use="optional"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
@@ -88,6 +88,8 @@ public class LCoinShopData implements IXmlReader
|
|||||||
|
|
||||||
final int id = parseInteger(attrs, "id");
|
final int id = parseInteger(attrs, "id");
|
||||||
final int category = parseInteger(attrs, "category");
|
final int category = parseInteger(attrs, "category");
|
||||||
|
final int minLevel = parseInteger(attrs, "minLevel", 1);
|
||||||
|
final int maxLevel = parseInteger(attrs, "maxLevel", 999);
|
||||||
final int[] ingredientIds = new int[3];
|
final int[] ingredientIds = new int[3];
|
||||||
ingredientIds[0] = 0;
|
ingredientIds[0] = 0;
|
||||||
ingredientIds[1] = 0;
|
ingredientIds[1] = 0;
|
||||||
@@ -98,6 +100,7 @@ public class LCoinShopData implements IXmlReader
|
|||||||
ingredientQuantities[2] = 0;
|
ingredientQuantities[2] = 0;
|
||||||
int productionId = 0;
|
int productionId = 0;
|
||||||
int accountDailyLimit = 0;
|
int accountDailyLimit = 0;
|
||||||
|
int accountBuyLimit = 0;
|
||||||
for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
|
for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
|
||||||
{
|
{
|
||||||
attrs = b.getAttributes();
|
attrs = b.getAttributes();
|
||||||
@@ -144,6 +147,7 @@ public class LCoinShopData implements IXmlReader
|
|||||||
{
|
{
|
||||||
productionId = parseInteger(attrs, "id");
|
productionId = parseInteger(attrs, "id");
|
||||||
accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0);
|
accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0);
|
||||||
|
accountBuyLimit = parseInteger(attrs, "accountBuyLimit", 0);
|
||||||
|
|
||||||
final Item item = ItemTable.getInstance().getTemplate(productionId);
|
final Item item = ItemTable.getInstance().getTemplate(productionId);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
@@ -154,7 +158,7 @@ public class LCoinShopData implements IXmlReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_products.add(new LCoinShopProductHolder(id, category, ingredientIds, ingredientQuantities, productionId, accountDailyLimit));
|
_products.add(new LCoinShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, accountDailyLimit, accountBuyLimit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,19 +23,25 @@ public class LCoinShopProductHolder
|
|||||||
{
|
{
|
||||||
private final int _id;
|
private final int _id;
|
||||||
private final int _category;
|
private final int _category;
|
||||||
|
private final int _minLevel;
|
||||||
|
private final int _maxLevel;
|
||||||
private final int[] _ingredientIds;
|
private final int[] _ingredientIds;
|
||||||
private final long[] _ingredientQuantities;
|
private final long[] _ingredientQuantities;
|
||||||
private final int _productionId;
|
private final int _productionId;
|
||||||
private final int _accountDailyLimit;
|
private final int _accountDailyLimit;
|
||||||
|
private final int _accountBuyLimit;
|
||||||
|
|
||||||
public LCoinShopProductHolder(int id, int category, int[] ingredientIds, long[] ingredientQuantities, int productionId, int accountDailyLimit)
|
public LCoinShopProductHolder(int id, int category, int minLevel, int maxLevel, int[] ingredientIds, long[] ingredientQuantities, int productionId, int accountDailyLimit, int accountBuyLimit)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_category = category;
|
_category = category;
|
||||||
|
_minLevel = minLevel;
|
||||||
|
_maxLevel = maxLevel;
|
||||||
_ingredientIds = ingredientIds;
|
_ingredientIds = ingredientIds;
|
||||||
_ingredientQuantities = ingredientQuantities;
|
_ingredientQuantities = ingredientQuantities;
|
||||||
_productionId = productionId;
|
_productionId = productionId;
|
||||||
_accountDailyLimit = accountDailyLimit;
|
_accountDailyLimit = accountDailyLimit;
|
||||||
|
_accountBuyLimit = accountBuyLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
@@ -48,6 +54,16 @@ public class LCoinShopProductHolder
|
|||||||
return _category;
|
return _category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMinLevel()
|
||||||
|
{
|
||||||
|
return _minLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxLevel()
|
||||||
|
{
|
||||||
|
return _maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public int[] getIngredientIds()
|
public int[] getIngredientIds()
|
||||||
{
|
{
|
||||||
return _ingredientIds;
|
return _ingredientIds;
|
||||||
@@ -67,4 +83,9 @@ public class LCoinShopProductHolder
|
|||||||
{
|
{
|
||||||
return _accountDailyLimit;
|
return _accountDailyLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAccountBuyLimit()
|
||||||
|
{
|
||||||
|
return _accountBuyLimit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,8 @@ public class AccountVariables extends AbstractVariables
|
|||||||
// Public variable names
|
// Public variable names
|
||||||
public static final String HWID = "HWID";
|
public static final String HWID = "HWID";
|
||||||
public static final String HWIDSLIT_VAR = " ";
|
public static final String HWIDSLIT_VAR = " ";
|
||||||
|
public static final String LCOIN_SHOP_PRODUCT_TIME = "LCSTime";
|
||||||
|
public static final String LCOIN_SHOP_PRODUCT_COUNT = "LCSCount";
|
||||||
|
|
||||||
private final String _accountName;
|
private final String _accountName;
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@ 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.LCoinShopProductHolder;
|
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
|
||||||
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.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;
|
||||||
@@ -68,6 +69,12 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((player.getLevel() < product.getMinLevel()) || (player.getLevel() > product.getMaxLevel()))
|
||||||
|
{
|
||||||
|
player.sendPacket(SystemMessageId.YOUR_LEVEL_CANNOT_PURCHASE_THIS_ITEM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (player.hasItemRequest() || player.hasRequest(PrimeShopRequest.class))
|
if (player.hasItemRequest() || player.hasRequest(PrimeShopRequest.class))
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||||
@@ -77,19 +84,28 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
// Add request.
|
// Add request.
|
||||||
player.addRequest(new PrimeShopRequest(player));
|
player.addRequest(new PrimeShopRequest(player));
|
||||||
|
|
||||||
// Check account daily limit.
|
// Check limits.
|
||||||
if (product.getAccountDailyLimit() > 0)
|
if (product.getAccountDailyLimit() > 0) // Sale period.
|
||||||
{
|
{
|
||||||
if (player.getAccountVariables().getInt("LCSCount" + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
||||||
{
|
{
|
||||||
if ((player.getAccountVariables().getLong("LCSTime" + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
if ((player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
||||||
{
|
{
|
||||||
player.sendMessage("You have reached your daily limit."); // TODO: Retail system message?
|
player.sendMessage("You have reached your daily limit."); // TODO: Retail system message?
|
||||||
player.removeRequest(PrimeShopRequest.class);
|
player.removeRequest(PrimeShopRequest.class);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Reset limit.
|
// Reset limit.
|
||||||
player.getAccountVariables().set("LCSCount" + product.getProductionId(), 0);
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (product.getAccountBuyLimit() > 0) // Count limit.
|
||||||
|
{
|
||||||
|
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountBuyLimit())
|
||||||
|
{
|
||||||
|
player.sendMessage("You cannot buy any more of this item."); // TODO: Retail system message?
|
||||||
|
player.removeRequest(PrimeShopRequest.class);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,11 +153,15 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
// Reward.
|
// Reward.
|
||||||
player.addItem("LCoinShop", product.getProductionId(), _amount, player, true);
|
player.addItem("LCoinShop", product.getProductionId(), _amount, player, true);
|
||||||
|
|
||||||
// Update player variables.
|
// Update account variables.
|
||||||
if (product.getAccountDailyLimit() > 0)
|
if (product.getAccountDailyLimit() > 0)
|
||||||
{
|
{
|
||||||
player.getAccountVariables().set("LCSTime" + product.getProductionId(), Chronos.currentTimeMillis());
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), Chronos.currentTimeMillis());
|
||||||
player.getAccountVariables().set("LCSCount" + product.getProductionId(), player.getAccountVariables().getInt("LCSCount" + 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);
|
||||||
|
}
|
||||||
|
else if (product.getAccountBuyLimit() > 0)
|
||||||
|
{
|
||||||
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove request.
|
// Remove request.
|
||||||
|
@@ -23,6 +23,7 @@ import org.l2jmobius.commons.util.Chronos;
|
|||||||
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
|
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
|
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.AccountVariables;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
@@ -69,27 +70,38 @@ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket
|
|||||||
packet.writeC(-1); // ?
|
packet.writeC(-1); // ?
|
||||||
packet.writeC(-1); // ?
|
packet.writeC(-1); // ?
|
||||||
|
|
||||||
// Sale period.
|
// Check limits.
|
||||||
if (product.getAccountDailyLimit() > 0)
|
if (product.getAccountDailyLimit() > 0) // Sale period.
|
||||||
{
|
{
|
||||||
if (_player.getAccountVariables().getInt("LCSCount" + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
if (_player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
||||||
{
|
{
|
||||||
if ((_player.getAccountVariables().getLong("LCSTime" + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
if ((_player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
||||||
{
|
{
|
||||||
packet.writeD(0x00);
|
packet.writeD(0x00);
|
||||||
}
|
}
|
||||||
else // Reset limit.
|
else // Reset limit.
|
||||||
{
|
{
|
||||||
_player.getAccountVariables().remove("LCSCount" + product.getProductionId());
|
_player.getAccountVariables().remove(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId());
|
||||||
packet.writeD(product.getAccountDailyLimit());
|
packet.writeD(product.getAccountDailyLimit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
packet.writeD(product.getAccountDailyLimit() - _player.getAccountVariables().getInt("LCSCount" + product.getProductionId(), 0));
|
packet.writeD(product.getAccountDailyLimit() - _player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // No account daily limit.
|
else if (product.getAccountBuyLimit() > 0) // Count limit.
|
||||||
|
{
|
||||||
|
if (_player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountBuyLimit())
|
||||||
|
{
|
||||||
|
packet.writeD(0x00);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packet.writeD(product.getAccountBuyLimit() - _player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // No account limits.
|
||||||
{
|
{
|
||||||
packet.writeD(0x01);
|
packet.writeD(0x01);
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,8 @@
|
|||||||
<xs:simpleContent>
|
<xs:simpleContent>
|
||||||
<xs:extension base="xs:string">
|
<xs:extension base="xs:string">
|
||||||
<xs:attribute type="xs:int" name="id" use="optional"/>
|
<xs:attribute type="xs:int" name="id" use="optional"/>
|
||||||
<xs:attribute type="xs:long" name="accountDailyLimit" use="optional"/>
|
<xs:attribute type="xs:int" name="accountDailyLimit" use="optional"/>
|
||||||
|
<xs:attribute type="xs:int" name="accountBuyLimit" use="optional"/>
|
||||||
</xs:extension>
|
</xs:extension>
|
||||||
</xs:simpleContent>
|
</xs:simpleContent>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
@@ -28,6 +29,8 @@
|
|||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute type="xs:int" name="id" use="optional"/>
|
<xs:attribute type="xs:int" name="id" use="optional"/>
|
||||||
<xs:attribute type="xs:byte" name="category" use="optional"/>
|
<xs:attribute type="xs:byte" name="category" use="optional"/>
|
||||||
|
<xs:attribute type="xs:int" name="minLevel" use="optional"/>
|
||||||
|
<xs:attribute type="xs:int" name="maxLevel" use="optional"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
@@ -88,6 +88,8 @@ public class LCoinShopData implements IXmlReader
|
|||||||
|
|
||||||
final int id = parseInteger(attrs, "id");
|
final int id = parseInteger(attrs, "id");
|
||||||
final int category = parseInteger(attrs, "category");
|
final int category = parseInteger(attrs, "category");
|
||||||
|
final int minLevel = parseInteger(attrs, "minLevel", 1);
|
||||||
|
final int maxLevel = parseInteger(attrs, "maxLevel", 999);
|
||||||
final int[] ingredientIds = new int[5];
|
final int[] ingredientIds = new int[5];
|
||||||
ingredientIds[0] = 0;
|
ingredientIds[0] = 0;
|
||||||
ingredientIds[1] = 0;
|
ingredientIds[1] = 0;
|
||||||
@@ -102,6 +104,7 @@ public class LCoinShopData implements IXmlReader
|
|||||||
ingredientQuantities[4] = 0;
|
ingredientQuantities[4] = 0;
|
||||||
int productionId = 0;
|
int productionId = 0;
|
||||||
int accountDailyLimit = 0;
|
int accountDailyLimit = 0;
|
||||||
|
int accountBuyLimit = 0;
|
||||||
for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
|
for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
|
||||||
{
|
{
|
||||||
attrs = b.getAttributes();
|
attrs = b.getAttributes();
|
||||||
@@ -164,6 +167,7 @@ public class LCoinShopData implements IXmlReader
|
|||||||
{
|
{
|
||||||
productionId = parseInteger(attrs, "id");
|
productionId = parseInteger(attrs, "id");
|
||||||
accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0);
|
accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0);
|
||||||
|
accountBuyLimit = parseInteger(attrs, "accountBuyLimit", 0);
|
||||||
|
|
||||||
final Item item = ItemTable.getInstance().getTemplate(productionId);
|
final Item item = ItemTable.getInstance().getTemplate(productionId);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
@@ -174,7 +178,7 @@ public class LCoinShopData implements IXmlReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_products.add(new LCoinShopProductHolder(id, category, ingredientIds, ingredientQuantities, productionId, accountDailyLimit));
|
_products.add(new LCoinShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, accountDailyLimit, accountBuyLimit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,19 +23,25 @@ public class LCoinShopProductHolder
|
|||||||
{
|
{
|
||||||
private final int _id;
|
private final int _id;
|
||||||
private final int _category;
|
private final int _category;
|
||||||
|
private final int _minLevel;
|
||||||
|
private final int _maxLevel;
|
||||||
private final int[] _ingredientIds;
|
private final int[] _ingredientIds;
|
||||||
private final long[] _ingredientQuantities;
|
private final long[] _ingredientQuantities;
|
||||||
private final int _productionId;
|
private final int _productionId;
|
||||||
private final int _accountDailyLimit;
|
private final int _accountDailyLimit;
|
||||||
|
private final int _accountBuyLimit;
|
||||||
|
|
||||||
public LCoinShopProductHolder(int id, int category, int[] ingredientIds, long[] ingredientQuantities, int productionId, int accountDailyLimit)
|
public LCoinShopProductHolder(int id, int category, int minLevel, int maxLevel, int[] ingredientIds, long[] ingredientQuantities, int productionId, int accountDailyLimit, int accountBuyLimit)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_category = category;
|
_category = category;
|
||||||
|
_minLevel = minLevel;
|
||||||
|
_maxLevel = maxLevel;
|
||||||
_ingredientIds = ingredientIds;
|
_ingredientIds = ingredientIds;
|
||||||
_ingredientQuantities = ingredientQuantities;
|
_ingredientQuantities = ingredientQuantities;
|
||||||
_productionId = productionId;
|
_productionId = productionId;
|
||||||
_accountDailyLimit = accountDailyLimit;
|
_accountDailyLimit = accountDailyLimit;
|
||||||
|
_accountBuyLimit = accountBuyLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
@@ -48,6 +54,16 @@ public class LCoinShopProductHolder
|
|||||||
return _category;
|
return _category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMinLevel()
|
||||||
|
{
|
||||||
|
return _minLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxLevel()
|
||||||
|
{
|
||||||
|
return _maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public int[] getIngredientIds()
|
public int[] getIngredientIds()
|
||||||
{
|
{
|
||||||
return _ingredientIds;
|
return _ingredientIds;
|
||||||
@@ -67,4 +83,9 @@ public class LCoinShopProductHolder
|
|||||||
{
|
{
|
||||||
return _accountDailyLimit;
|
return _accountDailyLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAccountBuyLimit()
|
||||||
|
{
|
||||||
|
return _accountBuyLimit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,8 @@ public class AccountVariables extends AbstractVariables
|
|||||||
// Public variable names
|
// Public variable names
|
||||||
public static final String HWID = "HWID";
|
public static final String HWID = "HWID";
|
||||||
public static final String HWIDSLIT_VAR = " ";
|
public static final String HWIDSLIT_VAR = " ";
|
||||||
|
public static final String LCOIN_SHOP_PRODUCT_TIME = "LCSTime";
|
||||||
|
public static final String LCOIN_SHOP_PRODUCT_COUNT = "LCSCount";
|
||||||
|
|
||||||
private final String _accountName;
|
private final String _accountName;
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@ 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.LCoinShopProductHolder;
|
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
|
||||||
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.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;
|
||||||
@@ -68,6 +69,12 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((player.getLevel() < product.getMinLevel()) || (player.getLevel() > product.getMaxLevel()))
|
||||||
|
{
|
||||||
|
player.sendPacket(SystemMessageId.YOUR_LEVEL_CANNOT_PURCHASE_THIS_ITEM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (player.hasItemRequest() || player.hasRequest(PrimeShopRequest.class))
|
if (player.hasItemRequest() || player.hasRequest(PrimeShopRequest.class))
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||||
@@ -77,19 +84,28 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
// Add request.
|
// Add request.
|
||||||
player.addRequest(new PrimeShopRequest(player));
|
player.addRequest(new PrimeShopRequest(player));
|
||||||
|
|
||||||
// Check account daily limit.
|
// Check limits.
|
||||||
if (product.getAccountDailyLimit() > 0)
|
if (product.getAccountDailyLimit() > 0) // Sale period.
|
||||||
{
|
{
|
||||||
if (player.getAccountVariables().getInt("LCSCount" + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
||||||
{
|
{
|
||||||
if ((player.getAccountVariables().getLong("LCSTime" + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
if ((player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
||||||
{
|
{
|
||||||
player.sendMessage("You have reached your daily limit."); // TODO: Retail system message?
|
player.sendMessage("You have reached your daily limit."); // TODO: Retail system message?
|
||||||
player.removeRequest(PrimeShopRequest.class);
|
player.removeRequest(PrimeShopRequest.class);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Reset limit.
|
// Reset limit.
|
||||||
player.getAccountVariables().set("LCSCount" + product.getProductionId(), 0);
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (product.getAccountBuyLimit() > 0) // Count limit.
|
||||||
|
{
|
||||||
|
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountBuyLimit())
|
||||||
|
{
|
||||||
|
player.sendMessage("You cannot buy any more of this item."); // TODO: Retail system message?
|
||||||
|
player.removeRequest(PrimeShopRequest.class);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,11 +153,15 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
|
|||||||
// Reward.
|
// Reward.
|
||||||
player.addItem("LCoinShop", product.getProductionId(), _amount, player, true);
|
player.addItem("LCoinShop", product.getProductionId(), _amount, player, true);
|
||||||
|
|
||||||
// Update player variables.
|
// Update account variables.
|
||||||
if (product.getAccountDailyLimit() > 0)
|
if (product.getAccountDailyLimit() > 0)
|
||||||
{
|
{
|
||||||
player.getAccountVariables().set("LCSTime" + product.getProductionId(), Chronos.currentTimeMillis());
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), Chronos.currentTimeMillis());
|
||||||
player.getAccountVariables().set("LCSCount" + product.getProductionId(), player.getAccountVariables().getInt("LCSCount" + 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);
|
||||||
|
}
|
||||||
|
else if (product.getAccountBuyLimit() > 0)
|
||||||
|
{
|
||||||
|
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove request.
|
// Remove request.
|
||||||
|
@@ -23,6 +23,7 @@ import org.l2jmobius.commons.util.Chronos;
|
|||||||
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
|
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
|
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.AccountVariables;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
@@ -75,27 +76,38 @@ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket
|
|||||||
packet.writeC(-1); // ?
|
packet.writeC(-1); // ?
|
||||||
packet.writeC(-1); // ?
|
packet.writeC(-1); // ?
|
||||||
|
|
||||||
// Sale period.
|
// Check limits.
|
||||||
if (product.getAccountDailyLimit() > 0)
|
if (product.getAccountDailyLimit() > 0) // Sale period.
|
||||||
{
|
{
|
||||||
if (_player.getAccountVariables().getInt("LCSCount" + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
if (_player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountDailyLimit())
|
||||||
{
|
{
|
||||||
if ((_player.getAccountVariables().getLong("LCSTime" + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
if ((_player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
|
||||||
{
|
{
|
||||||
packet.writeD(0x00);
|
packet.writeD(0x00);
|
||||||
}
|
}
|
||||||
else // Reset limit.
|
else // Reset limit.
|
||||||
{
|
{
|
||||||
_player.getAccountVariables().remove("LCSCount" + product.getProductionId());
|
_player.getAccountVariables().remove(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId());
|
||||||
packet.writeD(product.getAccountDailyLimit());
|
packet.writeD(product.getAccountDailyLimit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
packet.writeD(product.getAccountDailyLimit() - _player.getAccountVariables().getInt("LCSCount" + product.getProductionId(), 0));
|
packet.writeD(product.getAccountDailyLimit() - _player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // No account daily limit.
|
else if (product.getAccountBuyLimit() > 0) // Count limit.
|
||||||
|
{
|
||||||
|
if (_player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountBuyLimit())
|
||||||
|
{
|
||||||
|
packet.writeD(0x00);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packet.writeD(product.getAccountBuyLimit() - _player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // No account limits.
|
||||||
{
|
{
|
||||||
packet.writeD(0x01);
|
packet.writeD(0x01);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user