Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2018, 9:57:36 PM (6 years ago)
Author:
stadlero
Message:

Added winning-stage

File:
1 edited

Legend:

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

    r12162 r12163  
    145145        case MOVE_STAGE:{
    146146            player->setActive(false);
    147             if(this->active_player < this->players.size()){
    148                 this->active_player++;
     147            int tc;
     148            do{
     149                if(this->active_player < this->players.size()){
     150                    this->active_player++;
     151                }else{
     152                    this->active_player = 1;
     153                }
     154                tc = provincesOfPlayerCounter(this->active_player);
     155            }while(tc == 0); //Skip players without provinces.
     156
     157            if(player->Player_ID == this->active_player){
     158                //If all players except one got skipped, we got a winner
     159                this->gameStage = WINNER_STAGE;
     160                player->gameStage = WINNER_STAGE;
    149161            }else{
    150                 this->active_player = 1;
    151             }
    152             WagnisPlayer* next = this->players[this->active_player - 1];
    153             orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement."<<endl;
    154             next->gameStage = REINFORCEMENT_STAGE;
    155             this->gameStage = REINFORCEMENT_STAGE;
    156             next->setActive(true);
    157             next->reinforcements = provincesOfPlayerCounter(next->Player_ID);
     162                WagnisPlayer* next = this->players[this->active_player - 1];
     163                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement."<<endl;
     164                next->gameStage = REINFORCEMENT_STAGE;
     165                this->gameStage = REINFORCEMENT_STAGE;
     166                next->setActive(true);
     167                next->reinforcements = tc;
     168            }
     169           
    158170            break;
    159171        }
Note: See TracChangeset for help on using the changeset viewer.