Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12170


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

Reinforcements counter works

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  
    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
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h

    r12157 r12170  
    5252        bool findGameBoard();
    5353        int provinceCount();
    54         int provincesOfPlayerCounter(int);
     54        int reinforcementsCounter(int);
     55        int getContinentValue(int);
    5556    };
    5657}
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.cc

    r12160 r12170  
    1414        this->connections_string = "";
    1515    }
    16     WagnisGameboard::~WagnisGameboard(){}
     16    WagnisGameboard::~WagnisGameboard(){
     17        for(std::vector<WagnisProvince*>* vec: this->continents){
     18            delete vec;
     19        }
     20    }
    1721
    1822    void WagnisGameboard::XMLPort(Element& xmlelement,XMLPort::Mode mode){
     
    107111    }
    108112
     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
    109131    //Returns the parsed int and the offset encoded in an int. the upper 16bit(incl MSB) is the number
    110132    //and the lower 16 bits is the new n(after the last digit)
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h

    r12124 r12170  
    3737       
    3838        void initializeNeighbors();
     39        void initializeContinents();
    3940
    4041
     
    4243        std::string connections_string;
    4344        std::vector<WagnisProvince*> provs;
     45        std::vector<std::vector<WagnisProvince*>*> continents;
    4446        int parse_int(std::string,unsigned int);
    4547    };
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc

    r12160 r12170  
    2323        this->setRadarObjectColour(colour({128,128,128}, 100.0f));
    2424        this->ID = -1;
    25         this->continent = -1;
     25        this->continent = 0;
    2626        this->neighbors = std::vector<WagnisProvince*>();
    2727       
Note: See TracChangeset for help on using the changeset viewer.