diff options
author | David Athay <ko2fan@gmail.com> | 2008-02-28 12:31:04 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-02-28 12:31:04 +0000 |
commit | fb3cbeddd6f5d59e3f83da059b2a1d4bed2cb80f (patch) | |
tree | 65e3086f341bb92154e99806f3b6255d9696ed4b /src/localplayer.cpp | |
parent | ac2de5e0bd7dfc79e344b6724ee6a13db9994aa4 (diff) | |
download | mana-fb3cbeddd6f5d59e3f83da059b2a1d4bed2cb80f.tar.gz mana-fb3cbeddd6f5d59e3f83da059b2a1d4bed2cb80f.tar.bz2 mana-fb3cbeddd6f5d59e3f83da059b2a1d4bed2cb80f.tar.xz mana-fb3cbeddd6f5d59e3f83da059b2a1d4bed2cb80f.zip |
Work in Progress commit of guilds.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 5a6457a4..3c70c228 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -115,6 +115,68 @@ void LocalPlayer::nextStep() Player::nextStep(); } +void LocalPlayer::addGuild(short guildId, bool inviteRights) +{ + Guild *guild = new Guild(guildId, inviteRights); + mGuilds.push_back(guild); +} + +void LocalPlayer::removeGuild(short guildId) +{ + std::vector<Guild*>::iterator itr; + for (itr = mGuilds.begin(); itr != mGuilds.end(); ++itr) + { + Guild *guild = (*itr); + if (guild->getId() == guildId) + { + delete guild; + mGuilds.erase(itr); + return; + } + } +} + +Guild* LocalPlayer::findGuildById(short guildId) +{ + for (unsigned int i = 0; i < mGuilds.size(); ++i) + { + if (mGuilds[i]->getId() == guildId) + { + return mGuilds[i]; + } + } + + // not found return NULL + return NULL; +} + +Guild* LocalPlayer::findGuildByName(const std::string &guildName) +{ + for (unsigned int i = 0; i < mGuilds.size(); ++i) + { + if(mGuilds[i]->getName() == guildName) + { + return mGuilds[i]; + } + } + + // Not found, so return NULL + return NULL; +} + +short LocalPlayer::getNumberOfGuilds() +{ + return mGuilds.size(); +} + +bool LocalPlayer::checkInviteRights(const std::string &guildName) +{ + Guild *guild = findGuildByName(guildName); + if(guild) + return guild->getInviteRights(); + return false; +} + void LocalPlayer::clearInventory() { mEquipment->clear(); |