Exemplo n.º 1
0
        public Guild GetGuildByCharacterID(int characterID)
        {
            DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETGUILDBYCHARACTERID_CHARACTERID, characterID);
            characterIdParameter.DbType = DbType.Int32;

            Guild g = null;

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETGUILDBYCHARACTERID, CommandType.StoredProcedure, characterIdParameter);

            int ordinalGuild_id = reader.GetOrdinal(DbNames.GUILD_ID);
            int ordinalGuild_name = reader.GetOrdinal(DbNames.GUILD_NAME);
            int ordinalGuild_notice = reader.GetOrdinal(DbNames.GUILD_NOTICE);
            int ordinalGuild_fame = reader.GetOrdinal(DbNames.GUILD_FAME);
            int ordinalGuild_donations = reader.GetOrdinal(DbNames.GUILD_DONATIONS);

            while (reader.Read())
            {
                g = new Guild();
                g.ID = reader.GetInt32(ordinalGuild_id);
                g.Fame = reader.GetInt32(ordinalGuild_fame);
                g.Donations = reader.GetInt32(ordinalGuild_donations);
                g.Name = reader.GetString(ordinalGuild_name);
                g.Notice = reader.GetString(ordinalGuild_notice);
            }

            reader.Close();
            _db.Close();

            // get member list, get member with rank 1 as leader.
            if (g != null)
            {
                g.Members = GetGuildMembersByGuildID(g.ID);
                GuildMember master = g.Members.Single(x => x.Rank == GuildOrder.Guild_Master);
                if (master != null)
                    g.Leader = master;
            }

            return g;
        }
Exemplo n.º 2
0
        public void InsertGuildMember(GuildMember gm, Guild g)
        {
            DbParameter guildIdParameter = _db.CreateParameter(DbNames.INSERTGUILDMEMBER_GUILDID, g.ID);

            DbParameter characterIdParameter = _db.CreateParameter(DbNames.INSERTGUILDMEMBER_CHARACTERID, gm.Character.CharacterId);
            characterIdParameter.DbType = DbType.Int32;

            DbParameter titleParameter = _db.CreateParameter(DbNames.INSERTGUILDMEMBER_TITLE, gm.Title);
            titleParameter.DbType = DbType.String;

            DbParameter rankParameter = _db.CreateParameter(DbNames.INSERTGUILDMEMBER_RANK, gm.Rank);
            rankParameter.DbType = DbType.Int32;

            _db.Open();
            _db.ExecuteNonQuery(DbNames.INSERTGUILDMEMBER, CommandType.StoredProcedure, guildIdParameter, characterIdParameter, titleParameter, rankParameter);
            _db.Close();
        }
Exemplo n.º 3
0
        public void UpdateGuild(Guild g)
        {
            DbParameter guildIdParameter = _db.CreateParameter(DbNames.UPDATEGUILD_ID, g.ID);
            guildIdParameter.DbType = DbType.Int32;

            DbParameter noticeParameter = _db.CreateParameter(DbNames.UPDATEGUILD_NOTICE, g.Notice);
            noticeParameter.DbType = DbType.String;

            DbParameter fameParameter = _db.CreateParameter(DbNames.UPDATEGUILD_FAME, g.Fame);
            fameParameter.DbType = DbType.Int32;

            DbParameter donationsParameter = _db.CreateParameter(DbNames.UPDATEGUILD_DONATIONS, g.Donations);
            donationsParameter.DbType = DbType.Int32;

            _db.Open();
            _db.ExecuteNonQuery(DbNames.UPDATEGUILD, CommandType.StoredProcedure, guildIdParameter, noticeParameter, fameParameter, donationsParameter);
            _db.Close();
        }
Exemplo n.º 4
0
        public void SendToGuild(Guild g, byte[] p)
        {
            foreach (GuildMember m in g.Members)
            {
                Client member = GetClientByCharacterID(m.Character.CharacterId);

                if (member != null)
                {
                    member.Send(p);
                }
            }
        }
Exemplo n.º 5
0
        public void UpdateGuildMemberStatus(Guild g)
        {
            foreach (GuildMember m in g.Members)
            {
                Client member = GetClientByCharacterID(m.Character.CharacterId);

                if (member != null)
                {
                    m.Online = true;
                }
                else
                    m.Online = false;
            }
        }
Exemplo n.º 6
0
 public static byte[] SendGuildStats(Guild g)
 {
     Packet p = new Packet(200);
     p.WriteHexString("00");
     p.WriteInt(g.ID);
     p.WriteString(g.Name);
     p.WriteInt(g.Leader.Character.CharacterId);
     p.WriteString(g.Leader.Character.Name);
     p.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 05 00 00 00 00");
     return p.GetWrittenBuffer(PacketIds.SendGuildStats);
 }
Exemplo n.º 7
0
 public static byte[] SendLeaveGuild(int ch, Guild g)
 {
     Packet p = new Packet(20);
     p.WriteHexString("00");
     p.WriteInt(g.ID);
     p.WriteHexString("00 00 00 00"); // unknown
     p.WriteInt(ch);
     return p.GetWrittenBuffer(PacketIds.SendLeaveGuild);
 }
Exemplo n.º 8
0
 public static byte[] SendGuildNotice(Guild g)
 {
     Packet p = new Packet(20);
     p.WriteInt(g.Leader.Character.CharacterId);
     p.WriteHexString("09");
     p.WriteString(g.Notice);
     return p.GetWrittenBuffer(PacketIds.SendGuildNotice);
 }
Exemplo n.º 9
0
 public static byte[] SendGuildMember(Guild g, GuildMember m)
 {
     Packet p = new Packet(20);
     p.WriteInt(m.Character.CharacterId);
     p.WriteInt(g.ID);
     p.WriteString(g.Name);
     p.WriteInt((int)m.Rank);
     p.WriteString(m.Title);
     p.WriteString(m.Character.Name); // owner name
     p.WriteHexString("00 00 00 00 00");
     p.WriteHexString("02 00 00 00");
     p.WriteHexString("00 00 00 00"); // more stats?
     p.WriteHexString("00 00 00 00"); // guild mark
     return p.GetWrittenBuffer(PacketIds.SendGuildOwner);
 }
Exemplo n.º 10
0
 public static byte[] SendGuildCreate(Guild g)
 {
     Packet p = new Packet(20);
     p.WriteHexString("00");
     p.WriteInt(g.ID);
     p.WriteString(g.Name);
     return p.GetWrittenBuffer(PacketIds.SendGuildCreate);
 }
Exemplo n.º 11
0
 public static byte[] SendGuildChangeMemberTitle(Guild g, GuildMember m, GuildMemberError e)
 {
     Packet p = new Packet(20);
     p.WriteByte((byte)e); // error proly
     if (e == GuildMemberError.Success)
     {
         p.WriteInt(g.ID);
         p.WriteInt(m.Character.CharacterId);
         p.WriteString(m.Title);
     }
     else
     {
         p.WriteInt(0);
         p.WriteInt(0);
         p.WriteString("");
     }
     return p.GetWrittenBuffer(PacketIds.SendGuildChangeMemberTitle);
 }
Exemplo n.º 12
0
        public static byte[] SendGuild(Guild g)
        {
            Packet p = new Packet(200);
            p.WriteInt(g.ID);
            p.WriteString(g.Name);
            p.WriteInt(g.Members.Count);

            foreach (GuildMember c in g.Members)
            {
                p.WriteInt((int)c.Rank);
                p.WriteInt(c.Character.CharacterId);
                p.WriteString(c.Character.Name);
                p.WriteString(c.Title);
                p.WriteByte(Convert.ToByte(c.Online));
                p.WriteHexString("01");
            }

            return p.GetWrittenBuffer(PacketIds.SendGuild);
        }