Exemplo n.º 1
0
        public void AddMember(Entities.GameClient client)
        {
            if (Members.Contains(client.DatabaseUID))
            {
                client.GuildMemberInfo = Members[client.DatabaseUID];
            }
            else
            {
                client.GuildMemberInfo = new GuildMember(client);
                if (Members.TryAdd(client.DatabaseUID, client.Name, client.GuildMemberInfo))
                {
                    client.Guild = this;

                    SendMessage(string.Format(Core.MessageConst.NEW_MEMBER, client.Name));
                }
                else
                {
                    client.GuildMemberInfo = null;
                }

                Database.CharacterDatabase.Save(client);
            }

            ReorderIndex();
            client.SendGuild();
            client.Screen.FullUpdate();
        }
 public static void Handle(Entities.GameClient client, GuildPacket guild)
 {
     if (client.Guild != null)
     {
         client.SendGuild();
         using (var announce = new Packets.GuildPacket(new Packets.StringPacker(client.Guild.Bullentin)))
         {
             announce.Data   = Core.Kernel.TimeGet(Enums.TimeType.Day);
             announce.Action = Enums.GuildAction.SetAnnounce;
             client.Send(announce);
         }
     }
 }
Exemplo n.º 3
0
        public void DonateCPs(Entities.GameClient client, uint Amount)
        {
            if (client.CPs >= Amount)
            {
                client.CPs -= Amount;
                CPDonation += Amount;
                client.GuildMemberInfo.CPDonation += Amount;
                Database.GuildDatabase.UpdateGuildInfo(this, "GuildCPsFund", CPDonation);
                Database.CharacterDatabase.Save(client);
                client.SendGuild();

                SendMessage(string.Format(Core.MessageConst.GUILD_DONATE, client.Name, Amount, "CPs"));
            }
        }
Exemplo n.º 4
0
        public void DonateMoney(Entities.GameClient client, uint Amount)
        {
            if (client.Money >= Amount)
            {
                client.Money  -= Amount;
                MoneyDonation += Amount;
                client.GuildMemberInfo.MoneyDonation += Amount;
                Database.GuildDatabase.UpdateGuildInfo(this, "GuildFund", MoneyDonation);
                Database.CharacterDatabase.Save(client);
                client.SendGuild();

                SendMessage(string.Format(Core.MessageConst.GUILD_DONATE, client.Name, Amount, "Silvers"));
            }
        }
Exemplo n.º 5
0
        public static bool Create(Entities.GameClient leader, string Name)
        {
            if (Database.GuildDatabase.Create(leader, Name))
            {
                leader.SendGuild();
                leader.Screen.FullUpdate();
                leader.GuildMemberInfo.Index = 0;

                using (var msg = Packets.Message.MessageCore.CreateSystem("ALL",
                                                                          string.Format(Core.MessageConst.NEW_GUILD, Name, leader.Name)))
                {
                    Packets.Message.MessageCore.SendGlobalMessage(msg);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        public static bool Create(Entities.GameClient leader, string Name)
        {
            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                {
                    cmd.AddInsertValue("GuildName", Name);
                    cmd.AddInsertValue("GuildBullentin", "");
                    cmd.AddInsertValue("GuildFund", (ulong)0);
                    cmd.AddInsertValue("GuildCPsFund", (uint)0);
                    cmd.AddInsertValue("GuildLevel", (byte)0);
                    cmd.AddInsertValue("GuildAllie1", "");
                    cmd.AddInsertValue("GuildAllie2", "");
                    cmd.AddInsertValue("GuildAllie3", "");
                    cmd.AddInsertValue("GuildAllie4", "");
                    cmd.AddInsertValue("GuildAllie5", "");
                    cmd.AddInsertValue("GuildEnemy1", "");
                    cmd.AddInsertValue("GuildEnemy2", "");
                    cmd.AddInsertValue("GuildEnemy3", "");
                    cmd.AddInsertValue("GuildEnemy4", "");
                    cmd.AddInsertValue("GuildEnemy5", "");
                    cmd.Finish("DB_Guilds");
                }
                sql.Execute();
            }
            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, true))
                {
                    cmd.AddWhereValue("GuildName", Name);
                    cmd.Finish("DB_Guilds");
                }
                if (!sql.Read())
                {
                    return(false);
                }

                Data.Guild newGuild = new ProjectX_V3_Game.Data.Guild();
                newGuild.DatabaseID    = sql.ReadUInt32("GuildID");
                newGuild.Name          = sql.ReadString("GuildName");
                newGuild.Bullentin     = sql.ReadString("GuildBullentin");
                newGuild.MoneyDonation = sql.ReadUInt64("GuildFund");
                newGuild.CPDonation    = sql.ReadUInt32("GuildCPsFund");
                newGuild.Level         = sql.ReadByte("GuildLevel");

                if (Core.Kernel.Guilds.TryAdd(newGuild.GuildID, newGuild.Name, newGuild))
                {
                    newGuild.Leader          = new Data.GuildMember(leader);
                    newGuild.Leader.Rank     = Enums.GuildRank.GuildLeader;
                    newGuild.Leader.JoinDate = Core.Kernel.TimeGet(Enums.TimeType.Day);
                    newGuild.Members.TryAdd(leader.DatabaseUID, leader.Name, newGuild.Leader);
                    leader.Guild           = newGuild;
                    leader.GuildMemberInfo = newGuild.Leader;
                    leader.SendGuild();
                    Database.CharacterDatabase.Save(leader);
                    return(true);
                }
            }

            return(false);
        }