unit.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #pragma once
  2. #include "AbstractFactory.h"
  3. #include <QObject>
  4. #include <QString>
  5. #include <QImage>
  6. #include <iostream>
  7. #include <vector>
  8. class Spell {
  9. public:
  10. int a;
  11. };
  12. class Cell {
  13. //waiting for a realisation
  14. public:
  15. //must be in cell.h
  16. bool isEmpty() {
  17. return true;
  18. }
  19. std::vector <Cell*> actualPath(Cell* destination) { //the shortest existing path from (*this) to (*destination)
  20. std::vector <Cell*> path;
  21. return path;
  22. }
  23. };
  24. class Unit : public QObject {
  25. Q_OBJECT
  26. public:
  27. explicit Unit(QString parameters);
  28. virtual ~Unit() {}
  29. //---------------------------------------------//
  30. //---------Basic traits getters section--------//
  31. //---------------------------------------------//
  32. double getExperience();
  33. double getLevel();
  34. int getMovementSpeed();
  35. double getInitiative();
  36. double getDamagePerHit();
  37. double getIntelligence();
  38. double getStrength();
  39. double getAgility();
  40. int getActivityPoints();
  41. int getAttackPoints();
  42. int getAttackCost();
  43. double getAttackRange();
  44. double getHealthPoints();
  45. double getMagicDefence();
  46. double getPhysicDefence();
  47. int getCost();
  48. void setCost(int value);
  49. std::vector<QString> getParentSpecs();
  50. std::vector<QString> getUpgradeSpecs();
  51. //---------------------------------------------//
  52. //------------Unit location section------------//
  53. //---------------------------------------------//
  54. Cell* getLocation();
  55. void setLocation(Cell* to);
  56. double getRealX();
  57. void setRealX(double x);
  58. double getRealY();
  59. void setRealY(double y);
  60. //---------------------------------------------//
  61. //--------Damage checkers & calculators--------//
  62. //---------------------------------------------//
  63. virtual void calculateDamagePerHit();
  64. virtual double reduceIncomingDamage(std::string damageType, int value);
  65. virtual bool canAttackForDistance(int distance) {}
  66. virtual bool canAttackToCell(Cell* destination) {}
  67. virtual bool canAttackUnit(Unit* target) {}
  68. //---------------------------------------------//
  69. //-------Movement checkers & calculators-------//
  70. //---------------------------------------------//
  71. int lenOfActualPath(Cell* destination);
  72. virtual bool canMoveForDistance(int distance);
  73. virtual bool canMoveToCell(Cell* destination);
  74. virtual void moveToCell(Cell* destination);
  75. //---------------------------------------------//
  76. //----------------GUI section------------------//
  77. //---------------------------------------------//
  78. QString getUnitName() const;
  79. QString getUnitDescr() const;
  80. QString getUnitBaseClassId() const;
  81. std::vector<QString> getUnitTraits() const;
  82. QImage getUnitIcon() const;
  83. //---------------------------------------------//
  84. //-----------Parameters load section-----------//
  85. //---------------------------------------------//
  86. private:
  87. void loadUnitName(QString unit_folder);
  88. void loadUnitDescr(QString unit_folder);
  89. void loadUnitBaseClass(QString unit_folder);
  90. void loadUnitTraits(QString unit_folder);
  91. void loadUnitIcon(QString unit_folder);
  92. void loadUnitPrevSpecs(QString unit_folder);
  93. void loadUnitUpgradeSpecs(QString unit_folder);
  94. public:
  95. bool operator <(const Unit &b) {
  96. if (base_class_id_ != b.base_class_id_)
  97. return base_class_id_ < b.base_class_id_;
  98. return unit_id_ < b.unit_id_;
  99. }
  100. protected:
  101. std::vector <Spell> skills_;
  102. //personal information
  103. int cost_;
  104. std::vector<QString> parent_specs_;
  105. std::vector<QString> upgrade_specs_;
  106. double experience_;
  107. double level_;
  108. std::string race_; //lower case
  109. //actions and events
  110. double initiative_;
  111. int activity_points_;
  112. //movement
  113. Cell* location_;
  114. int movement_speed_; //how many cells can move for one activity point
  115. double real_x_;
  116. double real_y_;
  117. //attack action
  118. double agility_;
  119. double attack_range_;
  120. double damage_per_hit_;
  121. double intelligence_;
  122. double strength_;
  123. int attack_cost_; //how many activity points does attack cost
  124. //durability
  125. double health_points_;
  126. double magic_defence_; //less or equal 40
  127. double physic_defence_; //less or equal 40
  128. // GUI values
  129. QString race_id_;
  130. QString unit_id_;
  131. QString unit_name_;
  132. QString unit_descr_;
  133. QString base_class_id_;
  134. QImage unit_icon_;
  135. };