Example #1
0
        public void AddPlayerToParty(Player invited, ref Party party)
        {
            if (!CanPlayerJoinParty(invited, party))
                return;

            lock (party.MemberLock)
            {
                party.PartyMembers.Add(invited);
                invited.Party = party;
            }

            UpdateParty(party);

            Communication.Global.RelationService.ResendRelation(invited);
        }
Example #2
0
        public bool CanPlayerJoinParty(Player player, Party party, bool sendErrors = true)
        {
            if (party.PartyMembers.Contains(player))
                return false;

            if (player.Party != null)
                return false;

            if (party.PartyMembers.Count >= MaxPlayersInParty)
            {
                if(sendErrors)
                    SystemMessages.ThePartyIsFull.Send(player);
                return false;
            }
            //todo: other checks

            return true;
        }
Example #3
0
 public List<Player> GetOnlineMembers(Party party)
 {
     return party.PartyMembers.Where(member => Communication.Global.PlayerService.IsPlayerOnline(member)).ToList();
 }
Example #4
0
        public void UpdateParty(Party party)
        {
            if(party == null)
                return;

            SendPacketToPartyMembers(party, new SpPartyList(party.PartyMembers));
            SendLifestatsToPartyMembers(party);
            SendEffectsToPartyMembers(party);
        }
Example #5
0
 private Player GetPayerById(Party party, int playerId)
 {
     return party.PartyMembers.FirstOrDefault(member => member.PlayerId == playerId);
 }
Example #6
0
        public void SendPacketToPartyMembers(Party party, ISendPacket packet, Player sender = null)
        {
            if (party == null)
                return;

                lock (party.MemberLock)
                    foreach (Player member in party.PartyMembers)
                        if (!member.Equals(sender) && Communication.Global.PlayerService.IsPlayerOnline(member))
                            packet.Send(member.Connection);
        }
Example #7
0
        public void SendLifestatsToPartyMembers(Party party)
        {
            if(party == null)
                return;

            lock (party.MemberLock)
                foreach (Player partyMember in party.PartyMembers)
                    if (Communication.Global.PlayerService.IsPlayerOnline(partyMember))
                        foreach (Player member in party.PartyMembers)
                            if (Communication.Global.PlayerService.IsPlayerOnline(member))
                                new SpPartyStats(member).Send(partyMember);
        }
Example #8
0
        public void SendEffectsToPartyMembers(Party party)
        {
            if (party == null)
                return;

            //lock (party.MemberLock)
            //    foreach (Player partyMember in party.PartyMembers)
            //        if (Communication.Global.PlayerService.IsPlayerOnline(partyMember))
            //            foreach (Player member in party.PartyMembers)
            //                if (Communication.Global.PlayerService.IsPlayerOnline(member))
            //                    new SpPartyAbnormals(member).Send(partyMember);
        }
Example #9
0
        public void RemovePlayerFromParty(Player player, ref Party party)
        {
            if (player.Party.PartyMembers.Count <= 2)
            {
                RemoveParty(ref player.Party);
                return;
            }

            lock (player.Party.MemberLock)
                player.Party.PartyMembers.Remove(player);

            SendPacketToPartyMembers(party, new SpPartyRemoveMember(player));

            UpdateParty(player.Party);

            player.Party = null;

            new SpPartyLeave().Send(player);
        }
Example #10
0
        public void RemoveParty(ref Party party)
        {
            _partys.Remove(party);

            lock (party.MemberLock)
            {
                foreach (Player member in party.PartyMembers)
                {
                    member.Party = null;
                    new SpPartyLeave().Send(member);
                }
            }
            party = null;
        }