L2PcTemplate.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.templates;
  16. import java.util.List;
  17. import javolution.util.FastList;
  18. import net.sf.l2j.gameserver.model.base.ClassId;
  19. import net.sf.l2j.gameserver.model.base.Race;
  20. /**
  21. * @author mkizub
  22. *
  23. * TODO To change the template for this generated type comment go to
  24. * Window - Preferences - Java - Code Style - Code Templates
  25. */
  26. public class L2PcTemplate extends L2CharTemplate {
  27. /** The Class object of the L2PcInstance */
  28. public final ClassId classId;
  29. public final Race race;
  30. public final String className;
  31. public final int spawnX;
  32. public final int spawnY;
  33. public final int spawnZ;
  34. public final int classBaseLevel;
  35. public final float lvlHpAdd;
  36. public final float lvlHpMod;
  37. public final float lvlCpAdd;
  38. public final float lvlCpMod;
  39. public final float lvlMpAdd;
  40. public final float lvlMpMod;
  41. private List<PcTemplateItem> _items = new FastList<PcTemplateItem>();
  42. public L2PcTemplate(StatsSet set)
  43. {
  44. super(set);
  45. classId = ClassId.values()[set.getInteger("classId")];
  46. race = Race.values()[set.getInteger("raceId")];
  47. className = set.getString("className");
  48. spawnX = set.getInteger("spawnX");
  49. spawnY = set.getInteger("spawnY");
  50. spawnZ = set.getInteger("spawnZ");
  51. classBaseLevel = set.getInteger("classBaseLevel");
  52. lvlHpAdd = set.getFloat("lvlHpAdd");
  53. lvlHpMod = set.getFloat("lvlHpMod");
  54. lvlCpAdd = set.getFloat("lvlCpAdd");
  55. lvlCpMod = set.getFloat("lvlCpMod");
  56. lvlMpAdd = set.getFloat("lvlMpAdd");
  57. lvlMpMod = set.getFloat("lvlMpMod");
  58. }
  59. /**
  60. * Adds starter equipment
  61. * @param i
  62. */
  63. public void addItem(int itemId, int amount, boolean equipped)
  64. {
  65. _items.add(new PcTemplateItem(itemId, amount, equipped));
  66. }
  67. /**
  68. *
  69. * @return itemIds of all the starter equipment
  70. */
  71. public List<PcTemplateItem> getItems()
  72. {
  73. return _items;
  74. }
  75. public static final class PcTemplateItem
  76. {
  77. private final int _itemId;
  78. private final int _amount;
  79. private final boolean _equipped;
  80. /**
  81. * @param amount
  82. * @param itemId
  83. */
  84. public PcTemplateItem(int itemId, int amount, boolean equipped)
  85. {
  86. _itemId = itemId;
  87. _amount = amount;
  88. _equipped = equipped;
  89. }
  90. /**
  91. * @return Returns the itemId.
  92. */
  93. public int getItemId()
  94. {
  95. return _itemId;
  96. }
  97. /**
  98. * @return Returns the amount.
  99. */
  100. public int getAmount()
  101. {
  102. return _amount;
  103. }
  104. /**
  105. * @return Returns the if the item should be equipped after char creation.
  106. */
  107. public boolean isEquipped()
  108. {
  109. return _equipped;
  110. }
  111. }
  112. }