EntityIdentifiers.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. /*
  2. * EntityIdentifiers.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "NumericConstants.h"
  12. #include "IdentifierBase.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class Artifact;
  15. class ArtifactService;
  16. class Creature;
  17. class CreatureService;
  18. namespace spells
  19. {
  20. class Spell;
  21. class Service;
  22. }
  23. class CArtifact;
  24. class CArtifactInstance;
  25. class CCreature;
  26. class CHero;
  27. class CSpell;
  28. class CSkill;
  29. class CGameInfoCallback;
  30. class CNonConstInfoCallback;
  31. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. // Note: use template to force different type, blocking any Identifier<A> <=> Identifier<B> comparisons
  33. template<typename FinalClass>
  34. class Identifier : public IdentifierBase
  35. {
  36. using BaseClass = IdentifierBase;
  37. public:
  38. constexpr Identifier()
  39. {}
  40. explicit constexpr Identifier(int32_t value):
  41. IdentifierBase(value)
  42. {}
  43. constexpr bool operator == (const Identifier & b) const { return BaseClass::num == b.num; }
  44. constexpr bool operator <= (const Identifier & b) const { return BaseClass::num <= b.num; }
  45. constexpr bool operator >= (const Identifier & b) const { return BaseClass::num >= b.num; }
  46. constexpr bool operator != (const Identifier & b) const { return BaseClass::num != b.num; }
  47. constexpr bool operator < (const Identifier & b) const { return BaseClass::num < b.num; }
  48. constexpr bool operator > (const Identifier & b) const { return BaseClass::num > b.num; }
  49. constexpr FinalClass & operator++()
  50. {
  51. ++BaseClass::num;
  52. return static_cast<FinalClass&>(*this);
  53. }
  54. constexpr FinalClass & operator--()
  55. {
  56. --BaseClass::num;
  57. return static_cast<FinalClass&>(*this);
  58. }
  59. constexpr FinalClass operator--(int)
  60. {
  61. FinalClass ret(num);
  62. --BaseClass::num;
  63. return ret;
  64. }
  65. constexpr FinalClass operator++(int)
  66. {
  67. FinalClass ret(num);
  68. ++BaseClass::num;
  69. return ret;
  70. }
  71. };
  72. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  73. template<typename FinalClass, typename BaseClass>
  74. class IdentifierWithEnum : public BaseClass
  75. {
  76. using EnumType = typename BaseClass::Type;
  77. static_assert(std::is_same_v<std::underlying_type_t<EnumType>, int32_t>, "Entity Identifier must use int32_t");
  78. public:
  79. constexpr EnumType toEnum() const
  80. {
  81. return static_cast<EnumType>(BaseClass::num);
  82. }
  83. constexpr IdentifierWithEnum(const EnumType & enumValue)
  84. {
  85. BaseClass::num = static_cast<int32_t>(enumValue);
  86. }
  87. constexpr IdentifierWithEnum(int32_t _num = -1)
  88. {
  89. BaseClass::num = _num;
  90. }
  91. constexpr bool operator == (const EnumType & b) const { return BaseClass::num == static_cast<int32_t>(b); }
  92. constexpr bool operator <= (const EnumType & b) const { return BaseClass::num <= static_cast<int32_t>(b); }
  93. constexpr bool operator >= (const EnumType & b) const { return BaseClass::num >= static_cast<int32_t>(b); }
  94. constexpr bool operator != (const EnumType & b) const { return BaseClass::num != static_cast<int32_t>(b); }
  95. constexpr bool operator < (const EnumType & b) const { return BaseClass::num < static_cast<int32_t>(b); }
  96. constexpr bool operator > (const EnumType & b) const { return BaseClass::num > static_cast<int32_t>(b); }
  97. constexpr bool operator == (const IdentifierWithEnum & b) const { return BaseClass::num == b.num; }
  98. constexpr bool operator <= (const IdentifierWithEnum & b) const { return BaseClass::num <= b.num; }
  99. constexpr bool operator >= (const IdentifierWithEnum & b) const { return BaseClass::num >= b.num; }
  100. constexpr bool operator != (const IdentifierWithEnum & b) const { return BaseClass::num != b.num; }
  101. constexpr bool operator < (const IdentifierWithEnum & b) const { return BaseClass::num < b.num; }
  102. constexpr bool operator > (const IdentifierWithEnum & b) const { return BaseClass::num > b.num; }
  103. constexpr FinalClass & operator++()
  104. {
  105. ++BaseClass::num;
  106. return static_cast<FinalClass&>(*this);
  107. }
  108. constexpr FinalClass operator++(int)
  109. {
  110. FinalClass ret(BaseClass::num);
  111. ++BaseClass::num;
  112. return ret;
  113. }
  114. };
  115. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  116. class ArtifactInstanceID : public Identifier<ArtifactInstanceID>
  117. {
  118. public:
  119. using Identifier<ArtifactInstanceID>::Identifier;
  120. };
  121. class QueryID : public Identifier<QueryID>
  122. {
  123. public:
  124. using Identifier<QueryID>::Identifier;
  125. DLL_LINKAGE static const QueryID NONE;
  126. DLL_LINKAGE static const QueryID CLIENT;
  127. };
  128. class BattleID : public Identifier<BattleID>
  129. {
  130. public:
  131. using Identifier<BattleID>::Identifier;
  132. DLL_LINKAGE static const BattleID NONE;
  133. };
  134. class DLL_LINKAGE ObjectInstanceID : public Identifier<ObjectInstanceID>
  135. {
  136. public:
  137. using Identifier<ObjectInstanceID>::Identifier;
  138. static const ObjectInstanceID NONE;
  139. static si32 decode(const std::string & identifier);
  140. static std::string encode(const si32 index);
  141. };
  142. class HeroClassID : public Identifier<HeroClassID>
  143. {
  144. public:
  145. using Identifier<HeroClassID>::Identifier;
  146. ///json serialization helpers
  147. DLL_LINKAGE static si32 decode(const std::string & identifier);
  148. DLL_LINKAGE static std::string encode(const si32 index);
  149. static std::string entityType();
  150. };
  151. class HeroTypeID : public Identifier<HeroTypeID>
  152. {
  153. public:
  154. using Identifier<HeroTypeID>::Identifier;
  155. ///json serialization helpers
  156. DLL_LINKAGE static si32 decode(const std::string & identifier);
  157. DLL_LINKAGE static std::string encode(const si32 index);
  158. static std::string entityType();
  159. DLL_LINKAGE static const HeroTypeID NONE;
  160. DLL_LINKAGE static const HeroTypeID RANDOM;
  161. bool isValid() const
  162. {
  163. return getNum() >= 0;
  164. }
  165. };
  166. class SlotID : public Identifier<SlotID>
  167. {
  168. public:
  169. using Identifier<SlotID>::Identifier;
  170. DLL_LINKAGE static const SlotID COMMANDER_SLOT_PLACEHOLDER;
  171. DLL_LINKAGE static const SlotID SUMMONED_SLOT_PLACEHOLDER; ///<for all summoned creatures, only during battle
  172. DLL_LINKAGE static const SlotID WAR_MACHINES_SLOT; ///<for all war machines during battle
  173. DLL_LINKAGE static const SlotID ARROW_TOWERS_SLOT; ///<for all arrow towers during battle
  174. bool validSlot() const
  175. {
  176. return getNum() >= 0 && getNum() < GameConstants::ARMY_SIZE;
  177. }
  178. };
  179. class DLL_LINKAGE PlayerColor : public Identifier<PlayerColor>
  180. {
  181. public:
  182. using Identifier<PlayerColor>::Identifier;
  183. enum EPlayerColor
  184. {
  185. PLAYER_LIMIT_I = 8,
  186. };
  187. static const PlayerColor SPECTATOR; //252
  188. static const PlayerColor CANNOT_DETERMINE; //253
  189. static const PlayerColor UNFLAGGABLE; //254 - neutral objects (pandora, banks)
  190. static const PlayerColor NEUTRAL; //255
  191. static const PlayerColor PLAYER_LIMIT; //player limit per map
  192. bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
  193. bool isSpectator() const;
  194. std::string toString() const;
  195. static si32 decode(const std::string& identifier);
  196. static std::string encode(const si32 index);
  197. static std::string entityType();
  198. };
  199. class TeamID : public Identifier<TeamID>
  200. {
  201. public:
  202. using Identifier<TeamID>::Identifier;
  203. DLL_LINKAGE static const TeamID NO_TEAM;
  204. };
  205. class TeleportChannelID : public Identifier<TeleportChannelID>
  206. {
  207. public:
  208. using Identifier<TeleportChannelID>::Identifier;
  209. };
  210. class SecondarySkillBase : public IdentifierBase
  211. {
  212. public:
  213. enum Type : int32_t
  214. {
  215. NONE = -1,
  216. PATHFINDING = 0,
  217. ARCHERY,
  218. LOGISTICS,
  219. SCOUTING,
  220. DIPLOMACY,
  221. NAVIGATION,
  222. LEADERSHIP,
  223. WISDOM,
  224. MYSTICISM,
  225. LUCK,
  226. BALLISTICS,
  227. EAGLE_EYE,
  228. NECROMANCY,
  229. ESTATES,
  230. FIRE_MAGIC,
  231. AIR_MAGIC,
  232. WATER_MAGIC,
  233. EARTH_MAGIC,
  234. SCHOLAR,
  235. TACTICS,
  236. ARTILLERY,
  237. LEARNING,
  238. OFFENCE,
  239. ARMORER,
  240. INTELLIGENCE,
  241. SORCERY,
  242. RESISTANCE,
  243. FIRST_AID,
  244. SKILL_SIZE
  245. };
  246. static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills");
  247. };
  248. class SecondarySkill : public IdentifierWithEnum<SecondarySkill, SecondarySkillBase>
  249. {
  250. public:
  251. using IdentifierWithEnum<SecondarySkill, SecondarySkillBase>::IdentifierWithEnum;
  252. static std::string entityType();
  253. static si32 decode(const std::string& identifier);
  254. static std::string encode(const si32 index);
  255. };
  256. class DLL_LINKAGE PrimarySkill : public Identifier<PrimarySkill>
  257. {
  258. public:
  259. using Identifier<PrimarySkill>::Identifier;
  260. static const PrimarySkill NONE;
  261. static const PrimarySkill ATTACK;
  262. static const PrimarySkill DEFENSE;
  263. static const PrimarySkill SPELL_POWER;
  264. static const PrimarySkill KNOWLEDGE;
  265. static const PrimarySkill BEGIN;
  266. static const PrimarySkill END;
  267. static const PrimarySkill EXPERIENCE;
  268. static si32 decode(const std::string& identifier);
  269. static std::string encode(const si32 index);
  270. static std::string entityType();
  271. };
  272. class DLL_LINKAGE FactionID : public Identifier<FactionID>
  273. {
  274. public:
  275. using Identifier<FactionID>::Identifier;
  276. static const FactionID NONE;
  277. static const FactionID DEFAULT;
  278. static const FactionID RANDOM;
  279. static const FactionID ANY;
  280. static const FactionID CASTLE;
  281. static const FactionID RAMPART;
  282. static const FactionID TOWER;
  283. static const FactionID INFERNO;
  284. static const FactionID NECROPOLIS;
  285. static const FactionID DUNGEON;
  286. static const FactionID STRONGHOLD;
  287. static const FactionID FORTRESS;
  288. static const FactionID CONFLUX;
  289. static const FactionID NEUTRAL;
  290. static si32 decode(const std::string& identifier);
  291. static std::string encode(const si32 index);
  292. static std::string entityType();
  293. bool isValid() const
  294. {
  295. return getNum() >= 0;
  296. }
  297. };
  298. class BuildingIDBase : public IdentifierBase
  299. {
  300. public:
  301. //Quite useful as long as most of building mechanics hardcoded
  302. // NOTE: all building with completely configurable mechanics will be removed from list
  303. enum Type
  304. {
  305. DEFAULT = -50,
  306. HORDE_PLACEHOLDER7 = -36,
  307. HORDE_PLACEHOLDER6 = -35,
  308. HORDE_PLACEHOLDER5 = -34,
  309. HORDE_PLACEHOLDER4 = -33,
  310. HORDE_PLACEHOLDER3 = -32,
  311. HORDE_PLACEHOLDER2 = -31,
  312. HORDE_PLACEHOLDER1 = -30,
  313. NONE = -1,
  314. FIRST_REGULAR_ID = 0,
  315. MAGES_GUILD_1 = 0, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
  316. TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
  317. VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
  318. RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
  319. SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
  320. HORDE_2_UPGR, GRAIL, EXTRA_TOWN_HALL, EXTRA_CITY_HALL, EXTRA_CAPITOL,
  321. DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LAST=36,
  322. DWELL_UP_FIRST=37, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
  323. DWELL_LVL_6_UP, DWELL_UP_LAST=43,
  324. DWELL_LVL_1 = DWELL_FIRST,
  325. DWELL_LVL_7 = DWELL_LAST,
  326. DWELL_LVL_1_UP = DWELL_UP_FIRST,
  327. DWELL_LVL_7_UP = DWELL_UP_LAST,
  328. DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
  329. // //Special buildings for towns.
  330. CASTLE_GATE = SPECIAL_3, //Inferno
  331. FREELANCERS_GUILD = SPECIAL_2, //Stronghold
  332. ARTIFACT_MERCHANT = SPECIAL_1,
  333. };
  334. bool IsSpecialOrGrail() const
  335. {
  336. return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
  337. }
  338. };
  339. class BuildingID : public IdentifierWithEnum<BuildingID, BuildingIDBase>
  340. {
  341. public:
  342. using IdentifierWithEnum<BuildingID, BuildingIDBase>::IdentifierWithEnum;
  343. DLL_LINKAGE static si32 decode(const std::string & identifier);
  344. DLL_LINKAGE static std::string encode(const si32 index);
  345. static std::string entityType();
  346. };
  347. class ObjBase : public IdentifierBase
  348. {
  349. public:
  350. enum Type
  351. {
  352. NO_OBJ = -1,
  353. ALTAR_OF_SACRIFICE [[deprecated]] = 2,
  354. ANCHOR_POINT = 3,
  355. ARENA = 4,
  356. ARTIFACT = 5,
  357. PANDORAS_BOX = 6,
  358. BLACK_MARKET [[deprecated]] = 7,
  359. BOAT = 8,
  360. BORDERGUARD = 9,
  361. KEYMASTER = 10,
  362. BUOY = 11,
  363. CAMPFIRE = 12,
  364. CARTOGRAPHER = 13,
  365. SWAN_POND = 14,
  366. COVER_OF_DARKNESS = 15,
  367. CREATURE_BANK = 16,
  368. CREATURE_GENERATOR1 = 17,
  369. CREATURE_GENERATOR2 = 18,
  370. CREATURE_GENERATOR3 = 19,
  371. CREATURE_GENERATOR4 = 20,
  372. CURSED_GROUND1 = 21,
  373. CORPSE = 22,
  374. MARLETTO_TOWER = 23,
  375. DERELICT_SHIP = 24,
  376. DRAGON_UTOPIA = 25,
  377. EVENT = 26,
  378. EYE_OF_MAGI = 27,
  379. FAERIE_RING = 28,
  380. FLOTSAM = 29,
  381. FOUNTAIN_OF_FORTUNE = 30,
  382. FOUNTAIN_OF_YOUTH = 31,
  383. GARDEN_OF_REVELATION = 32,
  384. GARRISON = 33,
  385. HERO = 34,
  386. HILL_FORT = 35,
  387. GRAIL = 36,
  388. HUT_OF_MAGI = 37,
  389. IDOL_OF_FORTUNE = 38,
  390. LEAN_TO = 39,
  391. LIBRARY_OF_ENLIGHTENMENT = 41,
  392. LIGHTHOUSE = 42,
  393. MONOLITH_ONE_WAY_ENTRANCE = 43,
  394. MONOLITH_ONE_WAY_EXIT = 44,
  395. MONOLITH_TWO_WAY = 45,
  396. MAGIC_PLAINS1 = 46,
  397. SCHOOL_OF_MAGIC = 47,
  398. MAGIC_SPRING = 48,
  399. MAGIC_WELL = 49,
  400. MARKET_OF_TIME = 50,
  401. MERCENARY_CAMP = 51,
  402. MERMAID = 52,
  403. MINE = 53,
  404. MONSTER = 54,
  405. MYSTICAL_GARDEN = 55,
  406. OASIS = 56,
  407. OBELISK = 57,
  408. REDWOOD_OBSERVATORY = 58,
  409. OCEAN_BOTTLE = 59,
  410. PILLAR_OF_FIRE = 60,
  411. STAR_AXIS = 61,
  412. PRISON = 62,
  413. PYRAMID = 63,//subtype 0
  414. WOG_OBJECT = 63,//subtype > 0
  415. RALLY_FLAG = 64,
  416. RANDOM_ART = 65,
  417. RANDOM_TREASURE_ART = 66,
  418. RANDOM_MINOR_ART = 67,
  419. RANDOM_MAJOR_ART = 68,
  420. RANDOM_RELIC_ART = 69,
  421. RANDOM_HERO = 70,
  422. RANDOM_MONSTER = 71,
  423. RANDOM_MONSTER_L1 = 72,
  424. RANDOM_MONSTER_L2 = 73,
  425. RANDOM_MONSTER_L3 = 74,
  426. RANDOM_MONSTER_L4 = 75,
  427. RANDOM_RESOURCE = 76,
  428. RANDOM_TOWN = 77,
  429. REFUGEE_CAMP = 78,
  430. RESOURCE = 79,
  431. SANCTUARY = 80,
  432. SCHOLAR = 81,
  433. SEA_CHEST = 82,
  434. SEER_HUT = 83,
  435. CRYPT = 84,
  436. SHIPWRECK = 85,
  437. SHIPWRECK_SURVIVOR = 86,
  438. SHIPYARD = 87,
  439. SHRINE_OF_MAGIC_INCANTATION = 88,
  440. SHRINE_OF_MAGIC_GESTURE = 89,
  441. SHRINE_OF_MAGIC_THOUGHT = 90,
  442. SIGN = 91,
  443. SIRENS = 92,
  444. SPELL_SCROLL = 93,
  445. STABLES = 94,
  446. TAVERN = 95,
  447. TEMPLE = 96,
  448. DEN_OF_THIEVES = 97,
  449. TOWN = 98,
  450. TRADING_POST [[deprecated]] = 99,
  451. LEARNING_STONE = 100,
  452. TREASURE_CHEST = 101,
  453. TREE_OF_KNOWLEDGE = 102,
  454. SUBTERRANEAN_GATE = 103,
  455. UNIVERSITY [[deprecated]] = 104,
  456. WAGON = 105,
  457. WAR_MACHINE_FACTORY = 106,
  458. SCHOOL_OF_WAR = 107,
  459. WARRIORS_TOMB = 108,
  460. WATER_WHEEL = 109,
  461. WATERING_HOLE = 110,
  462. WHIRLPOOL = 111,
  463. WINDMILL = 112,
  464. WITCH_HUT = 113,
  465. HOLE = 124,
  466. RANDOM_MONSTER_L5 = 162,
  467. RANDOM_MONSTER_L6 = 163,
  468. RANDOM_MONSTER_L7 = 164,
  469. BORDER_GATE = 212,
  470. FREELANCERS_GUILD [[deprecated]] = 213,
  471. HERO_PLACEHOLDER = 214,
  472. QUEST_GUARD = 215,
  473. RANDOM_DWELLING = 216,
  474. RANDOM_DWELLING_LVL = 217, //subtype = creature level
  475. RANDOM_DWELLING_FACTION = 218, //subtype = faction
  476. GARRISON2 = 219,
  477. ABANDONED_MINE = 220,
  478. TRADING_POST_SNOW [[deprecated]] = 221,
  479. CLOVER_FIELD = 222,
  480. CURSED_GROUND2 = 223,
  481. EVIL_FOG = 224,
  482. FAVORABLE_WINDS = 225,
  483. FIERY_FIELDS = 226,
  484. HOLY_GROUNDS = 227,
  485. LUCID_POOLS = 228,
  486. MAGIC_CLOUDS = 229,
  487. MAGIC_PLAINS2 = 230,
  488. ROCKLANDS = 231,
  489. };
  490. };
  491. class DLL_LINKAGE Obj : public IdentifierWithEnum<Obj, ObjBase>
  492. {
  493. public:
  494. using IdentifierWithEnum<Obj, ObjBase>::IdentifierWithEnum;
  495. static std::string encode(int32_t index);
  496. static si32 decode(const std::string & identifier);
  497. };
  498. class DLL_LINKAGE RoadId : public Identifier<RoadId>
  499. {
  500. public:
  501. using Identifier<RoadId>::Identifier;
  502. static const RoadId NO_ROAD;
  503. static const RoadId DIRT_ROAD;
  504. static const RoadId GRAVEL_ROAD;
  505. static const RoadId COBBLESTONE_ROAD;
  506. };
  507. class DLL_LINKAGE RiverId : public Identifier<RiverId>
  508. {
  509. public:
  510. using Identifier<RiverId>::Identifier;
  511. static const RiverId NO_RIVER;
  512. static const RiverId WATER_RIVER;
  513. static const RiverId ICY_RIVER;
  514. static const RiverId MUD_RIVER;
  515. static const RiverId LAVA_RIVER;
  516. };
  517. class DLL_LINKAGE EPathfindingLayerBase : public IdentifierBase
  518. {
  519. public:
  520. enum Type : int32_t
  521. {
  522. LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS, WRONG, AUTO
  523. };
  524. };
  525. class EPathfindingLayer : public IdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>
  526. {
  527. public:
  528. using IdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>::IdentifierWithEnum;
  529. };
  530. class ArtifactPositionBase : public IdentifierBase
  531. {
  532. public:
  533. enum Type
  534. {
  535. TRANSITION_POS = -3,
  536. FIRST_AVAILABLE = -2,
  537. PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
  538. // Hero
  539. HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
  540. RIGHT_RING, LEFT_RING, FEET, //8
  541. MISC1, MISC2, MISC3, MISC4, //12
  542. MACH1, MACH2, MACH3, MACH4, //16
  543. SPELLBOOK, MISC5, //18
  544. BACKPACK_START = 19,
  545. // Creatures
  546. CREATURE_SLOT = 0,
  547. // Commander
  548. COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6
  549. };
  550. static_assert(MISC5 < BACKPACK_START, "incorrect number of artifact slots");
  551. DLL_LINKAGE static si32 decode(const std::string & identifier);
  552. DLL_LINKAGE static std::string encode(const si32 index);
  553. };
  554. class ArtifactPosition : public IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>
  555. {
  556. public:
  557. using IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>::IdentifierWithEnum;
  558. };
  559. class ArtifactIDBase : public IdentifierBase
  560. {
  561. public:
  562. enum Type
  563. {
  564. NONE = -1,
  565. SPELLBOOK = 0,
  566. SPELL_SCROLL = 1,
  567. GRAIL = 2,
  568. CATAPULT = 3,
  569. BALLISTA = 4,
  570. AMMO_CART = 5,
  571. FIRST_AID_TENT = 6,
  572. VIAL_OF_DRAGON_BLOOD = 127,
  573. ARMAGEDDONS_BLADE = 128,
  574. TITANS_THUNDER = 135,
  575. ART_SELECTION = 144,
  576. ART_LOCK = 145, // FIXME: We must get rid of this one since it's conflict with artifact from mods. See issue 2455
  577. };
  578. DLL_LINKAGE const CArtifact * toArtifact() const;
  579. DLL_LINKAGE const Artifact * toArtifact(const ArtifactService * service) const;
  580. };
  581. class ArtifactID : public IdentifierWithEnum<ArtifactID, ArtifactIDBase>
  582. {
  583. public:
  584. using IdentifierWithEnum<ArtifactID, ArtifactIDBase>::IdentifierWithEnum;
  585. ///json serialization helpers
  586. DLL_LINKAGE static si32 decode(const std::string & identifier);
  587. DLL_LINKAGE static std::string encode(const si32 index);
  588. static std::string entityType();
  589. };
  590. class CreatureIDBase : public IdentifierBase
  591. {
  592. public:
  593. enum Type
  594. {
  595. NONE = -1,
  596. ARCHER = 2, // for debug / fallback
  597. IMP = 42, // for Deity of Fire
  598. SKELETON = 56, // for Skeleton Transformer
  599. BONE_DRAGON = 68, // for Skeleton Transformer
  600. TROGLODYTES = 70, // for Abandoned Mine
  601. MEDUSA = 76, // for Siege UI workaround
  602. HYDRA = 110, // for Skeleton Transformer
  603. CHAOS_HYDRA = 111, // for Skeleton Transformer
  604. AIR_ELEMENTAL = 112, // for tests
  605. FIRE_ELEMENTAL = 114, // for tests
  606. PSYCHIC_ELEMENTAL = 120, // for hardcoded ability
  607. MAGIC_ELEMENTAL = 121, // for hardcoded ability
  608. CATAPULT = 145,
  609. BALLISTA = 146,
  610. FIRST_AID_TENT = 147,
  611. AMMO_CART = 148,
  612. ARROW_TOWERS = 149
  613. };
  614. DLL_LINKAGE const CCreature * toCreature() const;
  615. DLL_LINKAGE const Creature * toCreature(const CreatureService * creatures) const;
  616. };
  617. class DLL_LINKAGE CreatureID : public IdentifierWithEnum<CreatureID, CreatureIDBase>
  618. {
  619. public:
  620. using IdentifierWithEnum<CreatureID, CreatureIDBase>::IdentifierWithEnum;
  621. ///json serialization helpers
  622. static si32 decode(const std::string & identifier);
  623. static std::string encode(const si32 index);
  624. static std::string entityType();
  625. };
  626. class DLL_LINKAGE SpellIDBase : public IdentifierBase
  627. {
  628. public:
  629. enum Type
  630. {
  631. // Special ID's
  632. SPELLBOOK_PRESET = -3,
  633. PRESET = -2,
  634. NONE = -1,
  635. // Adventure map spells
  636. SUMMON_BOAT = 0,
  637. SCUTTLE_BOAT = 1,
  638. VISIONS = 2,
  639. VIEW_EARTH = 3,
  640. DISGUISE = 4,
  641. VIEW_AIR = 5,
  642. FLY = 6,
  643. WATER_WALK = 7,
  644. DIMENSION_DOOR = 8,
  645. TOWN_PORTAL = 9,
  646. // Combar spells
  647. QUICKSAND = 10,
  648. LAND_MINE = 11,
  649. FORCE_FIELD = 12,
  650. FIRE_WALL = 13,
  651. EARTHQUAKE = 14,
  652. MAGIC_ARROW = 15,
  653. ICE_BOLT = 16,
  654. LIGHTNING_BOLT = 17,
  655. IMPLOSION = 18,
  656. CHAIN_LIGHTNING = 19,
  657. FROST_RING = 20,
  658. FIREBALL = 21,
  659. INFERNO = 22,
  660. METEOR_SHOWER = 23,
  661. DEATH_RIPPLE = 24,
  662. DESTROY_UNDEAD = 25,
  663. ARMAGEDDON = 26,
  664. SHIELD = 27,
  665. AIR_SHIELD = 28,
  666. FIRE_SHIELD = 29,
  667. PROTECTION_FROM_AIR = 30,
  668. PROTECTION_FROM_FIRE = 31,
  669. PROTECTION_FROM_WATER = 32,
  670. PROTECTION_FROM_EARTH = 33,
  671. ANTI_MAGIC = 34,
  672. DISPEL = 35,
  673. MAGIC_MIRROR = 36,
  674. CURE = 37,
  675. RESURRECTION = 38,
  676. ANIMATE_DEAD = 39,
  677. SACRIFICE = 40,
  678. BLESS = 41,
  679. CURSE = 42,
  680. BLOODLUST = 43,
  681. PRECISION = 44,
  682. WEAKNESS = 45,
  683. STONE_SKIN = 46,
  684. DISRUPTING_RAY = 47,
  685. PRAYER = 48,
  686. MIRTH = 49,
  687. SORROW = 50,
  688. FORTUNE = 51,
  689. MISFORTUNE = 52,
  690. HASTE = 53,
  691. SLOW = 54,
  692. SLAYER = 55,
  693. FRENZY = 56,
  694. TITANS_LIGHTNING_BOLT = 57,
  695. COUNTERSTRIKE = 58,
  696. BERSERK = 59,
  697. HYPNOTIZE = 60,
  698. FORGETFULNESS = 61,
  699. BLIND = 62,
  700. TELEPORT = 63,
  701. REMOVE_OBSTACLE = 64,
  702. CLONE = 65,
  703. SUMMON_FIRE_ELEMENTAL = 66,
  704. SUMMON_EARTH_ELEMENTAL = 67,
  705. SUMMON_WATER_ELEMENTAL = 68,
  706. SUMMON_AIR_ELEMENTAL = 69,
  707. // Creature abilities
  708. STONE_GAZE = 70,
  709. POISON = 71,
  710. BIND = 72,
  711. DISEASE = 73,
  712. PARALYZE = 74,
  713. AGE = 75,
  714. DEATH_CLOUD = 76,
  715. THUNDERBOLT = 77,
  716. DISPEL_HELPFUL_SPELLS = 78,
  717. DEATH_STARE = 79,
  718. ACID_BREATH_DEFENSE = 80,
  719. ACID_BREATH_DAMAGE = 81,
  720. // Special ID's
  721. FIRST_NON_SPELL = 70,
  722. AFTER_LAST = 82
  723. };
  724. const CSpell * toSpell() const; //deprecated
  725. const spells::Spell * toSpell(const spells::Service * service) const;
  726. };
  727. class DLL_LINKAGE SpellID : public IdentifierWithEnum<SpellID, SpellIDBase>
  728. {
  729. public:
  730. using IdentifierWithEnum<SpellID, SpellIDBase>::IdentifierWithEnum;
  731. ///json serialization helpers
  732. static si32 decode(const std::string & identifier);
  733. static std::string encode(const si32 index);
  734. static std::string entityType();
  735. };
  736. class BattleFieldInfo;
  737. class DLL_LINKAGE BattleField : public Identifier<BattleField>
  738. {
  739. public:
  740. using Identifier<BattleField>::Identifier;
  741. static const BattleField NONE;
  742. const BattleFieldInfo * getInfo() const;
  743. static si32 decode(const std::string & identifier);
  744. static std::string encode(const si32 index);
  745. };
  746. class DLL_LINKAGE BoatId : public Identifier<BoatId>
  747. {
  748. public:
  749. using Identifier<BoatId>::Identifier;
  750. static const BoatId NONE;
  751. static const BoatId NECROPOLIS;
  752. static const BoatId CASTLE;
  753. static const BoatId FORTRESS;
  754. };
  755. class TerrainIdBase : public IdentifierBase
  756. {
  757. public:
  758. enum Type : int32_t
  759. {
  760. NATIVE_TERRAIN = -4,
  761. ANY_TERRAIN = -3,
  762. NONE = -1,
  763. FIRST_REGULAR_TERRAIN = 0,
  764. DIRT = 0,
  765. SAND,
  766. GRASS,
  767. SNOW,
  768. SWAMP,
  769. ROUGH,
  770. SUBTERRANEAN,
  771. LAVA,
  772. WATER,
  773. ROCK,
  774. ORIGINAL_REGULAR_TERRAIN_COUNT = ROCK
  775. };
  776. };
  777. class TerrainId : public IdentifierWithEnum<TerrainId, TerrainIdBase>
  778. {
  779. public:
  780. using IdentifierWithEnum<TerrainId, TerrainIdBase>::IdentifierWithEnum;
  781. DLL_LINKAGE static si32 decode(const std::string & identifier);
  782. DLL_LINKAGE static std::string encode(const si32 index);
  783. static std::string entityType();
  784. };
  785. class ObstacleInfo;
  786. class Obstacle : public Identifier<Obstacle>
  787. {
  788. public:
  789. using Identifier<Obstacle>::Identifier;
  790. DLL_LINKAGE const ObstacleInfo * getInfo() const;
  791. };
  792. class DLL_LINKAGE SpellSchool : public Identifier<SpellSchool>
  793. {
  794. public:
  795. using Identifier<SpellSchool>::Identifier;
  796. static const SpellSchool ANY;
  797. static const SpellSchool AIR;
  798. static const SpellSchool FIRE;
  799. static const SpellSchool WATER;
  800. static const SpellSchool EARTH;
  801. static si32 decode(const std::string & identifier);
  802. static std::string encode(const si32 index);
  803. static std::string entityType();
  804. };
  805. class GameResIDBase : public IdentifierBase
  806. {
  807. public:
  808. enum Type : int32_t
  809. {
  810. WOOD = 0,
  811. MERCURY,
  812. ORE,
  813. SULFUR,
  814. CRYSTAL,
  815. GEMS,
  816. GOLD,
  817. MITHRIL,
  818. COUNT,
  819. WOOD_AND_ORE = 127, // special case for town bonus resource
  820. NONE = -1
  821. };
  822. };
  823. class DLL_LINKAGE GameResID : public IdentifierWithEnum<GameResID, GameResIDBase>
  824. {
  825. public:
  826. using IdentifierWithEnum<GameResID, GameResIDBase>::IdentifierWithEnum;
  827. static si32 decode(const std::string & identifier);
  828. static std::string encode(const si32 index);
  829. static std::string entityType();
  830. };
  831. class BuildingTypeUniqueID : public Identifier<BuildingTypeUniqueID>
  832. {
  833. public:
  834. BuildingTypeUniqueID(FactionID faction, BuildingID building );
  835. static si32 decode(const std::string & identifier);
  836. static std::string encode(const si32 index);
  837. BuildingID getBuilding() const;
  838. FactionID getFaction() const;
  839. using Identifier<BuildingTypeUniqueID>::Identifier;
  840. };
  841. class DLL_LINKAGE CampaignScenarioID : public Identifier<CampaignScenarioID>
  842. {
  843. public:
  844. using Identifier<CampaignScenarioID>::Identifier;
  845. static si32 decode(const std::string & identifier);
  846. static std::string encode(int32_t index);
  847. static const CampaignScenarioID NONE;
  848. };
  849. // Deprecated
  850. // TODO: remove
  851. using ETownType = FactionID;
  852. using EGameResID = GameResID;
  853. using River = RiverId;
  854. using Road = RoadId;
  855. using ETerrainId = TerrainId;
  856. VCMI_LIB_NAMESPACE_END