123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- /*
- * Copyright (C) 2004-2015 L2J Server
- *
- * This file is part of L2J Server.
- *
- * L2J Server 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.
- *
- * L2J Server 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 com.l2jserver.gameserver.model;
- /**
- * This class describes a Recipe used by Dwarf to craft Item. All L2RecipeList are made of L2RecipeInstance (1 line of the recipe : Item-Quantity needed).
- */
- public class L2RecipeList
- {
- /** The table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList */
- private L2RecipeInstance[] _recipes;
-
- /** The table containing all L2RecipeStatInstance for the statUse parameter of the L2RecipeList */
- private L2RecipeStatInstance[] _statUse;
-
- /** The table containing all L2RecipeStatInstance for the altStatChange parameter of the L2RecipeList */
- private L2RecipeStatInstance[] _altStatChange;
-
- /** The Identifier of the Instance */
- private final int _id;
-
- /** The crafting level needed to use this L2RecipeList */
- private final int _level;
-
- /** The Identifier of the L2RecipeList */
- private final int _recipeId;
-
- /** The name of the L2RecipeList */
- private final String _recipeName;
-
- /** The crafting success rate when using the L2RecipeList */
- private final int _successRate;
-
- /** The Identifier of the Item crafted with this L2RecipeList */
- private final int _itemId;
-
- /** The quantity of Item crafted when using this L2RecipeList */
- private final int _count;
-
- /** The Identifier of the Rare Item crafted with this L2RecipeList */
- private int _rareItemId;
-
- /** The quantity of Rare Item crafted when using this L2RecipeList */
- private int _rareCount;
-
- /** The chance of Rare Item crafted when using this L2RecipeList */
- private int _rarity;
-
- /** If this a common or a dwarven recipe */
- private final boolean _isDwarvenRecipe;
-
- /**
- * Constructor of L2RecipeList (create a new Recipe).
- * @param set
- * @param haveRare
- */
- public L2RecipeList(StatsSet set, boolean haveRare)
- {
- _recipes = new L2RecipeInstance[0];
- _statUse = new L2RecipeStatInstance[0];
- _altStatChange = new L2RecipeStatInstance[0];
- _id = set.getInt("id");
- _level = set.getInt("craftLevel");
- _recipeId = set.getInt("recipeId");
- _recipeName = set.getString("recipeName");
- _successRate = set.getInt("successRate");
- _itemId = set.getInt("itemId");
- _count = set.getInt("count");
- if (haveRare)
- {
- _rareItemId = set.getInt("rareItemId");
- _rareCount = set.getInt("rareCount");
- _rarity = set.getInt("rarity");
- }
- _isDwarvenRecipe = set.getBoolean("isDwarvenRecipe");
- }
-
- /**
- * Add a L2RecipeInstance to the L2RecipeList (add a line Item-Quantity needed to the Recipe).
- * @param recipe
- */
- public void addRecipe(L2RecipeInstance recipe)
- {
- int len = _recipes.length;
- L2RecipeInstance[] tmp = new L2RecipeInstance[len + 1];
- System.arraycopy(_recipes, 0, tmp, 0, len);
- tmp[len] = recipe;
- _recipes = tmp;
- }
-
- /**
- * Add a L2RecipeStatInstance of the statUse parameter to the L2RecipeList.
- * @param statUse
- */
- public void addStatUse(L2RecipeStatInstance statUse)
- {
- int len = _statUse.length;
- L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
- System.arraycopy(_statUse, 0, tmp, 0, len);
- tmp[len] = statUse;
- _statUse = tmp;
- }
-
- /**
- * Add a L2RecipeStatInstance of the altStatChange parameter to the L2RecipeList.
- * @param statChange
- */
- public void addAltStatChange(L2RecipeStatInstance statChange)
- {
- int len = _altStatChange.length;
- L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
- System.arraycopy(_altStatChange, 0, tmp, 0, len);
- tmp[len] = statChange;
- _altStatChange = tmp;
- }
-
- /**
- * @return the Identifier of the Instance.
- */
- public int getId()
- {
- return _id;
- }
-
- /**
- * @return the crafting level needed to use this L2RecipeList.
- */
- public int getLevel()
- {
- return _level;
- }
-
- /**
- * @return the Identifier of the L2RecipeList.
- */
- public int getRecipeId()
- {
- return _recipeId;
- }
-
- /**
- * @return the name of the L2RecipeList.
- */
- public String getRecipeName()
- {
- return _recipeName;
- }
-
- /**
- * @return the crafting success rate when using the L2RecipeList.
- */
- public int getSuccessRate()
- {
- return _successRate;
- }
-
- /**
- * @return the Identifier of the Item crafted with this L2RecipeList.
- */
- public int getItemId()
- {
- return _itemId;
- }
-
- /**
- * @return the quantity of Item crafted when using this L2RecipeList.
- */
- public int getCount()
- {
- return _count;
- }
-
- /**
- * @return the Identifier of the Rare Item crafted with this L2RecipeList.
- */
- public int getRareItemId()
- {
- return _rareItemId;
- }
-
- /**
- * @return the quantity of Rare Item crafted when using this L2RecipeList.
- */
- public int getRareCount()
- {
- return _rareCount;
- }
-
- /**
- * @return the chance of Rare Item crafted when using this L2RecipeList.
- */
- public int getRarity()
- {
- return _rarity;
- }
-
- /**
- * @return {@code true} if this a Dwarven recipe or {@code false} if its a Common recipe
- */
- public boolean isDwarvenRecipe()
- {
- return _isDwarvenRecipe;
- }
-
- /**
- * @return the table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList.
- */
- public L2RecipeInstance[] getRecipes()
- {
- return _recipes;
- }
-
- /**
- * @return the table containing all L2RecipeStatInstance of the statUse parameter of the L2RecipeList.
- */
- public L2RecipeStatInstance[] getStatUse()
- {
- return _statUse;
- }
-
- /**
- * @return the table containing all L2RecipeStatInstance of the AltStatChange parameter of the L2RecipeList.
- */
- public L2RecipeStatInstance[] getAltStatChange()
- {
- return _altStatChange;
- }
- }
|