SuperTuxKart
Loading...
Searching...
No Matches
free_for_all.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2018 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef FREE_FOR_ALL_HPP
19#define FREE_FOR_ALL_HPP
20
21#include "modes/world_with_rank.hpp"
22#include "states_screens/race_gui_base.hpp"
23
24#include <vector>
25
26class NetworkString;
27
29{
30protected:
31 bool m_count_down_reached_zero;
32
33 std::vector<int> m_scores;
34 // ------------------------------------------------------------------------
35 void handleScoreInServer(int kart_id, int hitter);
36
37private:
38 // ------------------------------------------------------------------------
39 virtual video::SColor getColor(unsigned int kart_id) const;
40
41public:
42 // ------------------------------------------------------------------------
43 FreeForAll();
44 // ------------------------------------------------------------------------
45 virtual ~FreeForAll();
46 // ------------------------------------------------------------------------
47 virtual void init() OVERRIDE;
48 // ------------------------------------------------------------------------
49 virtual bool isRaceOver() OVERRIDE;
50 // ------------------------------------------------------------------------
51 virtual void reset(bool restart=false) OVERRIDE;
52 // ------------------------------------------------------------------------
53 virtual void getKartsDisplayInfo(
54 std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
55 // ------------------------------------------------------------------------
56 virtual bool raceHasLaps() OVERRIDE { return false; }
57 // ------------------------------------------------------------------------
58 virtual const std::string& getIdent() const OVERRIDE;
59 // ------------------------------------------------------------------------
60 virtual bool kartHit(int kart_id, int hitter = -1) OVERRIDE;
61 // ------------------------------------------------------------------------
62 virtual void update(int ticks) OVERRIDE;
63 // ------------------------------------------------------------------------
64 virtual void countdownReachedZero() OVERRIDE;
65 // ------------------------------------------------------------------------
66 virtual void terminateRace() OVERRIDE;
67 // ------------------------------------------------------------------------
68 void setKartScoreFromServer(NetworkString& ns);
69 // ------------------------------------------------------------------------
70 int getKartScore(int kart_id) const { return m_scores.at(kart_id); }
71 // ------------------------------------------------------------------------
72 bool getKartFFAResult(int kart_id) const;
73 // ------------------------------------------------------------------------
74 virtual std::pair<uint32_t, uint32_t> getGameStartedProgress() const
75 OVERRIDE;
76 // ------------------------------------------------------------------------
77 virtual void addReservedKart(int kart_id) OVERRIDE
78 {
79 WorldWithRank::addReservedKart(kart_id);
80 m_scores.at(kart_id) = 0;
81 }
82 // ------------------------------------------------------------------------
83 virtual void saveCompleteState(BareNetworkString* bns,
84 STKPeer* peer) OVERRIDE;
85 // ------------------------------------------------------------------------
86 virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
87}; // FreeForAll
88
89
90#endif
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Definition: free_for_all.hpp:29
void handleScoreInServer(int kart_id, int hitter)
Called when the score of kart needs updated.
Definition: free_for_all.cpp:115
virtual bool kartHit(int kart_id, int hitter=-1) OVERRIDE
Called when a kart is hit.
Definition: free_for_all.cpp:97
virtual void update(int ticks) OVERRIDE
Updates the physics, all karts, the track, and projectile manager.
Definition: free_for_all.cpp:154
virtual void reset(bool restart=false) OVERRIDE
Called when a battle is restarted.
Definition: free_for_all.cpp:64
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this race.
Definition: free_for_all.cpp:148
virtual bool raceHasLaps() OVERRIDE
Called when it is needed to know whether this kind of race involves counting laps.
Definition: free_for_all.hpp:56
virtual void getKartsDisplayInfo(std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
Returns the data to display in the race gui.
Definition: free_for_all.cpp:203
virtual bool isRaceOver() OVERRIDE
The battle is over if only one kart is left, or no player kart.
Definition: free_for_all.cpp:184
virtual void terminateRace() OVERRIDE
Called at the end of a race.
Definition: free_for_all.cpp:230
virtual void countdownReachedZero() OVERRIDE
Called when the match time ends.
Definition: free_for_all.cpp:84
virtual void init() OVERRIDE
call just after instanciating.
Definition: free_for_all.cpp:53
FreeForAll()
Constructor.
Definition: free_for_all.cpp:34
virtual std::pair< uint32_t, uint32_t > getGameStartedProgress() const OVERRIDE
Used by server to get the current started game progress in either or both remaining time or progress ...
Definition: free_for_all.cpp:272
A new implementation of NetworkString, which has a fixed format: Byte 0: The type of the message,...
Definition: network_string.hpp:422
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:76
A WorldWithRank is a world where the karts are ranked.
Definition: world_with_rank.hpp:39