1 | // SuperTux |
2 | // Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de> |
3 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
4 | // |
5 | // This program is free software: you can redistribute it and/or modify |
6 | // it under the terms of the GNU General Public License as published by |
7 | // the Free Software Foundation, either version 3 of the License, or |
8 | // (at your option) any later version. |
9 | // |
10 | // This program is distributed in the hope that it will be useful, |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // GNU General Public License for more details. |
14 | // |
15 | // You should have received a copy of the GNU General Public License |
16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | |
18 | #ifndef HEADER_SUPERTUX_SUPERTUX_PLAYER_STATUS_HPP |
19 | #define |
20 | |
21 | #include <memory> |
22 | #include <string> |
23 | #include <algorithm> |
24 | |
25 | class DrawingContext; |
26 | class ReaderMapping; |
27 | class Writer; |
28 | |
29 | static const float BORDER_X = 10; |
30 | static const float BORDER_Y = 10; |
31 | |
32 | enum BonusType { |
33 | NO_BONUS = 0, GROWUP_BONUS, FIRE_BONUS, ICE_BONUS, AIR_BONUS, EARTH_BONUS |
34 | }; |
35 | |
36 | /** This class keeps player status between different game sessions (for |
37 | example when switching maps in the worldmap) */ |
38 | class PlayerStatus final |
39 | { |
40 | public: |
41 | PlayerStatus(); |
42 | void reset(); |
43 | void add_coins(int count, bool play_sound = true); |
44 | void take_checkpoint_coins() { coins -= std::max(coins / 10, 25); } |
45 | |
46 | void write(Writer& writer); |
47 | void read(const ReaderMapping& mapping); |
48 | |
49 | int get_max_coins() const; |
50 | bool can_reach_checkpoint() const; |
51 | std::string get_bonus_prefix() const;/**Returns the prefix of the animations that should be displayed*/ |
52 | bool has_hat_sprite() const { return bonus > GROWUP_BONUS; } |
53 | |
54 | public: |
55 | int coins; |
56 | BonusType bonus; |
57 | int max_fire_bullets; /**< maximum number of fire bullets in play */ |
58 | int max_ice_bullets; /**< maximum number of ice bullets in play */ |
59 | int max_air_time; /**<determines maximum number of seconds player can float in air */ |
60 | int max_earth_time; /**< determines maximum number of seconds player can turn to stone */ |
61 | |
62 | std::string worldmap_sprite; /**< the sprite of Tux that should be used in worldmap */ |
63 | std::string last_worldmap; /**< the last played worldmap */ |
64 | |
65 | private: |
66 | PlayerStatus(const PlayerStatus&) = delete; |
67 | PlayerStatus& operator=(const PlayerStatus&) = delete; |
68 | }; |
69 | |
70 | #endif |
71 | |
72 | /* EOF */ |
73 | |