- Timestamp:
- Dec 7, 2018, 5:14:21 PM (6 years ago)
- Location:
- code/branches/wagnis_HS18/src/modules/wagnis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
r12163 r12170 118 118 }else{ 119 119 //No more troops left to place and player 1 is next. 120 next->reinforcements = provincesOfPlayerCounter(1);120 next->reinforcements = this->reinforcementsCounter(1); 121 121 } 122 122 }else{ … … 152 152 this->active_player = 1; 153 153 } 154 tc = provincesOfPlayerCounter(this->active_player); 154 155 tc = 0; 156 for(WagnisProvince* p: this->gameBoard->provs){ 157 if(p->getOwner_ID() == this->active_player){ 158 tc++; 159 } 160 } 155 161 }while(tc == 0); //Skip players without provinces. 156 162 … … 165 171 this->gameStage = REINFORCEMENT_STAGE; 166 172 next->setActive(true); 167 next->reinforcements = tc;173 next->reinforcements = reinforcementsCounter(next->Player_ID); 168 174 } 169 175 … … 186 192 187 193 this->gameBoard->initializeNeighbors(); 194 this->gameBoard->initializeContinents(); 188 195 189 196 orxout() << "Game creation finished" << endl; … … 215 222 } 216 223 217 int Wagnis:: provincesOfPlayerCounter(int player){224 int Wagnis::reinforcementsCounter(int player){ 218 225 int n = 0; 219 226 for(WagnisProvince* p:this->gameBoard->provs){ … … 226 233 } 227 234 } 235 236 n = n/3; 237 if(n<3)n=3; 238 239 int i = 0; 240 bool b = true; 241 242 for(std::vector<WagnisProvince*>* cont_vec:this->gameBoard->continents){ 243 for(WagnisProvince* p: *(cont_vec)){ 244 if(p->getOwner_ID() != player) b = false; 245 } 246 247 if(b) n += this->getContinentValue(i); 248 b = true; i++; 249 } 250 228 251 return n; 229 252 } 230 253 231 232 233 234 235 236 237 238 239 240 254 int Wagnis::getContinentValue(int cont){ 255 switch(cont){ 256 case 1: return 7; 257 case 2: return 5; 258 case 3: return 5; 259 case 4: return 3; 260 case 5: return 2; 261 case 6: return 2; 262 default: return 0; 263 } 264 return 0; 265 } 241 266 242 267 -
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
r12157 r12170 52 52 bool findGameBoard(); 53 53 int provinceCount(); 54 int provincesOfPlayerCounter(int); 54 int reinforcementsCounter(int); 55 int getContinentValue(int); 55 56 }; 56 57 } -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc
r12160 r12170 14 14 this->connections_string = ""; 15 15 } 16 WagnisGameboard::~WagnisGameboard(){} 16 WagnisGameboard::~WagnisGameboard(){ 17 for(std::vector<WagnisProvince*>* vec: this->continents){ 18 delete vec; 19 } 20 } 17 21 18 22 void WagnisGameboard::XMLPort(Element& xmlelement,XMLPort::Mode mode){ … … 107 111 } 108 112 113 void WagnisGameboard::initializeContinents(){ 114 int maxconts=0; 115 for(WagnisProvince* p:this->provs){ 116 if(p->getContinent() > maxconts){ 117 maxconts = p->getContinent(); 118 } 119 } 120 for(int i=0;i<=maxconts;i++){ 121 this->continents.push_back(new std::vector<WagnisProvince*>()); 122 for(WagnisProvince* p:this->provs){ 123 if(p->getContinent() == i){ 124 this->continents[i]->push_back(p); 125 } 126 } 127 orxout()<<"There are "<<this->continents[i]->size()<<" Provinces in Continent "<< i << endl; 128 } 129 } 130 109 131 //Returns the parsed int and the offset encoded in an int. the upper 16bit(incl MSB) is the number 110 132 //and the lower 16 bits is the new n(after the last digit) -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h
r12124 r12170 37 37 38 38 void initializeNeighbors(); 39 void initializeContinents(); 39 40 40 41 … … 42 43 std::string connections_string; 43 44 std::vector<WagnisProvince*> provs; 45 std::vector<std::vector<WagnisProvince*>*> continents; 44 46 int parse_int(std::string,unsigned int); 45 47 }; -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
r12160 r12170 23 23 this->setRadarObjectColour(colour({128,128,128}, 100.0f)); 24 24 this->ID = -1; 25 this->continent = -1;25 this->continent = 0; 26 26 this->neighbors = std::vector<WagnisProvince*>(); 27 27
Note: See TracChangeset
for help on using the changeset viewer.