123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #pragma once
- #include "abstractfactory.h"
- #include <QObject>
- #include <QString>
- #include <QImage>
- #include <iostream>
- #include <vector>
- class Spell {
- public:
- int a;
- };
- class Cell;
- class Unit : public QObject {
- Q_OBJECT
- public:
- explicit Unit(QString parameters);
- virtual ~Unit() {}
- //---------------------------------------------//
- //---------Basic traits getters section--------//
- //---------------------------------------------//
- double getExperience();
- int getLevel();
- int getMovementSpeed();
- int getInitiative();
- int getIntelligence();
- int getStrength();
- int getAgility();
- int getActivityPoints();
- int getAttackPoints();
- int getAttackCost();
- int getAttackRange();
- int getStartingActivityPoints();
- int getHealthPoints();
- int getMagicDefence();
- int getPhysicDefence();
- int getCost();
- void setCost(int value);
- virtual bool isCharacter();
- std::vector<QString> getParentSpecs();
- std::vector<QString> getUpgradeSpecs();
- //---------------------------------------------//
- //------------Unit location section------------//
- //---------------------------------------------//
- Cell* getLocation();
- void setLocation(Cell* to);
- double getRealX();
- void setRealX(double x);
- double getRealY();
- void setRealY(double y);
- //---------------------------------------------//
- //--------Damage checkers & calculators--------//
- //---------------------------------------------//
- virtual int reduceIncomingDamage(std::string damageType, int value);
- virtual bool canAttackForDistance(std::string, int) {return false;}
- virtual bool canAttackToCell(Cell* ) {return false;}
- virtual bool canAttackUnit(Unit* ) {return false;}
- //---------------------------------------------//
- //-------Movement checkers & calculators-------//
- //---------------------------------------------//
- int lenOfActualPath(Cell* destination);
- virtual bool canMoveForDistance(int distance);
- virtual bool canMoveToCell(Cell* destination);
- virtual void moveToCell(Cell* destination);
- virtual int theSameNear();
- //---------------------------------------------//
- //----------------GUI section------------------//
- //---------------------------------------------//
- QString getUnitId() const;
- QString getUnitName() const;
- QString getUnitDescr() const;
- QString getUnitBaseClassId() const;
- std::vector<QString> getUnitTraits() const;
- QImage getUnitIcon() const;
- //---------------------------------------------//
- //-----------Parameters load section-----------//
- //---------------------------------------------//
- private:
- void loadUnitName(QString unit_folder);
- void loadUnitDescr(QString unit_folder);
- void loadUnitBaseClass(QString unit_folder);
- void loadUnitTraits(QString unit_folder);
- void loadUnitIcon(QString unit_folder);
- void loadUnitPrevSpecs(QString unit_folder);
- void loadUnitUpgradeSpecs(QString unit_folder);
- public:
- bool operator <(const Unit &b) {
- if (base_class_id_ != b.base_class_id_)
- return base_class_id_ < b.base_class_id_;
- return unit_id_ < b.unit_id_;
- }
- protected:
- std::vector <Spell> skills_;
- //personal information
- int cost_;
- std::vector<QString> parent_specs_;
- std::vector<QString> upgrade_specs_;
- double experience_;
- int level_;
- std::string race_; //lower case
- //actions and events
- double initiative_;
- int activity_points_;
- //movement
- Cell* location_;
- int movement_speed_; //how many cells can move for one activity point
- double real_x_;
- double real_y_;
- //attack action
- int agility_;
- int attack_range_;
- int intelligence_;
- int strength_;
- int attack_cost_; //how many activity points does attack cost
- int starting_activity_points_;
- //durability
- int health_points_;
- int magic_defence_; //less or equal 40
- int physic_defence_; //less or equal 40
- // GUI values
- QString race_id_;
- QString unit_id_;
- QString unit_name_;
- QString unit_descr_;
- QString base_class_id_;
- QImage unit_icon_;
- };
|