예제 #1
0
        public int changeMemberLevel(ChatClient player, Guild guild, int playerId, int level)
        {
            if(guild.checkInGuild((int)player.characterId)&&guild.checkInGuild(playerId))
            {
                int playerLevel=guild.getUserPermissions((int)player.characterId);

                if(playerLevel==(int)GuildAccessLevel.GAL_OWNER)
                {
                    // player can modify anyones permissions
                    setUserRights(guild, playerId, level);
                    return 0;
                }
            }

            return -1;
        }
예제 #2
0
파일: Storage.cs 프로젝트: Invertika/server
 public void removeGuild(Guild guild)
 {
     string sql=String.Format("DELETE FROM {0} WHERE ID = '{0}';", GUILDS_TBL_NAME, guild.getId());
     mDb.ExecuteNonQuery(sql);
 }
예제 #3
0
파일: Storage.cs 프로젝트: Invertika/server
        public void addGuild(Guild guild)
        {
            string sql=String.Format("INSERT INTO {0} name VALUES \"{1}\";", GUILDS_TBL_NAME, guild.getName());
            mDb.ExecuteNonQuery(sql);

            sql=String.Format("SELECT id FROM {0} WHERE name = \"{1}\"", GUILDS_TBL_NAME, guild.getName());
            DataTable table=mDb.ExecuteQuery(sql);

            long id=(long)table.Rows[0]["id"];
            guild.setId((int)id);
        }
예제 #4
0
파일: Storage.cs 프로젝트: Postremus/server
 public void removeGuild(Guild guild)
 {
     //try
     //{
     //    std::ostringstream sql;
     //    sql << "delete from " << GUILDS_TBL_NAME
     //        << " where id = '"
     //        << guild.getId() << "';";
     //    mDb.execSql(sql.str());
     //}
     //catch (const dal::DbSqlQueryExecFailure &e)
     //{
     //    utils::throwError("(DALStorage::removeGuild) SQL query failure: ", e);
     //}
 }
예제 #5
0
파일: Storage.cs 프로젝트: Postremus/server
        public void addGuild(Guild guild)
        {
            //try
            //{
            //    std::ostringstream sqlQuery;
            //    sqlQuery << "insert into " << GUILDS_TBL_NAME
            //             << " (name) VALUES (?)";
            //    if (mDb.prepareSql(sqlQuery.str()))
            //    {
            //        mDb.bindValue(1, guild.getName());
            //        mDb.processSql();
            //    }
            //    else
            //    {
            //        utils::throwError("(DALStorage::addGuild) "
            //                          "SQL query preparation failure #1.");
            //    }

            //    sqlQuery.clear();
            //    sqlQuery.str("");
            //    sqlQuery << "SELECT id FROM " << GUILDS_TBL_NAME
            //             << " WHERE name = ?";

            //    if (mDb.prepareSql(sqlQuery.str()))
            //    {
            //        mDb.bindValue(1, guild.getName());
            //        const dal::RecordSet& guildInfo = mDb.processSql();

            //        string_to<unsigned int> toUint;
            //        unsigned id = toUint(guildInfo(0, 0));
            //        guild.setId(id);
            //    }
            //    else
            //    {
            //        utils::throwError("(DALStorage::addGuild) "
            //                          "SQL query preparation failure #2.");
            //    }
            //}
            //catch (const std::exception &e)
            //{
            //    utils::throwError("(DALStorage::addGuild) SQL query failure: ", e);
            //}
        }
예제 #6
0
        public Guild createGuild(string name, int playerId)
        {
            Guild guild=new Guild(name);
            // Add guild to db
            Program.storage.addGuild(guild);

            // Add guild, and add owner
            mGuilds.Add(guild);
            mOwners.Add(playerId);

            // put the owner in the guild
            addGuildMember(guild, playerId);

            // Set and save the member rights
            Program.storage.setMemberRights(guild.getId(), playerId, (int)GuildAccessLevel.GAL_OWNER);

            guild.setOwner(playerId);

            return guild;
        }
예제 #7
0
 public void addGuildMember(Guild guild, int playerId)
 {
     Program.storage.addGuildMember(guild.getId(), playerId);
     guild.addMember(playerId, (int)GuildAccessLevel.GAL_NONE);
 }
예제 #8
0
        void setUserRights(Guild guild, int playerId, int rights)
        {
            // Set and save the member rights
            Program.storage.setMemberRights(guild.getId(), playerId, rights);

            // Set with guild
            guild.setUserPermissions(playerId, rights);
        }
예제 #9
0
 void removeGuild(Guild guild)
 {
     Program.storage.removeGuild(guild);
     mOwners.Remove(guild.getOwner());
     mGuilds.Remove(guild);
 }
예제 #10
0
        public void removeGuildMember(Guild guild, int playerId)
        {
            // remove the user from the guild
            Program.storage.removeGuildMember(guild.getId(), playerId);
            guild.removeMember(playerId);

            // if theres no more members left delete the guild
            if (guild.memberCount() == 0)
                removeGuild(guild);

            // remove the user from owners list
            mOwners.Remove(playerId);
        }