L2ArmorSet.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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 java.util.ArrayList;
  17. import java.util.List;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.holders.SkillHolder;
  20. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  21. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  22. /**
  23. * @author Luno
  24. */
  25. public final class L2ArmorSet
  26. {
  27. private int _chestId;
  28. private final List<Integer> _legs;
  29. private final List<Integer> _head;
  30. private final List<Integer> _gloves;
  31. private final List<Integer> _feet;
  32. private final List<Integer> _shield;
  33. private final List<SkillHolder> _skills;
  34. private final List<SkillHolder> _shieldSkills;
  35. private final List<SkillHolder> _enchant6Skill;
  36. private int _con;
  37. private int _dex;
  38. private int _str;
  39. private int _men;
  40. private int _wit;
  41. private int _int;
  42. public L2ArmorSet()
  43. {
  44. _legs = new ArrayList<>();
  45. _head = new ArrayList<>();
  46. _gloves = new ArrayList<>();
  47. _feet = new ArrayList<>();
  48. _shield = new ArrayList<>();
  49. _skills = new ArrayList<>();
  50. _shieldSkills = new ArrayList<>();
  51. _enchant6Skill = new ArrayList<>();
  52. }
  53. public void addChest(int id)
  54. {
  55. _chestId = id;
  56. }
  57. public void addLegs(int id)
  58. {
  59. _legs.add(id);
  60. }
  61. public void addHead(int id)
  62. {
  63. _head.add(id);
  64. }
  65. public void addGloves(int id)
  66. {
  67. _gloves.add(id);
  68. }
  69. public void addFeet(int id)
  70. {
  71. _feet.add(id);
  72. }
  73. public void addShield(int id)
  74. {
  75. _shield.add(id);
  76. }
  77. public void addSkill(SkillHolder holder)
  78. {
  79. _skills.add(holder);
  80. }
  81. public void addShieldSkill(SkillHolder holder)
  82. {
  83. _shieldSkills.add(holder);
  84. }
  85. public void addEnchant6Skill(SkillHolder holder)
  86. {
  87. _enchant6Skill.add(holder);
  88. }
  89. public void addCon(int val)
  90. {
  91. _con = val;
  92. }
  93. public void addDex(int val)
  94. {
  95. _dex = val;
  96. }
  97. public void addStr(int val)
  98. {
  99. _str = val;
  100. }
  101. public void addMen(int val)
  102. {
  103. _men = val;
  104. }
  105. public void addWit(int val)
  106. {
  107. _wit = val;
  108. }
  109. public void addInt(int val)
  110. {
  111. _int = val;
  112. }
  113. /**
  114. * Checks if player have equipped all items from set (not checking shield)
  115. * @param player whose inventory is being checked
  116. * @return True if player equips whole set
  117. */
  118. public boolean containAll(L2PcInstance player)
  119. {
  120. Inventory inv = player.getInventory();
  121. L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
  122. L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
  123. L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
  124. L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
  125. int legs = 0;
  126. int head = 0;
  127. int gloves = 0;
  128. int feet = 0;
  129. if (legsItem != null)
  130. {
  131. legs = legsItem.getItemId();
  132. }
  133. if (headItem != null)
  134. {
  135. head = headItem.getItemId();
  136. }
  137. if (glovesItem != null)
  138. {
  139. gloves = glovesItem.getItemId();
  140. }
  141. if (feetItem != null)
  142. {
  143. feet = feetItem.getItemId();
  144. }
  145. return containAll(_chestId, legs, head, gloves, feet);
  146. }
  147. public boolean containAll(int chest, int legs, int head, int gloves, int feet)
  148. {
  149. if ((_chestId != 0) && (_chestId != chest))
  150. {
  151. return false;
  152. }
  153. if (!_legs.isEmpty() && !_legs.contains(legs))
  154. {
  155. return false;
  156. }
  157. if (!_head.isEmpty() && !_head.contains(head))
  158. {
  159. return false;
  160. }
  161. if (!_gloves.isEmpty() && !_gloves.contains(gloves))
  162. {
  163. return false;
  164. }
  165. if (!_feet.isEmpty() && !_feet.contains(feet))
  166. {
  167. return false;
  168. }
  169. return true;
  170. }
  171. public boolean containItem(int slot, int itemId)
  172. {
  173. switch (slot)
  174. {
  175. case Inventory.PAPERDOLL_CHEST:
  176. return _chestId == itemId;
  177. case Inventory.PAPERDOLL_LEGS:
  178. return _legs.contains(itemId);
  179. case Inventory.PAPERDOLL_HEAD:
  180. return _head.contains(itemId);
  181. case Inventory.PAPERDOLL_GLOVES:
  182. return _gloves.contains(itemId);
  183. case Inventory.PAPERDOLL_FEET:
  184. return _feet.contains(itemId);
  185. default:
  186. return false;
  187. }
  188. }
  189. public int getChestId()
  190. {
  191. return _chestId;
  192. }
  193. public List<SkillHolder> getSkills()
  194. {
  195. return _skills;
  196. }
  197. public boolean containShield(L2PcInstance player)
  198. {
  199. Inventory inv = player.getInventory();
  200. L2ItemInstance shieldItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
  201. return ((shieldItem != null) && _shield.contains(Integer.valueOf(shieldItem.getItemId())));
  202. }
  203. public boolean containShield(int shield_id)
  204. {
  205. if (_shield.isEmpty())
  206. {
  207. return false;
  208. }
  209. return _shield.contains(Integer.valueOf(shield_id));
  210. }
  211. public List<SkillHolder> getShieldSkillId()
  212. {
  213. return _shieldSkills;
  214. }
  215. public List<SkillHolder> getEnchant6skillId()
  216. {
  217. return _enchant6Skill;
  218. }
  219. /**
  220. * @param player
  221. * @return true if all parts of set are enchanted to +6 or more
  222. */
  223. public boolean isEnchanted6(L2PcInstance player)
  224. {
  225. // Player don't have full set
  226. if (!containAll(player))
  227. {
  228. return false;
  229. }
  230. Inventory inv = player.getInventory();
  231. L2ItemInstance chestItem = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST);
  232. L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
  233. L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
  234. L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
  235. L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
  236. if ((chestItem == null) || (chestItem.getEnchantLevel() < 6))
  237. {
  238. return false;
  239. }
  240. if (!_legs.isEmpty() && ((legsItem == null) || (legsItem.getEnchantLevel() < 6)))
  241. {
  242. return false;
  243. }
  244. if (!_gloves.isEmpty() && ((glovesItem == null) || (glovesItem.getEnchantLevel() < 6)))
  245. {
  246. return false;
  247. }
  248. if (!_head.isEmpty() && ((headItem == null) || (headItem.getEnchantLevel() < 6)))
  249. {
  250. return false;
  251. }
  252. if (!_feet.isEmpty() && ((feetItem == null) || (feetItem.getEnchantLevel() < 6)))
  253. {
  254. return false;
  255. }
  256. return true;
  257. }
  258. public int getCON()
  259. {
  260. return _con;
  261. }
  262. public int getDEX()
  263. {
  264. return _dex;
  265. }
  266. public int getSTR()
  267. {
  268. return _str;
  269. }
  270. public int getMEN()
  271. {
  272. return _men;
  273. }
  274. public int getWIT()
  275. {
  276. return _wit;
  277. }
  278. public int getINT()
  279. {
  280. return _int;
  281. }
  282. }