예제 #1
0
        public static GroupMember LoadFromDatabase(ushort pCharId)
        {
            const string query = "SELECT * FROM `characters` WHERE CharId = @cid";
            GroupMember member = new GroupMember();

            using (var con = Program.DatabaseManager.GetClient())
            using (var cmd = new MySqlCommand(query, con.GetConnection()))
            {
                cmd.Parameters.AddWithValue("@cid", pCharId);
                using (var rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        member.Name = rdr.GetString("Name");
                        member.IsOnline = ClientManager.Instance.IsOnline(member.Name);
                        member.Role = rdr.GetBoolean("IsGroupMaster")
                                            ? GroupRole.Master
                                            : GroupRole.Member;
                        if (member.IsOnline)
                        {
                            member.Client = ClientManager.Instance.GetClientByCharname(member.Name);
                            member.Character = member.Client.Character;
                        }

                        return member;
                    }
                }
            }
            return member;
        }
예제 #2
0
 private void SendAddMemberInterPacket(GroupMember pMember)
 {
     ZoneConnection con = Program.GetZoneByMap(pMember.Character.Character.PositionInfo.Map);
     using (var pack = new InterPacket(InterHeader.AddPartyMember))
     {
         pack.WriteLong(this.Id);
         pack.WriteString(pMember.Name, 16);
         con.SendPacket(pack);
     }
 }
예제 #3
0
        public Group CreateNewGroup(WorldClient pMaster)
        {
            Group grp = new Group(GetNextId());
            GroupMember mstr = new GroupMember(pMaster, GroupRole.Master);
            pMaster.Character.GroupMember = mstr;
            pMaster.Character.Group = grp;
            grp.AddMember(mstr);

            AddGroup(grp);
            grp.CreateInDatabase();

            SendNewPartyInterPacket(grp.Id);
            return grp;
        }
예제 #4
0
 protected virtual void OnChangedMaster(GroupMember pOld, GroupMember pNew)
 {
     if(ChangedMaster != null)
         ChangedMaster(this, new ChangedMasterEventArgs(pOld, pNew));
 }
예제 #5
0
 private void ChangeMaster(GroupMember pFrom, GroupMember pTo)
 {
     if(pFrom.Role != GroupRole.Master)
         return;
     pFrom.Role = GroupRole.Member;
     pTo.Role = GroupRole.Master;
     OnChangedMaster(pFrom, pTo);
 }
예제 #6
0
 internal void RemoveMember(GroupMember pMember)
 {
     this.Members.Remove(pMember);
     pMember.Character.Group = null;
     pMember.Character.GroupMember = null;
     RemoveGroupDataInDatabase(pMember.CharId);
     // TEMP
     KickMember(pMember.Name);
     // NOTE: Send packet to other Members to update GroupList!
     AnnouncePartyList();
 }
예제 #7
0
 internal void AddMember(GroupMember pMember)
 {
     this.Members.Add(pMember);
     pMember.Group = this;
     UpdateInDatabase();
     SendAddMemberInterPacket(pMember);
 }
예제 #8
0
        public void MemberJoin(string pMember)
        {
            WorldClient client = ClientManager.Instance.GetClientByCharname(pMember);
            GroupMember gMember = new GroupMember(client, GroupRole.Member);
            client.Character.GroupMember = gMember;
            client.Character.Group = this;
            AddMember(gMember);

            AnnouncePartyList();
            UpdateInDatabase();
        }
예제 #9
0
 public ChangedMasterEventArgs(GroupMember pOld, GroupMember pNew)
 {
     this.OldMaster = pOld;
     this.NewMaster = pNew;
 }
예제 #10
0
 public void ChangeMaster(GroupMember pNewMaster)
 {
     ChangeMaster(this.Master, pNewMaster);
     AnnounceChangeMaster();
 }