WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Tribe.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_TRIBE_HPP
3 #define WORLDSIM_TRIBE_HPP
4 
5 /* WorldSim: Tribe.hpp
6  #include "Tribe.hpp"
7 
8  Tribes are nomadic groups. They wander the map trying to survive until they develop enough to become a civilization.
9 
10 */
11 
12 #include "CharacterManager.cpp"
13 
14 #include "Character.hpp"
15 
16 class World;
17 
18 #include <Game/Calendar/Calendar.hpp>
19 #include "WorldObjectGlobal.hpp"
20 
21 #include <Container/Table/TableInterface.hpp>
22 
23 class Tribe: public WorldObjectGlobal, public TableInterface
24 {
25 private:
26  Vector <std::string> familyNamePool;
27  CharacterManager characterManager;
28 
29 protected:
30  RandomNonStatic random;
31 
32 public:
33 
35 
37 
38  /* Identifying colour of the tribe so you can see who it is quickly. */
39  unsigned char colourRed;
40  unsigned char colourGreen;
41  unsigned char colourBlue;
42 
43  // Race can be Human, Dwarven or Elven.
44  int race;
45 
46  void setColour (const unsigned char, const unsigned char, const unsigned char);
47 
48  /* ABSTRACT TEST STUFF */
49  int nFood; /* 1 food can support 10 people. */
50 
52 
53  /* Counters to regulate logic */
56 
57 
58  Vector <Character*> vCharacter;
59  //std::string name;
60  //World* world;
61 
62  // Any Character that dies gets moved here */
63  Vector <Character*> vDeceased;
64 
65  Vector <HasXY*> vTerritory;
66 
68  bool isAlive;
69 
70  Tribe();
71  ~Tribe();
72 
73  /* LINK THE CIV TO A WORLD. ALSO LOAD UP CITIZEN FAMILIES. */
74  void init(World*);
75 
76  //void setColour (const int,const int,const int);
77 
78  /* Returns false if the spawn failed. Integer is the number of attempts to make. In the future it should guarantee to find a suitable tile. */
79  bool spawn();
80 
81  // WALK IN A RANDOM DIRECTION.
82  /* New behavior:
83  If there's a food surplus, explore nearby.
84  If there's a food shortage, travel to a fertile tile or raid a tribe.
85  */
86  virtual void wander();
87 
88  // All available characters will go out hunting/gathering for food.
89  void hunt();
90  // All characters will try to eat, otherwise people will starve.
91  void eat();
92  // The tribe will develop its crafting and technology.
93  void develop();
94 
95  void updateGovernment();
96 
97  // The tribe will lose influence over tiles it hasn't visited for a while.
98  void degradeInfluence();
99 
100  // Ensure territory vector is up to date.
101  void updateTerritory();
102 
103 
104  /* SIMULATE X TURNS OF THE CIV. */
105  virtual void incrementTicks ( int /* nTicks */ );
106 
107 
108 
109  void generateCouples(int /* amount */ = 1 );
110 
111  //getPopulation returns living population of tribe.
112  int getPopulation();
113 
114  // REMOVE THE CHARACTER FROM THE VECTOR.
115  bool removeCharacter( Character* );
116  // ADD THE CHARACTER TO THE VECTOR.
117  void addCharacter (Character * );
118 
119  // Everybody dies
120  void kill ();
121 
122  //Called if tribe wants to attack another tribe.
123  virtual void combat (Tribe* );
124 
125  // Return a Character capable of combat. If there is none, return 0.
127 
128  void add (Character& c);
129 
130  // Set one couple as legendary at this skill.
132 
134 
135  // LOCATION
136 
137  //Return the local map the tribe is on.
139 
140 
141  /* WORLD OBJECT GLOBAL */
142  Texture* currentTexture();
143 
144  /* TABLE INTERFACE */
145  std::string getColumn(std::string _column);
146  std::string getColumnType(std::string _column);
147 };
148 
149 #endif
unsigned char colourRed
Definition: Tribe.hpp:39
Character * getMostSkilledAt(AttributeManager::TYPE skill)
Definition: Tribe.cpp:587
virtual void incrementTicks(int)
Definition: Tribe.cpp:115
Government government
Definition: Tribe.hpp:34
Tribe()
Definition: Tribe.cpp:18
~Tribe()
Definition: Tribe.cpp:46
Definition: World.hpp:50
void kill()
Definition: Tribe.cpp:656
TYPE
Definition: Character_Attribute.cpp:16
void eat()
Definition: Tribe.cpp:259
std::string getColumnType(std::string _column)
Definition: Tribe.cpp:741
virtual void wander()
Definition: Tribe.cpp:121
Definition: WorldObjectGlobal.hpp:17
void setColour(const unsigned char, const unsigned char, const unsigned char)
Definition: Tribe.cpp:366
Character * setLegendaryCouple(AttributeManager::TYPE)
Definition: Tribe.cpp:606
void develop()
Definition: Tribe.cpp:328
int dailyCounter
Definition: Tribe.hpp:54
bool spawn()
Definition: Tribe.cpp:373
Vector< Character * > vDeceased
Definition: Tribe.hpp:63
Definition: World_Local.hpp:58
int race
Definition: Tribe.hpp:44
RandomNonStatic random
Definition: Tribe.hpp:30
World_Local * getCurrentMap()
Definition: Tribe.cpp:682
Vector< Character * > vCharacter
Definition: Tribe.hpp:58
bool isAlive
Definition: Tribe.hpp:68
unsigned char colourGreen
Definition: Tribe.hpp:40
Texture * currentTexture()
Definition: Tribe.cpp:502
std::string getColumn(std::string _column)
Definition: Tribe.cpp:692
void init(World *)
Definition: Tribe.cpp:52
Definition: CharacterManager.cpp:16
void updateGovernment()
Definition: Tribe.cpp:356
unsigned char colourBlue
Definition: Tribe.hpp:41
int getPopulation()
Definition: Tribe.cpp:81
void addCharacter(Character *)
Definition: Tribe.cpp:631
Definition: Character.hpp:38
bool removeCharacter(Character *)
Definition: Tribe.cpp:627
void hunt()
Definition: Tribe.cpp:235
bool foundSettlement
Definition: Tribe.hpp:67
Definition: Tribe.hpp:23
int monthlyCounter
Definition: Tribe.hpp:55
void degradeInfluence()
Definition: Tribe.cpp:97
void generateCouples(int=1)
Definition: Tribe.cpp:508
virtual void combat(Tribe *)
Definition: Tribe.cpp:230
int actionPoints
Definition: Tribe.hpp:51
int nFood
Definition: Tribe.hpp:49
Mythology * mythology
Definition: Tribe.hpp:36
Vector< HasXY * > vTerritory
Definition: Tribe.hpp:65
void add(Character &c)
Definition: Tribe.cpp:637
Definition: Mythology.hpp:57
void updateTerritory()
Definition: Tribe.cpp:280
Character * getDefender()
Definition: Tribe.cpp:665
Definition: Government.hpp:14