Esempio n. 1
0
 public static void DeleteGuild(Data.Guild guild)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.DELETE, true))
         {
             cmd.AddWhereValue("GuildName", guild.Name);
             cmd.Finish("DB_Guilds");
         }
         sql.Execute();
     }
 }
Esempio n. 2
0
 public static void UpdateGuildInfo(Data.Guild guild, string Column, object Value)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("GuildID", guild.DatabaseID);
             cmd.AddUpdateValue(Column, Value);
             cmd.Finish("DB_Guilds");
         }
         sql.Execute();
     }
 }
Esempio n. 3
0
        public static async Task Authenticate(string code, string url)
        {
            data = await RPCService.Invoke <Data>("AuthenticationService.AuthenticateCode", url, code);

            if (data == null)
            {
                throw new Exception("Authentication failed");
            }

            if (string.IsNullOrEmpty(data.AuthToken))
            {
                throw new Exception("Invalid token");
            }

            if (data.Guilds == null || data.Guilds.Count <= 0)
            {
                throw new Exception("You must be in at least one guild");
            }

            Console.WriteLine(">> User has " + data.Guilds.Count + " guilds");

            // set the first available guild as the default
            foreach (Data.Guild guild in data.Guilds)
            {
                if (!guild.CanManageGuild)
                {
                    continue;
                }

                RPCService.GuildId        = guild.GetId();
                RPCService.CanManageGuild = guild.CanManageGuild;
                break;
            }

            if (RPCService.GuildId == 0)
            {
                // Set to first
                Data.Guild defaultGuild = data.Guilds.GetFirst();
                RPCService.GuildId        = defaultGuild.GetId();
                RPCService.CanManageGuild = defaultGuild.CanManageGuild;
            }
        }
Esempio n. 4
0
        private static bool LoadGuildMembers(Data.Guild guild)
        {
            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, true))
                {
                    cmd.AddWhereValue("PlayerGuild", guild.Name);
                    cmd.Finish("DB_Players");
                }
                while (sql.Read())
                {
                    Data.GuildMember member = new ProjectX_V3_Game.Data.GuildMember();
                    member.DatabaseUID   = sql.ReadInt32("PlayerID");
                    member.JoinDate      = Core.Kernel.TimeGet(Enums.TimeType.Day);                //DateTime.Now;
                    member.Name          = sql.ReadString("PlayerName");
                    member.Level         = sql.ReadByte("PlayerLevel");
                    member.MoneyDonation = sql.ReadUInt32("PlayerGuildDonation");
                    member.CPDonation    = sql.ReadUInt32("PlayerGuildCPDonation");
                    member.Rank          = (Enums.GuildRank)Enum.Parse(typeof(Enums.GuildRank), sql.ReadString("PlayerGuildRank"));
                    if (!guild.Members.TryAdd(member.DatabaseUID, member.Name, member))
                    {
                        return(false);
                    }

                    if (member.Rank == Enums.GuildRank.GuildLeader)
                    {
                        guild.Leader = member;
                    }
                    else if (member.Rank == Enums.GuildRank.DeputyLeader)
                    {
                        if (!guild.DeputyLeaders.TryAdd(member.DatabaseUID, member.Name, member))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 5
0
        public void LoadGuildInfo()
        {
            // Send guild info
            string guildname = "";
            ProjectX_V3_Lib.Sql.SqlHandler sql = Database.CharacterDatabase.OpenRead(this, "DB_Players");
            if (sql != null)
            {
                guildname = sql.ReadString("PlayerGuild");//client.CharDB.databaseFiles[Database.CharacterDatabase.DatabaseFlag.CharacterFile].ReadString("Guild", string.Empty);
                sql.Dispose();
            }
            if (string.IsNullOrWhiteSpace(guildname))
            {
                this.Screen.FullUpdate();
                return;
            }
            if (Core.Kernel.Guilds.Contains(guildname))
            {
                Data.Guild guild;
                if (Core.Kernel.Guilds.TrySelect(guildname, out guild))
                {
                    Data.GuildMember memberinfo;
                    if (guild.Members.TrySelect(this.DatabaseUID, out memberinfo))
                    {
                        this.GuildMemberInfo = memberinfo;
                        this.GuildMemberInfo.Client = this;
                        this.Guild = guild;

                        SendGuild();
                        SendGuildAssociations();

                        using (var announce = new Packets.GuildPacket(new Packets.StringPacker(guild.Bullentin)))
                        {
                            announce.Data = Core.Kernel.TimeGet(Enums.TimeType.Day);
                            announce.Action = Enums.GuildAction.SetAnnounce;
                            this.Send(announce);
                        }

                        this.Screen.FullUpdate();
                    }
                }
            }
            else
                Database.CharacterDatabase.UpdateCharacter(this, "PlayerGuild", "");
            //client.CharDB.databaseFiles[Database.CharacterDatabase.DatabaseFlag.CharacterFile].WriteString("Guild", string.Empty);
        }