Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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