L2ArmorSet.java 7.0 KB

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