WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Social.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_SOCIAL_HPP
3 #define WORLDSIM_SOCIAL_HPP
4 
5 /* WorldSim: Social.hpp
6  #include "Social.hpp"
7 
8  Manage social standings and interactions. Each character has a Social object.
9  A person can have X friends and X enemies, where X is their charisma. A person is always able to know their
10  immediate family.
11 
12  Compatibility determines whether a person becomes a friend more than anything else. This is not a perfect system
13  as it could create a long circuit of relationships but it should work well enough. It also adds an element of
14  chance beyond just charisma detemining who will like you.
15 
16  Currently compatibility is mutually decided. An alternative system might be better.
17  This would work by having a second compatibility. SelfCompatibility and DesiredCompatibility.
18 
19  Note that if you have charisma 0, you will have 0 friends.
20 
21 */
22 
23 #include "Character.hpp"
24 #include <Math/WrappingUChar.cpp>
25 #include <vector>
26 
28 {
29  public:
33  unsigned char compatibility; // lower is better
34 
35  Relationship(Character* _sourceCharacter, Character* _destinationCharacter, char _relationshipLevel,
36  unsigned char _compatibility);
37 
38  // Operator overloads
39  bool operator==(Relationship& other);
40  bool operator>(Relationship& other);
41  bool operator<(Relationship& other);
42 
44  friend std::ostream& operator<<(std::ostream& os, const Relationship& r);
45 };
46 
47 class Social
48 {
49  private:
50  WrappingUChar personality; // Character's personalituy
51  WrappingUChar desiredPersonality; // Personality that the Character likes
52  Vector<Relationship> vFamily;
53  Vector<Relationship> vAcquaintance;
54  Vector<Relationship> vFriend;
55  Vector<Relationship> vEnemy;
56 
57  Character* thisCharacter;
58 
59  public:
60  Social(Character* _thisCharacter);
61 
62  // Operator Overloads
63  // bool operator==(Social& other);
64  // bool operator>(Social& other);
65  // bool operator<(Social& other);
67  friend std::ostream& operator<<(std::ostream& os, const Social& r);
68 
69  unsigned char compatibilityWith(Social* social);
70  unsigned char compatibilityWith(Social& social);
71  WrappingUChar getPersonality();
72  WrappingUChar getDesiredPersonality();
73 
74  void setCompatibility(unsigned char _compatibility);
75  void setCompatibility(unsigned char _compatibility, unsigned char _desiredPersonality);
76  void setCompatibility(Social* compatible);
77  void setCompatibility(Social& compatible);
78 
79  void setFullyCompatible(Social * compatible);
80  void setFullyCompatible(Social & compatible);
81 
82  Relationship* getBestFriend();
83  Relationship* getWorstFriend();
84  int getWorstFriendSlot();
85 
86  int getWorstAcquaintanceSlot();
87 
88  int getFamilySlot(Character* c);
89  int getFriendSlot(Character* c);
90  int getEnemySlot(Character* c);
91  int getAcquaintanceSlot(Character* c);
92 
93  void addFamily(Character* c);
94 
95  void interact(Character* c);
96  void updateLists(int maxFriends);
97 
98  void shareIdeas(Character* c);
99 
100  Vector<Relationship>& getAcquaintances();
101 
102  void print();
103 };
104 
105 #endif // WORLDSIM_SOCIAL_HPP
friend std::ostream & operator<<(std::ostream &os, const Relationship &r)
cout
Definition: Social.cpp:29
Character * destinationCharacter
Definition: Social.hpp:31
Definition: Social.hpp:27
bool operator==(Relationship &other)
Definition: Social.cpp:13
unsigned char compatibility
Definition: Social.hpp:33
Definition: Character.hpp:38
Relationship(Character *_sourceCharacter, Character *_destinationCharacter, char _relationshipLevel, unsigned char _compatibility)
Definition: Social.cpp:7
Character * sourceCharacter
Definition: Social.hpp:30
char relationshipLevel
Definition: Social.hpp:32
bool operator<(Relationship &other)
Definition: Social.cpp:23
bool operator>(Relationship &other)
Definition: Social.cpp:18
Definition: Social.hpp:47