Planeshift
|
A guild alliance between 2+ guilds. More...
#include <psguildinfo.h>
Public Member Functions | |
bool | AddNewMember (psGuildInfo *member) |
Adds a new guild to the alliance. | |
bool | CheckMembership (psGuildInfo *member) const |
Checks if a guild is in this alliance. | |
int | GetID () const |
Gets the ID. | |
psGuildInfo * | GetLeader () const |
Gets the leader. | |
psGuildInfo * | GetMember (int memberNum) |
Gets a guild based off its index. | |
size_t | GetMemberCount () const |
Gets the number of members in this alliance. | |
const csString & | GetName () const |
Gets the name. | |
bool | InsertNew () |
INSERTs alliance data in database. | |
bool | Load (int id) |
Loads alliance data from database. | |
psGuildAlliance (const csString &n_name) | |
Basic constructor with name parameter. | |
psGuildAlliance () | |
Basic constructor. | |
bool | RemoveAlliance () |
Removes alliance. | |
bool | RemoveMember (psGuildInfo *member) |
Removes a guild from the alliance. | |
bool | SetLeader (psGuildInfo *newLeader) |
Sets a new alliance leader. | |
Static Public Attributes | |
static csString | lastError |
When a psGuildAlliance method fails (returns false), this contains a description of the problem. | |
Protected Attributes | |
int | id |
The ID of the alliance, used for storing in the DB. | |
psGuildInfo * | leader |
Leader of the alliance, must also be a member. | |
csArray< psGuildInfo * > | members |
Array of the members of this alliance. | |
csString | name |
Viewable name of the alliance. |
A guild alliance between 2+ guilds.
Primary database table : alliances
Secondary database tables: guilds
Definition at line 731 of file psguildinfo.h.
psGuildAlliance::psGuildAlliance | ( | ) |
Basic constructor.
psGuildAlliance::psGuildAlliance | ( | const csString & | n_name | ) |
Basic constructor with name parameter.
Used when inserting a new alliance.
n_name | Sets name |
bool psGuildAlliance::AddNewMember | ( | psGuildInfo * | member | ) |
Adds a new guild to the alliance.
Returns false if the guild to add is already in the alliance. Also returns false if the DB update fails. Otherwise, the DB is updated and the new guild is added to members.
member | The new guild to add |
bool psGuildAlliance::CheckMembership | ( | psGuildInfo * | member | ) | const |
Checks if a guild is in this alliance.
Checks if the guild is in members.
member | The guild to check |
int psGuildAlliance::GetID | ( | ) | const [inline] |
psGuildInfo* psGuildAlliance::GetLeader | ( | ) | const [inline] |
psGuildInfo* psGuildAlliance::GetMember | ( | int | memberNum | ) |
Gets a guild based off its index.
Asserts that the index is > 0 and < GetMemberCount().
memberNum | Index of the guild to look up |
size_t psGuildAlliance::GetMemberCount | ( | ) | const [inline] |
Gets the number of members in this alliance.
Definition at line 825 of file psguildinfo.h.
const csString& psGuildAlliance::GetName | ( | ) | const [inline] |
bool psGuildAlliance::InsertNew | ( | ) |
bool psGuildAlliance::Load | ( | int | id | ) |
Loads alliance data from database.
Uses parameter to overwrite id. Uses id select from the DB the name and leading guild's ID. If select fails, false is returned. The leader guild is then pulled from the cache manager. If it fails, false is returned. All of the members are then selected from the DB based on this alliance's ID sorted by name. Each member is then actually pulled from the cache manager. If any of the members fail, false is returned.
id | The ID to pull from the DB |
bool psGuildAlliance::RemoveAlliance | ( | ) |
Removes alliance.
Deletes alliance data from database and updates psGuildInfo::alliance of members to 0
bool psGuildAlliance::RemoveMember | ( | psGuildInfo * | member | ) |
Removes a guild from the alliance.
Checks to make sure the guild is actually a member of this alliance and that it is not the leader, if both are true then the guild is removed from members.
member | The guild to remove |
bool psGuildAlliance::SetLeader | ( | psGuildInfo * | newLeader | ) |
Sets a new alliance leader.
Calls CheckMembership with the new leader, then updates the DB and sets leader to the new leader.
newLeader | The guild that will be the new leader |
int psGuildAlliance::id [protected] |
The ID of the alliance, used for storing in the DB.
Definition at line 885 of file psguildinfo.h.
csString psGuildAlliance::lastError [static] |
When a psGuildAlliance method fails (returns false), this contains a description of the problem.
Definition at line 882 of file psguildinfo.h.
psGuildInfo* psGuildAlliance::leader [protected] |
Leader of the alliance, must also be a member.
Definition at line 887 of file psguildinfo.h.
csArray<psGuildInfo*> psGuildAlliance::members [protected] |
Array of the members of this alliance.
Definition at line 888 of file psguildinfo.h.
csString psGuildAlliance::name [protected] |
Viewable name of the alliance.
Definition at line 886 of file psguildinfo.h.