Esempio n. 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));
        }
    }
Esempio n. 2
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));
                }
            }
        }