mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Refactoring.
Dividing CBattleCallback into smaller files with classes.
This commit is contained in:
51
lib/battle/BattleAttackInfo.cpp
Normal file
51
lib/battle/BattleAttackInfo.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* BattleAttackInfo.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "BattleAttackInfo.h"
|
||||
#include "CStack.h"
|
||||
|
||||
|
||||
BattleAttackInfo::BattleAttackInfo(const CStack *Attacker, const CStack *Defender, bool Shooting)
|
||||
{
|
||||
attacker = Attacker;
|
||||
defender = Defender;
|
||||
|
||||
attackerBonuses = Attacker;
|
||||
defenderBonuses = Defender;
|
||||
|
||||
attackerPosition = Attacker->position;
|
||||
defenderPosition = Defender->position;
|
||||
|
||||
attackerCount = Attacker->count;
|
||||
defenderCount = Defender->count;
|
||||
|
||||
shooting = Shooting;
|
||||
chargedFields = 0;
|
||||
|
||||
luckyHit = false;
|
||||
unluckyHit = false;
|
||||
deathBlow = false;
|
||||
ballistaDoubleDamage = false;
|
||||
}
|
||||
|
||||
BattleAttackInfo BattleAttackInfo::reverse() const
|
||||
{
|
||||
BattleAttackInfo ret = *this;
|
||||
std::swap(ret.attacker, ret.defender);
|
||||
std::swap(ret.attackerBonuses, ret.defenderBonuses);
|
||||
std::swap(ret.attackerPosition, ret.defenderPosition);
|
||||
std::swap(ret.attackerCount, ret.defenderCount);
|
||||
|
||||
ret.shooting = false;
|
||||
ret.chargedFields = 0;
|
||||
ret.luckyHit = ret.ballistaDoubleDamage = ret.deathBlow = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user