示例#1
0
        /// <summary>
        /// A quantified message is a message that starts with a special character. For example,
        /// in tibia 6.4, # is a quantifier, so #y is used to yell, #w is used to whisper etc.
        /// </summary>
        /// <param name="sender">Sender of the quantified message.</param>
        /// <param name="msg">The message itself.</param>
        private void HandleQuantifiedMessage(Creature sender, string msg, ThingSet tSet)
        {
            if (!msg.StartsWith(MSG_QUANTIFIER))
            {
                throw new Exception("Invalid call to HandleQuantifiedMessage()");
            }
            msg = msg.Substring(1); //Remove first quanitifer
            char quantifierType = char.ToLower(msg[0]);

            switch (quantifierType)
            {
            case BROADCAST_TYPE:
                HandleBroadcast(sender, msg);
                break;

            case WHISPER_TYPE:
                gameMap.GetThingsInWhisperVicinity(sender.CurrentPosition, tSet);
                //msg.Substring(2) is called in order to remove quantifier type and a space
                HandleLocalChat(ChatLocal.WHISPER, tSet, msg.Substring(2), sender);

                break;

            case YELL_TYPE:
                gameMap.GetThingsInYellVacinity(sender.CurrentPosition, tSet);
                //msg.Substring(2) is called in order to remove quantifier type and a space
                HandleLocalChat(ChatLocal.YELLS, tSet, msg.Substring(2).ToUpper(), sender);
                break;

            default:
#if DEBUG
                Log.WriteDebug("Invalid quantifier type");
#endif
                break;
            }
        }