ClassId.java 11 KB

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