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