[Orxonox-commit 7508] r12114 - code/branches/wagnis_HS18/src/modules/wagnis

stadlero at orxonox.net stadlero at orxonox.net
Wed Nov 21 12:03:16 CET 2018


Author: stadlero
Date: 2018-11-21 12:03:16 +0100 (Wed, 21 Nov 2018)
New Revision: 12114

Modified:
   code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
   code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h
Log:
WIP 21 nov

Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc	2018-11-21 11:03:16 UTC (rev 12114)
@@ -1,23 +1,23 @@
+
+
+
 #include "Wagnis.h"
-#include "WagnisGameboard.h"
-#include "WagnisProvince.h"
 
-       
-        RegisterClass(Wagnis);
-        
-        void Wagnis::createGame()       
-        {   
-            //todo
-            void Wagnis::setPlayers()
-            {
-                //todo
-            }        
-            
-            void Wagnis::chooseProvinces()
-            {
-                //todo
-            }   
-        }
 
+
+namespace orxonox{
+
+RegisterClass(Wagnis);
+
+Wagnis::Wagnis(Context* context) : Deathmatch(context){
+    RegisterObject(Wagnis);
+}
+//Destructor
+Wagnis::~Wagnis(){}
+
+
+}
+
+
         
     
\ No newline at end of file

Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h	2018-11-21 11:03:16 UTC (rev 12114)
@@ -1,6 +1,15 @@
+
+
+
+#ifndef Wagnis_h
+#define Wagnis_h
+
+
 #include "WagnisGameboard.h"
 #include "WagnisProvince.h"
+#include "gametypes/Deathmatch.h"
 
+
 /** Die Wagnis Klasse hat die folgenden Aufgaben:
  *  1. Das Spiel erstellen.
  *  - Gameboard initialisieren
@@ -17,25 +26,14 @@
  * 
  **/
 
+
+
 namespace orxonox
 {
-    class _WagnisExport Wagnis : public Deathmatch
+    class /**_WagnisExport**/ Wagnis : public Deathmatch
     {
-        public: 
 
-        // to start the game
-        void createGame();        // creates and links provinces
-
-        
-        // additional checking funtions
-        int troopCounter(int);       // counts how many reinforcements player gets
-        bool attackChecker;     // checks whether an attack move is valid
-                                    // (provinces linked, enough troops, no own province) 
-        bool moveChecker;       // checks whether a troop movement is valid
-                                    // (start and target belong to player, link existing)
-        void attackSimulator;   // calculates outcome of battle 
-        
-    
-    }
-
-}
\ No newline at end of file
+    };
+}
+#endif
+ /* Wagnis_h */
\ No newline at end of file

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h	2018-11-21 11:03:16 UTC (rev 12114)
@@ -36,10 +36,8 @@
         std::string connections_string;
         void initializeNeighbors(std::string);
 
-    
-    private:
+
         std::vector<WagnisProvince*> provs;
-        
         int parse_int(std::string,unsigned int);
     };
 }

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc	2018-11-21 11:03:16 UTC (rev 12114)
@@ -15,14 +15,57 @@
     //Constructor
     WagnisPlayer::WagnisPlayer(Context* context) : HumanPlayer(context){
         RegisterObject(WagnisPlayer);
-        this->origin = nullptr;
-        this->target = nullptr;
         this->gameBoard = nullptr;
+        this->is_active = false;
+        this->origin_province = nullptr;
+        this->target_province = nullptr;
+        this->province_selection_changed = false;
     }
     //Destructor
     WagnisPlayer::~WagnisPlayer(){
 
     }
+    //Tick
+    void WagnisPlayer::tick(float dt){
+        SUPER(WagnisPlayer, tick, dt);
+
+        if(this->is_active){
+            for(WagnisProvince* prov:this->gameBoard->provs){
+                if(prov->getHealth() < prov->getMaxHealth()){
+                    if(prov->getHealth() <= prov->getMaxHealth()-1000.0f){
+                        this->target_province = prov;
+                        this->province_selection_changed = true;
+                    }else{
+                        this->origin_province = prov;
+                        this->province_selection_changed = true;
+                    }
+                }
+            }
+
+            if(this->province_selection_changed && this->origin_province != nullptr && this->target_province != nullptr){
+                this->province_selection_changed = false;
+                switch(gamestage){
+                    case CHOOSE_PROVINCE_STAGE: 
+                    {   
+                        break;
+                    }
+                    case REINFORCEMENT_STAGE:
+                    {
+                        break;
+                    }
+                    case ATTACK_STAGE:{
+                        break;
+                    }
+                    case MOVE_STAGE:{
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+
+
     //Manages a Players turn
     void WagnisPlayer::playerTurn(){
         
@@ -32,11 +75,11 @@
     {
         if (move_type == ATTACK)
         {
-            if (isNeighbour(this->origin, this->target))//TODO: provinces neighbours
+            if (isNeighbour(this->origin_province, this->target_province))//TODO: provinces neighbours
             {
-                if (this->origin->getOwner_ID() == this->Player_ID) //origin belongs to player
+                if (this->origin_province->getOwner_ID() == this->Player_ID) //origin belongs to player
                 {
-                    if (this->target->getOwner_ID() != this->Player_ID)//target belongs to enemy
+                    if (this->target_province->getOwner_ID() != this->Player_ID)//target belongs to enemy
                         return true;
                 }
             }
@@ -44,9 +87,9 @@
 
         if (move_type == MOVE)
         {
-            if (existPath(this->origin, this->target))//TODO: path exists, all belong to same player
+            if (existPath(this->origin_province, this->target_province))//TODO: path exists, all belong to same player
             {
-                if (this->origin->getOwner_ID() == this->Player_ID)//origin belongs to player
+                if (this->origin_province->getOwner_ID() == this->Player_ID)//origin belongs to player
                     return true;
             }
 
@@ -54,13 +97,13 @@
 
         if (move_type == SET_TROOPS)
         {
-            if (this->target->getOwner_ID() == this->Player_ID)//target belongs to player
+            if (this->target_province->getOwner_ID() == this->Player_ID)//target belongs to player
                 return true;
         }
 
         if (move_type == SET_TROOPS_INITIAL)
         {
-            if (this->target->getOwner_ID() == 0)//target belongs to nobody
+            if (this->target_province->getOwner_ID() == 0)//target belongs to nobody
                 return true;
         }
         
@@ -88,9 +131,9 @@
     //checks if provinces are neighbours for move
     bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*)
     {
-        for (unsigned int i = 0; i < this->origin->neighbors.size(); ++i)
+        for (unsigned int i = 0; i < this->origin_province->neighbors.size(); ++i)
         {
-            if (this->target == this->origin->neighbors[i])
+            if (this->target_province == this->origin_province->neighbors[i])
                 return true;
         }
 
@@ -101,13 +144,13 @@
     //checks if path is complete with provinces owned by player
     bool WagnisPlayer::existPath(WagnisProvince*,WagnisProvince*)
     {
-        if (this->origin->getOwner_ID() == this->target->getOwner_ID() && isNeighbour(this->origin, this->target))
+        if (this->origin_province->getOwner_ID() == this->target_province->getOwner_ID() && isNeighbour(this->origin_province, this->target_province))
             return true;
         
-        for (unsigned int i = 0; i < this->origin->neighbors.size(); ++i)
+        for (unsigned int i = 0; i < this->origin_province->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_province->getOwner_ID() == this->origin_province->neighbors[i]->getOwner_ID())
+                return existPath(this->origin_province->neighbors[i], this->target_province);
         }
             
         return false;

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h	2018-11-21 11:03:16 UTC (rev 12114)
@@ -6,6 +6,7 @@
 #ifndef Wagnis_Player_h
 #define Wagnis_Player_h
 
+#include "Wagnis.h"
 #include "OrxonoxPrereqs.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -16,16 +17,18 @@
 #include "infos/HumanPlayer.h"
 
 enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL };
+enum GameStagexyz { CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE };
 
 
 
 namespace orxonox
 {
-    class WagnisPlayer : public HumanPlayer
+    class WagnisPlayer : public HumanPlayer, public Tickable
     {
     public:
         WagnisPlayer(Context*);
         virtual ~WagnisPlayer();
+        void tick(float);
 
         void playerTurn();
         bool checkMove(WagnisProvince*,WagnisProvince*,MoveType);
@@ -34,11 +37,15 @@
         void moveTroops(WagnisProvince*,WagnisProvince*);
         std::string toString();
 
-    private:
+
+
+        GameStagexyz gamestage;
+        bool province_selection_changed;
+        bool is_active;
         int Player_ID;
         WagnisGameboard* gameBoard;
-        WagnisProvince* origin;
-        WagnisProvince* target;
+        WagnisProvince* origin_province;
+        WagnisProvince* target_province;
         bool isNeighbour(WagnisProvince*,WagnisProvince*);
         bool existPath(WagnisProvince*,WagnisProvince*);
     };

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc	2018-11-21 11:03:16 UTC (rev 12114)
@@ -1,3 +1,5 @@
+
+
 #include "WagnisProvince.h"
 #include "core/CoreIncludes.h"
 #include "BulletDynamics/Dynamics/btRigidBody.h"
@@ -33,15 +35,6 @@
 
     }
 
-    //Tick
-    void WagnisProvince::tick(float dt){
-        SUPER(WagnisProvince, tick, dt);
-
-        if(this->health_ < this->maxHealth_){
-            this->health_ = this->maxHealth_;
-            orxout() << "Health test ok" << endl;        }
-    }
-
     //XML Port
     void WagnisProvince::XMLPort(Element& xmlelement,XMLPort::Mode mode){
         SUPER(WagnisProvince, XMLPort, xmlelement, mode);
@@ -106,4 +99,8 @@
     void WagnisProvince::addNeighbor(WagnisProvince* prov){
         neighbors.push_back(prov);
     }
+
+    void WagnisProvince::setBillbardVisibility(bool b){
+        //TODO set visibility of billboard
+    }
 }

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h	2018-11-21 11:01:38 UTC (rev 12113)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h	2018-11-21 11:03:16 UTC (rev 12114)
@@ -21,7 +21,6 @@
     public:
         WagnisProvince(Context*);
         virtual ~WagnisProvince();
-        void tick(float);
 
 
         virtual void XMLPort(Element&,XMLPort::Mode);
@@ -39,9 +38,10 @@
         int getContinent() const;
 
         void addNeighbor(WagnisProvince*);
+        void setBillbardVisibility(bool);
+
+
         std::vector<WagnisProvince*> neighbors;
-
- 
         int owner_ID;
         int troops;
         int ID;



More information about the Orxonox-commit mailing list