Пример #1
0
        internal override void Process()
        {
            if (m_vAllianceName == null)
            {
                m_vAllianceName = "Clan";
            }

            if (m_vAllianceName.Length < 16 || m_vAllianceName.Length < 1)
            {
                if (m_vAllianceDescription.Length < 259 || m_vAllianceDescription.Length < 0)
                {
                    Alliance alliance = ObjectManager.CreateAlliance(0);
                    alliance.m_vAllianceName        = m_vAllianceName;
                    alliance.m_vAllianceDescription = m_vAllianceDescription;
                    alliance.m_vAllianceType        = m_vAllianceType;
                    alliance.m_vRequiredScore       = m_vRequiredScore;
                    alliance.m_vAllianceBadgeData   = m_vAllianceBadgeData;
                    alliance.m_vAllianceOrigin      = m_vAllianceOrigin;
                    alliance.m_vWarFrequency        = m_vWarFrequency;
                    alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus);
                    this.Device.Player.Avatar.AllianceId = alliance.m_vAllianceId;

                    AllianceMemberEntry member = new AllianceMemberEntry(this.Device.Player.Avatar.UserId)
                    {
                        Role = 2
                    };
                    alliance.AddAllianceMember(member);

                    JoinedAllianceCommand b = new JoinedAllianceCommand(this.Device);
                    b.SetAlliance(alliance);

                    AllianceRoleUpdateCommand d = new AllianceRoleUpdateCommand(this.Device);
                    d.SetAlliance(alliance);
                    d.SetRole(2);
                    d.Tick(this.Device.Player);

                    new AvailableServerCommandMessage(this.Device, b.Handle()).Send();

                    new AvailableServerCommandMessage(this.Device, d.Handle()).Send();
                }
                else
                {
                    ResourcesManager.DisconnectClient(Device);
                }
            }
            else
            {
                ResourcesManager.DisconnectClient(Device);
            }
        }
Пример #2
0
        internal override async void Process()
        {
            try
            {
                Alliance alliance = ObjectManager.GetAlliance(m_vAllianceId);
                if (alliance != null)
                {
                    if (!alliance.IsAllianceFull())
                    {
                        this.Device.Player.Avatar.AllianceId = alliance.m_vAllianceId;
                        AllianceMemberEntry member = new AllianceMemberEntry(this.Device.Player.Avatar.UserId);
                        member.Role = 1;
                        alliance.AddAllianceMember(member);

                        JoinedAllianceCommand b = new JoinedAllianceCommand(this.Device);
                        b.SetAlliance(alliance);

                        AllianceRoleUpdateCommand c = new AllianceRoleUpdateCommand(this.Device);
                        c.SetAlliance(alliance);
                        c.SetRole(1);
                        c.Tick(this.Device.Player);

                        AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry();
                        eventStreamEntry.ID = alliance.m_vChatMessages.Count + 1;
                        eventStreamEntry.SetSender(this.Device.Player.Avatar);
                        eventStreamEntry.EventType = 3;
                        alliance.AddChatMessage(eventStreamEntry);

                        new AvailableServerCommandMessage(this.Device, b.Handle()).Send();

                        new AvailableServerCommandMessage(this.Device, c.Handle()).Send();

                        new AllianceStreamMessage(Device, alliance).Send();

                        foreach (AllianceMemberEntry a in alliance.GetAllianceMembers())
                        {
                            Level l = await ResourcesManager.GetPlayer(a.AvatarId);

                            new AllianceStreamEntryMessage(l.Client)
                            {
                                StreamEntry = eventStreamEntry
                            }.Send();
                        }
                    }
                }
            } catch (Exception) { }
        }
Пример #3
0
        internal async void Process()
        {
            try
            {
                Alliance    a         = ObjectManager.GetAlliance(this.Device.Player.Avatar.AllianceId);
                StreamEntry message   = a.m_vChatMessages.Find(c => c.ID == MessageID);
                Level       requester = await ResourcesManager.GetPlayer(message.SenderID);

                if (Choice == 1)
                {
                    if (!a.IsAllianceFull())
                    {
                        requester.Avatar.AllianceId = a.m_vAllianceId;

                        AllianceMemberEntry member = new AllianceMemberEntry(requester.Avatar.UserId);
                        member.Role = 1;
                        a.AddAllianceMember(member);

                        StreamEntry e = a.m_vChatMessages.Find(c => c.ID == MessageID);
                        e.SetJudgeName(this.Device.Player.Avatar.AvatarName);
                        e.SetState(2);

                        AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry();
                        eventStreamEntry.ID = a.m_vChatMessages.Count + 1;
                        eventStreamEntry.SetSender(requester.Avatar);
                        eventStreamEntry.EventType = 2;

                        a.AddChatMessage(eventStreamEntry);

                        foreach (AllianceMemberEntry op in a.GetAllianceMembers())
                        {
                            Level player = await ResourcesManager.GetPlayer(op.AvatarId);

                            if (player.Client != null)
                            {
                                new AllianceStreamEntryMessage(player.Client)
                                {
                                    StreamEntry = eventStreamEntry
                                }.Send();
                                new AllianceStreamEntryMessage(player.Client)
                                {
                                    StreamEntry = e
                                }.Send();
                            }
                        }
                        if (ResourcesManager.IsPlayerOnline(requester))
                        {
                            JoinedAllianceCommand joinAllianceCommand = new JoinedAllianceCommand(requester.Client);
                            joinAllianceCommand.SetAlliance(a);

                            new AvailableServerCommandMessage(requester.Client, joinAllianceCommand.Handle()).Send();

                            AllianceRoleUpdateCommand d = new AllianceRoleUpdateCommand(requester.Client);
                            d.SetAlliance(a);
                            d.SetRole(4);
                            d.Tick(requester);

                            new AvailableServerCommandMessage(requester.Client, d.Handle()).Send();

                            new AllianceStreamMessage(requester.Client, a).Send();
                        }
                    }
                }
                else
                {
                    StreamEntry e = a.m_vChatMessages.Find(c => c.ID == MessageID);
                    e.SetJudgeName(this.Device.Player.Avatar.AvatarName);
                    e.SetState(3);

                    foreach (AllianceMemberEntry op in a.GetAllianceMembers())
                    {
                        Level player = await ResourcesManager.GetPlayer(op.AvatarId);

                        if (player.Client != null)
                        {
                            new AllianceStreamEntryMessage(player.Client)
                            {
                                StreamEntry = e
                            }.Send();
                        }
                    }
                }
            } catch (Exception) { }
        }