Procházet zdrojové kódy

added primal movement func

noath před 7 roky
rodič
revize
498341b4e9
2 změnil soubory, kde provedl 38 přidání a 6 odebrání
  1. 20 2
      unit.cpp
  2. 18 4
      unit.h

+ 20 - 2
unit.cpp

@@ -70,10 +70,10 @@ void Unit::setMovementSpeed(double value) {
 	movement_speed_ = value;
 }
 
-double Unit::getInitiative_() {
+double Unit::getInitiative() {
 	return initiative_;
 }
-void Unit::setInitiative_(double value) {
+void Unit::setInitiative(double value) {
 	initiative_ = value;
 }
 
@@ -135,3 +135,21 @@ double Unit::reduceIncomingDamage(std::string damageType, int damage) { //return
 		return (1 - 2.5 * magic_defence_ / 100) * damage;
 	}
 }
+
+bool Unit::canMoveForDistance(int distance) {
+	if (active_points_ >= double(distance) / movement_speed_) {
+		return true;
+	}
+	else return false;
+}
+
+bool Unit::canMoveToCell(Cell* to) {
+	if (to->isEmpty() && canMoveForDistance(to->actualPath.size())) {
+		return true;
+	}
+	else return false;
+}
+
+/*bool canAttack(int distance) {
+
+}*/

+ 18 - 4
unit.h

@@ -3,10 +3,18 @@
 #include <vector>
 
 class Spell {
-	//empty for allow to compile
+	//waiting for a realisation
 };
 class Cell {
-	//waiting a realisation
+	//waiting for a realisation
+public:
+	bool isEmpty() {
+		return true;
+	}
+	std::vector <Cell*> actualPath() {
+		std::vector <Cell*> path;
+		return path;
+	}
 };
 
 class Unit {
@@ -24,8 +32,8 @@ private:
 	double initiative_;
 
 	//movement
-	Cell* location_; //x - first, y - second
-	double movement_speed_;
+	Cell* location_;
+	double movement_speed_; //how many cells can move for one activity point
 
 	//attack action
 	double agility_;
@@ -96,4 +104,10 @@ public:
 	virtual void calculateDamagePerHit();
 
 	double reduceIncomingDamage(std::string damageType, int value);
+
+	bool canMoveForDistance(int distance);
+
+	bool Unit::canMoveToCell(Cell* to);
+
+//	bool canAttackForDistance(int distance);
 };