Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 29, 2018, 7:22:46 PM (5 years ago)
Author:
stadlero
Message:

Wagnis runs without crashing on startup

File:
1 edited

Legend:

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

    r12130 r12132  
    1818
    1919    int n = 3;
    20     this->players.push_back(nullptr);
    21     for(int i = 1;i <= n;i++){
     20    for(int i = 0;i < n;i++){
    2221        WagnisPlayer* p = new WagnisPlayer(context);
    23         p->gameBoard = this->gameBoard;
    24         p->Player_ID = i;
     22        p->Player_ID = i+1;
    2523        p->master = this;
    26         //p->finishedStageCallback = &Wagnis::playerFinishedStage;
    2724        this->players.push_back(p);
    2825    }
     
    3734    if(this->gameStage == NOT_READY){
    3835        this->createGame();
     36
     37        for(WagnisPlayer* ptr: this->players){
     38            ptr->gameBoard = this->gameBoard;
     39        }
    3940    }
    4041
    41     //this->gameStage = CHOOSE_PROVINCE_STAGE;
    42     //this->players[1]->gameStage = this->gameStage;
    43     //this->players[1]->is_active = true;
     42    this->gameStage = CHOOSE_PROVINCE_STAGE;
     43    this->players.at(0)->gameStage = this->gameStage;
     44    this->players.at(0)->is_active = true;
    4445}
    4546
     
    5758 * enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE };
    5859 **/
    59 void Wagnis::playerFinishedStage(WagnisPlayer* player){
    60 
    61     /////////////////TEST////////////
    62     orxout()<<"juhuuuuuuuuuuuuuuuuuuu"<<endl;
    63     /////////////////TEST////////////
     60void Wagnis::playerFinishedStageCallback(WagnisPlayer* player){
    6461
    6562    if(this->active_player != player->Player_ID){
     
    6966        case CHOOSE_PROVINCE_STAGE:{
    7067            player->is_active = false;
    71             if(this->active_player+1 < this->players.size()){
     68            if(this->active_player < this->players.size()){
    7269                this->active_player++;
    73                 this->players[this->active_player]->gameStage = CHOOSE_PROVINCE_STAGE;
    74                 this->players[this->active_player]->is_active = true;
     70                WagnisPlayer* next = this->players[this->active_player-1];
     71                next->gameStage = CHOOSE_PROVINCE_STAGE;
     72                next->is_active = true;
     73                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Please choose province"<<endl;
    7574            }else{
    7675                this->active_player = 1;
    77                 this->players[this->active_player]->gameStage = REINFORCEMENT_STAGE;
    78                 this->players[this->active_player]->is_active = true;
     76                WagnisPlayer* next = this->players[this->active_player-1];
     77                next->gameStage = REINFORCEMENT_STAGE;
     78                this->gameStage = REINFORCEMENT_STAGE;
     79                next->is_active = true;
     80                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement"<<endl;
    7981            }
    8082            break;
    8183        }
    8284        case REINFORCEMENT_STAGE:{
    83            
     85            break;
    8486        }
    8587        case ATTACK_STAGE:{
    86            
     88            break;
    8789        }
    8890        case MOVE_STAGE:{
    89            
     91            break;
    9092        }
     93        default:{}
    9194    }
    9295}
Note: See TracChangeset for help on using the changeset viewer.