unit.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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*) { //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. int getStartingActivityPoints();
  45. double getHealthPoints();
  46. double getMagicDefence();
  47. double getPhysicDefence();
  48. int getCost();
  49. void setCost(int value);
  50. std::vector<QString> getParentSpecs();
  51. std::vector<QString> getUpgradeSpecs();
  52. //---------------------------------------------//
  53. //------------Unit location section------------//
  54. //---------------------------------------------//
  55. Cell* getLocation();
  56. void setLocation(Cell* to);
  57. double getRealX();
  58. void setRealX(double x);
  59. double getRealY();
  60. void setRealY(double y);
  61. //---------------------------------------------//
  62. //--------Damage checkers & calculators--------//
  63. //---------------------------------------------//
  64. virtual void calculateDamagePerHit();
  65. virtual double reduceIncomingDamage(std::string damageType, int value);
  66. virtual bool canAttackForDistance(int ) {return false;}
  67. virtual bool canAttackToCell(Cell* ) {return false;}
  68. virtual bool canAttackUnit(Unit* ) {return false;}
  69. //---------------------------------------------//
  70. //-------Movement checkers & calculators-------//
  71. //---------------------------------------------//
  72. int lenOfActualPath(Cell* destination);
  73. virtual bool canMoveForDistance(int distance);
  74. virtual bool canMoveToCell(Cell* destination);
  75. virtual void moveToCell(Cell* destination);
  76. //---------------------------------------------//
  77. //----------------GUI section------------------//
  78. //---------------------------------------------//
  79. QString getUnitId() const;
  80. QString getUnitName() const;
  81. QString getUnitDescr() const;
  82. QString getUnitBaseClassId() const;
  83. std::vector<QString> getUnitTraits() const;
  84. QImage getUnitIcon() const;
  85. //---------------------------------------------//
  86. //-----------Parameters load section-----------//
  87. //---------------------------------------------//
  88. private:
  89. void loadUnitName(QString unit_folder);
  90. void loadUnitDescr(QString unit_folder);
  91. void loadUnitBaseClass(QString unit_folder);
  92. void loadUnitTraits(QString unit_folder);
  93. void loadUnitIcon(QString unit_folder);
  94. void loadUnitPrevSpecs(QString unit_folder);
  95. void loadUnitUpgradeSpecs(QString unit_folder);
  96. public:
  97. bool operator <(const Unit &b) {
  98. if (base_class_id_ != b.base_class_id_)
  99. return base_class_id_ < b.base_class_id_;
  100. return unit_id_ < b.unit_id_;
  101. }
  102. protected:
  103. std::vector <Spell> skills_;
  104. //personal information
  105. int cost_;
  106. std::vector<QString> parent_specs_;
  107. std::vector<QString> upgrade_specs_;
  108. double experience_;
  109. double level_;
  110. std::string race_; //lower case
  111. //actions and events
  112. double initiative_;
  113. int activity_points_;
  114. //movement
  115. Cell* location_;
  116. int movement_speed_; //how many cells can move for one activity point
  117. double real_x_;
  118. double real_y_;
  119. //attack action
  120. double agility_;
  121. double attack_range_;
  122. double damage_per_hit_;
  123. double intelligence_;
  124. double strength_;
  125. int attack_cost_; //how many activity points does attack cost
  126. int starting_activity_points_;
  127. //durability
  128. double health_points_;
  129. double magic_defence_; //less or equal 40
  130. double physic_defence_; //less or equal 40
  131. // GUI values
  132. QString race_id_;
  133. QString unit_id_;
  134. QString unit_name_;
  135. QString unit_descr_;
  136. QString base_class_id_;
  137. QImage unit_icon_;
  138. };