Ejemplo n.º 1
0
        public override void Handle()
        {
            DateTime playerDOB = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);

            playerDOB = playerDOB.AddSeconds(Session.Player.PropertiesInt[Entity.Enum.Properties.PropertyInt.CreationTimestamp]).ToUniversalTime();

            var dobEvent = new GameMessages.Messages.GameMessageSystemChat($"You were born on {playerDOB.ToString("G")}.", ChatMessageType.Broadcast);

            Session.Network.EnqueueSend(dobEvent);
        }
Ejemplo n.º 2
0
        public static void Handle(ClientMessage message, Session session)
        {
            var      target    = message.Payload.ReadString16L();
            DateTime playerDOB = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);

            playerDOB = playerDOB.AddSeconds(session.Player.CreationTimestamp).ToUniversalTime();

            var dobEvent = new GameMessages.Messages.GameMessageSystemChat($"You were born on {playerDOB:G}.", ChatMessageType.Broadcast);

            session.Network.EnqueueSend(dobEvent);
        }
Ejemplo n.º 3
0
        public override void Handle()
        {
            switch (groupChatType)
            {
            case GroupChatType.TellAbuse:
            {
                //TODO: Proper permissions check. This command should work for any character with AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdmin:
            {
                if (!Session.Player.IsAdmin)
                {
                    break;
                }

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
                //NetworkManager.SendWorldMessage(recipient, gameMessageSystemChat);
            }
            break;

            case GroupChatType.TellAudit:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Sentinel or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdvocate:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdvocate2:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdvocate3:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellSentinel:
            {
                //TODO: Proper permissions check. This command should work for any character with AccessLevel.Sentinel or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellHelp:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellHelp Needs work.", ChatMessageType.Broadcast);
                //TODO: I don't remember exactly how this was triggered. I don't think it sent back a "You say" message to the person who triggered it
                //TODO: Proper permissions check. Requesting urgent help should work for any character but only displays the "says" mesage for those subscribed to the Help channel
                //      which would be Advocates and above.
                //if (!Session.Player.IsAdmin)
                //    break;
                string onTheWhatChannel = "on the " + System.Enum.GetName(typeof(GroupChatType), groupChatType).Replace("Tell", "") + " channel";
                string whoSays          = Session.Player.Name + " says ";

                //ChatPacket.SendServerMessage(Session, $"You say {onTheWhatChannel}, \"{message}\"", ChatMessageType.OutgoingHelpSay);

                var gameMessageSystemChat = new GameMessages.Messages.GameMessageSystemChat(whoSays + onTheWhatChannel + ", \"" + message + "\"", ChatMessageType.Help);

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(gameMessageSystemChat);
                    }
                }

                // again not sure what way to go with this.. the code below was added after I realized I should be handling things differently
                // and by handling differently I mean letting the client do all of the work it was already designed to do.

                //foreach (var recipient in WorldManager.GetAll())
                //    if (recipient != Session)
                //        NetworkManager.SendWorldMessage(recipient, new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                //    else
                //        NetworkManager.SendWorldMessage(recipient, new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
            }
            break;


            case GroupChatType.TellFellowship:
            {
                var statusMessage = new GameEventDisplayStatusMessage(Session, StatusMessageType1.YouDoNotBelongToAFellowship);
                Session.Network.EnqueueSend(statusMessage);

                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellFellowship Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellVassals:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellVassals Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellPatron:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellPatron Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellMonarch:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellMonarch Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellCoVassals:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellCoVassals Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.AllegianceBroadcast:
            {
                // The client knows if we're in an allegiance or not, and will throw an error to the user if they try to /a, and no message will be dispatched to the server.

                ChatPacket.SendServerMessage(Session, "GameActionChatChannel AllegianceBroadcast Needs work.", ChatMessageType.Broadcast);
            }
            break;

            default:
                Console.WriteLine($"Unhandled ChatChannel GroupChatType: 0x{(uint)groupChatType:X4}");
                break;
            }
        }
Ejemplo n.º 4
0
        public static void Handle(ClientMessage clientMessage, Session session)
        {
            var groupChatType = (Channel)clientMessage.Payload.ReadUInt32();
            var message = clientMessage.Payload.ReadString16L();

            switch (groupChatType)
            {
                case Channel.Abuse:
                    {
                        // Should anyone be able to post to this channel? If so should they just a response back stating their message has been posted.
                        // Should messages here also be written to a log?
                        if (session.AccessLevel < AccessLevel.Advocate)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel >= AccessLevel.Advocate)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Admin:
                    {
                        if (!session.Player.IsAdmin)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel == AccessLevel.Admin)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Audit:
                    {
                        if (session.AccessLevel < AccessLevel.Sentinel)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel >= AccessLevel.Sentinel)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Advocate1:
                    {
                        if (session.AccessLevel < AccessLevel.Advocate)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel >= AccessLevel.Advocate)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Advocate2:
                    {
                        if (session.AccessLevel < AccessLevel.Advocate)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel >= AccessLevel.Advocate)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Advocate3:
                    {
                        if (session.AccessLevel < AccessLevel.Advocate)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel >= AccessLevel.Advocate)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Sentinel:
                    {
                        if (session.AccessLevel < AccessLevel.Sentinel)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                            {
                                if (recipient.Session.AccessLevel >= AccessLevel.Sentinel)
                                    recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, session.Player.Name, message));
                            }
                            else
                            {
                                recipient.Session.Network.EnqueueSend(new GameEventChannelBroadcast(recipient.Session, groupChatType, "", message));
                            }
                    }
                    break;
                case Channel.Help:
                    {
                        ChatPacket.SendServerMessage(session, "GameActionChatChannel TellHelp Needs work.", ChatMessageType.Broadcast);
                        // TODO: I don't remember exactly how this was triggered. I don't think it sent back a "You say" message to the person who triggered it
                        // TODO: Proper permissions check. Requesting urgent help should work for any character but only displays the "says" mesage for those subscribed to the Help channel
                        //      which would be Advocates and above.
                        // if (!session.Player.IsAdmin)
                        //    break;
                        string onTheWhatChannel = "on the " + System.Enum.GetName(typeof(Channel), groupChatType).Replace("Tell", "") + " channel";
                        string whoSays = session.Player.Name + " says ";

                        // ChatPacket.SendServerMessage(session, $"You say {onTheWhatChannel}, \"{message}\"", ChatMessageType.OutgoingHelpSay);

                        var gameMessageSystemChat = new GameMessages.Messages.GameMessageSystemChat(whoSays + onTheWhatChannel + ", \"" + message + "\"", ChatMessageType.Help);

                        // TODO This should check if the recipient is subscribed to the channel
                        foreach (var recipient in PlayerManager.GetAllOnline())
                            if (recipient.Session != session)
                                recipient.Session.Network.EnqueueSend(gameMessageSystemChat);

                        // again not sure what way to go with this.. the code below was added after I realized I should be handling things differently
                        // and by handling differently I mean letting the client do all of the work it was already designed to do.

                        // foreach (var recipient in WorldManager.GetAll())
                        //    if (recipient != session)
                        //        NetworkManager.SendWorldMessage(recipient, new GameEventChannelBroadcast(recipient, groupChatType, session.Player.Name, message));
                        //    else
                        //        NetworkManager.SendWorldMessage(recipient, new GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                    break;
                case Channel.Fellow:
                    {
                        if (session.Player.Fellowship == null)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouDoNotBelongToAFellowship);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var fellowmember in session.Player.Fellowship.FellowshipMembers)
                            if (fellowmember.Session != session)
                                fellowmember.Session.Network.EnqueueSend(new GameEventChannelBroadcast(fellowmember.Session, groupChatType, session.Player.Name, message));
                            else
                                session.Network.EnqueueSend(new GameEventChannelBroadcast(session, groupChatType, "", message));
                    }
                    break;
                case Channel.Vassals:
                    {
                        if (!session.Player.HasAllegiance)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouAreNotInAllegiance);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        if (session.Player.AllegianceNode.TotalVassals == 0)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        foreach (var vassal in session.Player.AllegianceNode.Vassals)
                        {
                            var vassalPlayer = PlayerManager.GetOnlinePlayer(vassal.PlayerGuid);

                            if (vassalPlayer != null)
                                vassalPlayer.Session.Network.EnqueueSend(new GameEventChannelBroadcast(vassalPlayer.Session, groupChatType, session.Player.Name, message));
                        }
                        session.Network.EnqueueSend(new GameEventChannelBroadcast(session, groupChatType, "", message));
                    }
                    break;
                case Channel.Patron:
                    {
                        if (!session.Player.HasAllegiance)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouAreNotInAllegiance);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        if (!session.Player.Patron.HasValue)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        var patronPlayer = PlayerManager.GetOnlinePlayer(session.Player.AllegianceNode.Patron.PlayerGuid);

                        if (patronPlayer != null)
                            patronPlayer.Session.Network.EnqueueSend(new GameEventChannelBroadcast(patronPlayer.Session, groupChatType, session.Player.Name, message));

                        session.Network.EnqueueSend(new GameEventChannelBroadcast(session, groupChatType, "", message));
                    }
                    break;
                case Channel.Monarch:
                    {
                        if (!session.Player.HasAllegiance)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouAreNotInAllegiance);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        if (!session.Player.Monarch.HasValue)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        var monarchPlayer = PlayerManager.GetOnlinePlayer(session.Player.AllegianceNode.Monarch.PlayerGuid);

                        if (monarchPlayer != null)
                            monarchPlayer.Session.Network.EnqueueSend(new GameEventChannelBroadcast(monarchPlayer.Session, Channel.Patron, session.Player.Name, message));

                        session.Network.EnqueueSend(new GameEventChannelBroadcast(session, groupChatType, "", message));
                    }
                    break;
                case Channel.CoVassals:
                    {
                        if (!session.Player.HasAllegiance)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouAreNotInAllegiance);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        if (!session.Player.Patron.HasValue)
                        {
                            var statusMessage = new GameEventWeenieError(session, WeenieError.YouCantUseThatChannel);
                            session.Network.EnqueueSend(statusMessage);
                            break;
                        }

                        var patronPlayer = PlayerManager.GetOnlinePlayer(session.Player.AllegianceNode.Patron.PlayerGuid);

                        if (patronPlayer != null)
                            patronPlayer.Session.Network.EnqueueSend(new GameEventChannelBroadcast(patronPlayer.Session, Channel.Patron, session.Player.Name, message));

                        foreach (var covassal in session.Player.AllegianceNode.Patron.Vassals)
                        {
                            if (covassal.PlayerGuid.Full == session.Player.Guid.Full)
                            {
                                session.Network.EnqueueSend(new GameEventChannelBroadcast(session, groupChatType, "", message));
                            }
                            else
                            {
                                var covassalPlayer = PlayerManager.GetOnlinePlayer(covassal.PlayerGuid);

                                if (covassalPlayer != null)
                                    covassalPlayer.Session.Network.EnqueueSend(new GameEventChannelBroadcast(covassalPlayer.Session, groupChatType, session.Player.Name, message));
                            }
                        }
                    }
                    break;
                case Channel.AllegianceBroadcast:
                    {
                        // The client knows if we're in an allegiance or not, and will throw an error to the user if they try to /a, and no message will be dispatched to the server.
                        // 
                        ChatPacket.SendServerMessage(session, "GameActionChatChannel AllegianceBroadcast Needs work.", ChatMessageType.Broadcast);
                    }
                    break;
                default:
                    Console.WriteLine($"Unhandled ChatChannel GroupChatType: 0x{(uint)groupChatType:X4}");
                    break;
            }
        }