CHeroClass.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * CHeroClass.cpp, 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. #include "StdInc.h"
  11. #include "CHeroClass.h"
  12. #include "../faction/CFaction.h"
  13. #include "../../GameLibrary.h"
  14. #include "../../texts/CGeneralTextHandler.h"
  15. #include <vstd/RNG.h>
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. bool CHeroClass::isMagicHero() const
  18. {
  19. return affinity == MAGIC;
  20. }
  21. int CHeroClass::tavernProbability(FactionID targetFaction) const
  22. {
  23. auto it = selectionProbability.find(targetFaction);
  24. if (it != selectionProbability.end())
  25. return it->second;
  26. return 0;
  27. }
  28. EAlignment CHeroClass::getAlignment() const
  29. {
  30. return faction.toEntity(LIBRARY)->getAlignment();
  31. }
  32. int32_t CHeroClass::getIndex() const
  33. {
  34. return id.getNum();
  35. }
  36. int32_t CHeroClass::getIconIndex() const
  37. {
  38. return getIndex();
  39. }
  40. std::string CHeroClass::getJsonKey() const
  41. {
  42. return modScope + ':' + identifier;
  43. }
  44. std::string CHeroClass::getModScope() const
  45. {
  46. return modScope;
  47. }
  48. HeroClassID CHeroClass::getId() const
  49. {
  50. return id;
  51. }
  52. void CHeroClass::registerIcons(const IconRegistar & cb) const
  53. {
  54. }
  55. std::string CHeroClass::getNameTranslated() const
  56. {
  57. return LIBRARY->generaltexth->translate(getNameTextID());
  58. }
  59. std::string CHeroClass::getNameTextID() const
  60. {
  61. return TextIdentifier("heroClass", modScope, identifier, "name").get();
  62. }
  63. void CHeroClass::updateFrom(const JsonNode & data)
  64. {
  65. //TODO: CHeroClass::updateFrom
  66. }
  67. void CHeroClass::serializeJson(JsonSerializeFormat & handler)
  68. {
  69. }
  70. CHeroClass::CHeroClass():
  71. faction(0),
  72. affinity(0),
  73. defaultTavernChance(0)
  74. {
  75. }
  76. VCMI_LIB_NAMESPACE_END