Unit.h 4.1 KB

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