Forráskód Böngészése

added function getPoints. deleted printAll

GeorgeKolog 6 éve
szülő
commit
e6b4331e48

+ 3 - 2
include/cell.h

@@ -2,6 +2,7 @@
 #include <queue>
 #include <vector>
 #include <iostream>
+#include <list>
 /*
  * Решили, что метод canAttackForDistance(int) имеет шаблон, который обозначает тип атаки
  * Melee - без учёта препятствий
@@ -144,6 +145,6 @@ public:
 	 * Выполнится только с лучае, если эта следующая клетка существует
 	 * Gi1dor знает, что это такое
 	 */
-	Cell* getRealShootTarget(Cell*);
-    void print();
+    std::list<std::pair<double, double> > getPoints(double, std::pair<double, double>);
+    Cell* getRealShootTarget(Cell*);
 };

+ 0 - 2
include/hotseatgame/gamemanager.h

@@ -11,8 +11,6 @@ private:
     std::vector< std::vector< Cell* > > game_table_;
     int col_table_size_, row_table_size_;
     void generateTable();
-    void printAll();
-
     /******************************/
     UnitsQueue turn_queue_;
     PlayerManager* player_manager_;

+ 16 - 5
source/cell.cpp

@@ -8,6 +8,7 @@
 #include <vector>
 #include <map>
 #include <iostream>
+#include <cmath>
 
 class EffectsForCell{
 public:
@@ -203,7 +204,7 @@ void Cell::clearTable_() {
 }
 
 void Cell::recalcAttackable_(Cell * Now,bool isReached){
-   /* if(Now == nullptr)return;
+    if(Now == nullptr)return;
     if (!isEmpty() && !Now->isEmpty() &&
         getCharacter()->canAttackForDistance("Melee", Now->getdistance_barrier())
             ) {
@@ -213,7 +214,7 @@ void Cell::recalcAttackable_(Cell * Now,bool isReached){
         getCharacter()->canAttackForDistance("Range", Now->getdistance_barrier())
             ) {
         Now->setisRangeAttackAble(true);
-    }*/
+    }
     return;
 }
 
@@ -260,6 +261,7 @@ void Cell::updateMoveableCells_(std::queue<Cell*> & Q) {
 void Cell::updateUnMovealeCells_(std::queue<Cell*> & Q) {
 	auto f = [&Q](Cell * t, Cell * parent) {
 		if (t && !t->AddedToQuery_) {
+            parent->getCharacter();
 			t->AddedToQuery_ = true;
 			Q.push(t);
 		}
@@ -328,7 +330,16 @@ Cell* Cell::getRealShootTarget(Cell* next){
 	}
 }
 
-void Cell::print(){
-    return;
-    //do nothing, need content
+std::list<std::pair<double, double> > Cell::getPoints(double radius, std::pair<double, double> center){
+    const double delta_radians = acos(-1) / 180.0;
+
+    std::list<std::pair<double, double> > res;
+    res.push_back({center.first + radius * std::cos(30.0 * delta_radians), center.second + radius * std::sin(30.0 * delta_radians)});
+    res.push_back({center.first + radius * std::cos(90.0 * delta_radians), center.second + radius * std::sin(90.0 * delta_radians)});
+    res.push_back({center.first + radius * std::cos(150.0 * delta_radians), center.second + radius * std::sin(150.0 * delta_radians)});
+    res.push_back({center.first + radius * std::cos(210.0 * delta_radians), center.second + radius * std::sin(210.0 * delta_radians)});
+    res.push_back({center.first + radius * std::cos(270.0 * delta_radians), center.second + radius * std::sin(270.0 * delta_radians)});
+    res.push_back({center.first + radius * std::cos(330.0 * delta_radians), center.second + radius * std::sin(330.0 * delta_radians)});
+    return res;
 }
+

+ 0 - 10
source/hotseatgame/gamemanager.cpp

@@ -50,16 +50,6 @@ void GameManager::generateTable() {
     }
 }
 
-void GameManager::printAll() {
-    game_table_[0][0]->RecalculateTableWithCenterThisPoint();
-    for (int col = 0; col < col_table_size_; ++col) {
-        for (int row = 0; row < row_table_size_; ++row) {
-            game_table_[col][row]->print();
-        }
-        std::cout << std::endl;
-    }
-}
-
 UnitsQueue* GameManager::getTurnQueue(){
     return &turn_queue_;
 }