Exemplo n.º 1
0
        public override void Process(Level level)
        {
            var a        = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
            var defender = ResourcesManager.GetPlayer(a.GetChatMessages().Find(c => c.GetId() == ID).GetSenderId());

            if (defender != null)
            {
                defender.Tick();
                new ChallangeAttackDataMessage(Client, defender).Send();
            }
            else
            {
                new OwnHomeDataMessage(Client, level);
            }

            var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
            var s        = alliance.GetChatMessages().Find(c => c.GetStreamEntryType() == 12);

            if (s != null)
            {
                alliance.GetChatMessages().RemoveAll(t => t == s);

                foreach (AllianceMemberEntry op in alliance.GetAllianceMembers())
                {
                    Level playera = ResourcesManager.GetPlayer(op.GetAvatarId());
                    if (playera.GetClient() != null)
                    {
                        var p = new AllianceStreamEntryMessage(playera.GetClient());
                        p.SetStreamEntry(s);
                        p.Send();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void Process(Level level)
        {
            var avatar      = level.GetPlayerAvatar();
            var alliance    = ObjectManager.GetAlliance(Id);
            var streamEntry = new InvitationStreamEntry();

            streamEntry.SetId(alliance.GetChatMessages().Count + 1);
            streamEntry.SetSenderId(avatar.GetId());
            streamEntry.SetHomeId(avatar.GetId());
            streamEntry.SetSenderLeagueId(avatar.GetLeagueId());
            streamEntry.SetSenderName(avatar.GetAvatarName());
            streamEntry.SetSenderRole(avatar.GetAllianceRole());
            streamEntry.SetMessage(Message);
            streamEntry.SetState(1);
            alliance.AddChatMessage(streamEntry);

            var members = alliance.GetAllianceMembers();

            foreach (var member in members)
            {
                var memberLevel  = ResourcesManager.GetPlayer(member.GetAvatarId(), false);
                var memberClient = memberLevel.GetClient();
                if (memberClient != null)
                {
                    var message = new AllianceStreamEntryMessage(memberClient);
                    message.SetStreamEntry(streamEntry);
                    message.Send();
                }
            }
        }
Exemplo n.º 3
0
        public override void Execute(Level level)
        {
            ChallangeCommand challangeCommand = this;

            try
            {
                ClientAvatar         player   = level.GetPlayerAvatar();
                Alliance             alliance = ObjectManager.GetAlliance(player.GetAllianceId());
                ChallengeStreamEntry cm       = new ChallengeStreamEntry();
                cm.SetMessage(challangeCommand.Message);
                cm.SetSenderId(player.GetId());
                cm.SetSenderName(player.GetAvatarName());
                cm.SetSenderLevel(player.GetAvatarLevel());
                ChallengeStreamEntry challengeStreamEntry = cm;
                int allianceRole = player.GetAllianceRole();
                challengeStreamEntry.SetSenderRole(allianceRole);
                challengeStreamEntry = (ChallengeStreamEntry)null;
                cm.SetId(alliance.GetChatMessages().Count + 1);
                cm.SetSenderLeagueId(player.GetLeagueId());
                alliance.AddChatMessage((UCS.Logic.StreamEntry.StreamEntry)cm);
                UCS.Logic.StreamEntry.StreamEntry      s = alliance.GetChatMessages().Find((Predicate <UCS.Logic.StreamEntry.StreamEntry>)(c => c.GetStreamEntryType() == 12));
                List <AllianceMemberEntry> .Enumerator enumerator;
                if (s != null)
                {
                    alliance.GetChatMessages().RemoveAll((Predicate <UCS.Logic.StreamEntry.StreamEntry>)(t => t == s));
                    foreach (AllianceMemberEntry allianceMember in alliance.GetAllianceMembers())
                    {
                        Level player1 = ResourcesManager.GetPlayer(allianceMember.GetAvatarId(), false);
                        if (player1.GetClient() != null)
                        {
                            new AllianceStreamEntryRemovedMessage(player1.GetClient(), s.GetId()).Send();
                        }
                    }
                    enumerator = new List <AllianceMemberEntry> .Enumerator();
                }
                foreach (AllianceMemberEntry allianceMember in alliance.GetAllianceMembers())
                {
                    Level player1 = ResourcesManager.GetPlayer(allianceMember.GetAvatarId(), false);
                    if (player1.GetClient() != null)
                    {
                        AllianceStreamEntryMessage Message = new AllianceStreamEntryMessage(player1.GetClient());
                        ChallengeStreamEntry       challengeStreamEntry1 = cm;
                        Message.SetStreamEntry((UCS.Logic.StreamEntry.StreamEntry)challengeStreamEntry1);
                        Message.Send();
                    }
                }
                enumerator = new List <AllianceMemberEntry> .Enumerator();

                player   = (ClientAvatar)null;
                alliance = (Alliance)null;
                cm       = (ChallengeStreamEntry)null;
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 4
0
        public override void Process(Level level)
        {
            var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());

            if (alliance != null)
            {
                alliance.SetAllianceDescription(m_vAllianceDescription);
                alliance.SetAllianceBadgeData(m_vAllianceBadgeData);
                alliance.SetAllianceType(m_vAllianceType);
                alliance.SetRequiredScore(m_vRequiredScore);
                alliance.SetWarFrequency(m_vWarFrequency);
                alliance.SetAllianceOrigin(m_vAllianceOrigin);
                alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus);

                var avatar           = level.GetPlayerAvatar();
                var allianceId       = avatar.GetAllianceId();
                var eventStreamEntry = new AllianceEventStreamEntry();
                eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                eventStreamEntry.SetSender(avatar);
                eventStreamEntry.SetEventType(10);
                eventStreamEntry.SetAvatarId(avatar.GetId());
                eventStreamEntry.SetAvatarName(avatar.GetAvatarName());
                eventStreamEntry.SetSenderId(avatar.GetId());
                eventStreamEntry.SetSenderName(avatar.GetAvatarName());
                alliance.AddChatMessage(eventStreamEntry);

                var edit = new AllianceSettingChangedCommand();
                edit.SetAlliance(alliance);
                edit.SetPlayer(level);

                var availableServerCommandMessage = new AvailableServerCommandMessage(level.GetClient());
                availableServerCommandMessage.SetCommandId(6);
                availableServerCommandMessage.SetCommand(edit);
                availableServerCommandMessage.Send();

                Parallel.ForEach(alliance.GetAllianceMembers(), op =>
                {
                    var user = ResourcesManager.GetPlayer(op.GetAvatarId());
                    if (ResourcesManager.IsPlayerOnline(user))
                    {
                        var p = new AllianceStreamEntryMessage(user.GetClient());
                        p.SetStreamEntry(eventStreamEntry);
                        p.Send();
                    }
                });

                var clan = DatabaseManager.Single().Save(alliance);
                clan.Wait();
            }
        }
Exemplo n.º 5
0
        public override void Execute(Level level)
        {
            var player     = level.GetPlayerAvatar();
            var allianceID = player.GetAllianceId();
            var alliance   = ObjectManager.GetAlliance(allianceID);

            var cm = new ChallangeStreamEntry();

            cm.SetMessage(Message);
            cm.SetSenderId(player.GetId());
            cm.SetSenderName(player.GetAvatarName());
            cm.SetSenderLevel(player.GetAvatarLevel());
            cm.SetSenderRole(player.GetAllianceRole());
            cm.SetId(alliance.GetChatMessages().Count + 1);
            cm.SetSenderLeagueId(player.GetLeagueId());

            var s = alliance.GetChatMessages().Find(c => c.GetStreamEntryType() == 12);

            if (s != null)
            {
                alliance.GetChatMessages().RemoveAll(t => t == s);
                Parallel.ForEach((alliance.GetAllianceMembers()), op =>
                {
                    var alliancemembers = ResourcesManager.GetPlayer(op.GetAvatarId());
                    if (alliancemembers.GetClient() != null)
                    {
                        new AllianceStreamEntryRemovedMessage(alliancemembers.GetClient(), s.GetId()).Send();
                    }
                });
            }

            alliance.AddChatMessage(cm);

            Parallel.ForEach((alliance.GetAllianceMembers()), op =>
            {
                var alliancemembers = ResourcesManager.GetPlayer(op.GetAvatarId());
                if (alliancemembers.GetClient() != null)
                {
                    var p = new AllianceStreamEntryMessage(alliancemembers.GetClient());
                    p.SetStreamEntry(cm);
                    p.Send();
                }
            });
        }
Exemplo n.º 6
0
        public override void Process(Level level)
        {
            var target   = ResourcesManager.GetPlayer(m_vId);
            var player   = level.GetPlayerAvatar();
            var alliance = ObjectManager.GetAlliance(player.GetAllianceId());

            if (player.GetAllianceRole() == 2 || player.GetAllianceRole() == 4)
            {
                if (player.GetAllianceId() == target.GetPlayerAvatar().GetAllianceId())
                {
                    int oldrole = target.GetPlayerAvatar().GetAllianceRole();
                    target.GetPlayerAvatar().SetAllianceRole(m_vRole);
                    if (m_vRole == 2)
                    {
                        player.SetAllianceRole(4);

                        AllianceEventStreamEntry demote = new AllianceEventStreamEntry();
                        demote.SetId(alliance.GetChatMessages().Count + 1);
                        demote.SetSender(player);
                        demote.SetEventType(6);
                        demote.SetAvatarId(player.GetId());
                        demote.SetAvatarName(player.GetAvatarName());

                        alliance.AddChatMessage(demote);

                        AllianceEventStreamEntry promote = new AllianceEventStreamEntry();
                        promote.SetId(alliance.GetChatMessages().Count + 1);
                        promote.SetSender(target.GetPlayerAvatar());
                        promote.SetEventType(5);
                        promote.SetAvatarId(player.GetId());
                        promote.SetAvatarName(player.GetAvatarName());

                        alliance.AddChatMessage(promote);

                        PromoteAllianceMemberOkMessage rup = new PromoteAllianceMemberOkMessage(Client);
                        PromoteAllianceMemberOkMessage rub = new PromoteAllianceMemberOkMessage(target.GetClient());

                        AllianceRoleUpdateCommand     p  = new AllianceRoleUpdateCommand();
                        AvailableServerCommandMessage pa = new AvailableServerCommandMessage(Client);

                        AllianceRoleUpdateCommand     t  = new AllianceRoleUpdateCommand();
                        AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.GetClient());

                        rup.SetID(level.GetPlayerAvatar().GetId());
                        rup.SetRole(4);
                        rub.SetID(target.GetPlayerAvatar().GetId());
                        rub.SetRole(2);

                        t.SetAlliance(alliance);
                        p.SetAlliance(alliance);
                        t.SetRole(2);
                        p.SetRole(4);
                        t.Tick(target);
                        p.Tick(level);

                        ta.SetCommandId(8);
                        pa.SetCommandId(8);
                        ta.SetCommand(t);
                        pa.SetCommand(p);
                        if (ResourcesManager.IsPlayerOnline(target))
                        {
                            ta.Send();
                            rub.Send();
                        }
                        rup.Send();
                        pa.Send();


                        // New function for send a message
                        foreach (AllianceMemberEntry op in alliance.GetAllianceMembers())
                        {
                            Level aplayer = ResourcesManager.GetPlayer(op.GetAvatarId());
                            if (aplayer.GetClient() != null)
                            {
                                AllianceStreamEntryMessage a = new AllianceStreamEntryMessage(aplayer.GetClient());
                                AllianceStreamEntryMessage b = new AllianceStreamEntryMessage(aplayer.GetClient());

                                a.SetStreamEntry(demote);
                                b.SetStreamEntry(promote);

                                a.Send();
                                b.Send();
                            }
                        }
                    }
                    else
                    {
                        AllianceRoleUpdateCommand      t      = new AllianceRoleUpdateCommand();
                        AvailableServerCommandMessage  ta     = new AvailableServerCommandMessage(target.GetClient());
                        PromoteAllianceMemberOkMessage ru     = new PromoteAllianceMemberOkMessage(target.GetClient());
                        AllianceEventStreamEntry       stream = new AllianceEventStreamEntry();

                        stream.SetId(alliance.GetChatMessages().Count + 1);
                        stream.SetSender(target.GetPlayerAvatar());
                        stream.SetAvatarId(player.GetId());
                        stream.SetAvatarName(player.GetAvatarName());
                        if (m_vRole > oldrole)
                        {
                            stream.SetEventType(5);
                        }
                        else
                        {
                            stream.SetEventType(6);
                        }

                        t.SetAlliance(alliance);
                        t.SetRole(m_vRole);
                        t.Tick(target);

                        ta.SetCommandId(8);
                        ta.SetCommand(t);

                        ru.SetID(target.GetPlayerAvatar().GetId());
                        ru.SetRole(m_vRole);

                        alliance.AddChatMessage(stream);

                        if (ResourcesManager.IsPlayerOnline(target))
                        {
                            ta.Send();
                            ru.Send();
                        }
                        // New function for send a message
                        foreach (AllianceMemberEntry op in alliance.GetAllianceMembers())
                        {
                            Level aplayer = ResourcesManager.GetPlayer(op.GetAvatarId());
                            if (aplayer.GetClient() != null)
                            {
                                AllianceStreamEntryMessage b = new AllianceStreamEntryMessage(aplayer.GetClient());
                                b.SetStreamEntry(stream);
                                PacketManager.Send(b);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override void Execute(Level level)
        {
            var targetAccount = ResourcesManager.GetPlayer(m_vAvatarId);

            if (targetAccount != null)
            {
                var targetAvatar        = targetAccount.GetPlayerAvatar();
                var targetAllianceId    = targetAvatar.GetAllianceId();
                var requesterAvatar     = level.GetPlayerAvatar();
                var requesterAllianceId = requesterAvatar.GetAllianceId();
                if (requesterAllianceId > 0 && targetAllianceId == requesterAllianceId)
                {
                    var alliance        = ObjectManager.GetAlliance(requesterAllianceId);
                    var requesterMember = alliance.GetAllianceMember(requesterAvatar.GetId());
                    var targetMember    = alliance.GetAllianceMember(m_vAvatarId);
                    if (targetMember.HasLowerRoleThan(requesterMember.GetRole()))
                    {
                        targetAvatar.SetAllianceId(0);
                        alliance.RemoveMember(m_vAvatarId);
                        if (ResourcesManager.IsPlayerOnline(targetAccount))
                        {
                            var leaveAllianceCommand = new LeavedAllianceCommand();
                            leaveAllianceCommand.SetAlliance(alliance);
                            leaveAllianceCommand.SetReason(2); //Kick
                            var availableServerCommandMessage = new AvailableServerCommandMessage(targetAccount.GetClient());
                            availableServerCommandMessage.SetCommandId(2);
                            availableServerCommandMessage.SetCommand(leaveAllianceCommand);
                            availableServerCommandMessage.Send();

                            var kickOutStreamEntry = new AllianceKickOutStreamEntry();
                            kickOutStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                            kickOutStreamEntry.SetAvatar(requesterAvatar);
                            kickOutStreamEntry.SetIsNew(0);
                            kickOutStreamEntry.SetAllianceId(alliance.GetAllianceId());
                            kickOutStreamEntry.SetAllianceBadgeData(alliance.GetAllianceBadgeData());
                            kickOutStreamEntry.SetAllianceName(alliance.GetAllianceName());
                            kickOutStreamEntry.SetMessage(m_vMessage);

                            var p = new AvatarStreamEntryMessage(targetAccount.GetClient());
                            p.SetAvatarStreamEntry(kickOutStreamEntry);
                            p.Send();
                        }

                        var eventStreamEntry = new AllianceEventStreamEntry();
                        eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                        eventStreamEntry.SetSender(targetAvatar);
                        eventStreamEntry.SetEventType(1);
                        eventStreamEntry.SetAvatarId(requesterAvatar.GetId());
                        eventStreamEntry.SetAvatarName(requesterAvatar.GetAvatarName());
                        alliance.AddChatMessage(eventStreamEntry);

                        Parallel.ForEach((alliance.GetAllianceMembers()), op =>
                        {
                            var alliancemembers = ResourcesManager.GetPlayer(op.GetAvatarId());
                            if (alliancemembers.GetClient() != null)
                            {
                                var p = new AllianceStreamEntryMessage(alliancemembers.GetClient());
                                p.SetStreamEntry(eventStreamEntry);
                                p.Send();
                            }
                        });
                    }
                }
            }
        }
Exemplo n.º 8
0
        public override void Process(Level level)
        {
            EditClanSettingsMessage clanSettingsMessage = this;

            try
            {
                Alliance alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                if (alliance != null)
                {
                    if (clanSettingsMessage.m_vAllianceDescription.Length < 259 || clanSettingsMessage.m_vAllianceDescription.Length < 0)
                    {
                        if (clanSettingsMessage.m_vAllianceBadgeData < 1 || (long)clanSettingsMessage.m_vAllianceBadgeData < 10000000000L)
                        {
                            if (clanSettingsMessage.m_vAllianceType < 0 || clanSettingsMessage.m_vAllianceType < 10)
                            {
                                if (clanSettingsMessage.m_vRequiredScore < 0 || clanSettingsMessage.m_vRequiredScore < 4201)
                                {
                                    if (clanSettingsMessage.m_vWarFrequency < 0 || clanSettingsMessage.m_vWarFrequency < 10)
                                    {
                                        if (clanSettingsMessage.m_vAllianceOrigin < 0 || clanSettingsMessage.m_vAllianceOrigin < 42000000)
                                        {
                                            if ((int)clanSettingsMessage.m_vWarAndFriendlyStatus < 0 || (int)clanSettingsMessage.m_vWarAndFriendlyStatus < 5)
                                            {
                                                alliance.SetAllianceDescription(m_vAllianceDescription);
                                                alliance.SetAllianceBadgeData(m_vAllianceBadgeData);
                                                alliance.SetAllianceType(m_vAllianceType);
                                                alliance.SetRequiredScore(m_vRequiredScore);
                                                alliance.SetWarFrequency(m_vWarFrequency);
                                                alliance.SetAllianceOrigin(m_vAllianceOrigin);
                                                alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus);
                                                ClientAvatar avatar = level.GetPlayerAvatar();
                                                avatar.GetAllianceId();
                                                AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry();
                                                eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                                                eventStreamEntry.SetSender(avatar);
                                                eventStreamEntry.SetEventType(10);
                                                eventStreamEntry.SetAvatarId(avatar.GetId());
                                                eventStreamEntry.SetAvatarName(avatar.GetAvatarName());
                                                eventStreamEntry.SetSenderId(avatar.GetId());
                                                eventStreamEntry.SetSenderName(avatar.GetAvatarName());
                                                alliance.AddChatMessage(eventStreamEntry);
                                                AllianceSettingChangedCommand Command = new AllianceSettingChangedCommand();
                                                Command.SetAlliance(alliance);
                                                Command.SetPlayer(level);
                                                var availableServerCommandMessage = new AvailableServerCommandMessage(level.GetClient());
                                                availableServerCommandMessage.SetCommandId(6);
                                                availableServerCommandMessage.SetCommand(Command);
                                                availableServerCommandMessage.Send();
                                                foreach (AllianceMemberEntry allianceMember in alliance.GetAllianceMembers())
                                                {
                                                    Level player = ResourcesManager.GetPlayer(allianceMember.GetAvatarId(), false);
                                                    if (ResourcesManager.IsPlayerOnline(player))
                                                    {
                                                        var p = new AllianceStreamEntryMessage(player.GetClient());
                                                        AllianceEventStreamEntry eventStreamEntry1 = eventStreamEntry;
                                                        p.SetStreamEntry(eventStreamEntry1);
                                                        p.Send();
                                                    }
                                                }
                                                List <AllianceMemberEntry> .Enumerator enumerator = new List <AllianceMemberEntry> .Enumerator();

                                                DatabaseManager.Instance.Save(alliance);
                                                eventStreamEntry = (AllianceEventStreamEntry)null;
                                            }
                                            else
                                            {
                                                ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                                            }
                                        }
                                        else
                                        {
                                            ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                                        }
                                    }
                                    else
                                    {
                                        ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                                    }
                                }
                                else
                                {
                                    ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                                }
                            }
                            else
                            {
                                ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                            }
                        }
                        else
                        {
                            ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                        }
                    }
                    else
                    {
                        ResourcesManager.DisconnectClient(clanSettingsMessage.Client);
                    }
                }
                alliance = (Alliance)null;
            }
            catch (Exception ex)
            {
            }
        }