[Orxonox-commit 7499] r12105 - code/branches/wagnis_HS18/src/modules/wagnis

samuelbl at orxonox.net samuelbl at orxonox.net
Wed Nov 14 11:58:59 CET 2018


Author: samuelbl
Date: 2018-11-14 11:58:59 +0100 (Wed, 14 Nov 2018)
New Revision: 12105

Modified:
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
Log:
Player update

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc	2018-11-14 09:43:18 UTC (rev 12104)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc	2018-11-14 10:58:59 UTC (rev 12105)
@@ -67,20 +67,6 @@
         return false;
     }
     
-    //TODO
-    bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*)
-    {
-        for ()
-        
-        return false;
-    }
-
-    //TODO
-    bool WagnisPlayer::existPath(WagnisProvince*,WagnisProvince*)
-    {
-        return false;
-    }
-    
     //
     void WagnisPlayer::setTroops(WagnisProvince*){
 
@@ -100,11 +86,11 @@
 
     //private function for CheckMove
     //checks if provinces are neighbours for move
-    bool isNeighbour(WagnisProvince*,WagnisProvince*)
+    bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*)
     {
-        for (int i = 0; i < this->origin->getNeighbours().size(); ++i)
+        for (int i = 0; i < this->origin->neighbors.size(); ++i)
         {
-            if (this->target == this->origin->getNeighbours()(i))
+            if (this->target == this->origin->neighbors(i))
                 return true;
         }
 
@@ -113,8 +99,17 @@
 
     //private function for CheckMove
     //checks if path is complete with provinces owned by player
-    bool existPath(WagnisProvince*,WagnisProvince*)
+    bool WagnisPlayer::existPath(WagnisProvince*,WagnisProvince*)
     {
-        WagnisProvince
+        if (this->origin->getOwner_ID() == this->target->getOwner_ID() && isNeighbour(this->origin, this->target))
+            return true;
+        
+        for (int i = 0; i < this->origin->neighbors.size(); ++i)
+        {
+            if (this->origin->getOwner_ID() == this->origin->neighbors(i)->getOwner_ID())
+                return existPath(this->origin->neighbors(i), this->target);
+        }
+            
+        return false;
     }
 }

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h	2018-11-14 09:43:18 UTC (rev 12104)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h	2018-11-14 10:58:59 UTC (rev 12105)
@@ -39,7 +39,7 @@
         WagnisProvince* origin;
         WagnisProvince* target;
         bool isNeighbour(WagnisProvince*,WagnisProvince*);
-        bool existPath(WagnisProvince*,WagnisProvince*)
+        bool existPath(WagnisProvince*,WagnisProvince*);
     };
 }
 



More information about the Orxonox-commit mailing list