unit.h 4.2 KB

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