Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 10, 2012, 5:03:16 PM (12 years ago)
Author:
jo
Message:

Adaptions for easier merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pCuts/src/modules/pong/Pong.cc

    r9090 r9285  
    7676        // Set the type of Bots for this particular Gametype.
    7777        this->botclass_ = Class(PongBot);
     78
    7879        this->scoreLimit_ = 10;
    7980        this->setConfigValues();
     
    8889        if (this->isInitialized())
    8990            this->cleanup();
     91    }
     92
     93    void Pong::setConfigValues()
     94    {
     95        SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
    9096    }
    9197
     
    283289        }
    284290
    285         // If a palyer gets 21 points, he won the game -> end of game
    286 
    287         PlayerInfo* player1 = this->getLeftPlayer();
    288         PlayerInfo* player2 = this->getRightPlayer();
    289         if(player1==NULL||player2==NULL) return; //safety
    290         if(this->getScore(player1) >= scoreLimit_)
    291         {
    292             std::string name1=player1->getName();
    293             std::string message(name1 + " has won!");
    294             ChatManager::message(message);
    295             this->end();
    296         }
    297         else if(this->getScore(player2) >= scoreLimit_)
    298         {
    299              std::string name2=player2->getName();
    300              std::string message2(name2 + " has won!");
    301              ChatManager::message(message2);
     291        // If a player gets enough points, he won the game -> end of game
     292        PlayerInfo* winningPlayer = NULL;
     293        if (this->getLeftPlayer() && this->getScore(this->getLeftPlayer()) >= scoreLimit_)
     294            winningPlayer = this->getLeftPlayer();
     295        else if (this->getRightPlayer() && this->getScore(this->getRightPlayer()) >= scoreLimit_)
     296            winningPlayer = this->getRightPlayer();
     297
     298        if (winningPlayer)
     299        {
     300             ChatManager::message(winningPlayer->getName() + " has won!");
    302301             this->end();
    303302        }
     303
    304304        // Restart the timer to start the ball.
    305305        this->starttimer_.startTimer();
    306 
    307306    }
    308307
     
    344343            return 0;
    345344    }
    346 
    347     /**
    348      @brief
    349          Make scoreLimit_ configurable e.g. in the menu.
    350      */
    351     void Pong::setConfigValues()
    352     {
    353         SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
    354     }
    355345}
Note: See TracChangeset for help on using the changeset viewer.