1 /**
2  * @file handler_players.h
3  * @brief players handler
4  * @date 2012-09-05
5  * @copyright 1991-2014 TLK Games
6  * @author Bruno Ethvignot
7  * @version $Revision: 24 $
8  */
9 /*
10  * copyright (c) 1991-2014 TLK Games all rights reserved
11  * $Id: handler_players.h 24 2014-09-28 15:30:04Z bruno.ethvignot@gmail.com $
12  *
13  * TecnoballZ is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * TecnoballZ is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  * MA  02110-1301, USA.
27  */
28 #ifndef __HANDLER_PLAYERS__
29 #define __HANDLER_PLAYERS__
30 class handler_players;
31 
32 
33 #include "../include/tecnoballz.h"
34 #include "../include/controller_capsules.h"
35 #include "../include/supervisor_shop.h"
36 
37 class handler_players:public virtual tecnoballz
38 {
39   friend class right_panel_score;
40   friend class supervisor_guards_level;
41   friend class supervisor_bricks_level;
42   friend class controller_indicators;
43   friend class handler_high_score;
44 public:
45   static const Uint32 PLAYER_NAME_LENGTH = 6;
46   static const Uint32 MAX_OF_PLAYERS = 6;
47 
48 public:
49   /** List of all players object */
50   static handler_players **players_list;
51 
52 private:
53   /** Maximum number of players */
54   static Uint32 max_of_players;
55   /** Pointer to the first player alive */
56   static handler_players *first_player;
57   /** Pointer to the next player object */
58   handler_players *next_player;
59   /** Pointer to the previsous player object */
60   handler_players *previous_player;
61   /** Name of the player */
62   char player_name[PLAYER_NAME_LENGTH + 1];
63   /** Player number from 1 to 6 */
64   Uint32 player_num;
65   /** Player score value */
66   Uint32 score_value;
67   /** Bonus life granted every 25,000 points */
68   Uint32 bonus_life_counter;
69   /** Area number from 1 to 5 */
70   Uint32 area_number;
71   /** Level number in the current area, from 1 to 13 */
72   Uint32 level_number;
73   /** Number of lifes remaining */
74   Sint32 number_of_lifes;
75   /** List ot the items bought in the shop */
76   //Sint32 shopping_cart[supervisor_shop::MAX_OF_CAPSULES_BOUGHT + 1];
77   Sint32 shopping_cart[20];
78   /** The number of items in the shopping cart */
79   Uint32 shopping_cart_items;
80   /** Amount of money available to be spend in the shop */
81   Uint32 amount_of_money;
82   /** State of the left wall of bricks */
83   bool map_left_wall[12];
84   /** State of the right  wall of bricks */
85   bool map_right_wall[12];
86   /** State of the top wall of bricks */
87   bool map_top_wall[12];
88   /** Alive counter of the right paddle, 0 = paddle disabled */
89   Uint32 right_paddle_alive_counter;
90   /** Alive counter of the top paddle, 0 = paddle disabled */
91   Uint32 top_paddle_alive_counter;
92   /** Alive counter of the left paddle, 0 = paddle disabled */
93   Uint32 left_paddle_alive_counter;
94   /** If true, then the wall must be rebuilt on the next level
95    * ihis option is only available in area 5 */
96   bool must_rebuild_walls;
97   /** Less bricks counter */
98   Uint32 less_bricks_count;
99   /** Width of the horizontal paddles
100    * and height of the vertical paddles */
101   Uint32 paddle_length;
102   /** If true all options prices will be to 1 in the next shop */
103   bool budget_prices;
104   /* states of the gems, collected or not */
105   bool gems_state_list[6];
106   Sint32 guardianPt;            //pt / level_list of the guards
107 
108 private:
109     handler_players ();
110    ~handler_players ();
111 public:
112   void initialize (Uint32 lifes, Uint32 areaN,
113                    Uint32 level, Uint32 monay, Uint32 grdPt);
114   void set_name (const char *playername);
115   char *get_name ();
116   Uint32 get_area_number ();
117   Uint32 get_level_number ();
118   Sint32 get_num_of_lifes ();
119   Uint32 get_paddle_length ();
120   void set_paddle_length (Uint32 length);
121   Uint32 get_money_amount ();
122   bool decrease_money_amount (Uint32 value);
123   void increase_money_amount (Uint32 value);
124 
125   void add_score (Uint32 value);
126   void clear_shopping_cart ();
127   Sint32 *get_shopping_cart ();
128   Uint32 get_numof_items_in_shopping_cart ();
129   void set_numof_items_in_shopping_cart (Uint32 count);
130 
131   void clear_collected_gems ();
132   bool are_collected_all_gems (Uint32 gemNu);
133   bool is_collected_gem (Uint32 gemNu);
134 
135   Uint32 get_paddle_alive_counter (Uint32 paddle_num);
136   void set_paddle_alive_counter (Uint32 paddle_num, Uint32 count);
137   void set_less_bricks (Uint32 count);
138   Uint32 get_less_bricks ();
139   void set_rebuild_walls (bool enable);
140   bool is_rebuild_walls ();
141   void set_budget_prices (bool enbale);
142   bool is_budget_prices ();
143   bool *get_map_left ();
144   bool *get_map_right ();
145   bool *get_map_top ();
146 
147   Sint32 zlastlevel ();
148   Sint32 next_level (Sint32 grdNx = 0);
149   Uint32 get_next_phase ();
150 
151   void add_life (Uint32 add);
152   void remove_life (Uint32 remove);
153   void remove_all_lifes ();
154 
155   Sint32 getGuardPt ();
156   void setGuardPt (Sint32 grdPt);
157 
158   static void release_all_players ();
159   static handler_players *create_all_players (Uint32 numof);
160   static handler_players *get_next_player (handler_players *, Uint32 *,
161                                       Sint32 grdNx = 0);
162 
163 
164 private:
165   handler_players *get_previous_player ();
166   void set_next_player (handler_players *player);
167   void set_previous_player (handler_players *player);
168   void reset_members ();
169 
170 
171 };
172 #endif
173