BattleAttackInfo.cpp 945 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * BattleAttackInfo.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 "BattleAttackInfo.h"
  12. #include "CUnitState.h"
  13. BattleAttackInfo::BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, bool Shooting)
  14. : attacker(Attacker),
  15. defender(Defender)
  16. {
  17. shooting = Shooting;
  18. chargedFields = 0;
  19. additiveBonus = 0.0;
  20. multBonus = 1.0;
  21. attackerPos = BattleHex::INVALID;
  22. defenderPos = BattleHex::INVALID;
  23. }
  24. BattleAttackInfo BattleAttackInfo::reverse() const
  25. {
  26. BattleAttackInfo ret = *this;
  27. std::swap(ret.attacker, ret.defender);
  28. std::swap(ret.defenderPos, ret.attackerPos);
  29. ret.shooting = false;
  30. ret.chargedFields = 0;
  31. ret.additiveBonus = 0.0;
  32. ret.multBonus = 1.0;
  33. return ret;
  34. }