00001
00002
00003
00004
00005
00006
00007
00008
00009
00014 #ifndef __GUILD_H__
00015 #define __GUILD_H__
00016
00017 #include "constants.h"
00018 #include "typedefs.h"
00019 #include "worldmain.h"
00020
00025 class cGuildRecruit
00026 {
00027 public:
00028
00029 SERIAL serial;
00030 P_GUILD_MEMBER recruiter;
00031
00032 cGuildRecruit( SERIAL recruit );
00033 ~cGuildRecruit();
00034
00035 void load( cStringFile& file );
00036 void save( FILE* file );
00037 };
00038
00039 typedef enum {
00040 GUILD_TOGGLE_ALL,
00041 GUILD_TOGGLE_SAMEGUILD,
00042 GUILD_TOGGLE_NONE
00043 } GUILD_TITLE_TOGGLE;
00044
00045
00046
00047
00048
00049 class cGuildMember
00050 {
00051
00052
00053 public:
00054
00055 SERIAL serial;
00056 std::string title;
00057 GUILD_TITLE_TOGGLE toggle;
00058 UI32 rank;
00059 SERIAL fealty;
00060
00061 cGuildMember( SERIAL serial );
00062 ~cGuildMember();
00063
00064 void load( cStringFile& file );
00065 void save( FILE* file );
00066 inline const SERIAL getSerial() const
00067 { return serial; }
00068 inline void setSerial(SERIAL newSerial)
00069 { serial = newSerial; }
00070 inline const UI32 getRank() const
00071 { return rank; }
00072 inline void setRank(UI32 newRank )
00073 { rank= newRank; }
00074 inline const SERIAL getFealty() const
00075 { return fealty; }
00076 inline void setFealty(SERIAL newFealty )
00077 { fealty= newFealty; }
00078
00079 };
00080
00081
00082 #define GUILD_POLITICS_WAR 0
00083 #define GUILD_POLITICS_PEACE 1
00084 #define GUILD_POLITICS_ALLIED 2
00085
00090 typedef enum {
00091 GUILD_POLITICS_BLUE = 1,
00092 GUILD_POLITICS_GREEN,
00093 GUILD_POLITICS_ORANGE,
00094 GUILD_POLITICS_RED,
00095 GUILD_POLITICS_TRANSPARENT
00096 } GUILD_POLITICS_COLOR;
00097
00098
00099
00104 class cGuildPolitics {
00105
00106 public:
00107
00108 SERIAL serial;
00109 GUILD_POLITICS_COLOR color;
00110 UI08 type;
00111 bool forever;
00112
00113 cGuildPolitics();
00114 ~cGuildPolitics();
00115 };
00116
00117
00118 typedef enum {
00119 GUILD_TYPE_NORMAL,
00120 GUILD_TYPE_CHAOS,
00121 GUILD_TYPE_ORDER,
00122 GUILD_TYPE_CITY
00123 } GUILD_TYPE;
00124
00125
00130 class cGuild
00131 {
00132 private:
00133 SERIAL serial;
00134 GUILD_TYPE type;
00135
00136 public:
00137
00138 void load( cStringFile& file );
00139 void save( FILE* file );
00140
00141 public:
00142
00143
00144
00145 private:
00146 std::string name;
00147 std::string abbreviation;
00148 SERIAL_VECTOR guildWar;
00149 SERIAL_VECTOR guildPeace;
00150 SERIAL_VECTOR guildAllies;
00151
00152 SERIAL guildMaster;
00153 typedef enum {
00154 RANK_GUILDMASTER,
00155 RANK_GUILDVICE,
00156 RANK_GUILDMEMBER,
00157 RANK_GUILDRECRUIT,
00158 ALL_RANKS
00159 } GUILD_RANK;
00160 public:
00161
00162 std::map< SERIAL, P_GUILD_MEMBER > members;
00163 std::wstring charter;
00164 std::string webpage;
00165
00166 cGuild( SERIAL guildstone );
00167 ~cGuild();
00168 void load();
00169 SERIAL getSerial();
00170
00171 void setName( std::string &newName );
00172 std::string getName();
00173 void setAbbreviation( std::string &newAbbr );
00174 std::string getAbbreviation();
00175 inline const GUILD_TYPE getGuildType() const { return type; };
00176 inline void setGuildType(GUILD_TYPE newGuildType)
00177 { if ( newGuildType >= GUILD_TYPE_NORMAL && newGuildType <= GUILD_TYPE_ORDER) type = newGuildType; };
00178
00179
00180 inline const SERIAL cGuild::getGuildMaster() const { return guildMaster; };
00181 inline void cGuild::setGuildMaster(SERIAL newGuildMaster)
00182 { guildMaster=newGuildMaster; getMember(guildMaster)->setRank(RANK_GUILDMASTER); };
00183 void cGuild::calculateFealty();
00184 void cGuild::showTitle(P_CHAR pc, P_CHAR pc2);
00185 public:
00186 inline std::map< SERIAL, P_GUILD_MEMBER >getMembers()
00187 { return members; }
00188 P_GUILD_MEMBER addMember( P_CHAR pc );
00189 void resignMember( P_CHAR pc );
00190 inline void removeMember(SERIAL member)
00191 { members.erase(member); }
00192 P_GUILD_MEMBER getMember( SERIAL member );
00193 int getMemberPosition(SERIAL member);
00194 SERIAL getMemberByIndex(int index);
00195 int getRecruitIndex(SERIAL member);
00196 SERIAL getRecruitByIndex(int index);
00197 std::vector<SERIAL> *getGuildsInWar();
00198 std::vector<SERIAL> *getGuildsInPeace();
00199 std::vector<SERIAL> *getGuildsAllied();
00200 void addWar(SERIAL guild);
00201 void addPeace(SERIAL guild);
00202 void addAlly(SERIAL guild);
00203 bool hasWarWith(SERIAL guild);
00204 bool hasPeaceWith(SERIAL guild);
00205 bool hasAllianceWith(SERIAL guild);
00206 void cGuild::makePeace(SERIAL guild);
00207 public:
00208
00209 std::map< SERIAL, P_GUILD_RECRUIT > recruits;
00210
00211 P_GUILD_RECRUIT addNewRecruit( P_CHAR recruit, P_CHAR recruiter );
00212 void refuseRecruit( P_CHAR pc );
00213 P_GUILD_RECRUIT getRecruit( SERIAL recruit );
00214
00215
00216 };
00217
00218
00223 class cGuildz
00224 {
00225 private:
00226
00227 void safeoldsave();
00228 std::string getFullAdress();
00229
00230 public:
00231
00232 void archive();
00233 bool load();
00234 bool save();
00235
00236 public:
00237
00238 std::map< SERIAL, P_GUILD > guilds;
00239
00240 cGuildz();
00241 ~cGuildz();
00242
00243 P_GUILD getGuild( SERIAL guild );
00244 P_GUILD addGuild( SERIAL stone );
00245 void removeGuild( SERIAL guild );
00246 int cGuildz::compareGuilds(P_GUILD guild1,P_GUILD guild2);
00247 void cGuildz::checkConsistancy(void );
00248 };
00249
00250 extern cGuildz Guildz;
00251
00252
00253 #endif
00254