unit.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #pragma once
  2. #include "AbstractFactory.h"
  3. #include <QObject>
  4. #include <QString>
  5. #include <iostream>
  6. #include <vector>
  7. class Spell {
  8. public:
  9. int a;
  10. };
  11. class Cell {
  12. //waiting for a realisation
  13. public:
  14. //must be in cell.h
  15. bool isEmpty() {
  16. return true;
  17. }
  18. std::vector <Cell*> actualPath(Cell* destination) { //the shortest existing path from (*this) to (*destination)
  19. std::vector <Cell*> path;
  20. return path;
  21. }
  22. };
  23. class Unit : public QObject {
  24. Q_OBJECT
  25. public:
  26. explicit Unit(QString unit_name);
  27. virtual ~Unit() {}
  28. //---------------------------------------------//
  29. //---------Basic traits getters section--------//
  30. //---------------------------------------------//
  31. double getExperience();
  32. double getLevel();
  33. int getMovementSpeed();
  34. double getInitiative();
  35. double getDamagePerHit();
  36. double getIntelligence();
  37. double getStrength();
  38. double getAgility();
  39. int getActivityPoints();
  40. int getAttackPoints();
  41. int getAttackCost();
  42. double getAttackRange();
  43. double getHealthPoints();
  44. double getMagicDefence();
  45. double getPhysicDefence();
  46. int getCost();
  47. void setCost(int value);
  48. std::string getParentSpec();
  49. std::vector<std::string> getUpgradeSpecs();
  50. //---------------------------------------------//
  51. //------------Unit location section------------//
  52. //---------------------------------------------//
  53. Cell* getLocation();
  54. void setLocation(Cell* to);
  55. double getRealX();
  56. void setRealX(double x);
  57. double getRealY();
  58. void setRealY(double y);
  59. //---------------------------------------------//
  60. //--------Damage checkers & calculators--------//
  61. //---------------------------------------------//
  62. virtual void calculateDamagePerHit();
  63. virtual double reduceIncomingDamage(std::string damageType, int value);
  64. virtual bool canAttackForDistance(int distance) {}
  65. virtual bool canAttackToCell(Cell* destination) {}
  66. virtual bool canAttackUnit(Unit* target) {}
  67. //---------------------------------------------//
  68. //-------Movement checkers & calculators-------//
  69. //---------------------------------------------//
  70. int lenOfActualPath(Cell* destination);
  71. virtual bool canMoveForDistance(int distance);
  72. virtual bool canMoveToCell(Cell* destination);
  73. virtual void moveToCell(Cell* destination);
  74. protected:
  75. std::vector <Spell> skills_;
  76. //personal information
  77. int cost_;
  78. std::string parent_spec_;
  79. std::vector<std::string> upgrade_specs_;
  80. double experience_;
  81. double level_;
  82. std::string race_; //lower case
  83. //actions and events
  84. double initiative_;
  85. int activity_points_;
  86. //movement
  87. Cell* location_;
  88. int movement_speed_; //how many cells can move for one activity point
  89. double real_x_;
  90. double real_y_;
  91. //attack action
  92. double agility_;
  93. double attack_range_;
  94. double damage_per_hit_;
  95. double intelligence_;
  96. double strength_;
  97. int attack_cost_; //how many activity points does attack cost
  98. //durability
  99. double health_points_;
  100. double magic_defence_; //less or equal 40
  101. double physic_defence_; //less or equal 40
  102. };