ClassId.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 com.l2jserver.gameserver.model.base;
  16. /**
  17. * This class defines all classes (ex : human fighter, darkFighter...) that a player can chose.<br>
  18. * Data:
  19. * <ul>
  20. * <li>id : The Identifier of the class</li>
  21. * <li>isMage : True if the class is a mage class</li>
  22. * <li>race : The race of this class</li>
  23. * <li>parent : The parent ClassId or null if this class is the root</li>
  24. * </ul>
  25. * @version $Revision: 1.4.4.4 $ $Date: 2005/03/27 15:29:33 $
  26. */
  27. public enum ClassId
  28. {
  29. fighter(0x00, false, Race.Human, null),
  30. warrior(0x01, false, Race.Human, fighter),
  31. gladiator(0x02, false, Race.Human, warrior),
  32. warlord(0x03, false, Race.Human, warrior),
  33. knight(0x04, false, Race.Human, fighter),
  34. paladin(0x05, false, Race.Human, knight),
  35. darkAvenger(0x06, false, Race.Human, knight),
  36. rogue(0x07, false, Race.Human, fighter),
  37. treasureHunter(0x08, false, Race.Human, rogue),
  38. hawkeye(0x09, false, Race.Human, rogue),
  39. mage(0x0a, true, Race.Human, null),
  40. wizard(0x0b, true, Race.Human, mage),
  41. sorceror(0x0c, true, Race.Human, wizard),
  42. necromancer(0x0d, true, Race.Human, wizard),
  43. warlock(0x0e, true, true, Race.Human, wizard),
  44. cleric(0x0f, true, Race.Human, mage),
  45. bishop(0x10, true, Race.Human, cleric),
  46. prophet(0x11, true, Race.Human, cleric),
  47. elvenFighter(0x12, false, Race.Elf, null),
  48. elvenKnight(0x13, false, Race.Elf, elvenFighter),
  49. templeKnight(0x14, false, Race.Elf, elvenKnight),
  50. swordSinger(0x15, false, Race.Elf, elvenKnight),
  51. elvenScout(0x16, false, Race.Elf, elvenFighter),
  52. plainsWalker(0x17, false, Race.Elf, elvenScout),
  53. silverRanger(0x18, false, Race.Elf, elvenScout),
  54. elvenMage(0x19, true, Race.Elf, null),
  55. elvenWizard(0x1a, true, Race.Elf, elvenMage),
  56. spellsinger(0x1b, true, Race.Elf, elvenWizard),
  57. elementalSummoner(0x1c, true, true, Race.Elf, elvenWizard),
  58. oracle(0x1d, true, Race.Elf, elvenMage),
  59. elder(0x1e, true, Race.Elf, oracle),
  60. darkFighter(0x1f, false, Race.DarkElf, null),
  61. palusKnight(0x20, false, Race.DarkElf, darkFighter),
  62. shillienKnight(0x21, false, Race.DarkElf, palusKnight),
  63. bladedancer(0x22, false, Race.DarkElf, palusKnight),
  64. assassin(0x23, false, Race.DarkElf, darkFighter),
  65. abyssWalker(0x24, false, Race.DarkElf, assassin),
  66. phantomRanger(0x25, false, Race.DarkElf, assassin),
  67. darkMage(0x26, true, Race.DarkElf, null),
  68. darkWizard(0x27, true, Race.DarkElf, darkMage),
  69. spellhowler(0x28, true, Race.DarkElf, darkWizard),
  70. phantomSummoner(0x29, true, true, Race.DarkElf, darkWizard),
  71. shillienOracle(0x2a, true, Race.DarkElf, darkMage),
  72. shillenElder(0x2b, true, Race.DarkElf, shillienOracle),
  73. orcFighter(0x2c, false, Race.Orc, null),
  74. orcRaider(0x2d, false, Race.Orc, orcFighter),
  75. destroyer(0x2e, false, Race.Orc, orcRaider),
  76. orcMonk(0x2f, false, Race.Orc, orcFighter),
  77. tyrant(0x30, false, Race.Orc, orcMonk),
  78. orcMage(0x31, false, Race.Orc, null),
  79. orcShaman(0x32, true, Race.Orc, orcMage),
  80. overlord(0x33, true, Race.Orc, orcShaman),
  81. warcryer(0x34, true, Race.Orc, orcShaman),
  82. dwarvenFighter(0x35, false, Race.Dwarf, null),
  83. scavenger(0x36, false, Race.Dwarf, dwarvenFighter),
  84. bountyHunter(0x37, false, Race.Dwarf, scavenger),
  85. artisan(0x38, false, Race.Dwarf, dwarvenFighter),
  86. warsmith(0x39, false, Race.Dwarf, artisan),
  87. /*
  88. * Dummy Entries (id's already in decimal format) btw FU NCSoft for the amount of work you put me through to do this!! <START>
  89. */
  90. dummyEntry1(58, false, null, null),
  91. dummyEntry2(59, false, null, null),
  92. dummyEntry3(60, false, null, null),
  93. dummyEntry4(61, false, null, null),
  94. dummyEntry5(62, false, null, null),
  95. dummyEntry6(63, false, null, null),
  96. dummyEntry7(64, false, null, null),
  97. dummyEntry8(65, false, null, null),
  98. dummyEntry9(66, false, null, null),
  99. dummyEntry10(67, false, null, null),
  100. dummyEntry11(68, false, null, null),
  101. dummyEntry12(69, false, null, null),
  102. dummyEntry13(70, false, null, null),
  103. dummyEntry14(71, false, null, null),
  104. dummyEntry15(72, false, null, null),
  105. dummyEntry16(73, false, null, null),
  106. dummyEntry17(74, false, null, null),
  107. dummyEntry18(75, false, null, null),
  108. dummyEntry19(76, false, null, null),
  109. dummyEntry20(77, false, null, null),
  110. dummyEntry21(78, false, null, null),
  111. dummyEntry22(79, false, null, null),
  112. dummyEntry23(80, false, null, null),
  113. dummyEntry24(81, false, null, null),
  114. dummyEntry25(82, false, null, null),
  115. dummyEntry26(83, false, null, null),
  116. dummyEntry27(84, false, null, null),
  117. dummyEntry28(85, false, null, null),
  118. dummyEntry29(86, false, null, null),
  119. dummyEntry30(87, false, null, null),
  120. /*
  121. * <END> Of Dummy entries
  122. */
  123. /*
  124. * Now the bad boys! new class ids :)) (3rd classes)
  125. */
  126. duelist(0x58, false, Race.Human, gladiator),
  127. dreadnought(0x59, false, Race.Human, warlord),
  128. phoenixKnight(0x5a, false, Race.Human, paladin),
  129. hellKnight(0x5b, false, Race.Human, darkAvenger),
  130. sagittarius(0x5c, false, Race.Human, hawkeye),
  131. adventurer(0x5d, false, Race.Human, treasureHunter),
  132. archmage(0x5e, true, Race.Human, sorceror),
  133. soultaker(0x5f, true, Race.Human, necromancer),
  134. arcanaLord(0x60, true, true, Race.Human, warlock),
  135. cardinal(0x61, true, Race.Human, bishop),
  136. hierophant(0x62, true, Race.Human, prophet),
  137. evaTemplar(0x63, false, Race.Elf, templeKnight),
  138. swordMuse(0x64, false, Race.Elf, swordSinger),
  139. windRider(0x65, false, Race.Elf, plainsWalker),
  140. moonlightSentinel(0x66, false, Race.Elf, silverRanger),
  141. mysticMuse(0x67, true, Race.Elf, spellsinger),
  142. elementalMaster(0x68, true, true, Race.Elf, elementalSummoner),
  143. evaSaint(0x69, true, Race.Elf, elder),
  144. shillienTemplar(0x6a, false, Race.DarkElf, shillienKnight),
  145. spectralDancer(0x6b, false, Race.DarkElf, bladedancer),
  146. ghostHunter(0x6c, false, Race.DarkElf, abyssWalker),
  147. ghostSentinel(0x6d, false, Race.DarkElf, phantomRanger),
  148. stormScreamer(0x6e, true, Race.DarkElf, spellhowler),
  149. spectralMaster(0x6f, true, true, Race.DarkElf, phantomSummoner),
  150. shillienSaint(0x70, true, Race.DarkElf, shillenElder),
  151. titan(0x71, false, Race.Orc, destroyer),
  152. grandKhavatari(0x72, false, Race.Orc, tyrant),
  153. dominator(0x73, true, Race.Orc, overlord),
  154. doomcryer(0x74, true, Race.Orc, warcryer),
  155. fortuneSeeker(0x75, false, Race.Dwarf, bountyHunter),
  156. maestro(0x76, false, Race.Dwarf, warsmith),
  157. dummyEntry31(0x77, false, null, null),
  158. dummyEntry32(0x78, false, null, null),
  159. dummyEntry33(0x79, false, null, null),
  160. dummyEntry34(0x7a, false, null, null),
  161. maleSoldier(0x7b, false, Race.Kamael, null),
  162. femaleSoldier(0x7C, false, Race.Kamael, null),
  163. trooper(0x7D, false, Race.Kamael, maleSoldier),
  164. warder(0x7E, false, Race.Kamael, femaleSoldier),
  165. berserker(0x7F, false, Race.Kamael, trooper),
  166. maleSoulbreaker(0x80, false, Race.Kamael, trooper),
  167. femaleSoulbreaker(0x81, false, Race.Kamael, warder),
  168. arbalester(0x82, false, Race.Kamael, warder),
  169. doombringer(0x83, false, Race.Kamael, berserker),
  170. maleSoulhound(0x84, false, Race.Kamael, maleSoulbreaker),
  171. femaleSoulhound(0x85, false, Race.Kamael, femaleSoulbreaker),
  172. trickster(0x86, false, Race.Kamael, arbalester),
  173. inspector(0x87, false, Race.Kamael, warder), // DS: yes, both male/female inspectors use skills from warder
  174. judicator(0x88, false, Race.Kamael, inspector);
  175. /** The Identifier of the Class */
  176. private final int _id;
  177. /** True if the class is a mage class */
  178. private final boolean _isMage;
  179. /** True if the class is a summoner class */
  180. private final boolean _isSummoner;
  181. /** The Race object of the class */
  182. private final Race _race;
  183. /** The parent ClassId or null if this class is a root */
  184. private final ClassId _parent;
  185. /**
  186. * Class constructor.
  187. * @param pId the class Id.
  188. * @param pIsMage {code true} if the class is mage class.
  189. * @param pRace the race related to the class.
  190. * @param pParent the parent class Id.
  191. */
  192. private ClassId(int pId, boolean pIsMage, Race pRace, ClassId pParent)
  193. {
  194. _id = pId;
  195. _isMage = pIsMage;
  196. _isSummoner = false;
  197. _race = pRace;
  198. _parent = pParent;
  199. }
  200. /**
  201. * Class constructor.
  202. * @param pId the class Id.
  203. * @param pIsMage {code true} if the class is mage class.
  204. * @param pIsSummoner {code true} if the class is summoner class.
  205. * @param pRace the race related to the class.
  206. * @param pParent the parent class Id.
  207. */
  208. private ClassId(int pId, boolean pIsMage, boolean pIsSummoner, Race pRace, ClassId pParent)
  209. {
  210. _id = pId;
  211. _isMage = pIsMage;
  212. _isSummoner = pIsSummoner;
  213. _race = pRace;
  214. _parent = pParent;
  215. }
  216. /**
  217. * @return the Id of the Class.
  218. */
  219. public final int getId()
  220. {
  221. return _id;
  222. }
  223. /**
  224. * @return {code true} if the class is a mage class.
  225. */
  226. public final boolean isMage()
  227. {
  228. return _isMage;
  229. }
  230. /**
  231. * @return {code true} if the class is a summoner class.
  232. */
  233. public final boolean isSummoner()
  234. {
  235. return _isSummoner;
  236. }
  237. /**
  238. * @return the Race object of the class.
  239. */
  240. public final Race getRace()
  241. {
  242. return _race;
  243. }
  244. /**
  245. * @param cid the parent ClassId to check.
  246. * @return {code true} if this Class is a child of the selected ClassId.
  247. */
  248. public final boolean childOf(ClassId cid)
  249. {
  250. if (_parent == null)
  251. {
  252. return false;
  253. }
  254. if (_parent == cid)
  255. {
  256. return true;
  257. }
  258. return _parent.childOf(cid);
  259. }
  260. /**
  261. * @param cid the parent ClassId to check.
  262. * @return {code true} if this Class is equal to the selected ClassId or a child of the selected ClassId.
  263. */
  264. public final boolean equalsOrChildOf(ClassId cid)
  265. {
  266. return (this == cid) || childOf(cid);
  267. }
  268. /**
  269. * @return the child level of this Class (0=root, 1=child leve 1...)
  270. */
  271. public final int level()
  272. {
  273. if (_parent == null)
  274. {
  275. return 0;
  276. }
  277. return 1 + _parent.level();
  278. }
  279. /**
  280. * @return its parent Class Id
  281. */
  282. public final ClassId getParent()
  283. {
  284. return _parent;
  285. }
  286. public static ClassId getClassId(int cId)
  287. {
  288. try
  289. {
  290. return ClassId.values()[cId];
  291. }
  292. catch (Exception e)
  293. {
  294. return null;
  295. }
  296. }
  297. }