[Orxonox-commit 7503] r12109 - code/branches/wagnis_HS18/src/modules/wagnis

stadlero at orxonox.net stadlero at orxonox.net
Wed Nov 21 10:19:21 CET 2018


Author: stadlero
Date: 2018-11-21 10:19:21 +0100 (Wed, 21 Nov 2018)
New Revision: 12109

Modified:
   code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
Log:
Player class does now compile

Modified: code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt	2018-11-21 08:32:15 UTC (rev 12108)
+++ code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt	2018-11-21 09:19:21 UTC (rev 12109)
@@ -1,6 +1,7 @@
 SET_SOURCE_FILES(WAGNIS_SRC_FILES
   WagnisProvince.cc
   WagnisGameboard.cc
+  WagnisPlayer.cc
 )
 
 ORXONOX_ADD_LIBRARY(wagnis

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc	2018-11-21 08:32:15 UTC (rev 12108)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc	2018-11-21 09:19:21 UTC (rev 12109)
@@ -13,11 +13,11 @@
     RegisterClass(WagnisPlayer);
 
     //Constructor
-    WagnisPlayer::WagnisPlayer(Context* context,WagnisGameboard* gb) : Baseclass(context){
+    WagnisPlayer::WagnisPlayer(Context* context) : HumanPlayer(context){
         RegisterObject(WagnisPlayer);
         this->origin = nullptr;
         this->target = nullptr;
-        this->gameBoard = gb;
+        this->gameBoard = nullptr;
     }
     //Destructor
     WagnisPlayer::~WagnisPlayer(){
@@ -28,9 +28,9 @@
         
     }
     //checks if a move is valid, possible MoveTypes: ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL
-    bool WagnisPlayer::checkMove(WagnisProvince*,WagnisProvince*,MoveType)
+    bool WagnisPlayer::checkMove(WagnisProvince*,WagnisProvince*,MoveType move_type)
     {
-        if (MoveType == ATTACK)
+        if (move_type == ATTACK)
         {
             if (isNeighbour(this->origin, this->target))//TODO: provinces neighbours
             {
@@ -42,7 +42,7 @@
             }
         }
 
-        if (MoveType == MOVE)
+        if (move_type == MOVE)
         {
             if (existPath(this->origin, this->target))//TODO: path exists, all belong to same player
             {
@@ -52,13 +52,13 @@
 
         }
 
-        if (MoveType == SET_Troops)
+        if (move_type == SET_TROOPS)
         {
             if (this->target->getOwner_ID() == this->Player_ID)//target belongs to player
                 return true;
         }
 
-        if (MoveType == SET_TROOPS_INITIAL)
+        if (move_type == SET_TROOPS_INITIAL)
         {
             if (this->target->getOwner_ID() == 0)//target belongs to nobody
                 return true;
@@ -80,7 +80,7 @@
     //Return a "Player x" String
     std::string WagnisPlayer::toString(){
         std::string str = "Player ";
-        str.append(std::to_string(Player_ID);
+        str.append(std::to_string(Player_ID));
         return str;
     }
 
@@ -88,9 +88,9 @@
     //checks if provinces are neighbours for move
     bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*)
     {
-        for (int i = 0; i < this->origin->neighbors.size(); ++i)
+        for (unsigned int i = 0; i < this->origin->neighbors.size(); ++i)
         {
-            if (this->target == this->origin->neighbors(i))
+            if (this->target == this->origin->neighbors[i])
                 return true;
         }
 
@@ -104,10 +104,10 @@
         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)
+        for (unsigned 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);
+            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-21 08:32:15 UTC (rev 12108)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h	2018-11-21 09:19:21 UTC (rev 12109)
@@ -13,6 +13,7 @@
 #include "WagnisGameboard.h"
 #include <vector>
 #include <string>
+#include "infos/HumanPlayer.h"
 
 enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL };
 
@@ -20,10 +21,10 @@
 
 namespace orxonox
 {
-    class WagnisPlayer : public BaseClass
+    class WagnisPlayer : public HumanPlayer
     {
     public:
-        WagnisPlayer(Context*,WagnisGameboard*);
+        WagnisPlayer(Context*);
         virtual ~WagnisPlayer();
 
         void playerTurn();



More information about the Orxonox-commit mailing list