Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem/src/orxonox/objects/AddReward.cc @ 2138

Last change on this file since 2138 was 2076, checked in by dafrick, 16 years ago

Completed XMLPort for all objects.

File size: 2.4 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
29#include "core/CoreIncludes.h"
[2021]30
[1992]31#include "AddReward.h"
32
33namespace orxonox {
34   
35    CreateFactory(AddReward);
36   
[2021]37    AddReward::AddReward() : QuestEffect()
38    {
[1992]39        this->initialize();
40    }
41   
42    /**
43    @brief
44        Destructor.
45    */
46    AddReward::~AddReward()
47    {
48    }
49
[2076]50    void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode)
51    {
52        SUPER(AddReward, XMLPort, xmlelement, mode);
53       
54        XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
55       
56    }
57
[1992]58    /**
59    @brief
60        Initializes the object. Needs to be called first by every constructor of this class.
61    */
62    void AddReward::initialize(void)
63    {
64        RegisterObject(AddReward);
65    }
[2076]66   
67    const Rewardable* AddReward::getRewardables(unsigned int index) const
68    {
69        int i = index;
70        for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward)
71        {
72            if(i == 0)
73            {
74               return *reward;
75            }
76            i--;
77        }
78        return NULL;
79    }
[1992]80
81    /**
82    @brief
83        Invokes the effect.
84    @param player
85        The player.
[2068]86    @return
87        Returns true if the effect was invoked successfully.
[1992]88    */
[2068]89    bool AddReward::invoke(Player* player)
[1992]90    {
[2068]91        bool check = true;
[2076]92        for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
[1992]93        {
[2068]94            check = check && (*reward)->reward(player);
[1992]95        }
[2068]96       
97        return check;
[1992]98    }
99
100}
Note: See TracBrowser for help on using the repository browser.