示例#1
0
    private void EstablishClub(Player player)
    {
        if (IsEstablished)
        {
            // player joins normally
            AcceptInvite(player);
            return;
        }

        if (Members.Any(x => x.InviteResponse == ClubInviteResponse.Pending))
        {
            return;
        }

        IsEstablished = true;
        DatabaseManager.Clubs.Update(this);

        foreach (ClubMember member in Members)
        {
            if (member.InviteResponse != ClubInviteResponse.Accept)
            {
                continue;
            }

            if (member.Player.CharacterId == LeaderCharacterId)
            {
                member?.Player.Session?.Send(ClubPacket.Join(member.Player.Name, this));
                member?.Player.Session?.Send(ClubPacket.Establish(this));
            }
            member?.Player.Session?.Send(ClubPacket.ClubProposalInviteResponse(Id, ClubInviteResponse.Accept, member.Player.Name));
        }
    }
示例#2
0
 public void AcceptInvite(Player player)
 {
     AddMember(player, out ClubMember member);
     BroadcastPacketClub(ClubPacket.ConfirmInvite(this, member));
     player.Session.Send(ClubPacket.Join(player.Name, this));
     player.Session.Send(ClubPacket.UpdateClub(this));
     BroadcastPacketClub(ClubPacket.UpdatePlayer(member, this));
 }
示例#3
0
        private static void HandleJoin(GameSession session, PacketReader packet)
        {
            Party party = GameServer.PartyManager.GetPartyById(session.Player.PartyId);

            if (party == null)
            {
                return;
            }

            long clubId = packet.ReadLong();

            Club club = GameServer.ClubManager.GetClubById(clubId);

            if (club == null)
            {
                return;
            }

            if (club.Leader.CharacterId == session.Player.CharacterId)
            {
                party.BroadcastPacketParty(ClubPacket.UpdatePlayerClubList(session.Player, club));
            }
            else
            {
                int response = packet.ReadInt(); // 0 = accept, 76 (0x4C) = reject

                if (response == 0)
                {
                    party.BroadcastPacketParty(ClubPacket.ConfirmCreate(club.Id));
                    club.Leader.Session.Send(ClubPacket.Join(session.Player, club));
                    club.Leader.Session.Send(ClubPacket.Establish(club));
                    // TODO add member to club (club.AddMember(session.Player);)
                }
                else
                {
                    // TODO update to proper rejection packet
                    party.Leader.Session.Send(ChatPacket.Send(party.Leader, session.Player.Name + " declined the invitation.", ChatType.NoticeAlert2));
                }
            }
        }
示例#4
0
        private static void HandleInviteResponse(GameSession session, PacketReader packet)
        {
            long   clubId     = packet.ReadLong();
            string clubName   = packet.ReadUnicodeString();
            string clubLeader = packet.ReadUnicodeString();
            string invitee    = packet.ReadUnicodeString(); //playerName. TODO: verify player name
            byte   response   = packet.ReadByte();          // 1 = accept

            Club club = GameServer.ClubManager.GetClubById(clubId);

            if (club == null)
            {
                return;
            }

            Player other = GameServer.Storage.GetPlayerByName(invitee);

            if (other == null)
            {
                return;
            }

            if (response == 1)
            {
                club.Leader.Session.Send(ClubPacket.LeaderInviteResponse(club, invitee, response));
                club.BroadcastPacketClub(ClubPacket.ConfirmInvite(club, other.Session.Player));
                other.Session.Send(ClubPacket.InviteResponse(club, session.Player));
                other.Session.Send(ClubPacket.Join(session.Player, club));
                other.Session.Send(ClubPacket.UpdateClub(club));
                club.BroadcastPacketClub(ClubPacket.UpdatePlayerClubList(session.Player, club));
                // TODO add member to club (club.AddMember(other);)
            }
            else
            {
                club.Leader.Session.Send(ClubPacket.LeaderInviteResponse(club, invitee, response));
                other.Session.Send(ClubPacket.InviteResponse(club, session.Player));
            }
        }