Quellcode durchsuchen

Merge branch 'cell' of GooseHouse/game-client into dev

Ivan Arkhipov vor 6 Jahren
Ursprung
Commit
7a558e85e7
3 geänderte Dateien mit 8 neuen und 39 gelöschten Zeilen
  1. 1 16
      include/units/unit.h
  2. 6 23
      source/Cell.cpp
  3. 1 0
      source/units/unit.cpp

+ 1 - 16
include/units/unit.h

@@ -1,11 +1,9 @@
 #pragma once
 
 #include "abstractfactory.h"
-
 #include <QObject>
 #include <QString>
 #include <QImage>
-
 #include <iostream>
 #include <vector>
 
@@ -14,19 +12,6 @@ public:
     int a;
 };
 
-class Cell {
-	//waiting for a realisation
-public:
-	//must be in cell.h
-	bool isEmpty() { 
-		return true;
-	}
-    std::vector <Cell*> actualPath(Cell*) { //the shortest existing path from (*this) to (*destination)
-		std::vector <Cell*> path;
-		return path;
-	}
-};
-
 class Unit : public QObject {
     Q_OBJECT
 
@@ -88,7 +73,7 @@ public:
 
     virtual double reduceIncomingDamage(std::string damageType, int value);
 
-    virtual	bool canAttackForDistance(int ) {return false;}
+    virtual	bool canAttackForDistance(std::string, int) {return false;}
 
     virtual bool canAttackToCell(Cell* ) {return false;}
 

+ 6 - 23
source/Cell.cpp

@@ -1,24 +1,11 @@
 #include "Cell.h"
-#include <assert.h>
+#include "unit.h"
 #include <string>
-#include <string.h>
-//#include "unit.h"
 #include <queue>
 #include <vector>
 #include <map>
 #include <iostream>
 
-class Unit{
-private:
-public:
-    bool CanMoveForDistance(int distance){
-        return true;
-    }
-    bool CanAttackForDistance(std::string AttackType, int distance){
-        return true;
-    }
-};
-
 class EffectsForCell{
 public:
 	void OperateOnCell(Cell*){}
@@ -161,7 +148,7 @@ std::vector <Cell*> Cell::actualPath(Cell* to) {
                 parent = TestParent;
             }
         };
-        assert(parent != nullptr);
+        if(parent == nullptr) throw std::string("Don`t recalculated");
         f(to->getleftUp(), to);
         f(to->getleft(), to);
         f(to->getleftDown(), to);
@@ -215,12 +202,12 @@ void Cell::clearTable_() {
 void Cell::recalcAttackable_(Cell * Now,bool isReached){
     if(Now == nullptr)return;
     if (!isEmpty() && !Now->isEmpty() &&
-        getCharacter()->CanAttackForDistance("Melee", Now->getdistance_barrier())
+        getCharacter()->canAttackForDistance("Melee", Now->getdistance_barrier())
             ) {
         Now->setisMeleeAttackAble(isReached);
     }
     if (!isEmpty() && !Now->isEmpty() &&
-        getCharacter()->CanAttackForDistance("Range", Now->getdistance_barrier())
+        getCharacter()->canAttackForDistance("Range", Now->getdistance_barrier())
             ) {
         Now->setisRangeAttackAble(true);
     }
@@ -229,7 +216,7 @@ void Cell::recalcAttackable_(Cell * Now,bool isReached){
 void Cell::recalcMoveable_(Cell * Now, bool isReached){
     if(Now == nullptr || Now->isEmpty() || isEmpty())return;
     if(!isEmpty() && Now->isEmpty() &&
-	   getCharacter()->CanMoveForDistance(Now->getdistance_barrier())){
+	   getCharacter()->canMoveForDistance(Now->getdistance_barrier())){
     	Now->setisMoveAble(isReached);
     }
 }
@@ -287,10 +274,6 @@ void Cell::updateUnMovealeCells_(std::queue<Cell*> & Q) {
 	}
 }
 
-void Cell::print() {
-	std::cout << "(" << col_ << ", " << row_ << ")";
-}
-
 Cell* Cell::getRealShootTarget(Cell* next){
 	if(next == this){
 		return next;
@@ -339,4 +322,4 @@ Cell* Cell::getRealShootTarget(Cell* next){
 		if(next_row < row_main_diag)return getrightDown();
 		return getright();
 	}
-}
+}

+ 1 - 0
source/units/unit.cpp

@@ -1,5 +1,6 @@
 #include "abstractfactory.h"
 #include "units/unit.h"
+#include "Cell.h"
 
 #include <iostream>
 #include <algorithm>