Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2018, 5:14:21 PM (7 years ago)
Author:
stadlero
Message:

Reinforcements counter works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc

    r12163 r12170  
    118118                    }else{
    119119                        //No more troops left to place and player 1 is next.
    120                         next->reinforcements = provincesOfPlayerCounter(1);
     120                        next->reinforcements = this->reinforcementsCounter(1);
    121121                    }
    122122                }else{
     
    152152                    this->active_player = 1;
    153153                }
    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                }
    155161            }while(tc == 0); //Skip players without provinces.
    156162
     
    165171                this->gameStage = REINFORCEMENT_STAGE;
    166172                next->setActive(true);
    167                 next->reinforcements = tc;
     173                next->reinforcements = reinforcementsCounter(next->Player_ID);
    168174            }
    169175           
     
    186192
    187193    this->gameBoard->initializeNeighbors();
     194    this->gameBoard->initializeContinents();
    188195   
    189196    orxout() << "Game creation finished" << endl;
     
    215222}
    216223
    217 int Wagnis::provincesOfPlayerCounter(int player){
     224int Wagnis::reinforcementsCounter(int player){
    218225    int n = 0;
    219226    for(WagnisProvince* p:this->gameBoard->provs){
     
    226233        }
    227234    }
     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
    228251    return n;
    229252}
    230253
    231 
    232 
    233 
    234 
    235 
    236 
    237 
    238 
    239 
    240 
     254int 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}
    241266
    242267
Note: See TracChangeset for help on using the changeset viewer.