CObstacleInstance.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "StdInc.h"
  2. #include "CObstacleInstance.h"
  3. #include "CHeroHandler.h"
  4. #include "VCMI_Lib.h"
  5. CObstacleInstance::CObstacleInstance()
  6. {
  7. obstacleType = USUAL;
  8. casterSide = -1;
  9. spellLevel = -1;
  10. turnsRemaining = -1;
  11. visibleForAnotherSide = -1;
  12. }
  13. const CObstacleInfo & CObstacleInstance::getInfo() const
  14. {
  15. switch(obstacleType)
  16. {
  17. case ABSOLUTE_OBSTACLE:
  18. return VLC->heroh->absoluteObstacles[ID];
  19. case USUAL:
  20. return VLC->heroh->obstacles[ID];
  21. default:
  22. assert(0);
  23. }
  24. }
  25. std::vector<BattleHex> CObstacleInstance::getBlocked() const
  26. {
  27. switch(obstacleType)
  28. {
  29. case ABSOLUTE_OBSTACLE:
  30. case USUAL:
  31. return getInfo().getBlocked(pos);
  32. //TODO Force Field
  33. }
  34. return std::vector<BattleHex>();
  35. }
  36. std::vector<BattleHex> CObstacleInstance::getAffectedTiles() const
  37. {
  38. switch(obstacleType)
  39. {
  40. case QUICKSAND:
  41. case LAND_MINE:
  42. return std::vector<BattleHex>(1, pos);
  43. //TODO Fire Wall
  44. }
  45. return std::vector<BattleHex>();
  46. }
  47. bool CObstacleInstance::spellGenerated() const
  48. {
  49. if(obstacleType == USUAL || obstacleType == ABSOLUTE_OBSTACLE)
  50. return false;
  51. return true;
  52. }
  53. bool CObstacleInstance::visibleForSide(ui8 side) const
  54. {
  55. switch(obstacleType)
  56. {
  57. case ABSOLUTE_OBSTACLE:
  58. case USUAL:
  59. return true;
  60. default:
  61. //we hide mines and not discovered quicksands
  62. return casterSide == side || visibleForAnotherSide;
  63. }
  64. }