SubClass.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.base;
  16. /**
  17. * Character Sub-Class Definition
  18. * <BR>
  19. * Used to store key information about a character's sub-class.
  20. *
  21. * @author Tempy
  22. */
  23. public final class SubClass
  24. {
  25. private PlayerClass _class;
  26. private long _exp = Experience.LEVEL[40];
  27. private int _sp = 0;
  28. private byte _level = 40;
  29. private int _classIndex = 1;
  30. public SubClass(int classId, long exp, int sp, byte level, int classIndex)
  31. {
  32. _class = PlayerClass.values()[classId];
  33. _exp = exp;
  34. _sp = sp;
  35. _level = level;
  36. _classIndex = classIndex;
  37. }
  38. public SubClass(int classId, int classIndex)
  39. {
  40. // Used for defining a sub class using default values for XP, SP and player level.
  41. _class = PlayerClass.values()[classId];
  42. _classIndex = classIndex;
  43. }
  44. public SubClass()
  45. {
  46. // Used for specifying ALL attributes of a sub class directly,
  47. // using the preset default values.
  48. }
  49. public PlayerClass getClassDefinition()
  50. {
  51. return _class;
  52. }
  53. public int getClassId()
  54. {
  55. return _class.ordinal();
  56. }
  57. public long getExp()
  58. {
  59. return _exp;
  60. }
  61. public int getSp()
  62. {
  63. return _sp;
  64. }
  65. public byte getLevel()
  66. {
  67. return _level;
  68. }
  69. public int getClassIndex()
  70. {
  71. return _classIndex;
  72. }
  73. public void setClassId(int classId)
  74. {
  75. _class = PlayerClass.values()[classId];
  76. }
  77. public void setExp(long expValue)
  78. {
  79. if (expValue > (Experience.LEVEL[81] - 1))
  80. expValue = (Experience.LEVEL[81] - 1);
  81. _exp = expValue;
  82. }
  83. public void setSp(int spValue)
  84. {
  85. _sp = spValue;
  86. }
  87. public void setClassIndex(int classIndex)
  88. {
  89. _classIndex = classIndex;
  90. }
  91. public void setLevel(byte levelValue)
  92. {
  93. if (levelValue > 80)
  94. levelValue = 80;
  95. else if (levelValue < 40)
  96. levelValue = 40;
  97. _level = levelValue;
  98. }
  99. public void incLevel()
  100. {
  101. if (getLevel() == 80)
  102. return;
  103. _level++;
  104. setExp(Experience.LEVEL[getLevel()]);
  105. }
  106. public void decLevel()
  107. {
  108. if (getLevel() == 40)
  109. return;
  110. _level--;
  111. setExp(Experience.LEVEL[getLevel()]);
  112. }
  113. }