Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/AddReward.cc @ 2120

Last change on this file since 2120 was 2105, checked in by rgrieder, 16 years ago

updated msvc files and precompiled headers.

File size: 2.6 KB
RevLine 
[1992]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[2105]29#include "OrxonoxStableHeaders.h"
30#include "AddReward.h"
31
[1992]32#include "core/CoreIncludes.h"
[2021]33
[2095]34#include "Rewardable.h"
[1992]35
36namespace orxonox {
[2092]37
[1992]38    CreateFactory(AddReward);
[2092]39
40    AddReward::AddReward(BaseObject* creator) : QuestEffect(creator)
[2021]41    {
[2092]42        RegisterObject(AddReward);
43
[1992]44        this->initialize();
45    }
[2092]46
[1992]47    /**
48    @brief
49        Destructor.
50    */
51    AddReward::~AddReward()
52    {
53    }
54
[2076]55    void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode)
56    {
57        SUPER(AddReward, XMLPort, xmlelement, mode);
[2092]58
[2076]59        XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
[2092]60
[2076]61    }
62
[1992]63    /**
64    @brief
65        Initializes the object. Needs to be called first by every constructor of this class.
66    */
67    void AddReward::initialize(void)
68    {
69        RegisterObject(AddReward);
70    }
[2092]71
[2076]72    const Rewardable* AddReward::getRewardables(unsigned int index) const
73    {
74        int i = index;
75        for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward)
[2093]76        {
77            if(i == 0)
78            {
79               return *reward;
80            }
81            i--;
82        }
[2076]83        return NULL;
84    }
[1992]85
86    /**
87    @brief
88        Invokes the effect.
89    @param player
90        The player.
[2068]91    @return
92        Returns true if the effect was invoked successfully.
[1992]93    */
[2068]94    bool AddReward::invoke(Player* player)
[1992]95    {
[2093]96        bool check = true;
[2076]97        for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
[2093]98        {
99            check = check && (*reward)->reward(player);
100        }
[2092]101
[2093]102        return check;
[1992]103    }
104
105}
Note: See TracBrowser for help on using the repository browser.