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-07-01 20:05:10 +02:00
|
|
|
#include "StdInc.h"
|
2017-03-17 17:48:44 +02:00
|
|
|
#include "SiegeInfo.h"
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2017-03-17 17:48:44 +02:00
|
|
|
|
|
|
|
SiegeInfo::SiegeInfo()
|
|
|
|
{
|
2023-02-15 00:44:59 +02:00
|
|
|
for(int i = 0; i < static_cast<int>(EWallPart::PARTS_COUNT); ++i)
|
2017-03-17 17:48:44 +02:00
|
|
|
{
|
2023-02-15 00:44:59 +02:00
|
|
|
wallState[static_cast<EWallPart>(i)] = EWallState::NONE;
|
2017-03-17 17:48:44 +02:00
|
|
|
}
|
|
|
|
gateState = EGateState::NONE;
|
|
|
|
}
|
|
|
|
|
2023-01-13 00:35:58 +02:00
|
|
|
EWallState SiegeInfo::applyDamage(EWallState state, unsigned int value)
|
2017-03-17 17:48:44 +02:00
|
|
|
{
|
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
|
|
|
{
|
2023-01-13 01:09:24 +02:00
|
|
|
case EWallState::REINFORCED:
|
|
|
|
return EWallState::INTACT;
|
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
|
|
|
}
|
|
|
|
}
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|