Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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