[Orxonox-commit 7560] r12163 - code/branches/wagnis_HS18/src/modules/wagnis

stadlero at orxonox.net stadlero at orxonox.net
Wed Dec 5 21:57:36 CET 2018


Author: stadlero
Date: 2018-12-05 21:57:36 +0100 (Wed, 05 Dec 2018)
New Revision: 12163

Modified:
   code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUDinfo.cc
   code/branches/wagnis_HS18/src/modules/wagnis/WagnisPrereqs.h
Log:
Added winning-stage

Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc	2018-12-05 20:08:38 UTC (rev 12162)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc	2018-12-05 20:57:36 UTC (rev 12163)
@@ -144,17 +144,29 @@
         }
         case MOVE_STAGE:{
             player->setActive(false);
-            if(this->active_player < this->players.size()){
-                this->active_player++;
+            int tc;
+            do{
+                if(this->active_player < this->players.size()){
+                    this->active_player++;
+                }else{
+                    this->active_player = 1;
+                }
+                tc = provincesOfPlayerCounter(this->active_player);
+            }while(tc == 0); //Skip players without provinces.
+
+            if(player->Player_ID == this->active_player){
+                //If all players except one got skipped, we got a winner
+                this->gameStage = WINNER_STAGE;
+                player->gameStage = WINNER_STAGE;
             }else{
-                this->active_player = 1;
+                WagnisPlayer* next = this->players[this->active_player - 1];
+                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement."<<endl;
+                next->gameStage = REINFORCEMENT_STAGE;
+                this->gameStage = REINFORCEMENT_STAGE;
+                next->setActive(true);
+                next->reinforcements = tc;
             }
-            WagnisPlayer* next = this->players[this->active_player - 1];
-            orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement."<<endl;
-            next->gameStage = REINFORCEMENT_STAGE;
-            this->gameStage = REINFORCEMENT_STAGE;
-            next->setActive(true);
-            next->reinforcements = provincesOfPlayerCounter(next->Player_ID);
+            
             break;
         }
         default:{}

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUDinfo.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUDinfo.cc	2018-12-05 20:08:38 UTC (rev 12162)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUDinfo.cc	2018-12-05 20:57:36 UTC (rev 12163)
@@ -97,6 +97,12 @@
                 setCaption( ss.str() );
                 break;
             }
+            case WINNER_STAGE: {
+                ss<<"PLAYER "<<wagnisgame->active_player<<" WINS!!!";
+                setCaption( ss.str() );
+                break;
+            }
+            default: {}
         }
     }
     void WagnisHUDinfo::findWagnis(){

Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPrereqs.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPrereqs.h	2018-12-05 20:08:38 UTC (rev 12162)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPrereqs.h	2018-12-05 20:57:36 UTC (rev 12163)
@@ -71,7 +71,7 @@
     class WagnisPlayer;
     class WagnisHUD;
     class WagnisHUDinfo;
-    enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE };
+    enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE, WINNER_STAGE };
     enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL };
 
 }



More information about the Orxonox-commit mailing list