WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Civ.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_CIV_HPP
3 #define WORLDSIM_CIV_HPP
4 
5 /* WorldSim: Civ
6  #include "Civ.hpp"
7 
8  Civs are an evolution of Tribes. They manage multiple Cities and can raise Armies and do other advanced things.
9 */
10 
11 #include "Technology.cpp"
12 
13 class Character;
14 class Settlement;
15 
16 
17  // CIVMANAGER STORES DATA SHARED ACROSS ALL CIVS.
18 
19 class Civ;
20 
22 {
23  public:
24  ArrayS2 <Civ*> aOwnerShip;
25 };
27 
28 class Civ: public TableInterface
29 {
30  private:
31 
32 
33  public:
34 
37 
38  // EACH TILE MAY ONLY BE OWNED BY ONE CIV, THEREFORE THIS ARRAY IS SHARED BETWEEN ALL CIVS.
39  static ArrayS2 <Civ*> aOwnership;
40 
41  /* The civ is at war with civs in this vector. */
42  Vector <Civ*> vAtWar;
43  /* The civ can only contact civs in this vector. */
44  Vector <Civ*> vAware;
45 
46  // TRUE IF A CIV CAN SEE THIS TILE, FALSE OTHERWISE.
47  ArrayS2 <bool> aVisible;
48 
49 
50  // A list of all characters owned by this Civ. Each Character is owned by exactly one Civ.
51  Vector <Character*> vCharacter;
52 
53  // A list of all settlements owned by this Civ. Each Settlement is owned by exactly one Civ.
54  Vector <Settlement*> vSettlement;
55 
56  std::string name;
57  int money;
59  int nSoldiers;
60 
61  int colourRed;
64 
65  int race;
66 
67  Civ();
68  void initSimulation();
69 
70  // MAKE THE CIV AWARE OF THE EXISTENCE OF THE PASSED CIV.
71  void addContact(Civ*);
72 
73  // SETTLEMENT FUNCTIONS
74 
75  void addSettlement( Settlement * );
76 
77 
78  void manageArmy();
79 
80  /* LINK THE CIV TO A WORLD. ALSO LOAD UP CITIZEN FAMILIES. */
81  void init(World*);
82  void collectTaxes();
83  void logicTick();
84 
85  void setColour (const int,const int,const int);
86 
87  /* Returns false if the spawn failed. */
88  bool spawn();
89 
90 
91  /* SIMULATE X TURNS OF THE CIV. */
92  void incrementTicks ( int /* nTicks */ );
93 
94  /* UPDATE FOG OF WAR ARRAY, AND ALSO CHECK FOR NEW CONTACTS. */
95  void updateFogOfWar();
96  // RETURN THE NUMBER OF NEIGHBORING FOG TILES. (0-8).
97  int neighboringFog ( int _x, int _y );
98  // RETURN THE NEIGHBORING TILE WITH THE MOST FOG. IF ALL OR SOME TILES ARE EQUALLY FOGGY, RETURN A RANDOM ONE OF THE FOGGIEST ONES.
99  void foggiestNeighbor (int _x, int _y, int* _rx, int* _ry, bool _landOnly);
100 
101  // Set values to a tile which is a priority for exploration.
102  void getExploreTile(int* _rx, int* _ry, bool _land);
103 
104  int getPopulation();
105 
106  void garbageCollect();
107 
108  /* DEPRECATED */
109  void aiDay(); /* Simulate Civ for one day of game world time. */
110  void aiSecond(); /* Simulate Civ for one second of game world time. */
111 
112  // RETURN TRUE IF THE CIV HAS CONTACT WITH THIS CIV.
113  bool knowsAbout(Civ*);
114  // RETURN TRUE IF THE CIV IS AT WAR WITH THE PASSED CIV.
115  bool atWarWith(Civ*);
116 
117  // RETURN TRUE IF THE TILE IS NOT FOGGY.
118  bool canSee(const int _x, const int _y);
119 
120  void rebuildCharacterList();
121 
122  /* TABLE INTERFACE */
123  std::string getColumn(std::string _column);
124  std::string getColumnType(std::string _column);
125 
126 };
127 
128 #endif
int colourRed
Definition: Civ.hpp:61
World * world
Definition: Civ.hpp:58
Vector< Character * > vCharacter
Definition: Civ.hpp:51
Definition: Civ.hpp:21
std::string name
Definition: Civ.hpp:56
Definition: World.hpp:50
Mythology * mythology
Definition: Civ.hpp:35
Definition: Civ.hpp:28
int colourGreen
Definition: Civ.hpp:62
Vector< Settlement * > vSettlement
Definition: Civ.hpp:54
int colourBlue
Definition: Civ.hpp:63
CivManager civManager
Definition: Civ.hpp:26
Vector< Civ * > vAtWar
Definition: Civ.hpp:42
int nSoldiers
Definition: Civ.hpp:59
int money
Definition: Civ.hpp:57
ArrayS2< bool > aVisible
Definition: Civ.hpp:47
void init()
Definition: Driver_Init.hpp:16
Technology technology
Definition: Civ.hpp:36
Definition: Settlement.hpp:15
Vector< Civ * > vAware
Definition: Civ.hpp:44
static ArrayS2< Civ * > aOwnership
Definition: Civ.hpp:39
Definition: Technology.hpp:19
Definition: Character.hpp:38
int race
Definition: Civ.hpp:65
ArrayS2< Civ * > aOwnerShip
Definition: Civ.hpp:24
Definition: Mythology.hpp:57