unit.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. int getMaxHealthPoints();
  28. int getMagicDefence();
  29. int getPhysicDefence();
  30. int getCost();
  31. void setCost(int value);
  32. virtual bool isCharacter();
  33. std::vector<QString> getParentSpecs();
  34. std::vector<QString> getUpgradeSpecs();
  35. //---------------------------------------------//
  36. //------------Unit location section------------//
  37. //---------------------------------------------//
  38. Cell* getLocation();
  39. void setLocation(Cell* to);
  40. double getRealX();
  41. void setRealX(double x);
  42. double getRealY();
  43. void setRealY(double y);
  44. //---------------------------------------------//
  45. //--------Effect processing & calling----------//
  46. //---------------------------------------------//
  47. void operateEffectList();
  48. void add(Effect*);
  49. void remove(std::vector<Effect*>::iterator);
  50. void remove(Effect*);
  51. std::vector<Effect*>::iterator beginIteratorEffectsList();
  52. std::vector<Effect*>::iterator endIteratorEffectsList();
  53. //---------------------------------------------//
  54. //----------------GUI section------------------//
  55. //---------------------------------------------//
  56. QString getUnitId() const;
  57. QString getUnitName() const;
  58. QString getUnitDescr() const;
  59. QString getUnitBaseClassId() const;
  60. std::vector<QString> getUnitTraits() const;
  61. QImage getUnitIcon() const;
  62. //---------------------------------------------//
  63. //-----------Parameters load section-----------//
  64. //---------------------------------------------//
  65. private:
  66. void loadUnitName(QString unit_folder);
  67. void loadUnitDescr(QString unit_folder);
  68. void loadUnitBaseClass(QString unit_folder);
  69. void loadUnitTraits(QString unit_folder);
  70. void loadUnitIcon(QString unit_folder);
  71. void loadUnitPrevSpecs(QString unit_folder);
  72. void loadUnitUpgradeSpecs(QString unit_folder);
  73. public:
  74. bool operator <(const Unit &b) {
  75. if (base_class_id_ != b.base_class_id_)
  76. return base_class_id_ < b.base_class_id_;
  77. return unit_id_ < b.unit_id_;
  78. }
  79. protected:
  80. std::vector <Effect*> effects_;
  81. //personal information
  82. int cost_;
  83. std::vector<QString> parent_specs_;
  84. std::vector<QString> upgrade_specs_;
  85. double experience_;
  86. int level_;
  87. std::string race_; //lower case
  88. //actions and events
  89. double initiative_;
  90. int activity_points_;
  91. //movement
  92. Cell* location_;
  93. double real_x_;
  94. double real_y_;
  95. //attack action
  96. int agility_;
  97. int intelligence_;
  98. int strength_;
  99. int starting_activity_points_;
  100. //durability
  101. int health_points_;
  102. int current_health_points_;
  103. int magic_defence_; //less or equal 40
  104. int physic_defence_; //less or equal 40
  105. // GUI values
  106. QString race_id_;
  107. QString unit_id_;
  108. QString unit_name_;
  109. QString unit_descr_;
  110. QString base_class_id_;
  111. QImage unit_icon_;
  112. };