[Orxonox-commit 7567] r12170 - code/branches/wagnis_HS18/src/modules/wagnis
stadlero at orxonox.net
stadlero at orxonox.net
Fri Dec 7 17:14:21 CET 2018
Author: stadlero
Date: 2018-12-07 17:14:21 +0100 (Fri, 07 Dec 2018)
New Revision: 12170
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.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
Log:
Reinforcements counter works
Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-12-07 16:13:29 UTC (rev 12169)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-12-07 16:14:21 UTC (rev 12170)
@@ -117,7 +117,7 @@
next->reinforcements = 1;
}else{
//No more troops left to place and player 1 is next.
- next->reinforcements = provincesOfPlayerCounter(1);
+ next->reinforcements = this->reinforcementsCounter(1);
}
}else{
//Player who finished was not the last player
@@ -151,7 +151,13 @@
}else{
this->active_player = 1;
}
- tc = provincesOfPlayerCounter(this->active_player);
+
+ tc = 0;
+ for(WagnisProvince* p: this->gameBoard->provs){
+ if(p->getOwner_ID() == this->active_player){
+ tc++;
+ }
+ }
}while(tc == 0); //Skip players without provinces.
if(player->Player_ID == this->active_player){
@@ -164,7 +170,7 @@
next->gameStage = REINFORCEMENT_STAGE;
this->gameStage = REINFORCEMENT_STAGE;
next->setActive(true);
- next->reinforcements = tc;
+ next->reinforcements = reinforcementsCounter(next->Player_ID);
}
break;
@@ -185,6 +191,7 @@
}
this->gameBoard->initializeNeighbors();
+ this->gameBoard->initializeContinents();
orxout() << "Game creation finished" << endl;
}
@@ -214,7 +221,7 @@
return n;
}
-int Wagnis::provincesOfPlayerCounter(int player){
+int Wagnis::reinforcementsCounter(int player){
int n = 0;
for(WagnisProvince* p:this->gameBoard->provs){
if(p != nullptr){
@@ -225,21 +232,39 @@
orxout()<<"Nullpointer found in provinces!!!"<<endl;
}
}
- return n;
-}
+ n = n/3;
+ if(n<3)n=3;
+ int i = 0;
+ bool b = true;
+ for(std::vector<WagnisProvince*>* cont_vec:this->gameBoard->continents){
+ for(WagnisProvince* p: *(cont_vec)){
+ if(p->getOwner_ID() != player) b = false;
+ }
+ if(b) n += this->getContinentValue(i);
+ b = true; i++;
+ }
+ return n;
+}
+int Wagnis::getContinentValue(int cont){
+ switch(cont){
+ case 1: return 7;
+ case 2: return 5;
+ case 3: return 5;
+ case 4: return 3;
+ case 5: return 2;
+ case 6: return 2;
+ default: return 0;
+ }
+ return 0;
+}
-
-
-
-
-
}
Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h 2018-12-07 16:13:29 UTC (rev 12169)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h 2018-12-07 16:14:21 UTC (rev 12170)
@@ -51,7 +51,8 @@
void createGame();
bool findGameBoard();
int provinceCount();
- int provincesOfPlayerCounter(int);
+ int reinforcementsCounter(int);
+ int getContinentValue(int);
};
}
#endif
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc 2018-12-07 16:13:29 UTC (rev 12169)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc 2018-12-07 16:14:21 UTC (rev 12170)
@@ -13,7 +13,11 @@
RegisterObject(WagnisGameboard);
this->connections_string = "";
}
- WagnisGameboard::~WagnisGameboard(){}
+ WagnisGameboard::~WagnisGameboard(){
+ for(std::vector<WagnisProvince*>* vec: this->continents){
+ delete vec;
+ }
+ }
void WagnisGameboard::XMLPort(Element& xmlelement,XMLPort::Mode mode){
SUPER(WagnisGameboard, XMLPort, xmlelement, mode);
@@ -106,6 +110,24 @@
}
}
+ void WagnisGameboard::initializeContinents(){
+ int maxconts=0;
+ for(WagnisProvince* p:this->provs){
+ if(p->getContinent() > maxconts){
+ maxconts = p->getContinent();
+ }
+ }
+ for(int i=0;i<=maxconts;i++){
+ this->continents.push_back(new std::vector<WagnisProvince*>());
+ for(WagnisProvince* p:this->provs){
+ if(p->getContinent() == i){
+ this->continents[i]->push_back(p);
+ }
+ }
+ orxout()<<"There are "<<this->continents[i]->size()<<" Provinces in Continent "<< i << endl;
+ }
+ }
+
//Returns the parsed int and the offset encoded in an int. the upper 16bit(incl MSB) is the number
//and the lower 16 bits is the new n(after the last digit)
int WagnisGameboard::parse_int(std::string str,unsigned int n){
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h 2018-12-07 16:13:29 UTC (rev 12169)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h 2018-12-07 16:14:21 UTC (rev 12170)
@@ -36,11 +36,13 @@
//XML end
void initializeNeighbors();
+ void initializeContinents();
std::string connections_string;
std::vector<WagnisProvince*> provs;
+ std::vector<std::vector<WagnisProvince*>*> continents;
int parse_int(std::string,unsigned int);
};
}
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc 2018-12-07 16:13:29 UTC (rev 12169)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc 2018-12-07 16:14:21 UTC (rev 12170)
@@ -22,7 +22,7 @@
this->setRadarName("");
this->setRadarObjectColour(colour({128,128,128}, 100.0f));
this->ID = -1;
- this->continent = -1;
+ this->continent = 0;
this->neighbors = std::vector<WagnisProvince*>();
this->initialHealth_ = WAGNIS_PROVINCE_MAX_HEALTH;
More information about the Orxonox-commit
mailing list