Clan Limit Shop implementation.

This commit is contained in:
MobiusDevelopment
2021-04-28 21:01:37 +00:00
parent f81e3d62ce
commit 84e9ea8d34
24 changed files with 540 additions and 274 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LCoinShop.xsd">
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LimitShop.xsd">
<!-- Cat 0 -->
<product id="2" category="0">
<ingredient id="91663" count="200" /> <!-- L-Coin -->

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LimitShop.xsd">
<product id="300" category="100">
<ingredient id="91663" count="8" /> <!-- L-Coin -->
<production id="91641" accountDailyLimit="15" /> <!-- Sayha's Blessing -->
</product>
<product id="400" category="100">
<ingredient id="91663" count="3" /> <!-- L-Coin -->
<production id="91690" accountDailyLimit="200" /> <!-- Special HP Recovery Potion -->
</product>
<product id="500" category="100">
<ingredient id="91663" count="1012" /> <!-- L-Coin -->
<production id="95583" accountDailyLimit="1" /> <!-- Hardin's Notes - Page 1 -->
</product>
<product id="501" category="100">
<ingredient id="91663" count="200" /> <!-- L-Coin -->
<production id="95636" accountDailyLimit="4" /> <!-- Clan Cloak -->
</product>
<product id="502" category="100">
<ingredient id="91663" count="2" /> <!-- L-Coin -->
<production id="95638" accountDailyLimit="10" /> <!-- Scroll: Enchant Clan Equipment -->
</product>
<product id="600" category="100">
<ingredient id="91663" count="3375" /> <!-- L-Coin -->
<production id="95584" accountDailyLimit="1" /> <!-- Hardin's Notes - Page 2 -->
</product>
<product id="601" category="100">
<ingredient id="91663" count="200" /> <!-- L-Coin -->
<production id="95637" accountDailyLimit="4" /> <!-- Clan Circlet -->
</product>
<product id="700" category="100">
<ingredient id="91663" count="5062" /> <!-- L-Coin -->
<production id="95585" accountDailyLimit="1" /> <!-- Hardin's Notes - Page 3 -->
</product>
</list>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LCoinShop.xsd">
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LimitShop.xsd">
<product id="1200" category="0">
<ingredient id="92314" count="63" /> <!-- Giran Seal -->
<production id="93801" chance="15" id2="92314" count2="10" accountBuyLimit="20" /> <!-- Package: Sirra's Blade (Sealed) -->

View File

@@ -40,8 +40,9 @@ import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FishingData;
import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData;
import org.l2jmobius.gameserver.data.xml.LimitShopClanData;
import org.l2jmobius.gameserver.data.xml.LimitShopData;
import org.l2jmobius.gameserver.data.xml.LimitShopCraftData;
import org.l2jmobius.gameserver.data.xml.MultisellData;
import org.l2jmobius.gameserver.data.xml.NpcData;
import org.l2jmobius.gameserver.data.xml.NpcNameLocalisationData;
@@ -285,8 +286,9 @@ public class AdminReload implements IAdminCommandHandler
}
case "limitshop":
{
LCoinShopData.getInstance().load();
LCoinShopSpecialCraftData.getInstance();
LimitShopData.getInstance().load();
LimitShopCraftData.getInstance().load();
LimitShopClanData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Limit Shop data.");
break;
}

View File

@@ -642,6 +642,7 @@
<set name="is_destroyable" val="false" />
<set name="is_depositable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_stackable" val="true" />
</item>
<item id="95571" name="Enchanted C-grade Armor Coupon" type="EtcItem">
<!-- Can be exchanged for a C-grade armor through the Game Assistant. -->

View File

@@ -5,7 +5,7 @@
<xs:element name="product" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="ingredient" maxOccurs="unbounded">
<xs:element name="ingredient" maxOccurs="5">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">

View File

@@ -80,8 +80,9 @@ import org.l2jmobius.gameserver.data.xml.InitialEquipmentData;
import org.l2jmobius.gameserver.data.xml.InitialShortcutData;
import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
import org.l2jmobius.gameserver.data.xml.KarmaData;
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData;
import org.l2jmobius.gameserver.data.xml.LimitShopClanData;
import org.l2jmobius.gameserver.data.xml.LimitShopData;
import org.l2jmobius.gameserver.data.xml.LimitShopCraftData;
import org.l2jmobius.gameserver.data.xml.LuckyGameData;
import org.l2jmobius.gameserver.data.xml.MagicLampData;
import org.l2jmobius.gameserver.data.xml.MultisellData;
@@ -281,8 +282,9 @@ public class GameServer
FishingData.getInstance();
HennaData.getInstance();
PrimeShopData.getInstance();
LCoinShopData.getInstance();
LCoinShopSpecialCraftData.getInstance();
LimitShopData.getInstance();
LimitShopCraftData.getInstance();
LimitShopClanData.getInstance();
PcCafePointsManager.getInstance();
AppearanceItemData.getInstance();
CommissionManager.getInstance();

View File

@@ -0,0 +1,215 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
import org.l2jmobius.gameserver.model.items.Item;
/**
* @author Mobius
*/
public class LimitShopClanData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(LimitShopClanData.class.getName());
private final List<LimitShopProductHolder> _products = new ArrayList<>();
protected LimitShopClanData()
{
load();
}
@Override
public void load()
{
_products.clear();
parseDatapackFile("data/LimitShopClan.xml");
if (!_products.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _products.size() + " items.");
}
else
{
LOGGER.info(getClass().getSimpleName() + ": System is disabled.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
final NamedNodeMap at = n.getAttributes();
final Node attribute = at.getNamedItem("enabled");
if ((attribute != null) && Boolean.parseBoolean(attribute.getNodeValue()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("product".equalsIgnoreCase(d.getNodeName()))
{
NamedNodeMap attrs = d.getAttributes();
Node att;
final StatSet set = new StatSet();
for (int i = 0; i < attrs.getLength(); i++)
{
att = attrs.item(i);
set.set(att.getNodeName(), att.getNodeValue());
}
final int id = parseInteger(attrs, "id");
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];
ingredientIds[0] = 0;
ingredientIds[1] = 0;
ingredientIds[2] = 0;
ingredientIds[3] = 0;
ingredientIds[4] = 0;
final long[] ingredientQuantities = new long[5];
ingredientQuantities[0] = 0;
ingredientQuantities[1] = 0;
ingredientQuantities[2] = 0;
ingredientQuantities[3] = 0;
ingredientQuantities[4] = 0;
int productionId = 0;
int accountDailyLimit = 0;
int accountBuyLimit = 0;
for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
{
attrs = b.getAttributes();
if ("ingredient".equalsIgnoreCase(b.getNodeName()))
{
final int ingredientId = parseInteger(attrs, "id");
final long ingredientQuantity = parseLong(attrs, "count", 1L);
final Item item = ItemTable.getInstance().getTemplate(ingredientId);
if (item == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Item template null for itemId: " + productionId + " productId: " + id);
continue;
}
if (ingredientIds[0] == 0)
{
ingredientIds[0] = ingredientId;
}
else if (ingredientIds[1] == 0)
{
ingredientIds[1] = ingredientId;
}
else if (ingredientIds[2] == 0)
{
ingredientIds[2] = ingredientId;
}
else if (ingredientIds[3] == 0)
{
ingredientIds[3] = ingredientId;
}
else
{
ingredientIds[4] = ingredientId;
}
if (ingredientQuantities[0] == 0)
{
ingredientQuantities[0] = ingredientQuantity;
}
else if (ingredientQuantities[1] == 0)
{
ingredientQuantities[1] = ingredientQuantity;
}
else if (ingredientQuantities[2] == 0)
{
ingredientQuantities[2] = ingredientQuantity;
}
else if (ingredientQuantities[3] == 0)
{
ingredientQuantities[3] = ingredientQuantity;
}
else
{
ingredientQuantities[4] = ingredientQuantity;
}
}
else if ("production".equalsIgnoreCase(b.getNodeName()))
{
productionId = parseInteger(attrs, "id");
accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0);
accountBuyLimit = parseInteger(attrs, "accountBuyLimit", 0);
final Item item = ItemTable.getInstance().getTemplate(productionId);
if (item == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Item template null for itemId: " + productionId + " productId: " + id);
continue;
}
}
}
_products.add(new LimitShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, 0, 0, 0, 0, 0, 0, 0, accountDailyLimit, accountBuyLimit));
}
}
}
}
}
}
public LimitShopProductHolder getProduct(int id)
{
for (LimitShopProductHolder product : _products)
{
if (product.getId() == id)
{
return product;
}
}
return null;
}
public Collection<LimitShopProductHolder> getProducts()
{
return _products;
}
public static LimitShopClanData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final LimitShopClanData INSTANCE = new LimitShopClanData();
}
}

View File

@@ -29,19 +29,19 @@ import org.w3c.dom.Node;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
import org.l2jmobius.gameserver.model.items.Item;
/**
* @author Mobius, GustavoFonseca
*/
public class LCoinShopSpecialCraftData implements IXmlReader
public class LimitShopCraftData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(LCoinShopData.class.getName());
private static final Logger LOGGER = Logger.getLogger(LimitShopData.class.getName());
private final List<LCoinShopProductHolder> _products = new ArrayList<>();
private final List<LimitShopProductHolder> _products = new ArrayList<>();
protected LCoinShopSpecialCraftData()
protected LimitShopCraftData()
{
load();
}
@@ -50,7 +50,7 @@ public class LCoinShopSpecialCraftData implements IXmlReader
public void load()
{
_products.clear();
parseDatapackFile("data/LCoinShopSpecialCraft.xml");
parseDatapackFile("data/LimitShopCraft.xml");
if (!_products.isEmpty())
{
@@ -192,7 +192,7 @@ public class LCoinShopSpecialCraftData implements IXmlReader
}
}
_products.add(new LCoinShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, count, chance, productionId2, count2, chance2, productionId3, count3, accountDailyLimit, accountBuyLimit));
_products.add(new LimitShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, count, chance, productionId2, count2, chance2, productionId3, count3, accountDailyLimit, accountBuyLimit));
}
}
}
@@ -200,9 +200,9 @@ public class LCoinShopSpecialCraftData implements IXmlReader
}
}
public LCoinShopProductHolder getProduct(int id)
public LimitShopProductHolder getProduct(int id)
{
for (LCoinShopProductHolder product : _products)
for (LimitShopProductHolder product : _products)
{
if (product.getId() == id)
{
@@ -212,18 +212,18 @@ public class LCoinShopSpecialCraftData implements IXmlReader
return null;
}
public Collection<LCoinShopProductHolder> getProducts()
public Collection<LimitShopProductHolder> getProducts()
{
return _products;
}
public static LCoinShopSpecialCraftData getInstance()
public static LimitShopCraftData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final LCoinShopSpecialCraftData INSTANCE = new LCoinShopSpecialCraftData();
protected static final LimitShopCraftData INSTANCE = new LimitShopCraftData();
}
}

View File

@@ -29,19 +29,19 @@ import org.w3c.dom.Node;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
import org.l2jmobius.gameserver.model.items.Item;
/**
* @author Mobius
*/
public class LCoinShopData implements IXmlReader
public class LimitShopData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(LCoinShopData.class.getName());
private static final Logger LOGGER = Logger.getLogger(LimitShopData.class.getName());
private final List<LCoinShopProductHolder> _products = new ArrayList<>();
private final List<LimitShopProductHolder> _products = new ArrayList<>();
protected LCoinShopData()
protected LimitShopData()
{
load();
}
@@ -50,7 +50,7 @@ public class LCoinShopData implements IXmlReader
public void load()
{
_products.clear();
parseDatapackFile("data/LCoinShop.xml");
parseDatapackFile("data/LimitShop.xml");
if (!_products.isEmpty())
{
@@ -178,7 +178,7 @@ public class LCoinShopData implements IXmlReader
}
}
_products.add(new LCoinShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, 0, 0, 0, 0, 0, 0, 0, accountDailyLimit, accountBuyLimit));
_products.add(new LimitShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, 0, 0, 0, 0, 0, 0, 0, accountDailyLimit, accountBuyLimit));
}
}
}
@@ -186,9 +186,9 @@ public class LCoinShopData implements IXmlReader
}
}
public LCoinShopProductHolder getProduct(int id)
public LimitShopProductHolder getProduct(int id)
{
for (LCoinShopProductHolder product : _products)
for (LimitShopProductHolder product : _products)
{
if (product.getId() == id)
{
@@ -198,18 +198,18 @@ public class LCoinShopData implements IXmlReader
return null;
}
public Collection<LCoinShopProductHolder> getProducts()
public Collection<LimitShopProductHolder> getProducts()
{
return _products;
}
public static LCoinShopData getInstance()
public static LimitShopData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final LCoinShopData INSTANCE = new LCoinShopData();
protected static final LimitShopData INSTANCE = new LimitShopData();
}
}

View File

@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.holders;
/**
* @author Mobius
*/
public class LCoinShopProductHolder
public class LimitShopProductHolder
{
private final int _id;
private final int _category;
@@ -38,7 +38,7 @@ public class LCoinShopProductHolder
private final int _accountDailyLimit;
private final int _accountBuyLimit;
public LCoinShopProductHolder(int id, int category, int minLevel, int maxLevel, int[] ingredientIds, long[] ingredientQuantities, int productionId, long count, float chance, int productionId2, long count2, float chance2, int productionId3, long count3, int accountDailyLimit, int accountBuyLimit)
public LimitShopProductHolder(int id, int category, int minLevel, int maxLevel, int[] ingredientIds, long[] ingredientQuantities, int productionId, long count, float chance, int productionId2, long count2, float chance2, int productionId3, long count3, int accountDailyLimit, int accountBuyLimit)
{
_id = id;
_category = category;

View File

@@ -19,12 +19,13 @@ package org.l2jmobius.gameserver.network.clientpackets.limitshop;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData;
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.enums.SpecialItemType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.network.GameClient;
@@ -40,31 +41,35 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
{
private int _productId;
private int _amount;
private LCoinShopProductHolder _product;
private LimitShopProductHolder _product;
@Override
public boolean read(GameClient client, PacketReader packet)
{
final int shopIndex = packet.readC(); // shopIndex 3 = Lcoin Store , 4 = Special Craft?
final int shopIndex = packet.readC(); // 3 Lcoin Store, 4 Special Craft, 100 Clan Shop
_productId = packet.readD();
_amount = packet.readD();
switch (shopIndex) // 3 = Lcoin Shop - 4 = Special Craft
switch (shopIndex)
{
case 3: // Normal Lcoin Shop
{
_product = LCoinShopData.getInstance().getProduct(_productId);
_product = LimitShopData.getInstance().getProduct(_productId);
break;
}
case 4: // Lcoin Special Craft
{
_product = LCoinShopSpecialCraftData.getInstance().getProduct(_productId);
_product = LimitShopCraftData.getInstance().getProduct(_productId);
break;
}
case 100: // Clan Shop
{
_product = LimitShopClanData.getInstance().getProduct(_productId);
break;
}
default:
{
_product = LCoinShopData.getInstance().getProduct(_productId);
_product = null;
}
}

View File

@@ -17,13 +17,15 @@
package org.l2jmobius.gameserver.network.serverpackets.limitshop;
import java.util.Collection;
import java.util.Collections;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.data.xml.LCoinShopData;
import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData;
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.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
import org.l2jmobius.gameserver.model.holders.LimitShopProductHolder;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
@@ -33,31 +35,35 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
*/
public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket
{
private final int _shopType; // 3 = Lcoin Shop - 4 = Special Craft
private final int _shopType; // 3 Lcoin Store, 4 Special Craft, 100 Clan Shop
private final PlayerInstance _player;
private final Collection<LCoinShopProductHolder> _products;
private final Collection<LimitShopProductHolder> _products;
public ExPurchaseLimitShopItemListNew(int shopType, PlayerInstance player)
{
_shopType = shopType;
_player = player;
switch (shopType) // 3 = Lcoin Shop - 4 = Special Craft
switch (shopType)
{
case 3: // Normal Lcoin Shop
{
_products = LCoinShopData.getInstance().getProducts();
_products = LimitShopData.getInstance().getProducts();
break;
}
case 4: // Lcoin Special Craft
{
_products = LCoinShopSpecialCraftData.getInstance().getProducts();
_products = LimitShopCraftData.getInstance().getProducts();
break;
}
case 100: // Clan Shop
{
_products = LimitShopClanData.getInstance().getProducts();
break;
}
default:
{
_products = LCoinShopData.getInstance().getProducts();
_products = Collections.emptyList();
}
}
}
@@ -69,7 +75,7 @@ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket
packet.writeC(_shopType); //
packet.writeD(_products.size());
for (LCoinShopProductHolder product : _products)
for (LimitShopProductHolder product : _products)
{
packet.writeD(product.getId());
packet.writeD(product.getProductionId());