From 99be9859a30e84e758ee3bfe7dcc3de33dfa2391 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 7 Nov 2009 11:47:24 -0700 Subject: More eAthena guild stuff Also some related chenges elsewhere --- src/guild.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 9 deletions(-) (limited to 'src/guild.h') diff --git a/src/guild.h b/src/guild.h index b9e9e4b6..d59f6020 100644 --- a/src/guild.h +++ b/src/guild.h @@ -24,16 +24,47 @@ #include +#include #include #include +class Guild; + +class GuildMember +{ +public: + GuildMember(int guildId, int id, const std::string &name); + + GuildMember(int guildId, int id); + + GuildMember(int guildId, const std::string &name); + + int getID() const { return mId; } + + void setID(int id) { mId = id; } + + std::string getName() const { return mName; } + + void setName(std::string name) { mName = name; } + + Guild *getGuild() const { return mGuild; } + + bool getOnline() const { return mOnline; } + + void setOnline(bool online) { mOnline = online; } + +protected: + friend class Guild; + + std::string mName; + int mId; + Guild *mGuild; + bool mOnline; +}; + class Guild : public gcn::ListModel { public: - /** - * Constructor with guild id passed to it. - */ - Guild(short id, short rights); /** * Set the guild's name. @@ -46,7 +77,21 @@ public: /** * Adds member to the list. */ - void addMember(const std::string &name); + void addMember(GuildMember *member); + + /** + * Find a member by ID. + * + * @return the member with the given ID, or NULL if they don't exist. + */ + GuildMember *getMember(int id); + + /** + * Find a member by name. + * + * @return the member with the given name, or NULL if they don't exist. + */ + GuildMember *getMember(std::string name); /** * Get the name of the guild. @@ -66,11 +111,23 @@ public: return mId; } + /** + * Removes a member from the guild. + */ + void removeMember(GuildMember *member); + + /** + * Removes a member from the guild. + */ + void removeMember(int id); + /** * Removes a member from the guild. */ void removeMember(const std::string &name); + void clearMembers() { mMembers.clear(); } + /** * Get size of members list. * @return Returns the number of members in the guild. @@ -83,9 +140,7 @@ public: * Get member at \a index. * @return Returns the name of member. */ - std::string getElementAt(int index) { - return mMembers[index]; - } + std::string getElementAt(int index); /** * Get whether user can invite users to this guild. @@ -96,12 +151,29 @@ public: return mCanInviteUsers; } + void setRights(short rights); + + bool isMember(GuildMember *member) const; + + bool isMember(int id) const; + bool isMember(const std::string &name) const; + static Guild *getGuild(int id); + private: + typedef std::map GuildMap; + static GuildMap guilds; + + /** + * Constructor with guild id passed to it. + */ + Guild(short id); + + typedef std::vector MemberList; + MemberList mMembers; std::string mName; short mId; - std::vector mMembers; bool mCanInviteUsers; }; -- cgit v1.2.3-60-g2f50