1 /* Politics.h
2 Copyright (c) 2014 by Michael Zahniser
3 
4 Endless Sky is free software: you can redistribute it and/or modify it under the
5 terms of the GNU General Public License as published by the Free Software
6 Foundation, either version 3 of the License, or (at your option) any later version.
7 
8 Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
11 */
12 
13 #ifndef POLITICS_H_
14 #define POLITICS_H_
15 
16 #include <map>
17 #include <set>
18 #include <string>
19 
20 class Government;
21 class Planet;
22 class PlayerInfo;
23 class Ship;
24 
25 
26 
27 // This class represents the current state of relationships between governments
28 // in the game, and in particular the relationship of each government to the
29 // player. The player has a reputation with each government, which is affected
30 // by what they do for a government or its allies or enemies.
31 class Politics {
32 public:
33 	// Reset to the initial political state defined in the game data.
34 	void Reset();
35 
36 	bool IsEnemy(const Government *first, const Government *second) const;
37 
38 	// Commit the given "offense" against the given government (which may not
39 	// actually consider it to be an offense). This may result in temporary
40 	// hostilities (if the event type is PROVOKE), or a permanent change to your
41 	// reputation.
42 	void Offend(const Government *gov, int eventType, int count = 1);
43 	// Bribe the given government to be friendly to you for one day.
44 	void Bribe(const Government *gov);
45 
46 	// Check if the given ship can land on the given planet.
47 	bool CanLand(const Ship &ship, const Planet *planet) const;
48 	// Check if the player can land on the given planet.
49 	bool CanLand(const Planet *planet) const;
50 	bool CanUseServices(const Planet *planet) const;
51 	// Bribe a planet to let the player's ships land there.
52 	void BribePlanet(const Planet *planet, bool fullAccess);
53 	void DominatePlanet(const Planet *planet, bool dominate = true);
54 	bool HasDominated(const Planet *planet) const;
55 
56 	// Check to see if the player has done anything they should be fined for.
57 	// Each government can only fine you once per day.
58 	std::string Fine(PlayerInfo &player, const Government *gov, int scan, const Ship *target, double security);
59 
60 	// Get or set your reputation with the given government.
61 	double Reputation(const Government *gov) const;
62 	void AddReputation(const Government *gov, double value);
63 	void SetReputation(const Government *gov, double value);
64 
65 	// Reset any temporary effects (typically because a day has passed).
66 	void ResetDaily();
67 
68 
69 private:
70 	// attitude[target][other] stores how much an action toward the given target
71 	// government will affect your reputation with the given other government.
72 	// The relationships need not be perfectly symmetrical. For example, just
73 	// because Republic ships will help a merchant under attack does not mean
74 	// that merchants will come to the aid of Republic ships.
75 	std::map<const Government *, double> reputationWith;
76 	std::set<const Government *> provoked;
77 	std::set<const Government *> bribed;
78 	std::map<const Planet *, bool> bribedPlanets;
79 	std::set<const Planet *> dominatedPlanets;
80 	std::set<const Government *> fined;
81 };
82 
83 
84 
85 #endif
86