コード例 #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()
        {
            Alliance a = ObjectManager.GetAlliance(this.Device.Player.Avatar.AllianceId);

            if (a != null)
            {
                AllianceMemberEntry _AllianceMemberEntry = a.m_vAllianceMembers[this.Device.Player.Avatar.UserId];
                _AllianceMemberEntry.ToggleStatus();
                PlayerWarStatusMessage _PlayerWarStatusMessage = new PlayerWarStatusMessage(this.Device)
                {
                    Status = _AllianceMemberEntry.WarOptInStatus
                };
                _PlayerWarStatusMessage.Send();
            }
        }
コード例 #3
0
        private void OnLeaveAllianceMessageReceived(LeaveAllianceMessage message)
        {
            if (this.m_session.Alliance != null)
            {
                Alliance            alliance    = this.m_session.Alliance;
                AllianceMemberEntry memberEntry = alliance.Members[this.m_session.AccountId];

                if (memberEntry.GetAllianceRole() == LogicAvatarAllianceRole.LEADER)
                {
                    AllianceMemberEntry     higherMemberEntry = null;
                    LogicAvatarAllianceRole higherMemberRole  = 0;

                    foreach (AllianceMemberEntry member in alliance.Members.Values)
                    {
                        if (member != memberEntry && (higherMemberEntry == null || !member.HasLowerRoleThan(higherMemberRole)))
                        {
                            higherMemberEntry = member;
                            higherMemberRole  = member.GetAllianceRole();
                        }
                    }

                    if (higherMemberEntry != null)
                    {
                        alliance.ChangeMemberRole(higherMemberEntry, LogicAvatarAllianceRole.LEADER, memberEntry.GetAvatarId(), memberEntry.GetName());
                    }
                }

                AllianceEventStreamEntry allianceEventStreamEntry = new AllianceEventStreamEntry();
                AllianceStreamEntryUtil.SetSenderInfo(allianceEventStreamEntry, memberEntry);

                allianceEventStreamEntry.SetEventType(AllianceEventStreamEntryType.LEFT);
                allianceEventStreamEntry.SetEventAvatarId(memberEntry.GetAvatarId());
                allianceEventStreamEntry.SetEventAvatarName(memberEntry.GetName());

                StreamManager.Create(alliance.Id, allianceEventStreamEntry);

                alliance.AddStreamEntry(allianceEventStreamEntry);
                alliance.RemoveMember(this.m_session.AccountId);

                ServerMessageManager.SendMessage(new AllianceLeavedMessage
                {
                    AccountId  = this.m_session.AccountId,
                    AllianceId = alliance.Id
                }, 9);

                AllianceManager.Save(alliance);
            }
        }
コード例 #4
0
        public override void Process(Level level)
        {
            if (m_vAllianceName == null)
            {
                m_vAllianceName = "Clan";
            }

            var alliance = ObjectManager.CreateAlliance(0);

            alliance.SetAllianceName(m_vAllianceName);
            alliance.SetAllianceDescription(m_vAllianceDescription);
            alliance.SetAllianceType(m_vAllianceType);
            alliance.SetRequiredScore(m_vRequiredScore);
            alliance.SetAllianceBadgeData(m_vAllianceBadgeData);
            alliance.SetAllianceOrigin(m_vAllianceOrigin);
            alliance.SetWarFrequency(m_vWarFrequency);
            alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus);
            level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());

            var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());

            member.SetRole(2);
            alliance.AddAllianceMember(member);

            var b = new JoinedAllianceCommand();

            b.SetAlliance(alliance);

            var d = new AllianceRoleUpdateCommand();

            d.SetAlliance(alliance);
            d.SetRole(2);
            d.Tick(level);

            var a = new AvailableServerCommandMessage(Client);

            a.SetCommandId(1);
            a.SetCommand(b);

            var c = new AvailableServerCommandMessage(Client);

            c.SetCommandId(8);
            c.SetCommand(d);

            a.Send();
            c.Send();
        }
コード例 #5
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) { }
        }
コード例 #6
0
        public void AddMember(AllianceMemberEntry member)
        {
            if (!this.Members.TryAdd(member.GetAvatarId(), member))
            {
                throw new Exception("Alliance.addMember: member already in this alliance!");
            }
            if (this.IsFull())
            {
                throw new Exception("Alliance.addMember: alliance is FULL!");
            }

            this.Header.SetNumberOfMembers(this.Members.Count);
            this.UpdateScoring();
            this.OnMemberAdded(member);

            this.KickedMembersTimes.Remove(member.GetAvatarId());
        }
コード例 #7
0
        public override async void Execute(Level level)
        {
            try
            {
                Alliance a = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());

                if (a != null)
                {
                    AllianceMemberEntry _AllianceMemberEntry = a.GetAllianceMember(level.GetPlayerAvatar().GetId());
                    _AllianceMemberEntry.ToggleStatus();
                    PlayerWarStatusMessage _PlayerWarStatusMessage = new PlayerWarStatusMessage(level.GetClient());
                    _PlayerWarStatusMessage.SetStatus(_AllianceMemberEntry.GetStatus());
                    PacketProcessor.Send(_PlayerWarStatusMessage);
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #8
0
        public override void Process(Level level)
        {
            var alliance = ObjectManager.GetAlliance(m_vAllianceId);

            if (alliance == null || alliance.IsAllianceFull())
            {
                return;
            }

            level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());
            var entry = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());

            entry.SetRole(1);
            alliance.AddAllianceMember(entry);

            var jaCommand = new JoinedAllianceCommand();

            jaCommand.SetAlliance(alliance);

            var aruCommand = new AllianceRoleUpdateCommand();

            aruCommand.SetAlliance(alliance);
            aruCommand.SetRole(1);
            aruCommand.Tick(level);

            var asCommand1 = new AvailableServerCommandMessage(Client);

            asCommand1.SetCommandId(1);
            asCommand1.SetCommand(jaCommand);

            var asCommand2 = new AvailableServerCommandMessage(Client);

            asCommand2.SetCommandId(8);
            asCommand2.SetCommand(aruCommand);

            asCommand1.Send();
            asCommand2.Send();

            new AllianceStreamMessage(Client, alliance).Send();
        }
コード例 #9
0
        public override async void Process(Level level)
        {
            try
            {
                Alliance alliance = await ObjectManager.GetAlliance(m_vAllianceId);

                if (alliance != null)
                {
                    if (!alliance.IsAllianceFull())
                    {
                        level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());
                        AllianceMemberEntry member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());
                        member.SetRole(1);
                        alliance.AddAllianceMember(member);

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

                        AllianceRoleUpdateCommand c = new AllianceRoleUpdateCommand();
                        c.SetAlliance(alliance);
                        c.SetRole(1);
                        c.Tick(level);

                        AvailableServerCommandMessage a = new AvailableServerCommandMessage(Client);
                        a.SetCommandId(1);
                        a.SetCommand(b);

                        AvailableServerCommandMessage d = new AvailableServerCommandMessage(Client);
                        d.SetCommandId(8);
                        d.SetCommand(c);

                        PacketProcessor.Send(a);
                        PacketProcessor.Send(d);

                        PacketProcessor.Send(new AllianceStreamMessage(Client, alliance));
                    }
                }
            } catch (Exception) { }
        }
コード例 #10
0
        private void OnChangeAllianceSettingsMessageReceived(ChangeAllianceSettingsMessage message)
        {
            if (this.m_session.Alliance != null)
            {
                this.m_session.Alliance.SetAllianceSettings(message.GetAllianceDescription(), (AllianceType)message.GetAllianceType(), message.GetAllianceBadgeId(), message.GetRequiredScore(),
                                                            message.GetRequiredDuelScore(), message.GetWarFrequency(), message.GetOriginData(), message.IsPublicWarLog(), message.IsAmicalWarEnabled());

                AllianceMemberEntry      memberEntry = this.m_session.Alliance.Members[this.m_session.AccountId];
                AllianceEventStreamEntry allianceEventStreamEntry = new AllianceEventStreamEntry();
                AllianceStreamEntryUtil.SetSenderInfo(allianceEventStreamEntry, memberEntry);

                allianceEventStreamEntry.SetEventType(AllianceEventStreamEntryType.CHANGED_SETTINGS);
                allianceEventStreamEntry.SetEventAvatarId(memberEntry.GetAvatarId());
                allianceEventStreamEntry.SetEventAvatarName(memberEntry.GetName());

                StreamManager.Create(this.m_session.Alliance.Id, allianceEventStreamEntry);

                this.m_session.Alliance.AddStreamEntry(allianceEventStreamEntry);

                AllianceManager.Save(this.m_session.Alliance);
            }
        }
コード例 #11
0
        public override void Process(Level level)
        {
            var alliance = ObjectManager.GetAlliance(m_vAllianceId);

            if (alliance != null)
            {
                if (!alliance.IsAllianceFull())
                {
                    level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());
                    var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());
                    member.SetRole(1);
                    alliance.AddAllianceMember(member);

                    var joinAllianceCommand = new JoinAllianceCommand();
                    joinAllianceCommand.SetAlliance(alliance);
                    var availableServerCommandMessage = new AvailableServerCommandMessage(Client);
                    availableServerCommandMessage.SetCommandId(1);
                    availableServerCommandMessage.SetCommand(joinAllianceCommand);
                    PacketManager.ProcessOutgoingPacket(availableServerCommandMessage);
                    PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(Client, alliance));
                }
            }
        }
コード例 #12
0
        protected sealed override void Load(LogicJSONObject jsonObject)
        {
            this.Header.Load(jsonObject);
            this.Header.SetAllianceId(this.Id);
            this.Description = jsonObject.GetJSONString(AllianceDocument.JSON_ATTRIBUTE_DESCRIPTION).GetStringValue();

            LogicJSONArray memberArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_MEMBERS);

            for (int i = 0; i < memberArray.Size(); i++)
            {
                AllianceMemberEntry allianceMemberEntry = new AllianceMemberEntry();
                allianceMemberEntry.Load(memberArray.GetJSONObject(i));
                this.Members.Add(allianceMemberEntry.GetAvatarId(), allianceMemberEntry);
            }

            LogicJSONArray kickedMemberTimeArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES);

            for (int i = 0; i < kickedMemberTimeArray.Size(); i++)
            {
                LogicJSONObject obj           = kickedMemberTimeArray.GetJSONObject(i);
                LogicJSONArray  avatarIdArray = obj.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES_ID);
                LogicLong       avatarId      = new LogicLong(avatarIdArray.GetJSONNumber(0).GetIntValue(), avatarIdArray.GetJSONNumber(1).GetIntValue());
                DateTime        kickTime      = DateTime.Parse(obj.GetJSONString(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES_TIME).GetStringValue());

                this.KickedMembersTimes.Add(avatarId, kickTime);
            }

            LogicJSONArray streamArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_STREAM_ENTRY_LIST);

            for (int i = 0; i < streamArray.Size(); i++)
            {
                LogicJSONArray avatarIdArray = streamArray.GetJSONArray(i);
                LogicLong      id            = new LogicLong(avatarIdArray.GetJSONNumber(0).GetIntValue(), avatarIdArray.GetJSONNumber(1).GetIntValue());

                this.StreamEntryList.Add(id);
            }
        }
コード例 #13
0
ファイル: JoinAllianceMessage.cs プロジェクト: Dekryptor/UCS
        public override void Process(Level level)
        {
            var alliance = ObjectManager.GetAlliance(m_vAllianceId);

            if (alliance != null)
            {
                if (!alliance.IsAllianceFull())
                {
                    level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());
                    var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());
                    member.SetRole(1);
                    alliance.AddAllianceMember(member);

                    var b = new JoinedAllianceCommand();
                    b.SetAlliance(alliance);

                    var c = new AllianceRoleUpdateCommand();
                    c.SetAlliance(alliance);
                    c.SetRole(1);
                    c.Tick(level);

                    var a = new AvailableServerCommandMessage(Client);
                    a.SetCommandId(1);
                    a.SetCommand(b);

                    var d = new AvailableServerCommandMessage(Client);
                    d.SetCommandId(8);
                    d.SetCommand(c);

                    a.Send();
                    d.Send();

                    new AllianceStreamMessage(Client, alliance).Send();
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Removes the specified member.
        /// </summary>
        /// <param name="Member">The member.</param>
        internal bool TryRemove(AllianceMemberEntry Member)
        {
            if (Member != null)
            {
                if (this.Entries.TryRemove(Member.PlayerID, out AllianceMemberEntry MemberEntry))
                {
                    if (!Member.Equals(MemberEntry))
                    {
                        Logging.Error(this.GetType(), "TryRemove() - Entry has been removed but TryRemove(PlayerID, out Member) returned a member not equal to the one we are trying to remove.");
                        return(false);
                    }

                    return(true);
                }

                this.Connected.TryRemove(Member.PlayerID, out _);
            }
            else
            {
                Logging.Error(this.GetType(), "TryRemove() - Member was null at Remove(Member).");
            }

            return(false);
        }
コード例 #15
0
        public override void Process(Level level)
        {
            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)
                {
                    if (m_vAllianceBadgeData < 1 || (long)m_vAllianceBadgeData < 10000000000L)
                    {
                        if (m_vAllianceType < 0 || m_vAllianceType < 10)
                        {
                            if (m_vRequiredScore < 0 || m_vRequiredScore < 4201)
                            {
                                if (m_vWarFrequency < 0 || m_vWarFrequency < 10)
                                {
                                    if (m_vAllianceOrigin < 0 || m_vAllianceOrigin < 42000000)
                                    {
                                        if ((int)m_vWarAndFriendlyStatus < 0 || (int)m_vWarAndFriendlyStatus < 5)
                                        {
                                            Alliance alliance = ObjectManager.CreateAlliance();
                                            alliance.SetAllianceName(m_vAllianceName);
                                            alliance.SetAllianceDescription(m_vAllianceDescription);
                                            alliance.SetAllianceType(m_vAllianceType);
                                            alliance.SetRequiredScore(m_vRequiredScore);
                                            alliance.SetAllianceBadgeData(m_vAllianceBadgeData);
                                            alliance.SetAllianceOrigin(m_vAllianceOrigin);
                                            alliance.SetWarFrequency(m_vWarFrequency);
                                            alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus);
                                            level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());
                                            AllianceMemberEntry entry = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());
                                            entry.SetRole(2);
                                            alliance.AddAllianceMember(entry);
                                            JoinedAllianceCommand Command1 = new JoinedAllianceCommand();
                                            Command1.SetAlliance(alliance);
                                            AllianceRoleUpdateCommand Command2 = new AllianceRoleUpdateCommand();
                                            Command2.SetAlliance(alliance);
                                            Command2.SetRole(2);
                                            Command2.Tick(level);
                                            var a = new AvailableServerCommandMessage(Client);
                                            a.SetCommandId(1);
                                            a.SetCommand(Command1);
                                            var c = new AvailableServerCommandMessage(Client);
                                            c.SetCommandId(8);
                                            c.SetCommand(Command2);
                                            a.Send();
                                            c.Send();
                                        }
                                        else
                                        {
                                            ResourcesManager.DisconnectClient(Client);
                                        }
                                    }
                                    else
                                    {
                                        ResourcesManager.DisconnectClient(Client);
                                    }
                                }
                                else
                                {
                                    ResourcesManager.DisconnectClient(Client);
                                }
                            }
                            else
                            {
                                ResourcesManager.DisconnectClient(Client);
                            }
                        }
                        else
                        {
                            ResourcesManager.DisconnectClient(Client);
                        }
                    }
                    else
                    {
                        ResourcesManager.DisconnectClient(Client);
                    }
                }
                else
                {
                    ResourcesManager.DisconnectClient(Client);
                }
            }
            else
            {
                ResourcesManager.DisconnectClient(Client);
            }
        }
コード例 #16
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) { }
        }
コード例 #17
0
        public override async void Process(Level level)
        {
            try
            {
                Alliance a = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());

                StreamEntry message   = a.GetChatMessages().Find(c => c.GetId() == MessageID);
                Level       requester = await ResourcesManager.GetPlayer(message.GetSenderId());

                if (Choice == 1)
                {
                    if (!a.IsAllianceFull())
                    {
                        requester.GetPlayerAvatar().SetAllianceId(a.GetAllianceId());

                        AllianceMemberEntry member = new AllianceMemberEntry(requester.GetPlayerAvatar().GetId());
                        member.SetRole(1);
                        a.AddAllianceMember(member);

                        StreamEntry e = a.GetChatMessages().Find(c => c.GetId() == MessageID);
                        e.SetJudgeName(level.GetPlayerAvatar().GetAvatarName());
                        e.SetState(2);

                        AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry();
                        eventStreamEntry.SetId(a.GetChatMessages().Count + 1);
                        eventStreamEntry.SetSender(requester.GetPlayerAvatar());
                        eventStreamEntry.SetAvatarName(level.GetPlayerAvatar().GetAvatarName());
                        eventStreamEntry.SetAvatarId(level.GetPlayerAvatar().GetId());
                        eventStreamEntry.SetEventType(2);

                        a.AddChatMessage(eventStreamEntry);

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

                            if (player.GetClient() != null)
                            {
                                AllianceStreamEntryMessage c = new AllianceStreamEntryMessage(player.GetClient());
                                AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(player.GetClient());
                                p.SetStreamEntry(eventStreamEntry);
                                c.SetStreamEntry(e);

                                PacketProcessor.Send(p);
                                PacketProcessor.Send(c);
                            }
                        }
                        if (ResourcesManager.IsPlayerOnline(requester))
                        {
                            JoinedAllianceCommand joinAllianceCommand = new JoinedAllianceCommand();
                            joinAllianceCommand.SetAlliance(a);

                            AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(requester.GetClient());
                            availableServerCommandMessage.SetCommandId(1);
                            availableServerCommandMessage.SetCommand(joinAllianceCommand);

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

                            AvailableServerCommandMessage c = new AvailableServerCommandMessage(Client);
                            c.SetCommandId(8);
                            c.SetCommand(d);

                            PacketProcessor.Send(new AnswerJoinRequestAllianceMessage(Client));
                            PacketProcessor.Send(availableServerCommandMessage);
                            PacketProcessor.Send(c);
                            PacketProcessor.Send(new AllianceStreamMessage(requester.GetClient(), a));
                        }
                    }
                }
                else
                {
                    StreamEntry e = a.GetChatMessages().Find(c => c.GetId() == MessageID);
                    e.SetJudgeName(level.GetPlayerAvatar().GetAvatarName());
                    e.SetState(3);

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

                        if (player.GetClient() != null)
                        {
                            AllianceStreamEntryMessage c = new AllianceStreamEntryMessage(player.GetClient());
                            c.SetStreamEntry(e);
                            PacketProcessor.Send(c);
                        }
                    }
                }
            } catch (Exception) { }
        }
コード例 #18
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
     memberEntry.SetLeagueType(this.LeagueType);
 }
コード例 #19
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
     memberEntry.SetDuelScore(memberEntry.GetDuelScore() + this.DuelScoreGain);
 }
コード例 #20
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
     memberEntry.SetWarPreference(this.Preference);
 }
コード例 #21
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
     memberEntry.SetName(this.Name);
 }
コード例 #22
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
     memberEntry.SetScore(LogicMath.Max(memberEntry.GetScore() + this.ScoreGain, 0));
 }
コード例 #23
0
        private void OnRespondToAllianceJoinRequestMessageReceived(RespondToAllianceJoinRequestMessage message)
        {
            if (this.m_session.Alliance != null)
            {
                Alliance            alliance    = this.m_session.Alliance;
                AllianceMemberEntry memberEntry = alliance.Members[this.m_session.AccountId];

                if (memberEntry.GetAllianceRole() == LogicAvatarAllianceRole.MEMBER)
                {
                    AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();
                    allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.NO_RIGHTS);
                    this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                    return;
                }

                LogicLong streamId = message.GetStreamEntryId();

                if (alliance.StreamEntryList.IndexOf(streamId) != -1)
                {
                    StreamEntry streamEntry = StreamManager.GetAllianceStream(message.GetStreamEntryId());

                    if (streamEntry.GetStreamEntryType() == StreamEntryType.JOIN_REQUEST)
                    {
                        JoinRequestAllianceStreamEntry joinRequestAllianceStreamEntry = (JoinRequestAllianceStreamEntry)streamEntry;

                        if (joinRequestAllianceStreamEntry.GetState() == 1)
                        {
                            if (message.IsAccepted())
                            {
                                ServerRequestManager.Create(new GameJoinAllianceRequestMessage
                                {
                                    AccountId  = joinRequestAllianceStreamEntry.GetSenderAvatarId(),
                                    AllianceId = alliance.Id,
                                    Invited    = true
                                }, ServerManager.GetDocumentSocket(9, joinRequestAllianceStreamEntry.GetSenderAvatarId())).OnComplete = args =>
                                {
                                    if (this.m_session.IsDestructed())
                                    {
                                        return;
                                    }

                                    if (args.ErrorCode == ServerRequestError.Success)
                                    {
                                        if (args.ResponseMessage.Success)
                                        {
                                            joinRequestAllianceStreamEntry.SetState(2);
                                            joinRequestAllianceStreamEntry.SetResponderName(memberEntry.GetName());
                                            alliance.UpdateStreamEntry(joinRequestAllianceStreamEntry);

                                            StreamManager.Save(joinRequestAllianceStreamEntry);
                                        }
                                        else
                                        {
                                            GameJoinAllianceResponseMessage     gameJoinAllianceResponseMessage     = (GameJoinAllianceResponseMessage)args.ResponseMessage;
                                            AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();

                                            switch (gameJoinAllianceResponseMessage.ErrorReason)
                                            {
                                            case GameJoinAllianceResponseMessage.Reason.NO_CASTLE:
                                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.NO_CASTLE);

                                                if (joinRequestAllianceStreamEntry.GetState() == 1)
                                                {
                                                    alliance.RemoveStreamEntry(joinRequestAllianceStreamEntry.GetId());
                                                    AllianceManager.Save(alliance);
                                                }

                                                break;

                                            case GameJoinAllianceResponseMessage.Reason.ALREADY_IN_ALLIANCE:
                                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.ALREADY_IN_ALLIANCE);

                                                if (joinRequestAllianceStreamEntry.GetState() == 1)
                                                {
                                                    alliance.RemoveStreamEntry(joinRequestAllianceStreamEntry.GetId());
                                                    AllianceManager.Save(alliance);
                                                }

                                                break;

                                            default:
                                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.GENERIC);
                                                break;
                                            }

                                            this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                                        }
                                    }
                                    else
                                    {
                                        AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();
                                        allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.GENERIC);
                                        this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                                    }
                                };
                            }
                            else
                            {
                                joinRequestAllianceStreamEntry.SetState(0);
                                joinRequestAllianceStreamEntry.SetResponderName(memberEntry.GetName());
                                alliance.UpdateStreamEntry(joinRequestAllianceStreamEntry);

                                StreamManager.Save(joinRequestAllianceStreamEntry);

                                JoinAllianceResponseAvatarStreamEntry joinAllianceResponseAvatarStreamEntry = new JoinAllianceResponseAvatarStreamEntry();

                                joinAllianceResponseAvatarStreamEntry.SetSenderAvatarId(memberEntry.GetAvatarId());
                                joinAllianceResponseAvatarStreamEntry.SetSenderHomeId(memberEntry.GetHomeId());
                                joinAllianceResponseAvatarStreamEntry.SetSenderName(memberEntry.GetName());
                                joinAllianceResponseAvatarStreamEntry.SetSenderLevel(memberEntry.GetExpLevel());
                                joinAllianceResponseAvatarStreamEntry.SetSenderLeagueType(memberEntry.GetLeagueType());

                                joinAllianceResponseAvatarStreamEntry.SetAllianceId(alliance.Id);
                                joinAllianceResponseAvatarStreamEntry.SetAllianceName(alliance.Header.GetAllianceName());
                                joinAllianceResponseAvatarStreamEntry.SetAllianceBadgeId(alliance.Header.GetAllianceBadgeId());

                                ServerMessageManager.SendMessage(new CreateAvatarStreamMessage
                                {
                                    AccountId = joinRequestAllianceStreamEntry.GetSenderAvatarId(),
                                    Entry     = joinAllianceResponseAvatarStreamEntry
                                }, 9);
                            }
                        }
                    }
                }
            }
        }
コード例 #24
0
        public static void SetLogicClientAvatarToAllianceMemberEntry(LogicClientAvatar avatar, AllianceMemberEntry allianceMemberEntry, Alliance alliance = null)
        {
            bool updateScoring = avatar.GetScore() != avatar.GetScore();

            allianceMemberEntry.SetAvatarId(avatar.GetId());
            allianceMemberEntry.SetHomeId(avatar.GetCurrentHomeId());
            allianceMemberEntry.SetName(avatar.GetName());
            allianceMemberEntry.SetExpLevel(avatar.GetExpLevel());
            allianceMemberEntry.SetLeagueType(avatar.GetLeagueType());
            allianceMemberEntry.SetScore(avatar.GetScore());
            allianceMemberEntry.SetDuelScore(avatar.GetDuelScore());
            allianceMemberEntry.SetWarPreference(avatar.GetWarPreference());

            if (alliance != null)
            {
                if (updateScoring)
                {
                    alliance.UpdateScoring();
                }
            }
        }
コード例 #25
0
        private void OnSendAllianceInvitationMessageReceived(SendAllianceInvitationMessage message)
        {
            if (this.m_session.Alliance != null)
            {
                Alliance            alliance    = this.m_session.Alliance;
                AllianceMemberEntry memberEntry = alliance.Members[this.m_session.AccountId];

                if (memberEntry.GetAllianceRole() == LogicAvatarAllianceRole.MEMBER)
                {
                    AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();
                    allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.NO_RIGHTS);
                    this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                    return;
                }

                if (memberEntry.GetAllianceRole() == LogicAvatarAllianceRole.ELDER)
                {
                    AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();
                    allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.USER_BANNED);
                    this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                    return;
                }

                AllianceInvitationAvatarStreamEntry allianceInvitationAvatarStreamEntry = new AllianceInvitationAvatarStreamEntry();

                allianceInvitationAvatarStreamEntry.SetSenderAvatarId(memberEntry.GetAvatarId());
                allianceInvitationAvatarStreamEntry.SetSenderHomeId(memberEntry.GetHomeId());
                allianceInvitationAvatarStreamEntry.SetSenderName(memberEntry.GetName());
                allianceInvitationAvatarStreamEntry.SetSenderLevel(memberEntry.GetExpLevel());
                allianceInvitationAvatarStreamEntry.SetSenderLeagueType(memberEntry.GetLeagueType());

                allianceInvitationAvatarStreamEntry.SetAllianceId(alliance.Id);
                allianceInvitationAvatarStreamEntry.SetAllianceName(alliance.Header.GetAllianceName());
                allianceInvitationAvatarStreamEntry.SetAllianceBadgeId(alliance.Header.GetAllianceBadgeId());
                allianceInvitationAvatarStreamEntry.SetAllianceLevel(alliance.Header.GetAllianceLevel());

                ServerRequestManager.Create(new GameCreateAllianceInvitationRequestMessage
                {
                    AccountId = message.GetAvatarId(),
                    Entry     = allianceInvitationAvatarStreamEntry
                }, ServerManager.GetDocumentSocket(9, message.GetAvatarId())).OnComplete = args =>
                {
                    if (this.m_session.IsDestructed())
                    {
                        return;
                    }

                    if (args.ErrorCode == ServerRequestError.Success)
                    {
                        GameCreateAllianceInvitationResponseMessage responseMessage = (GameCreateAllianceInvitationResponseMessage)args.ResponseMessage;

                        if (responseMessage.Success)
                        {
                            this.m_session.SendPiranhaMessage(new AllianceInvitationSentOkMessage(), 1);
                        }
                        else
                        {
                            AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();

                            switch (responseMessage.ErrorReason)
                            {
                            case GameCreateAllianceInvitationResponseMessage.Reason.GENERIC:
                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.GENERIC);
                                break;

                            case GameCreateAllianceInvitationResponseMessage.Reason.NO_CASTLE:
                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.NO_CASTLE);
                                break;

                            case GameCreateAllianceInvitationResponseMessage.Reason.ALREADY_IN_ALLIANCE:
                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.ALREADY_IN_ALLIANCE);
                                break;

                            case GameCreateAllianceInvitationResponseMessage.Reason.ALREADY_HAS_AN_INVITE:
                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.ALREADY_HAS_AN_INVITE);
                                break;

                            case GameCreateAllianceInvitationResponseMessage.Reason.HAS_TOO_MANY_INVITES:
                                allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.HAS_TOO_MANY_INVITES);
                                break;
                            }

                            this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                        }
                    }
                    else
                    {
                        AllianceInvitationSendFailedMessage allianceInvitationSendFailedMessage = new AllianceInvitationSendFailedMessage();
                        allianceInvitationSendFailedMessage.SetReason(AllianceInvitationSendFailedMessage.Reason.GENERIC);
                        this.m_session.SendPiranhaMessage(allianceInvitationSendFailedMessage, 1);
                    }
                };
            }
        }
コード例 #26
0
        private static void OnAllianceJoinRequestMessageReceived(AllianceJoinRequestMessage message)
        {
            AllianceJoinResponseMessage joinAllianceResponseMessage = new AllianceJoinResponseMessage();

            if (!AllianceManager.TryGet(message.AllianceId, out Alliance alliance))
            {
                joinAllianceResponseMessage.ErrorReason = AllianceJoinResponseMessage.Reason.GENERIC;
                ServerRequestManager.SendResponse(joinAllianceResponseMessage, message);
                return;
            }

            if (!message.Created)
            {
                if (alliance.IsFull())
                {
                    joinAllianceResponseMessage.ErrorReason = AllianceJoinResponseMessage.Reason.FULL;
                    ServerRequestManager.SendResponse(joinAllianceResponseMessage, message);
                    return;
                }

                if (!message.Invited)
                {
                    if (alliance.Header.GetAllianceType() != AllianceType.OPEN || alliance.Header.GetNumberOfMembers() == 0)
                    {
                        joinAllianceResponseMessage.ErrorReason =
                            alliance.Header.GetAllianceType() == AllianceType.CLOSED ? AllianceJoinResponseMessage.Reason.CLOSED : AllianceJoinResponseMessage.Reason.GENERIC;
                        ServerRequestManager.SendResponse(joinAllianceResponseMessage, message);
                        return;
                    }

                    if (alliance.IsBanned(message.Avatar.GetId()))
                    {
                        joinAllianceResponseMessage.ErrorReason = AllianceJoinResponseMessage.Reason.BANNED;
                        ServerRequestManager.SendResponse(joinAllianceResponseMessage, message);
                        return;
                    }

                    if (alliance.Header.GetRequiredScore() > message.Avatar.GetScore() || alliance.Header.GetRequiredDuelScore() > message.Avatar.GetDuelScore())
                    {
                        joinAllianceResponseMessage.ErrorReason = AllianceJoinResponseMessage.Reason.SCORE;
                        ServerRequestManager.SendResponse(joinAllianceResponseMessage, message);
                        return;
                    }
                }
            }
            else
            {
                if (alliance.Header.GetNumberOfMembers() != 0)
                {
                    throw new Exception("StreamMessageManager.joinAllianceRequestMessageReceived: A new alliance must be empty!");
                }
            }

            AllianceMemberEntry memberEntry = AllianceMemberUtil.GetAllianceMemberEntryFromAvatar(message.Avatar);

            memberEntry.SetAllianceRole(message.Created ? LogicAvatarAllianceRole.LEADER : LogicAvatarAllianceRole.MEMBER);
            alliance.AddMember(memberEntry);

            if (!message.Created)
            {
                AllianceEventStreamEntry allianceEventStreamEntry = new AllianceEventStreamEntry();
                AllianceStreamEntryUtil.SetSenderInfo(allianceEventStreamEntry, memberEntry);

                allianceEventStreamEntry.SetEventType(AllianceEventStreamEntryType.JOINED);
                allianceEventStreamEntry.SetEventAvatarId(memberEntry.GetAvatarId());
                allianceEventStreamEntry.SetEventAvatarName(memberEntry.GetName());

                StreamManager.Create(alliance.Id, allianceEventStreamEntry);

                alliance.AddStreamEntry(allianceEventStreamEntry);
            }

            joinAllianceResponseMessage.Success         = true;
            joinAllianceResponseMessage.AllianceId      = alliance.Id;
            joinAllianceResponseMessage.AllianceName    = alliance.Header.GetAllianceName();
            joinAllianceResponseMessage.AllianceBadgeId = alliance.Header.GetAllianceBadgeId();
            joinAllianceResponseMessage.AllianceLevel   = alliance.Header.GetAllianceLevel();
            joinAllianceResponseMessage.Created         = message.Created;

            AllianceManager.Save(alliance);
            ServerRequestManager.SendResponse(joinAllianceResponseMessage, message);
        }
コード例 #27
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
 }
コード例 #28
0
 public abstract void ApplyAvatarChange(AllianceMemberEntry memberEntry);
コード例 #29
0
 public override void ApplyAvatarChange(AllianceMemberEntry memberEntry)
 {
     memberEntry.SetExpLevel(memberEntry.GetExpLevel() + 1);
 }