SideInBattle.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * SideInBattle.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 "SideInBattle.h"
  12. #include "../callback/IGameInfoCallback.h"
  13. #include "../mapObjects/CGHeroInstance.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army)
  16. {
  17. armyObjectID = Army->id;
  18. if (Hero)
  19. {
  20. heroID = Hero->id;
  21. initialMana = Hero->mana;
  22. additionalMana = Hero->valOfBonuses(BonusType::COMBAT_MANA_BONUS);
  23. }
  24. switch(Army->ID.toEnum())
  25. {
  26. case Obj::CREATURE_GENERATOR1:
  27. case Obj::CREATURE_GENERATOR2:
  28. case Obj::CREATURE_GENERATOR3:
  29. case Obj::CREATURE_GENERATOR4:
  30. color = PlayerColor::NEUTRAL;
  31. break;
  32. default:
  33. color = Army->getOwner();
  34. }
  35. if(color == PlayerColor::UNFLAGGABLE)
  36. color = PlayerColor::NEUTRAL;
  37. }
  38. const CArmedInstance * SideInBattle::getArmy() const
  39. {
  40. if (armyObjectID.hasValue())
  41. return dynamic_cast<const CArmedInstance*>(cb->getObjInstance(armyObjectID));
  42. return nullptr;
  43. }
  44. const CGHeroInstance * SideInBattle::getHero() const
  45. {
  46. if (heroID.hasValue())
  47. return cb->getHero(heroID);
  48. return nullptr;
  49. }
  50. VCMI_LIB_NAMESPACE_END