unit.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #pragma once
  2. #include "abstractfactory.h"
  3. #include <QObject>
  4. #include <QString>
  5. #include <QImage>
  6. #include <iostream>
  7. #include <vector>
  8. class Effect;
  9. class Cell;
  10. class Unit : public QObject {
  11. Q_OBJECT
  12. public:
  13. explicit Unit(QString parameters);
  14. virtual ~Unit() {}
  15. //---------------------------------------------//
  16. //---------Basic traits getters section--------//
  17. //---------------------------------------------//
  18. double getExperience();
  19. int getLevel();
  20. int getInitiative();
  21. int getIntelligence();
  22. int getStrength();
  23. int getAgility();
  24. int getActivityPoints();
  25. int getStartingActivityPoints();
  26. int getHealthPoints();
  27. void setHealthPoints(int value);
  28. int getMaxHealthPoints();
  29. int getMagicDefence();
  30. int getPhysicDefence();
  31. int getCost();
  32. void setCost(int value);
  33. virtual bool isCharacter();
  34. std::vector<QString> getParentSpecs();
  35. std::vector<QString> getUpgradeSpecs();
  36. //---------------------------------------------//
  37. //------------Unit location section------------//
  38. //---------------------------------------------//
  39. Cell* getLocation();
  40. void setLocation(Cell* to);
  41. double getRealX();
  42. void setRealX(double x);
  43. double getRealY();
  44. void setRealY(double y);
  45. //---------------------------------------------//
  46. //--------Effect processing & calling----------//
  47. //---------------------------------------------//
  48. void operateEffectList();
  49. void add(Effect*);
  50. void remove(std::vector<Effect*>::iterator);
  51. void remove(Effect*);
  52. std::vector<Effect*>::iterator beginIteratorEffectsList();
  53. std::vector<Effect*>::iterator endIteratorEffectsList();
  54. //---------------------------------------------//
  55. //----------------GUI section------------------//
  56. //---------------------------------------------//
  57. QString getUnitId() const;
  58. QString getUnitName() const;
  59. QString getUnitDescr() const;
  60. QString getUnitBaseClassId() const;
  61. std::vector<QString> getUnitTraits() const;
  62. QImage getUnitIcon() const;
  63. //---------------------------------------------//
  64. //-----------Parameters load section-----------//
  65. //---------------------------------------------//
  66. private:
  67. void loadUnitName(QString unit_folder);
  68. void loadUnitDescr(QString unit_folder);
  69. void loadUnitBaseClass(QString unit_folder);
  70. void loadUnitTraits(QString unit_folder);
  71. void loadUnitIcon(QString unit_folder);
  72. void loadUnitPrevSpecs(QString unit_folder);
  73. void loadUnitUpgradeSpecs(QString unit_folder);
  74. public:
  75. bool operator <(const Unit &b) {
  76. if (base_class_id_ != b.base_class_id_)
  77. return base_class_id_ < b.base_class_id_;
  78. return unit_id_ < b.unit_id_;
  79. }
  80. protected:
  81. std::vector <Effect*> effects_;
  82. //personal information
  83. int cost_;
  84. std::vector<QString> parent_specs_;
  85. std::vector<QString> upgrade_specs_;
  86. double experience_;
  87. int level_;
  88. std::string race_; //lower case
  89. //actions and events
  90. double initiative_;
  91. int activity_points_;
  92. //movement
  93. Cell* location_;
  94. double real_x_;
  95. double real_y_;
  96. //attack action
  97. int agility_;
  98. int intelligence_;
  99. int strength_;
  100. int starting_activity_points_;
  101. //durability
  102. int health_points_;
  103. int max_health_points_;
  104. int magic_defence_; //less or equal 40
  105. int physic_defence_; //less or equal 40
  106. // GUI values
  107. QString race_id_;
  108. QString unit_id_;
  109. QString unit_name_;
  110. QString unit_descr_;
  111. QString base_class_id_;
  112. QImage unit_icon_;
  113. };