1- // Copyright (C) 2024 Settlers Freaks (sf-team at siedler25.org)
1+ // Copyright (C) 2025 Settlers Freaks (sf-team at siedler25.org)
22//
33// SPDX-License-Identifier: GPL-2.0-or-later
44
55#pragma once
66
7+ #include " gameTypes/MapCoordinates.h"
8+ #include < memory>
9+ #include < string>
10+ #include < unordered_set>
11+
12+ class GamePlayer ;
713class GameWorldBase ;
14+ class GameCommandFactory ;
815
916class Cheats
1017{
1118public:
12- Cheats (GameWorldBase& world);
19+ Cheats (GameWorldBase& world, GameCommandFactory& gcFactory );
1320
1421 bool areCheatsAllowed () const ;
1522
23+ /* * Toggles cheat mode on and off.
24+ * Cheat mode needs to be on for any cheats to trigger.
25+ */
1626 void toggleCheatMode ();
27+ /* * Check if cheat mode is on (e.g. to draw special sprites or enable or all buildings).
28+ * Cheat mode needs to be on for any cheats to trigger.
29+ *
30+ * @return true if cheat mode is on, false otherwise
31+ */
1732 bool isCheatModeOn () const { return isCheatModeOn_; }
1833
1934 // Classic S2 cheats
35+
36+ /* * The classic F7 cheat.
37+ * Does not modify game state, merely tricks clients into revealing the whole map.
38+ * In the background, visibility is tracked as expected, i.e. if you reveal the map, send a scout and unreveal the
39+ * map, you will see what was scouted.
40+ */
2041 void toggleAllVisible ();
2142 bool isAllVisible () const { return isAllVisible_; }
2243
@@ -26,9 +47,56 @@ class Cheats
2647 void toggleShowEnemyProductivityOverlay ();
2748 bool shouldShowEnemyProductivityOverlay () const { return shouldShowEnemyProductivityOverlay_; }
2849
50+ /* * The classic build headquarters cheat.
51+ * Check if the cheat building can be placed at the chosen point.
52+ *
53+ * @param mp - The map point, e.g. where the user clicked to open the activity window.
54+ * @return true if the building can be placed, false otherwise
55+ */
56+ bool canPlaceCheatBuilding (const MapPoint& mp) const ;
57+ /* * The classic build headquarters cheat.
58+ * Place the cheat HQ building at the chosen point.
59+ * The building is immediately fully built, there is no need for a building site.
60+ *
61+ * @param mp - The map point at which to place the building.
62+ * @param player - The player to whom the building should belong.
63+ */
64+ void placeCheatBuilding (const MapPoint& mp, const GamePlayer& player);
65+
2966 // RTTR cheats
67+
68+ /* * Shares control of the (human) user's country with the AI. Both the user and the AI retain full control of the
69+ * country, so the user can observe what the AI does or "cooperate" with it.
70+ */
3071 void toggleHumanAIPlayer ();
31- void armageddon () const ;
72+
73+ void armageddon ();
74+
75+ enum class ResourceRevealMode
76+ {
77+ // Order is important as each mode includes the previous ones
78+ Nothing,
79+ Ores,
80+ Fish, // / Ores + Fish
81+ Water // / Ores + Fish + Water
82+ };
83+ /* * Tells clients which resources to reveal:
84+ * Nothing - reveal nothing
85+ * Ores - reveal ores
86+ * Fish - reveal ores and fish
87+ * Water - reveal ores, fish and water
88+ */
89+ ResourceRevealMode getResourceRevealMode () const ;
90+ void toggleResourceRevealMode ();
91+
92+ using PlayerIDSet = std::unordered_set<unsigned >;
93+ /* * Destroys all buildings of given players, effectively defeating them.
94+ *
95+ * @param playerIds - Set of IDs of players.
96+ */
97+ void destroyBuildings (const PlayerIDSet& playerIds);
98+ // / Destroys all buildings of AI players.
99+ void destroyAllAIBuildings ();
32100
33101private:
34102 void turnAllCheatsOff ();
@@ -39,4 +107,6 @@ class Cheats
39107 bool shouldShowEnemyProductivityOverlay_ = false ;
40108 bool isHumanAIPlayer_ = false ;
41109 GameWorldBase& world_;
110+ GameCommandFactory& gcFactory_;
111+ ResourceRevealMode resourceRevealMode_ = ResourceRevealMode::Nothing;
42112};
0 commit comments