unit.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #pragma once
  2. #include <iostream>
  3. #include <vector>
  4. class Spell {
  5. //waiting for a realisation
  6. };
  7. class Cell {
  8. //waiting for a realisation
  9. public:
  10. bool isEmpty() {
  11. return true;
  12. }
  13. std::vector <Cell*> actualPath(Cell* destination) { //the shortest existing path from (*this) to (*destination)
  14. std::vector <Cell*> path;
  15. return path;
  16. }
  17. };
  18. class Unit {
  19. protected:
  20. std::vector <Spell> skills_;
  21. private:
  22. //personal information
  23. double experience_;
  24. double level_;
  25. std::string race_; //lower case
  26. //actions and events
  27. double initiative_;
  28. int activity_points_;
  29. //movement
  30. Cell* location_;
  31. int movement_speed_; //how many cells can move for one activity point
  32. double real_x_;
  33. double real_y_;
  34. //attack action
  35. double agility_;
  36. double attack_range_;
  37. double damage_per_hit_;
  38. double intelligence_;
  39. double strength_;
  40. int attack_cost_; //how many activity points does attack cost
  41. //durability
  42. double health_points_;
  43. double magic_defence_; //less or equal 40
  44. double physic_defence_; //less or equal 40
  45. public:
  46. Unit();
  47. virtual ~Unit() = delete;
  48. double getExperience();
  49. void setExperience(double value);
  50. double getLevel();
  51. void setLevel(double value);
  52. double getHealthPoints();
  53. void setHealthPoints(double value);
  54. double getAttackRange();
  55. void setAttackRange(double value);
  56. int getActivityPoints();
  57. void setActivityPoints(int value);
  58. Cell* getLocation();
  59. void setLocation(Cell* to);
  60. int getMovementSpeed();
  61. void setMovementSpeed(int value);
  62. int getAttackCost();
  63. void setAttackCost(int value);
  64. double getInitiative();
  65. void setInitiative(double value);
  66. double getDamagePerHit();
  67. void setDamagePerHit(double value);
  68. double getIntelligence();
  69. void setIntelligence(double value);
  70. double getStrength();
  71. void setStrength(double value);
  72. double getAgility();
  73. void setAgility(double value);
  74. int getAttackPoints();
  75. void setAttackPoints(int value);
  76. double getMagicDefence();
  77. void setMagicDefence(double value);
  78. double getPhysicDefence();
  79. void setPhysicDefence(double value);
  80. std::string getRace();
  81. void setRace(std::string new_race);
  82. double getRealX();
  83. void setRealX(double x);
  84. double getRealY();
  85. void setRealY(double y);
  86. virtual void calculateDamagePerHit();
  87. virtual double reduceIncomingDamage(std::string damageType, int value);
  88. int lenOfActualPath(Cell* destination);
  89. virtual bool canMoveForDistance(int distance);
  90. virtual bool canMoveToCell(Cell* destination);
  91. virtual void moveToCell(Cell* destination);
  92. virtual bool canAttackForDistance(int distance) = 0;
  93. virtual bool canAttackToCell(Cell* destination) = 0;
  94. virtual bool canAttackUnit(Unit* target) = 0;
  95. };
  96. class MeleeUnit : public Unit {
  97. protected:
  98. private:
  99. public:
  100. virtual ~MeleeUnit() = delete;
  101. virtual bool canAttackForDistance(int distance);
  102. virtual bool canAttackToCell(Cell* destination);
  103. virtual bool canAttackUnit(Unit* target);
  104. };
  105. class RangeUnit : public Unit {
  106. protected:
  107. private:
  108. public:
  109. virtual ~RangeUnit() = delete;
  110. };
  111. template <class Base>
  112. class AbstractUnitCreator {
  113. public:
  114. AbstractUnitCreator() {}
  115. virtual ~AbstractUnitCreator() {}
  116. virtual Base* create() const = 0;
  117. };