Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12150


Ignore:
Timestamp:
Dec 5, 2018, 11:54:14 AM (6 years ago)
Author:
stadlero
Message:

Game progression finished. still bugs.

Location:
code/branches/wagnis_HS18
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wagnis_HS18/data/levels/Wagnis_testlevel.oxw

    r12136 r12150  
    3232    <SpawnPoint position="-100, 45, 75" lookat="0,45,75" spawnclass=SpaceShip pawndesign=wagnisCursor />
    3333
    34 <WagnisGameboard position="20,20,20" connections_string="1=2+3, 2=1, 3=1">
     34<WagnisGameboard position="20,20,20" connections_string="1=2+4+5, 2=1+3, 3=2+4, 4=3+1, 5=1+6, 6=7+5, 7=6+8, 8=7">
    3535
    3636
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc

    r12136 r12150  
    1616    this->gameStage = NOT_READY;
    1717    this->active_player = 1;
    18 
    19     int n = 8;
     18    this->initial_reinforcements_left = 5;
     19    this->empty_provinces_left = 0;
     20
     21    int n = 3;
    2022    for(int i = 0;i < n;i++){
    2123        WagnisPlayer* p = new WagnisPlayer(context);
     
    4143
    4244    this->gameStage = CHOOSE_PROVINCE_STAGE;
     45    this->empty_provinces_left = this->provinceCount();
    4346    this->players.at(0)->gameStage = this->gameStage;
    44     this->players.at(0)->is_active = true;
     47    this->players.at(0)->setActive(true);
     48    this->players.at(0)->reinforcements = 0;
    4549    orxout()<<"Player "<<1<<"\'s turn. Please choose province."<<endl;
    4650}
     
    6670    switch(this->gameStage){
    6771        case CHOOSE_PROVINCE_STAGE:{
    68             player->is_active = false;
    69             if(this->active_player < this->players.size()){
    70                 this->active_player++;
     72            player->setActive(false);
     73            this->empty_provinces_left -= 1;
     74            if(this->empty_provinces_left > 0){
     75                //Still empty provinces left
     76                orxout()<<"DEBUG: Empty provs: "<<this->empty_provinces_left<<endl;
     77
     78                if(this->active_player < this->players.size()){
     79                    this->active_player++;
     80                }else{
     81                    this->active_player = 1;
     82                }
     83
    7184                WagnisPlayer* next = this->players[this->active_player - 1];
    7285                next->gameStage = CHOOSE_PROVINCE_STAGE;
    73                 next->is_active = true;
     86                next->setActive(true);
     87                next->reinforcements = 0;
    7488                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Please choose province."<<endl;
    7589            }else{
     90                //no empty provinces left
     91                orxout()<<"DEBUG: Empty provs: "<<this->empty_provinces_left<<endl;
    7692                this->active_player = 1;
    7793                WagnisPlayer* next = this->players[this->active_player - 1];
    7894                next->gameStage = REINFORCEMENT_STAGE;
    7995                this->gameStage = REINFORCEMENT_STAGE;
    80                 next->is_active = true;
     96                next->setActive(true);
     97                next->reinforcements = 1;
    8198                orxout()<<"Player "<<next->Player_ID<<"\'s turn. Reinforcement."<<endl;
    8299            }
     
    84101        }
    85102        case REINFORCEMENT_STAGE:{
     103           
     104            if(this->initial_reinforcements_left > 0){
     105                player->setActive(false);
     106                if(this->active_player == this->players.size()){
     107                    //Last player finished this round of initial troops.
     108                    this->initial_reinforcements_left -= 1;
     109                    WagnisPlayer* next = this->players.at(0);
     110                    this->active_player = 1;
     111                    next->setActive(true);
     112                    next->gameStage = REINFORCEMENT_STAGE;
     113                    if(this->initial_reinforcements_left > 0){
     114                        //Still more troops left to place and player 1 is next.
     115                        next->reinforcements = 1;
     116                    }else{
     117                        //No more troops left to place and player 1 is next.
     118                        next->reinforcements = provincesOfPlayerCounter(1);
     119                    }
     120                }else{
     121                    //Player who finished was not the last player
     122                    WagnisPlayer* next = this->players.at(this->active_player);
     123                    this->active_player += 1;
     124                    next->setActive(true);
     125                    next->gameStage = REINFORCEMENT_STAGE;
     126                    next->reinforcements = 1;
     127                }
     128                break;
     129            }
     130            //Standard Reinforcement
     131
    86132            player->gameStage = ATTACK_STAGE;
    87133            this->gameStage = ATTACK_STAGE;
     
    96142        }
    97143        case MOVE_STAGE:{
    98             player->is_active = false;
     144            player->setActive(false);
    99145            if(this->active_player < this->players.size()){
    100146                this->active_player++;
     
    106152            next->gameStage = REINFORCEMENT_STAGE;
    107153            this->gameStage = REINFORCEMENT_STAGE;
    108             next->is_active = true;
     154            next->setActive(true);
    109155            break;
    110156        }
     
    143189}
    144190
     191//Counts legit provinces(not including buttons)
     192int Wagnis::provinceCount(){
     193    int n = 0;
     194    for(WagnisProvince* p: this->gameBoard->provs){
     195        if(p != nullptr){
     196            if(p->ID < 1000){
     197                n++;
     198            }
     199        }else{
     200            orxout()<<"Nullpointer found in provines!!!"<<endl;
     201        }
     202    }
     203    return n;
     204}
     205
     206int Wagnis::provincesOfPlayerCounter(int player){
     207    int n = 0;
     208    for(WagnisProvince* p:this->gameBoard->provs){
     209        if(p != nullptr){
     210            if(p->getOwner_ID() == player){
     211                n++;
     212            }
     213        }else{
     214            orxout()<<"Nullpointer found in provines!!!"<<endl;
     215        }
     216    }
     217    return n;
     218}
     219
    145220
    146221
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h

    r12132 r12150  
    4646        private:
    4747        int active_player;
     48        int initial_reinforcements_left;
     49        int empty_provinces_left;
    4850        GameStage gameStage;
    4951        std::vector<WagnisPlayer*> players;
    5052        void createGame();
    5153        bool findGameBoard();
     54        int provinceCount();
     55        int provincesOfPlayerCounter(int);
    5256    };
    5357}
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc

    r12145 r12150  
    8080                            {
    8181                                this->target_province->setTroops(this->target_province->getTroops()+1);
     82                                this->reinforcements -= 1;
    8283                                orxout()<<"Province "<<this->target_province->getID()<<" owned by Player "<<this->target_province->getOwner_ID()<<" troops: "<<this->target_province->getTroops()<<endl;
    8384                            }
     
    8990
    9091                        if (checkMove(ATTACK))
     92                       
    9193                        {
     94                            orxout()<<"Attack move check returned valid"<<endl;
    9295                            while ((this->origin_province->getTroops() > 1) && (this->target_province->getTroops() > 0)) //still troops available
    9396                            {
     
    199202                                this->origin_province->setTroops(1);
    200203                            }
     204                        }else{
     205                            orxout()<<"Attack move check returned false"<<endl;
    201206                        }
    202207                       
     
    337342            return b;   
    338343    }
     344
     345    void WagnisPlayer::setActive(bool b){
     346        this->is_active = b;
     347        if(b == true) orxout()<<"Player "<<this->Player_ID<<"\'s turn"<<endl;
     348    }
     349
     350    bool WagnisPlayer::isActive() const {
     351        return this->is_active;
     352    }
    339353}
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h

    r12145 r12150  
    3636        void moveTroops(WagnisProvince*,WagnisProvince*);
    3737        std::string toString();
     38        void setActive(bool);
     39        bool isActive() const;
    3840
    3941
     
    4244        GameStage gameStage;
    4345        bool province_selection_changed;
    44         bool is_active;
    4546        int Player_ID;
    4647        WagnisGameboard* gameBoard;
     
    5556        int second3(int, int, int);
    5657        int second2(int, int);
     58
     59        private:
     60        bool is_active;
    5761    };
    5862}
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc

    r12136 r12150  
    5656            case 2: this->setRadarObjectColour( colour({0,255,0}, 100.0f) );
    5757                    break;
    58             case 3: this->setRadarObjectColour( colour({0,0,255}, 100.0f) );
     58            case 3: this->setRadarObjectColour( colour({255,255,0}, 100.0f) );
    5959                    break;
    60             case 4: this->setRadarObjectColour( colour({255,255,0}, 100.0f) );
     60            case 4: this->setRadarObjectColour( colour({0,0,255}, 100.0f) );
    6161                    break;
    6262            case 5: this->setRadarObjectColour( colour({255,0,255}, 100.0f) );
     
    7777        this->troops = troops;
    7878        this->setRadarName(std::to_string(troops));
    79         //TEST
    80         if(troops == 5){
    81             Ogre::ColourValue cv = colour({255,255,255}, 100.0f);
    82             this->setRadarObjectColour(cv);
    83         }
    84        
    8579    }
    8680    //set ID
Note: See TracChangeset for help on using the changeset viewer.