BattleAttackInfo.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 "CStack.h"
  13. BattleAttackInfo::BattleAttackInfo(const CStack * Attacker, const CStack * Defender, bool Shooting)
  14. {
  15. attacker = Attacker;
  16. defender = Defender;
  17. attackerBonuses = Attacker;
  18. defenderBonuses = Defender;
  19. attackerPosition = Attacker->position;
  20. defenderPosition = Defender->position;
  21. attackerCount = Attacker->count;
  22. defenderCount = Defender->count;
  23. shooting = Shooting;
  24. chargedFields = 0;
  25. luckyHit = false;
  26. unluckyHit = false;
  27. deathBlow = false;
  28. ballistaDoubleDamage = false;
  29. }
  30. BattleAttackInfo BattleAttackInfo::reverse() const
  31. {
  32. BattleAttackInfo ret = *this;
  33. std::swap(ret.attacker, ret.defender);
  34. std::swap(ret.attackerBonuses, ret.defenderBonuses);
  35. std::swap(ret.attackerPosition, ret.defenderPosition);
  36. std::swap(ret.attackerCount, ret.defenderCount);
  37. ret.shooting = false;
  38. ret.chargedFields = 0;
  39. ret.luckyHit = ret.ballistaDoubleDamage = ret.deathBlow = false;
  40. return ret;
  41. }