2
0

SiegeInfo.cpp 844 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * SiegeInfo.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 "SiegeInfo.h"
  12. SiegeInfo::SiegeInfo()
  13. {
  14. for (int i = 0; i < wallState.size(); ++i)
  15. {
  16. wallState[i] = EWallState::NONE;
  17. }
  18. gateState = EGateState::NONE;
  19. }
  20. EWallState::EWallState SiegeInfo::applyDamage(EWallState::EWallState state, unsigned int value)
  21. {
  22. if (value == 0)
  23. return state;
  24. switch (applyDamage(state, value - 1))
  25. {
  26. case EWallState::INTACT : return EWallState::DAMAGED;
  27. case EWallState::DAMAGED : return EWallState::DESTROYED;
  28. case EWallState::DESTROYED : return EWallState::DESTROYED;
  29. default: return EWallState::NONE;
  30. }
  31. }