Planeshift
psguildinfo.h
Go to the documentation of this file.
1 /*
2  * psguildinfo.h
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 
21 
22 #ifndef __PSGUILDINFO_H__
23 #define __PSGUILDINFO_H__
24 //=============================================================================
25 // Crystal Space Includes
26 //=============================================================================
27 #include <csutil/ref.h>
28 #include <csutil/refarr.h>
29 #include <csutil/refcount.h>
30 #include <csutil/weakreferenced.h>
31 
32 //=============================================================================
33 // Project Includes
34 //=============================================================================
35 #include "util/psconst.h"
36 
37 #include "rpgrules/psmoney.h"
38 
39 //=============================================================================
40 // Local Includes
41 //=============================================================================
42 
43 
44 class psCharacter;
45 class iResultRow;
46 
62 {
64 
66 
68 
70 
72 
74 
76 
78 
81 
84 
87 
89 
91 };
92 
100 {
101  csString title;
102  int level;
104 
111  inline bool HasRights(GUILD_PRIVILEGE rights) const
112  {
113  return (level == MAX_GUILD_LEVEL) || (privileges & rights);
114  }
115 };
116 
117 //------------------------------------------------------------------------------
118 
125 {
126 public:
127  PID char_id;
128  csString name;
132  csString public_notes;
133  csString private_notes;
134  csString last_login;
137 
146  {
147  return (guildlevel->HasRights(rights) && !(removedPrivileges & rights)) || (privileges & rights);
148  }
149 };
150 
151 //------------------------------------------------------------------------------
152 
160 {
161 protected:
162  int id;
163  csString name;
164  PID founder;
166  csString web_page;
167  csString motd;
168  bool secret;
171  csTicks lastNameChange;
172  int alliance;
173  csArray<psGuildMember*> members;
174  csArray<psGuildLevel*> levels;
175  csArray<int> guild_war_with_id;
176  friend class psGuildAlliance;
177 
178 public:
185  psGuildInfo();
186 
196  psGuildInfo(csString name, PID founder);
197 
201  ~psGuildInfo();
202 
212  bool Load(unsigned int id);
213 
223  bool Load(const csString &name);
224 
234  bool Load(iResultRow &row);
235 
244  bool InsertNew();
245 
256  bool RemoveGuild();
257 
266  void Connect(psCharacter* player);
267 
277  void Disconnect(psCharacter* player);
278 
288  void UpdateLastLogin(psCharacter* player);
289 
298  psGuildMember* FindMember(const char* name) const;
299 
308  psGuildMember* FindMember(PID char_id) const;
309 
319  psGuildMember* FindLeader() const;
320 
329  psGuildLevel* FindLevel(int level) const;
330 
339  bool MeetsMinimumRequirements() const;
340 
354  bool AddNewMember(psCharacter* player, int level=1);
355 
366  bool RemoveMember(psGuildMember* target);
367 
379  bool RenameLevel(int level, const char* levelname);
380 
393  bool SetPrivilege(int level, GUILD_PRIVILEGE privilege, bool on);
394 
410  bool SetMemberPrivilege(psGuildMember* member, GUILD_PRIVILEGE privilege, bool on);
411 
422  bool UpdateMemberLevel(psGuildMember* target, int level);
423 
430  inline void AdjustMoney(const psMoney &money, bool unused)
431  {
432  unused = unused;
433  AdjustMoney(money);
434  }
435 
442  void AdjustMoney(const psMoney &money);
443 
450  {
451  return bankMoney;
452  }
453 
459  void SaveBankMoney();
460 
471  unsigned int MinutesUntilUserChangeName() const;
472 
478  inline const csString &GetName() const
479  {
480  return name;
481  }
482 
490  bool SetMaxMemberPoints(int points);
491 
497  inline int GetMaxMemberPoints() const
498  {
499  return max_guild_points;
500  }
501 
514  bool SetMemberPoints(psGuildMember* member, int points);
515 
528  bool SetMemberNotes(psGuildMember* member, const csString &notes, bool isPublic);
529 
539  bool SetName(csString guildName);
540 
546  inline const csString &GetWebPage() const
547  {
548  return web_page;
549  }
550 
560  bool SetWebPage(const csString &web_page);
561 
571  bool SetSecret(bool secretGuild);
572 
578  inline bool IsSecret() const
579  {
580  return secret;
581  }
582 
588  inline const csString &GetMOTD() const
589  {
590  return motd;
591  }
592 
601  bool SetMOTD(const csString &str);
602 
608  inline int GetKarmaPoints() const
609  {
610  return karma_points;
611  }
612 
621  bool SetKarmaPoints(int n_karma_points);
622 
631  void AddGuildWar(psGuildInfo* other);
632 
642  bool IsGuildWarActive(psGuildInfo* other);
643 
650  void RemoveGuildWar(psGuildInfo* other);
651 
657  inline int GetAllianceID() const
658  {
659  return alliance;
660  }
661 
667  inline int GetID() const
668  {
669  return id;
670  }
671 
677  inline csArray<psGuildLevel*>::ConstIterator GetLevelIterator() const
678  {
679  return levels.GetIterator();
680  }
681 
687  inline csArray<psGuildLevel*>::Iterator GetLevelIterator()
688  {
689  return levels.GetIterator();
690  }
691 
697  inline csArray<psGuildMember*>::ConstIterator GetMemberIterator() const
698  {
699  return members.GetIterator();
700  }
701 
707  inline csArray<psGuildMember*>::Iterator GetMemberIterator()
708  {
709  return members.GetIterator();
710  }
711 
717  inline size_t GetMemberCount() const
718  {
719  return members.GetSize();
720  }
721 };
722 
723 //-----------------------------------------------------------------------------
724 
732 {
733 public:
734 
738  psGuildAlliance();
739 
747  psGuildAlliance(const csString &n_name);
748 
758  bool InsertNew();
759 
768  bool RemoveAlliance();
769 
783  bool Load(int id);
784 
796  bool AddNewMember(psGuildInfo* member);
797 
806  bool CheckMembership(psGuildInfo* member) const;
807 
818  bool RemoveMember(psGuildInfo* member);
819 
825  inline size_t GetMemberCount() const
826  {
827  return members.GetSize();
828  }
829 
838  psGuildInfo* GetMember(int memberNum);
839 
845  inline int GetID() const
846  {
847  return id;
848  }
849 
855  inline const csString &GetName() const
856  {
857  return name;
858  }
859 
865  inline psGuildInfo* GetLeader() const
866  {
867  return leader;
868  }
869 
880  bool SetLeader(psGuildInfo* newLeader);
881 
882  static csString lastError;
883 
884 protected:
885  int id;
886  csString name;
888  csArray<psGuildInfo*> members;
889 };
890 
893 #endif
894 
int GetID() const
Gets the ID.
Definition: psguildinfo.h:845
PID char_id
The character ID of the person.
Definition: psguildinfo.h:127
User can change guild points of players of lower level.
Definition: psguildinfo.h:75
User can view alliance chat (command /alliance /a)
Definition: psguildinfo.h:86
csString last_login
The last login time for that user.
Definition: psguildinfo.h:134
csString web_page
URL for the guild.
Definition: psguildinfo.h:166
bool Load(int id)
Loads alliance data from database.
csArray< psGuildMember * >::ConstIterator GetMemberIterator() const
Gets a const iterator for levels.
Definition: psguildinfo.h:697
User can view guild chat (command /guild)
Definition: psguildinfo.h:63
PID founder
Character id for the founder of the guild.
Definition: psguildinfo.h:164
int alliance
Alliance ID that this guild belongs to Default: 0(no alliance)
Definition: psguildinfo.h:172
int level
The rank of the level.
Definition: psguildinfo.h:102
int karma_points
Guild&#39;s current karma points.
Definition: psguildinfo.h:165
size_t GetMemberCount() const
Gets the number of members in this alliance.
Definition: psguildinfo.h:825
bool RemoveMember(psGuildInfo *member)
Removes a guild from the alliance.
User can view and edit private notes of players with a lower level. < Private notes are only visible ...
Definition: psguildinfo.h:83
Holds data for a guild.
Definition: psguildinfo.h:159
psGuildLevel * guildlevel
Members current level.
Definition: psguildinfo.h:130
int GetMaxMemberPoints() const
Simply returns the max member points allowed for this guild.
Definition: psguildinfo.h:497
int privileges
Bit field for additional privileges.
Definition: psguildinfo.h:135
csArray< int > guild_war_with_id
IDs of guild that this guild is at war with.
Definition: psguildinfo.h:175
csArray< psGuildInfo * > members
Array of the members of this alliance.
Definition: psguildinfo.h:888
int GetAllianceID() const
Gets the ID of the alliance this guild belongs to.
Definition: psguildinfo.h:657
bool IsSecret() const
Returns whether this guild is secret.
Definition: psguildinfo.h:578
bool InsertNew()
INSERTs alliance data in database.
A guild alliance between 2+ guilds.
Definition: psguildinfo.h:731
Defines a level inside a guild.
Definition: psguildinfo.h:99
csString motd
The guild&#39;s Message of the day.
Definition: psguildinfo.h:167
bool HasRights(GUILD_PRIVILEGE rights)
Checks if the request right is possessed by this guild member.
Definition: psguildinfo.h:145
Defines a guild member in a guild.
Definition: psguildinfo.h:124
bool HasRights(GUILD_PRIVILEGE rights) const
Checks if the request right is possessed by this guild level.
Definition: psguildinfo.h:111
csString private_notes
Private Guild notes for the player.
Definition: psguildinfo.h:133
int privileges
Bit field for the privileges.
Definition: psguildinfo.h:103
psCharacter * character
Pointer to the character data of the person.
Definition: psguildinfo.h:129
User can use guild bank.
Definition: psguildinfo.h:90
void AdjustMoney(const psMoney &money, bool unused)
Override for BankManager.
Definition: psguildinfo.h:430
int id
UID of the guild.
Definition: psguildinfo.h:162
int max_guild_points
Maximum guild points obtainable in the guild.
Definition: psguildinfo.h:170
csArray< psGuildLevel * >::ConstIterator GetLevelIterator() const
Gets a const iterator for levels.
Definition: psguildinfo.h:677
int GetKarmaPoints() const
Gets the karma points.
Definition: psguildinfo.h:608
csArray< psGuildMember * >::Iterator GetMemberIterator()
Gets an iterator for level.
Definition: psguildinfo.h:707
psMoney bankMoney
Money stored in the guild bank account.
Definition: psguildinfo.h:169
static csString lastError
When a psGuildAlliance method fails (returns false), this contains a description of the problem...
Definition: psguildinfo.h:882
csArray< psGuildLevel * > levels
All of the levels of the guild.
Definition: psguildinfo.h:174
csString name
Viewable name of the alliance.
Definition: psguildinfo.h:886
int guild_points
Their points in the guild.
Definition: psguildinfo.h:131
csString name
Name of the guild.
Definition: psguildinfo.h:163
User can send guild chat messages (command /guild)
Definition: psguildinfo.h:65
size_t GetMemberCount() const
Gets the number of members.
Definition: psguildinfo.h:717
csArray< psGuildMember * > members
All of the members of the guild.
Definition: psguildinfo.h:173
const csString & GetName() const
Simply returns this guild&#39;s name.
Definition: psguildinfo.h:478
const csString & GetWebPage() const
Gets the web page.
Definition: psguildinfo.h:546
csString public_notes
The public notes the member has.
Definition: psguildinfo.h:132
User can send alliace chat messages (command /alliace /a)
Definition: psguildinfo.h:88
bool secret
Flag if the guild is secret or not.
Definition: psguildinfo.h:168
#define MAX_GUILD_LEVEL
Definition: psconst.h:111
int id
The ID of the alliance, used for storing in the DB.
Definition: psguildinfo.h:885
const csString & GetName() const
Gets the name.
Definition: psguildinfo.h:855
const csString & GetMOTD() const
Gets the MOTD string.
Definition: psguildinfo.h:588
User can change privileges of lower guild levels.
Definition: psguildinfo.h:73
User can remove player of lower level from guild.
Definition: psguildinfo.h:69
GUILD_PRIVILEGE
Privileges that may be specifically given/taken from members of a guild.
Definition: psguildinfo.h:61
csString title
Name of the level.
Definition: psguildinfo.h:101
User can change guild name, guild secrecy, guild web page, max guild points < and can disband the gui...
Definition: psguildinfo.h:77
csString name
The name of the member.
Definition: psguildinfo.h:128
psGuildInfo * GetLeader() const
Gets the leader.
Definition: psguildinfo.h:865
bool AddNewMember(psGuildInfo *member)
Adds a new guild to the alliance.
int removedPrivileges
Bit field for privileges removed from this member.
Definition: psguildinfo.h:136
psMoney & GetBankMoney()
Returns the amount of money this guild has in it&#39;s bank.
Definition: psguildinfo.h:449
int GetID() const
Gets the ID of this guild.
Definition: psguildinfo.h:667
User can invite players to guild.
Definition: psguildinfo.h:67
User can promote/demote players of lower level to another lower level.
Definition: psguildinfo.h:71
csTicks lastNameChange
Last time the name of this guild was changed Default: 0
Definition: psguildinfo.h:171
csArray< psGuildLevel * >::Iterator GetLevelIterator()
Gets an iterator for level.
Definition: psguildinfo.h:687
psGuildInfo * leader
Leader of the alliance, must also be a member.
Definition: psguildinfo.h:887
User can edit public notes of players with a lower level. < Public notes are visible to all guild mem...
Definition: psguildinfo.h:80