2017-03-17 17:48:44 +02:00
|
|
|
/*
|
|
|
|
* SiegeInfo.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
|
|
|
|
*
|
|
|
|
*/
|
2017-06-29 01:02:05 +02:00
|
|
|
#include "../StdInc.h"
|
2017-03-17 17:48:44 +02:00
|
|
|
#include "SiegeInfo.h"
|
|
|
|
|
|
|
|
|
|
|
|
SiegeInfo::SiegeInfo()
|
|
|
|
{
|
2017-06-29 01:02:05 +02:00
|
|
|
for(int i = 0; i < wallState.size(); ++i)
|
2017-03-17 17:48:44 +02:00
|
|
|
{
|
|
|
|
wallState[i] = EWallState::NONE;
|
|
|
|
}
|
|
|
|
gateState = EGateState::NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EWallState::EWallState SiegeInfo::applyDamage(EWallState::EWallState state, unsigned int value)
|
|
|
|
{
|
2017-06-29 01:02:05 +02:00
|
|
|
if(value == 0)
|
2017-03-17 17:48:44 +02:00
|
|
|
return state;
|
|
|
|
|
2017-06-29 01:02:05 +02:00
|
|
|
switch(applyDamage(state, value - 1))
|
2017-03-17 17:48:44 +02:00
|
|
|
{
|
2017-06-29 01:02:05 +02:00
|
|
|
case EWallState::INTACT:
|
|
|
|
return EWallState::DAMAGED;
|
|
|
|
case EWallState::DAMAGED:
|
|
|
|
return EWallState::DESTROYED;
|
|
|
|
case EWallState::DESTROYED:
|
|
|
|
return EWallState::DESTROYED;
|
|
|
|
default:
|
|
|
|
return EWallState::NONE;
|
2017-03-17 17:48:44 +02:00
|
|
|
}
|
|
|
|
}
|