Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2011, 2:38:37 PM (13 years ago)
Author:
jo
Message:

teamgametype merged into trunk

Location:
code/branches/presentation2011
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2011

  • code/branches/presentation2011/src/modules/pong/Pong.cc

    r8858 r8980  
    3737#include "core/EventIncludes.h"
    3838#include "core/command/Executor.h"
     39#include "core/ConfigValueIncludes.h"
    3940
    4041#include "gamestates/GSLevel.h"
     42#include "chat/ChatManager.h"
    4143
    4244#include "PongCenterpoint.h"
     
    4547#include "PongBot.h"
    4648#include "PongAI.h"
    47 
    4849namespace orxonox
    4950{
     
    7576        // Set the type of Bots for this particular Gametype.
    7677        this->botclass_ = Class(PongBot);
     78        this->scoreLimit_ = 10;
     79        this->setConfigValues();
    7780    }
    7881
     
    280283        }
    281284
     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);
     302             this->end();
     303        }
    282304        // Restart the timer to start the ball.
    283305        this->starttimer_.startTimer();
     306
    284307    }
    285308
     
    321344            return 0;
    322345    }
     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    }
    323355}
Note: See TracChangeset for help on using the changeset viewer.