L2RecipeList.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model;
  20. /**
  21. * 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).
  22. */
  23. public class L2RecipeList
  24. {
  25. /** The table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList */
  26. private L2RecipeInstance[] _recipes;
  27. /** The table containing all L2RecipeStatInstance for the statUse parameter of the L2RecipeList */
  28. private L2RecipeStatInstance[] _statUse;
  29. /** The table containing all L2RecipeStatInstance for the altStatChange parameter of the L2RecipeList */
  30. private L2RecipeStatInstance[] _altStatChange;
  31. /** The Identifier of the Instance */
  32. private final int _id;
  33. /** The crafting level needed to use this L2RecipeList */
  34. private final int _level;
  35. /** The Identifier of the L2RecipeList */
  36. private final int _recipeId;
  37. /** The name of the L2RecipeList */
  38. private final String _recipeName;
  39. /** The crafting success rate when using the L2RecipeList */
  40. private final int _successRate;
  41. /** The Identifier of the Item crafted with this L2RecipeList */
  42. private final int _itemId;
  43. /** The quantity of Item crafted when using this L2RecipeList */
  44. private final int _count;
  45. /** The Identifier of the Rare Item crafted with this L2RecipeList */
  46. private int _rareItemId;
  47. /** The quantity of Rare Item crafted when using this L2RecipeList */
  48. private int _rareCount;
  49. /** The chance of Rare Item crafted when using this L2RecipeList */
  50. private int _rarity;
  51. /** If this a common or a dwarven recipe */
  52. private final boolean _isDwarvenRecipe;
  53. /**
  54. * Constructor of L2RecipeList (create a new Recipe).
  55. * @param set
  56. * @param haveRare
  57. */
  58. public L2RecipeList(StatsSet set, boolean haveRare)
  59. {
  60. _recipes = new L2RecipeInstance[0];
  61. _statUse = new L2RecipeStatInstance[0];
  62. _altStatChange = new L2RecipeStatInstance[0];
  63. _id = set.getInt("id");
  64. _level = set.getInt("craftLevel");
  65. _recipeId = set.getInt("recipeId");
  66. _recipeName = set.getString("recipeName");
  67. _successRate = set.getInt("successRate");
  68. _itemId = set.getInt("itemId");
  69. _count = set.getInt("count");
  70. if (haveRare)
  71. {
  72. _rareItemId = set.getInt("rareItemId");
  73. _rareCount = set.getInt("rareCount");
  74. _rarity = set.getInt("rarity");
  75. }
  76. _isDwarvenRecipe = set.getBoolean("isDwarvenRecipe");
  77. }
  78. /**
  79. * Add a L2RecipeInstance to the L2RecipeList (add a line Item-Quantity needed to the Recipe).
  80. * @param recipe
  81. */
  82. public void addRecipe(L2RecipeInstance recipe)
  83. {
  84. int len = _recipes.length;
  85. L2RecipeInstance[] tmp = new L2RecipeInstance[len + 1];
  86. System.arraycopy(_recipes, 0, tmp, 0, len);
  87. tmp[len] = recipe;
  88. _recipes = tmp;
  89. }
  90. /**
  91. * Add a L2RecipeStatInstance of the statUse parameter to the L2RecipeList.
  92. * @param statUse
  93. */
  94. public void addStatUse(L2RecipeStatInstance statUse)
  95. {
  96. int len = _statUse.length;
  97. L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
  98. System.arraycopy(_statUse, 0, tmp, 0, len);
  99. tmp[len] = statUse;
  100. _statUse = tmp;
  101. }
  102. /**
  103. * Add a L2RecipeStatInstance of the altStatChange parameter to the L2RecipeList.
  104. * @param statChange
  105. */
  106. public void addAltStatChange(L2RecipeStatInstance statChange)
  107. {
  108. int len = _altStatChange.length;
  109. L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
  110. System.arraycopy(_altStatChange, 0, tmp, 0, len);
  111. tmp[len] = statChange;
  112. _altStatChange = tmp;
  113. }
  114. /**
  115. * @return the Identifier of the Instance.
  116. */
  117. public int getId()
  118. {
  119. return _id;
  120. }
  121. /**
  122. * @return the crafting level needed to use this L2RecipeList.
  123. */
  124. public int getLevel()
  125. {
  126. return _level;
  127. }
  128. /**
  129. * @return the Identifier of the L2RecipeList.
  130. */
  131. public int getRecipeId()
  132. {
  133. return _recipeId;
  134. }
  135. /**
  136. * @return the name of the L2RecipeList.
  137. */
  138. public String getRecipeName()
  139. {
  140. return _recipeName;
  141. }
  142. /**
  143. * @return the crafting success rate when using the L2RecipeList.
  144. */
  145. public int getSuccessRate()
  146. {
  147. return _successRate;
  148. }
  149. /**
  150. * @return the Identifier of the Item crafted with this L2RecipeList.
  151. */
  152. public int getItemId()
  153. {
  154. return _itemId;
  155. }
  156. /**
  157. * @return the quantity of Item crafted when using this L2RecipeList.
  158. */
  159. public int getCount()
  160. {
  161. return _count;
  162. }
  163. /**
  164. * @return the Identifier of the Rare Item crafted with this L2RecipeList.
  165. */
  166. public int getRareItemId()
  167. {
  168. return _rareItemId;
  169. }
  170. /**
  171. * @return the quantity of Rare Item crafted when using this L2RecipeList.
  172. */
  173. public int getRareCount()
  174. {
  175. return _rareCount;
  176. }
  177. /**
  178. * @return the chance of Rare Item crafted when using this L2RecipeList.
  179. */
  180. public int getRarity()
  181. {
  182. return _rarity;
  183. }
  184. /**
  185. * @return {@code true} if this a Dwarven recipe or {@code false} if its a Common recipe
  186. */
  187. public boolean isDwarvenRecipe()
  188. {
  189. return _isDwarvenRecipe;
  190. }
  191. /**
  192. * @return the table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList.
  193. */
  194. public L2RecipeInstance[] getRecipes()
  195. {
  196. return _recipes;
  197. }
  198. /**
  199. * @return the table containing all L2RecipeStatInstance of the statUse parameter of the L2RecipeList.
  200. */
  201. public L2RecipeStatInstance[] getStatUse()
  202. {
  203. return _statUse;
  204. }
  205. /**
  206. * @return the table containing all L2RecipeStatInstance of the AltStatChange parameter of the L2RecipeList.
  207. */
  208. public L2RecipeStatInstance[] getAltStatChange()
  209. {
  210. return _altStatChange;
  211. }
  212. }