Пример #1
0
        /// <summary>
        /// Inspect a person, object, etc.
        /// </summary>
        /// <param name="smc">The character doing the inspecting</param>
        /// <param name="thingToInspect">The thing that the person wants to inspect</param>
        public void InspectThing(SMCharacter smc, string thingToInspect)
        {
            // Check if it's a character first
            SMCharacter targetCharacter = this.GetPeople().FirstOrDefault(checkChar => (checkChar.GetFullName().ToLower() == thingToInspect.ToLower()) || (checkChar.FirstName.ToLower() == thingToInspect.ToLower()) || (checkChar.LastName.ToLower() == thingToInspect.ToLower()));

            if (targetCharacter != null)
            {
                string levelText = "";
                if (int.Parse(targetCharacter.CalculateLevel()) > 0)
                {
                    levelText = " (Level " + targetCharacter.CalculateLevel() + ")";
                }

                smc.sendMessageToPlayer(this.Formatter.Bold("Description of " + targetCharacter.GetFullName() + levelText + ":"));
                if ((targetCharacter.Description != null) && (targetCharacter.Description != ""))
                {
                    smc.sendMessageToPlayer(this.Formatter.Italic(targetCharacter.Description));
                }
                else
                {
                    smc.sendMessageToPlayer(this.Formatter.Italic("No description set..."));
                }

                List <string> inventory       = targetCharacter.GetInventoryList();
                string        inventoryOutput = String.Empty;

                if (inventory.Any())
                {
                    foreach (string item in inventory)
                    {
                        inventoryOutput += this.Formatter.ListItem(item);
                    }

                    inventoryOutput += this.Formatter.GetNewLines(1);
                }

                smc.sendMessageToPlayer(inventoryOutput);

                targetCharacter.sendMessageToPlayer(this.Formatter.Italic(smc.GetFullName() + " looks at you"));
                return;
            }

            // If not a character, check if it is an NPC...
            SMNPC targetNPC = this.GetNPCs().FirstOrDefault(checkChar => (checkChar.GetFullName().ToLower() == thingToInspect.ToLower()) || (checkChar.NPCType.ToLower() == thingToInspect.ToLower()));

            if (targetNPC != null)
            {
                string levelText = "";
                if (int.Parse(targetNPC.CalculateLevel()) > 0)
                {
                    levelText = " (Level " + targetNPC.CalculateLevel() + ")";
                }

                smc.sendMessageToPlayer(this.Formatter.Bold("Description of " + targetNPC.GetFullName() + levelText + ":"));
                if ((targetNPC.Description != null) && (targetNPC.Description != ""))
                {
                    smc.sendMessageToPlayer(this.Formatter.Italic(targetNPC.Description));
                }
                else
                {
                    smc.sendMessageToPlayer(this.Formatter.Italic("No description set..."));
                }

                List <string> inventory       = targetNPC.GetInventoryList();
                string        inventoryOutput = String.Empty;

                if (inventory.Any())
                {
                    foreach (string item in inventory)
                    {
                        inventoryOutput += this.Formatter.ListItem(item);
                    }

                    inventoryOutput += this.Formatter.GetNewLines(1);
                }

                smc.sendMessageToPlayer(inventoryOutput);

                targetNPC.GetRoom().ProcessNPCReactions("PlayerCharacter.ExaminesThem", smc, targetNPC.UserID);
                targetNPC.GetRoom().ProcessNPCReactions("PlayerCharacter.Examines", smc);
                return;
            }

            // If not an NPC, check the players equipped items and the items in the room...
            SMItem smi = smc.GetEquippedItem(thingToInspect);

            if (smi == null)
            {
                smi = SMItemHelper.GetItemFromList(this.RoomItems, thingToInspect);
            }

            if (smi != null)
            {
                string itemDeatils = this.Formatter.Bold("Description of \"" + smi.ItemName + "\":", 1);
                itemDeatils += this.Formatter.General(smi.ItemDescription, 1);

                if (smi.CanHoldOtherItems())
                {
                    itemDeatils += this.Formatter.Italic($"This \"{smi.ItemName}\" contains the following items:", 1);
                    itemDeatils += SMItemHelper.GetContainerContents(smi);
                }

                if (smi.Effects != null)
                {
                    smi.InitiateEffects(smc);
                }

                smc.sendMessageToPlayer(itemDeatils);
                return;
            }

            // Otherwise nothing found
            smc.sendMessageToPlayer(this.Formatter.Italic("Can not inspect that item."));
        }
Пример #2
0
        /// <summary>
        /// Logs someone in with the Slack UserID
        /// </summary>
        /// <param name="userID">Slack UserID</param>
        /// <returns>A string response</returns>
        public string Login(string userID, bool newCharacter = false, string responseURL = null, string connectionService = "slack", string password = null)
        {
            // Variables for the return string
            string returnString = "";

            // Get all current characters
            List <SMCharacter> smcs      = (List <SMCharacter>)HttpContext.Current.Application["SMCharacters"];
            SMCharacter        character = smcs.FirstOrDefault(smc => smc.UserID == userID);

            // Get the right path, and work out if the file exists.
            string path = FilePathSystem.GetFilePath("Characters", "Char" + userID);

            // Check if the character exists..
            if (!File.Exists(path))
            {
                // If they don't exist inform the person as to how to create a new user
                returnString  = ResponseFormatterFactory.Get().General("You must create a character, to do so, use the command /sm CreateCharacter FIRSTNAME,LASTNAME,SEX,AGE");
                returnString += ResponseFormatterFactory.Get().General("i.e. /sm CreateCharacter Paul,Hutson,m,34");

                // return information [need to return this without a player!]
                return(returnString);
            }
            else
            {
                if ((character != null) && (!newCharacter))
                {
                    returnString = ResponseFormatterFactory.Get().General("You're already logged in!");
                    return(returnString);
                }
                else
                {
                    // Get the character
                    character = GetCharacter(userID, password);

                    // Reset the character activity, just in case!
                    character.CurrentActivity = null;

                    // Set the response URL of the character
                    if (responseURL != null)
                    {
                        character.ResponseURL = responseURL;
                    }

                    // Set the connection service
                    character.ConnectionService = connectionService;

                    // Set the last login datetime
                    character.LastLogindate = DateTime.Now;

                    // Check that the currency is OK.
                    if (character.Currency == null)
                    {
                        character.Currency = new SMCurrency();
                        character.Currency.AmountOfCurrency = 50;
                    }

                    if (!newCharacter)
                    {
                        returnString = ResponseFormatterFactory.Get().Bold("Welcome back " + character.FirstName + " " + character.LastName + " (you are level " + character.CalculateLevel() + ")", 1);
                    }
                    else
                    {
                        returnString  = ResponseFormatterFactory.Get().Bold("Welcome to SlackMud!");
                        returnString += ResponseFormatterFactory.Get().General("We've created your character in the magical world of Arrelvia!");                         // TODO, use a welcome script!
                    }

                    // Check if the player was last in an instanced location.
                    if (character.RoomID.Contains("||"))
                    {
                        // Find the details of the original room type
                        SMRoom originalRoom = GetRoom(character.RoomID.Substring(0, character.RoomID.IndexOf("||")));
                        character.RoomID = originalRoom.InstanceReloadLocation;
                    }

                    // Clear out any old party references
                    character.PartyReference = null;

                    // Get the location details
                    returnString += GetLocationDetails(character.RoomID, character);

                    // Clear old responses an quests from the character
                    character.ClearQuests();
                    if (character.NPCsWaitingForResponses != null)
                    {
                        character.NPCsWaitingForResponses.RemoveAll(a => a.NPCID != "");
                    }

                    // Return the text output
                    character.sendMessageToPlayer(returnString);

                    // Walk the character in
                    SMRoom room = character.GetRoom();
                    if (room != null)
                    {
                        // Announce someone has walked into the room.
                        room.Announce(ResponseFormatterFactory.Get().Italic(character.GetFullName() + " walks in."));
                        room.ProcessNPCReactions("PlayerCharacter.Enter", character);
                    }

                    return("");
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Inspect a person, object, etc.
        /// </summary>
        /// <param name="smc">The character doing the inspecting</param>
        /// <param name="thingToInspect">The thing that the person wants to inspect</param>
        public void InspectThing(SMCharacter smc, string thingToInspect)
        {
            // Check if it's a character first
            SMCharacter targetCharacter = this.GetPeople().FirstOrDefault(checkChar => checkChar.GetFullName().ToLower() == thingToInspect.ToLower());

            if (targetCharacter != null)
            {
                smc.sendMessageToPlayer(OutputFormatterFactory.Get().Bold("Description of " + targetCharacter.GetFullName() + " (Level " + targetCharacter.CalculateLevel() + "):"));
                if ((targetCharacter.Description != null) || (targetCharacter.Description != ""))
                {
                    smc.sendMessageToPlayer(OutputFormatterFactory.Get().Italic(targetCharacter.Description));
                }
                else
                {
                    smc.sendMessageToPlayer(OutputFormatterFactory.Get().Italic("No description set..."));
                }
                smc.sendMessageToPlayer(OutputFormatterFactory.Get().CodeBlock(targetCharacter.GetInventoryList()));
                targetCharacter.sendMessageToPlayer(OutputFormatterFactory.Get().Italic(smc.GetFullName() + " looks at you"));
                return;
            }

            // If not a character, check if it is an NPC...
            SMNPC targetNPC = this.GetNPCs().FirstOrDefault(checkChar => checkChar.GetFullName().ToLower() == thingToInspect.ToLower());

            if (targetNPC != null)
            {
                smc.sendMessageToPlayer(OutputFormatterFactory.Get().Bold("Description of " + targetNPC.GetFullName() + " (Level " + targetNPC.CalculateLevel() + "):"));
                if ((targetNPC.Description != null) || (targetNPC.Description != ""))
                {
                    smc.sendMessageToPlayer(OutputFormatterFactory.Get().Italic(targetNPC.Description));
                }
                else
                {
                    smc.sendMessageToPlayer(OutputFormatterFactory.Get().Italic("No description set..."));
                }
                smc.sendMessageToPlayer(OutputFormatterFactory.Get().CodeBlock(targetNPC.GetInventoryList()));
                targetNPC.GetRoom().ProcessNPCReactions("PlayerCharacter.ExaminesThem", smc, targetNPC.UserID);
                targetNPC.GetRoom().ProcessNPCReactions("PlayerCharacter.Examines", smc);
                return;
            }

            // If not an NPC, check the players equipped items and the items in the room...
            SMItem smi = smc.GetEquippedItem(thingToInspect);

            if (smi == null)
            {
                smi = SMItemHelper.GetItemFromList(this.RoomItems, thingToInspect);
            }

            if (smi != null)
            {
                string itemDeatils = OutputFormatterFactory.Get().Bold("Description of \"" + smi.ItemName + "\":");
                itemDeatils += OutputFormatterFactory.Get().ListItem(smi.ItemDescription);

                if (smi.CanHoldOtherItems())
                {
                    itemDeatils += OutputFormatterFactory.Get().Italic($"This \"{smi.ItemName}\" contains the following items:");
                    itemDeatils += SMItemHelper.GetContainerContents(smi);
                }

                smc.sendMessageToPlayer(itemDeatils);
                return;
            }

            // Otherwise nothing found
            smc.sendMessageToPlayer(OutputFormatterFactory.Get().Italic("Can not inspect that item."));
        }