L2RecipeList.java 6.7 KB

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