~ubuntu-branches/ubuntu/natty/plee-the-bear/natty

« back to all changes in this revision

Viewing changes to plee-the-bear/src/ptb/throwable_item/code/honeypot_throwable_item.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge, Julien Jorge
  • Date: 2010-11-17 20:13:34 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101117201334-o4dp7uq437to7oxb
Tags: 0.5.1-1
[ Julien Jorge ]
* New upstream release (Closes: #565062, #546514).
* Add armhf architecture (Closes: #604689).
* Remove patches integrated upstream: rpath-editors.diff, rpath-game.diff,
  editors-menu-section.diff.
* Bump the Standard-Version, no changes.
* Update my email address.
* Set build dependency of libclaw to 1.6.0.
* Add the missing ${misc:Depends} in debian/control.
* List gettext translations in bear-factory.install and plee-the-bear.install.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Plee the Bear
 
3
 
 
4
  Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
 
5
 
 
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.
 
10
 
 
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
 
14
  more details.
 
15
 
 
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
 
19
 
 
20
  contact: plee-the-bear@gamned.org
 
21
 
 
22
  Please add the tag [PTB] in the subject of your mails.
 
23
*/
 
24
/**
 
25
 * \file honeypot_throwable_item.cpp
 
26
 * \brief Implementation of the ptb::honeypot_throwable_item class.
 
27
 * \author Sebastien Angibaud
 
28
 */
 
29
#include "ptb/throwable_item/honeypot_throwable_item.hpp"
 
30
 
 
31
#include "ptb/game_variables.hpp"
 
32
#include "ptb/player.hpp"
 
33
#include "ptb/item/small_honeypot.hpp"
 
34
 
 
35
/*----------------------------------------------------------------------------*/
 
36
/**
 
37
 * \brief Contructor.
 
38
 * \param p The pointer on the player.
 
39
 * \param t The type of the honeypot.
 
40
 */
 
41
ptb::honeypot_throwable_item::honeypot_throwable_item
 
42
(player* p, throwable_item::throwable_item_type t)
 
43
  : throwable_item(p), m_type(t)
 
44
{
 
45
} // honeypot_throwable_item::honeypot_throwable_item()
 
46
 
 
47
/*----------------------------------------------------------------------------*/
 
48
/**
 
49
 * \brief Create the throwable_item.
 
50
 */
 
51
bear::engine::base_item*
 
52
ptb::honeypot_throwable_item::create_throwable_item() const
 
53
{
 
54
  small_honeypot* new_small_honeypot = new small_honeypot();
 
55
 
 
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);
 
60
  else
 
61
    new_small_honeypot->set_type(base_bonus::water_power);
 
62
 
 
63
  return new_small_honeypot;
 
64
} // honeypot_throwable_item::create_throwable_item()
 
65
 
 
66
/*----------------------------------------------------------------------------*/
 
67
/**
 
68
 * \brief Indicates if Plee can throw this throwable_item.
 
69
 */
 
70
bool ptb::honeypot_throwable_item::can_throw() const
 
71
{
 
72
  bool result(super::can_throw());
 
73
 
 
74
  if ( result )
 
75
    {
 
76
      if ( ( m_type == throwable_item::air_honeypot_throwable_item_type ) &&
 
77
           !m_player->can_throw_power(monster::air_attack) )
 
78
        result = false;
 
79
      else if ( ( m_type == throwable_item::fire_honeypot_throwable_item_type)
 
80
                && !m_player->can_throw_power(monster::fire_attack) )
 
81
        result = false;
 
82
      else if ((m_type == throwable_item::water_honeypot_throwable_item_type )
 
83
               && !m_player->can_throw_power(monster::water_attack) )
 
84
        result = false;
 
85
    }
 
86
 
 
87
  return result;
 
88
} // honeypot_throwable_item::can_throw()
 
89
 
 
90
/*----------------------------------------------------------------------------*/
 
91
/**
 
92
 * \brief Decrease the stock.
 
93
 */
 
94
void ptb::honeypot_throwable_item::decrease_stock() const
 
95
{
 
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()
 
103
 
 
104
/*----------------------------------------------------------------------------*/
 
105
/**
 
106
 * \brief Get the stock.
 
107
 */
 
108
unsigned int ptb::honeypot_throwable_item::get_stock() const
 
109
{
 
110
  unsigned int result = 0;
 
111
 
 
112
  if ( m_type == throwable_item::air_honeypot_throwable_item_type )
 
113
    {
 
114
      if ( game_variables::get_air_power(m_player->get_index()) )
 
115
        result = 1;
 
116
    }
 
117
  else if ( m_type == throwable_item::fire_honeypot_throwable_item_type )
 
118
    {
 
119
      if ( game_variables::get_fire_power(m_player->get_index()) )
 
120
        result = 1;
 
121
    }
 
122
  else if ( m_type == throwable_item::water_honeypot_throwable_item_type )
 
123
    {
 
124
      if ( game_variables::get_water_power(m_player->get_index()) )
 
125
        result = 1;
 
126
    }
 
127
 
 
128
  return result;
 
129
} // honeypot_throwable_item::get_stock()
 
130
 
 
131
/*----------------------------------------------------------------------------*/
 
132
/**
 
133
 * \brief Get the animation of the throwable_item.
 
134
 */
 
135
const bear::visual::animation&
 
136
ptb::honeypot_throwable_item::get_animation() const
 
137
{
 
138
  bear::engine::level_globals& glob = m_player->get_level_globals();
 
139
 
 
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");
 
144
  else
 
145
    return glob.get_animation("animation/powerup/small_water.canim");
 
146
} // honeypot_throwable_item::get_animation()