BattleAttackInfo.cpp 1.2 KB

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