4
Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of the GNU General Public License as published by the
8
Free Software Foundation; either version 2 of the License, or (at your
9
option) any later version.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
contact: plee-the-bear@gamned.org
22
Please add the tag [PTB] in the subject of your mails.
25
* \file honeypot_throwable_item.cpp
26
* \brief Implementation of the ptb::honeypot_throwable_item class.
27
* \author Sebastien Angibaud
29
#include "ptb/throwable_item/honeypot_throwable_item.hpp"
31
#include "ptb/game_variables.hpp"
32
#include "ptb/player.hpp"
33
#include "ptb/item/small_honeypot.hpp"
35
/*----------------------------------------------------------------------------*/
38
* \param p The pointer on the player.
39
* \param t The type of the honeypot.
41
ptb::honeypot_throwable_item::honeypot_throwable_item
42
(player* p, throwable_item::throwable_item_type t)
43
: throwable_item(p), m_type(t)
45
} // honeypot_throwable_item::honeypot_throwable_item()
47
/*----------------------------------------------------------------------------*/
49
* \brief Create the throwable_item.
51
bear::engine::base_item*
52
ptb::honeypot_throwable_item::create_throwable_item() const
54
small_honeypot* new_small_honeypot = new small_honeypot();
56
if ( m_type == throwable_item::air_honeypot_throwable_item_type )
57
new_small_honeypot->set_type(base_bonus::air_power);
58
else if ( m_type == throwable_item::fire_honeypot_throwable_item_type )
59
new_small_honeypot->set_type(base_bonus::fire_power);
61
new_small_honeypot->set_type(base_bonus::water_power);
63
return new_small_honeypot;
64
} // honeypot_throwable_item::create_throwable_item()
66
/*----------------------------------------------------------------------------*/
68
* \brief Indicates if Plee can throw this throwable_item.
70
bool ptb::honeypot_throwable_item::can_throw() const
72
bool result(super::can_throw());
76
if ( ( m_type == throwable_item::air_honeypot_throwable_item_type ) &&
77
!m_player->can_throw_power(monster::air_attack) )
79
else if ( ( m_type == throwable_item::fire_honeypot_throwable_item_type)
80
&& !m_player->can_throw_power(monster::fire_attack) )
82
else if ((m_type == throwable_item::water_honeypot_throwable_item_type )
83
&& !m_player->can_throw_power(monster::water_attack) )
88
} // honeypot_throwable_item::can_throw()
90
/*----------------------------------------------------------------------------*/
92
* \brief Decrease the stock.
94
void ptb::honeypot_throwable_item::decrease_stock() const
96
if ( m_type == throwable_item::air_honeypot_throwable_item_type )
97
game_variables::set_air_power(m_player->get_index(),false);
98
else if ( m_type == throwable_item::fire_honeypot_throwable_item_type )
99
game_variables::set_fire_power(m_player->get_index(),false);
100
else if ( m_type == throwable_item::water_honeypot_throwable_item_type )
101
game_variables::set_water_power(m_player->get_index(),false);
102
} // honeypot_throwable_item::decrease_stock()
104
/*----------------------------------------------------------------------------*/
106
* \brief Get the stock.
108
unsigned int ptb::honeypot_throwable_item::get_stock() const
110
unsigned int result = 0;
112
if ( m_type == throwable_item::air_honeypot_throwable_item_type )
114
if ( game_variables::get_air_power(m_player->get_index()) )
117
else if ( m_type == throwable_item::fire_honeypot_throwable_item_type )
119
if ( game_variables::get_fire_power(m_player->get_index()) )
122
else if ( m_type == throwable_item::water_honeypot_throwable_item_type )
124
if ( game_variables::get_water_power(m_player->get_index()) )
129
} // honeypot_throwable_item::get_stock()
131
/*----------------------------------------------------------------------------*/
133
* \brief Get the animation of the throwable_item.
135
const bear::visual::animation&
136
ptb::honeypot_throwable_item::get_animation() const
138
bear::engine::level_globals& glob = m_player->get_level_globals();
140
if ( m_type == throwable_item::air_honeypot_throwable_item_type )
141
return glob.get_animation("animation/powerup/small_air.canim");
142
else if ( m_type == throwable_item::fire_honeypot_throwable_item_type )
143
return glob.get_animation("animation/powerup/small_fire.canim");
145
return glob.get_animation("animation/powerup/small_water.canim");
146
} // honeypot_throwable_item::get_animation()