L2ArmorSet.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 net.sf.l2j.gameserver.model;
  16. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  17. /**
  18. *
  19. *
  20. * @author Luno
  21. */
  22. public final class L2ArmorSet
  23. {
  24. private final int _chest;
  25. private final int _legs;
  26. private final int _head;
  27. private final int _gloves;
  28. private final int _feet;
  29. private final int _skillId;
  30. private final int _shield;
  31. private final int _shieldSkillId;
  32. private final int _enchant6Skill;
  33. public L2ArmorSet(int chest, int legs, int head, int gloves, int feet, int skill_id, int shield, int shield_skill_id, int enchant6skill)
  34. {
  35. _chest = chest;
  36. _legs = legs;
  37. _head = head;
  38. _gloves = gloves;
  39. _feet = feet;
  40. _skillId = skill_id;
  41. _shield = shield;
  42. _shieldSkillId = shield_skill_id;
  43. _enchant6Skill = enchant6skill;
  44. }
  45. /**
  46. * Checks if player have equiped all items from set (not checking shield)
  47. * @param player whose inventory is being checked
  48. * @return True if player equips whole set
  49. */
  50. public boolean containAll(L2PcInstance player)
  51. {
  52. Inventory inv = player.getInventory();
  53. L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
  54. L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
  55. L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
  56. L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
  57. int legs = 0;
  58. int head = 0;
  59. int gloves = 0;
  60. int feet = 0;
  61. if(legsItem != null) legs = legsItem.getItemId();
  62. if(headItem != null) head = headItem.getItemId();
  63. if(glovesItem != null) gloves = glovesItem.getItemId();
  64. if(feetItem != null) feet = feetItem.getItemId();
  65. return containAll(_chest,legs,head,gloves,feet);
  66. }
  67. public boolean containAll(int chest, int legs, int head, int gloves, int feet)
  68. {
  69. if(_chest != 0 && _chest != chest)
  70. return false;
  71. if(_legs != 0 && _legs != legs)
  72. return false;
  73. if(_head != 0 && _head != head)
  74. return false;
  75. if(_gloves != 0 && _gloves != gloves)
  76. return false;
  77. if(_feet != 0 && _feet != feet)
  78. return false;
  79. return true;
  80. }
  81. public boolean containItem(int slot, int itemId)
  82. {
  83. switch(slot)
  84. {
  85. case Inventory.PAPERDOLL_CHEST:
  86. return _chest == itemId;
  87. case Inventory.PAPERDOLL_LEGS:
  88. return _legs == itemId;
  89. case Inventory.PAPERDOLL_HEAD:
  90. return _head == itemId;
  91. case Inventory.PAPERDOLL_GLOVES:
  92. return _gloves == itemId;
  93. case Inventory.PAPERDOLL_FEET:
  94. return _feet == itemId;
  95. default:
  96. return false;
  97. }
  98. }
  99. public int getSkillId()
  100. {
  101. return _skillId;
  102. }
  103. public boolean containShield(L2PcInstance player)
  104. {
  105. Inventory inv = player.getInventory();
  106. L2ItemInstance shieldItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
  107. if(shieldItem!= null && shieldItem.getItemId() == _shield)
  108. return true;
  109. return false;
  110. }
  111. public boolean containShield(int shield_id)
  112. {
  113. if(_shield == 0)
  114. return false;
  115. return _shield == shield_id;
  116. }
  117. public int getShieldSkillId()
  118. {
  119. return _shieldSkillId;
  120. }
  121. public int getEnchant6skillId()
  122. {
  123. return _enchant6Skill;
  124. }
  125. /**
  126. * Checks if all parts of set are enchanted to +6 or more
  127. * @param player
  128. * @return
  129. */
  130. public boolean isEnchanted6(L2PcInstance player)
  131. {
  132. // Player don't have full set
  133. if(!containAll(player))
  134. return false;
  135. Inventory inv = player.getInventory();
  136. L2ItemInstance chestItem = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST);
  137. L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
  138. L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
  139. L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
  140. L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
  141. if(chestItem.getEnchantLevel() < 6)
  142. return false;
  143. if(_legs != 0 && legsItem.getEnchantLevel() < 6)
  144. return false;
  145. if(_gloves != 0 && glovesItem.getEnchantLevel() < 6)
  146. return false;
  147. if(_head != 0 && headItem.getEnchantLevel() < 6)
  148. return false;
  149. if(_feet != 0 && feetItem.getEnchantLevel() < 6)
  150. return false;
  151. return true;
  152. }
  153. }