Esempio n. 1
0
        public static void Quit(string playerId, Room.Room room)
        {
            //remove player from room and player cache

            var oldRoom = room;

            int playerIndex = room.players.FindIndex(x => x.HubGuid == playerId);

            room.players.RemoveAt(playerIndex);

            Cache.updateRoom(room, oldRoom);

            PlayerSetup.Player playerData = null;
            MIMHub._PlayerCache.TryRemove(playerId, out playerData);

            if (playerData != null)
            {
                Save.UpdatePlayer(playerData);

                SendToClient("Gods take note of your progress", playerId);
                SendToClient("See you soon!", playerId);
                broadcastToRoom(playerData.Name + " has left the realm", room.players, playerId, true);

                HubContext.getHubContext.Clients.Client(playerId).quit();
            }
        }
Esempio n. 2
0
        //public static Dictionary<string, Action> commandList { get; set; }
        public static Dictionary <string, Action> Events(string eventName, PlayerSetup.Player player, PlayerSetup.Player mob, Room.Room room, string option = "", string calledBy = "")
        {
            var eventList = new Dictionary <String, Action>();

            eventList.Add("greet", () => Greeting.greet(player, mob, room));
            eventList.Add("tutorial", () => Tutorial.setUpTut(player, room, option, calledBy));
            eventList.Add("rescue", () => Tutorial.setUpAwakening(player, room, option, calledBy));
            eventList.Add("awakening awake", () => Tutorial.setUpRescue(player, room, option, calledBy));
            eventList.Add("Give Leather Quest", () =>
            {
                if (player.QuestLog.FirstOrDefault(x => x.Name == AnkerQuests.TutorialLeatherQuest().Name) == null)
                {
                    player.QuestLog.Add(AnkerQuests.TutorialLeatherQuest());
                    Score.UpdateUiQlog(player);

                    HubContext.Instance.SendToClient(
                        "<span class='questColor'>New Quest added: " + AnkerQuests.TutorialLeatherQuest().Name + "<br />" + AnkerQuests.TutorialLeatherQuest().Description + "</span>",
                        player.HubGuid);
                }
            });
            eventList.Add("wearEQ", () => Tutorial.setUpRescue(player, room, option, calledBy));


            return(eventList);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a or an if name starts with a Vowel
        /// but if the object has a name it returns that.
        ///
        /// e.g an apple / Liam /
        /// </summary>
        /// <param name="objName"></param>
        ///  /// <param name="itemName"></param>
        /// <returns></returns>
        public static string ReturnName(PlayerSetup.Player objName, string itemName)
        {
            if (objName != null)
            {
                var    result = AvsAnLib.AvsAn.Query(objName.Name).Article;
                string name;

                if (objName.KnownByName)
                {
                    name = objName.Name;
                }
                else
                {
                    name = result + " " + objName.Name;
                }


                return(name);
            }

            var itemResult = AvsAnLib.AvsAn.Query(itemName).Article;


            return(FirstLetterToUpper(itemResult + " " + itemName));
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a or an if name starts with a Vowel
        /// but if the object has a name it returns that.
        ///
        /// e.g an apple / Liam /
        /// </summary>
        /// <param name="objName"></param>
        ///  /// <param name="itemName"></param>
        /// <returns></returns>
        public static string ReturnName(PlayerSetup.Player player, PlayerSetup.Player target, string itemName)
        {
            if (player == null && target == null)
            {
                var itemResult = AvsAnLib.AvsAn.Query(itemName).Article;


                return(FirstLetterToUpper(itemResult + " " + itemName));
            }

            //TODO: ah a bug, if you have detects it will always say someone
            if (player.invis == true && target.DetectInvis == false || player.hidden == true && target.DetectHidden == false)
            {
                return("Someone");
            }


            string name;

            if (player.KnownByName)
            {
                name = player.Name;
            }
            else
            {
                var result = AvsAnLib.AvsAn.Query(player.Name).Article;

                name = result + " " + player.Name;
            }


            return(name);
        }
Esempio n. 5
0
        public static PlayerSetup.Player FindPlayer(Room.Room Room, PlayerSetup.Player player)
        {
            var playerFound = Room.players.FirstOrDefault(x => x.Name.StartsWith(player.Name, StringComparison.CurrentCultureIgnoreCase))
                              ?? Room.mobs.FirstOrDefault(x => x.Name.ToLower().Contains(player.Name.ToLower()));

            return(playerFound);
        }
Esempio n. 6
0
        public static void ParseCommand(string input, PlayerSetup.Player playerData, Room.Room room = null)
        {
            if (string.IsNullOrEmpty(input.Trim()))
            {
                HubContext.SendToClient("You need to enter a command, type help if you need it.", playerData.HubGuid);
                return;
            }

            //testing
            string enteredCommand = input;

            string[] commands   = enteredCommand.Split(' ');
            string   commandKey = commands[0];


            string commandOptions = string.Empty;

            // testing



            if (commands.Length >= 2)
            {
                if ((commands[1].Equals("in", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("at", StringComparison.InvariantCultureIgnoreCase)))
                {
                    commandKey     = commands[0] + " " + commands[1];
                    commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal)).Trim();
                }
                else if (commandKey.Equals("c", StringComparison.InvariantCultureIgnoreCase) || commandKey.Equals("cast", StringComparison.InvariantCultureIgnoreCase) && commands.Length > 1)
                {
                    commandKey = commands[0] + " " + commands[1];

                    commandOptions =
                        enteredCommand.Substring(enteredCommand.IndexOf(commands[0], StringComparison.Ordinal)).Trim();
                }
                else
                {
                    commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(' ', 1)).Trim();
                }
            }

            //TODO: do this only once
            var command = Command.Commands(commandOptions, commandKey, playerData, room);

            var fire = command.FirstOrDefault(x => x.Key.StartsWith(commandKey, StringComparison.InvariantCultureIgnoreCase));

            if (fire.Value != null)
            {
                fire.Value();
            }
            else
            {
                HubContext.SendToClient("Sorry you can't do that.", playerData.HubGuid);
            }

            playerData.LastCommandTime = DateTime.UtcNow;

            Score.UpdateUiPrompt(playerData);
        }
Esempio n. 7
0
        public static void Quit(string playerId, Room.Room room)
        {
            //remove player from room and player cache

            try
            {
                var Player = Cache.getPlayer(playerId);

                if (Player?.Target != null)
                {
                    SendToClient("You can't quit during combat.", playerId);
                    return;
                }

                if (Player != null)
                {
                    PlayerManager.RemovePlayerFromRoom(room, Player);



                    Save.UpdatePlayer(Player);

                    PlayerSetup.Player removedChar = null;

                    MIMHub._PlayerCache.TryRemove(Player.HubGuid, out removedChar);

                    SendToClient("Gods take note of your progress", playerId);
                    SendToClient("See you soon!", playerId);
                    broadcastToRoom(Player.Name + " has left the realm", room.players, playerId, true);

                    try
                    {
                        HubContext.getHubContext.Clients.Client(playerId).quit();
                    }
                    catch (Exception ex)
                    {
                        var log = new Error.Error
                        {
                            Date         = DateTime.Now,
                            ErrorMessage = ex.InnerException.ToString(),
                            MethodName   = "Quit"
                        };

                        Save.LogError(log);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Quit"
                };

                Save.LogError(log);
            }
        }
Esempio n. 8
0
        //public static Dictionary<string, Action> commandList { get; set; }
        public static Dictionary <string, Action> Events(string eventName, PlayerSetup.Player player, PlayerSetup.Player mob, Room.Room room)
        {
            var eventList = new Dictionary <String, Action>();

            eventList.Add("greet", () => Greeting.greet(player, mob, room));


            return(eventList);
        }
Esempio n. 9
0
        public static void ParseCommand(string eventName, PlayerSetup.Player player, PlayerSetup.Player mob, Room.Room room = null)
        {
            //TODO: do this only once
            var command = Event.Events(eventName, player, mob, room);

            var fire = command.FirstOrDefault(x => x.Key.StartsWith(eventName, StringComparison.InvariantCultureIgnoreCase));

            fire.Value?.Invoke();
        }
Esempio n. 10
0
        //public static Dictionary<string, Action> commandList { get; set; }
        public static Dictionary <string, Action> Events(string eventName, PlayerSetup.Player player, PlayerSetup.Player mob, Room.Room room, string option = "", string calledBy = "")
        {
            var eventList = new Dictionary <String, Action>();

            eventList.Add("greet", () => Greeting.greet(player, mob, room));
            eventList.Add("tutorial", () => Tutorial.setUpTut(player, room, option, calledBy));
            eventList.Add("rescue", () => Tutorial.setUpAwakening(player, room, option, calledBy));
            eventList.Add("awakening awake", () => Tutorial.setUpRescue(player, room, option, calledBy));
            eventList.Add("wearEQ", () => Tutorial.setUpRescue(player, room, option, calledBy));
            eventList.Add("AnkerIdiot", () => VilliageIdiot.Annoy(player, mob, room));

            return(eventList);
        }
Esempio n. 11
0
        public static string ReturnHisOrHers(PlayerSetup.Player player, PlayerSetup.Player target, bool plural = true)
        {
            if (player.invis == true && target.DetectInvis == false || player.hidden == true && target.DetectHidden == false)
            {
                return("their");
            }

            if (plural)
            {
                return(player.Gender == "male" ? "his" : "hers");
            }

            return(player.Gender == "male" ? "his" : "her");
        }
Esempio n. 12
0
        /// <summary>
        /// Returns a or an if name starts with a Vowel
        /// but if the object has a name it returns that.
        ///
        /// e.g an apple / Liam /
        /// </summary>
        /// <param name="objName"></param>
        ///  /// <param name="itemName"></param>
        /// <returns></returns>
        public static string ReturnName(PlayerSetup.Player player, PlayerSetup.Player target, string itemName)
        {
            try
            {
                if (player == null && target == null)
                {
                    var itemResult = AvsAnLib.AvsAn.Query(itemName).Article;


                    return(FirstLetterToUpper(itemResult + " " + itemName));
                }

                //TODO: ah a bug, if you have detects it will always say someone
                if (player.invis == true && target.DetectInvis == false ||
                    player.hidden == true && target.DetectHidden == false)
                {
                    return("Someone");
                }


                string name;

                if (player.KnownByName)
                {
                    name = player.Name;
                }
                else
                {
                    var result = AvsAnLib.AvsAn.Query(player.Name).Article;

                    name = result + " " + player.Name;
                }


                return(name);
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "return name"
                };

                Save.LogError(log);
            }
            return(string.Empty);
        }
Esempio n. 13
0
        //public static Dictionary<string, Action> commandList { get; set; }
        public static Dictionary <string, Action> Commands(string commandOptions, string commandKey, PlayerSetup.Player playerData, Room.Room room)
        {
            var commandList = new Dictionary <String, Action>
            {
                { "north", () => Movement.Move(playerData, room, "North") },
                { "south", () => Movement.Move(playerData, room, "South") },
                { "east", () => Movement.Move(playerData, room, "East") },
                { "west", () => Movement.Move(playerData, room, "West") },
                { "down", () => Movement.Move(playerData, room, "Down") },
                { "up", () => Movement.Move(playerData, room, "Up") },
                { "look", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look") },
                { "l in", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look in") },
                { "look in", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look in") },
                { "examine", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "examine") },
                { "touch", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "touch") },
                { "smell", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "smell") },
                { "taste", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "taste") },
                { "score", () => Score.ReturnScore(playerData) },
                { "inventory", () => Inventory.ReturnInventory(playerData.Inventory, playerData) },
                { "equipment", () => Equipment.ShowEquipment(playerData) },
                { "garb", () => Equipment.ShowEquipment(playerData) },
                { "get", () => ManipulateObject.GetItem(room, playerData, commandOptions, commandKey, "item") },
                { "take", () => ManipulateObject.GetItem(room, playerData, commandOptions, commandKey, "item") },
                { "drop", () => ManipulateObject.DropItem(room, playerData, commandOptions, commandKey) },
                { "give", () => ManipulateObject.GiveItem(room, playerData, commandOptions, commandKey, "killable") },
                { "put", () => ManipulateObject.DropItem(room, playerData, commandOptions, commandKey) },
                { "save", () => Save.UpdatePlayer(playerData) },
                { "'", () => Communicate.Say(commandOptions, playerData, room) },
                { "newbie", () => Communicate.NewbieChannel(commandOptions, playerData) },
                { "gossip", () => Communicate.GossipChannel(commandOptions, playerData) },
                { "ooc", () => Communicate.OocChannel(commandOptions, playerData) },
                { "say", () => Communicate.Say(commandOptions, playerData, room) },
                { "sayto", () => Communicate.SayTo(commandOptions, room, playerData) },
                { ">", () => Communicate.SayTo(commandOptions, room, playerData) },
                { "talkto", () => Talk.TalkTo(commandOptions, room, playerData) },
                { "emote", () => Emote.EmoteActionToRoom(commandOptions, playerData) },
                { "quit", () => HubContext.Quit(playerData.HubGuid, room) },
                { "wear", () => Equipment.WearItem(playerData, commandOptions) },
                { "remove", () => Equipment.RemoveItem(playerData, commandOptions) },
                { "doff", () => Equipment.RemoveItem(playerData, commandOptions) },
                { "wield", () => Equipment.WearItem(playerData, commandOptions, true) },
                { "unwield", () => Equipment.RemoveItem(playerData, commandOptions, false, true) },
                { "kill", () => Fight2.PerpareToFight(playerData, room, commandOptions) },
                { "flee", () => Flee.fleeCombat(playerData, room) },

                //spells
                { "c magic missile", () => MagicMissile.StartMagicMissile(playerData, room, commandOptions) },
                { "cast magic missile", () => MagicMissile.StartMagicMissile(playerData, room, commandOptions) },

                { "c armour", () => Armour.StartArmour(playerData, room, commandOptions) },
                { "cast armour", () => Armour.StartArmour(playerData, room, commandOptions) },

                { "c armor", () => Armour.StartArmour(playerData, room, commandOptions) },
                { "cast armor", () => Armour.StartArmour(playerData, room, commandOptions) },

                { "c continual light", () => ContinualLight.StarContinualLight(playerData, room, commandOptions) },
                { "cast continual light", () => ContinualLight.StarContinualLight(playerData, room, commandOptions) },

                { "c invis", () => Invis.StartInvis(playerData, room, commandOptions) },
                { "cast invis", () => Invis.StartInvis(playerData, room, commandOptions) },

                { "c weaken", () => Weaken.StartWeaken(playerData, room, commandOptions) },
                { "cast weaken", () => Weaken.StartWeaken(playerData, room, commandOptions) },

                { "c chill touch", () => ChillTouch.StartChillTouch(playerData, room, commandOptions) },
                { "cast chill touch", () => ChillTouch.StartChillTouch(playerData, room, commandOptions) },

                { "c fly", () => Fly.StartFly(playerData, room, commandOptions) },
                { "cast fly", () => Fly.StartFly(playerData, room, commandOptions) },

                { "c refresh", () => Refresh.StartRefresh(playerData, room, commandOptions) },
                { "cast refresh", () => Refresh.StartRefresh(playerData, room, commandOptions) },

                { "c faerie fire", () => FaerieFire.StartFaerieFire(playerData, room, commandOptions) },
                { "cast faerie fire", () => FaerieFire.StartFaerieFire(playerData, room, commandOptions) },

                { "c teleport", () => Teleport.StartTeleport(playerData, room) },
                { "cast teleport", () => Teleport.StartTeleport(playerData, room) },

                { "c blindness", () => Blindness.StartBlind(playerData, room, commandOptions) },
                { "cast blindess", () => Blindness.StartBlind(playerData, room, commandOptions) },

                { "c haste", () => Haste.StartHaste(playerData, room, commandOptions) },
                { "cast haste", () => Haste.StartHaste(playerData, room, commandOptions) },

                { "c create spring", () => CreateSpring.StartCreateSpring(playerData, room) },
                { "cast create spring", () => CreateSpring.StartCreateSpring(playerData, room) },

                //skills
                { "punch", () => Punch.StartPunch(playerData, room) },
                { "kick", () => Kick.StartKick(playerData, room) },

                //
                { "unlock", () => ManipulateObject.UnlockItem(room, playerData, commandOptions, commandKey) },
                { "lock", () => ManipulateObject.LockItem(room, playerData, commandOptions, commandKey) },
                { "open", () => ManipulateObject.Open(room, playerData, commandOptions, commandKey) },
                { "close", () => ManipulateObject.Close(room, playerData, commandOptions, commandKey) },
                { "drink", () => ManipulateObject.Drink(room, playerData, commandOptions, commandKey) },
                { "help", () => Help.ShowHelp(commandOptions, playerData) },
                { "time", Update.Time.ShowTime },
                { "clock", Update.Time.ShowTime },
                { "skills", () => ShowSkills.ShowPlayerSkills(playerData, commandOptions) },
                { "skills all", () => ShowSkills.ShowPlayerSkills(playerData, commandOptions) },
                { "practice", () => Trainer.Practice(playerData, room, commandOptions) },
                { "list", () => Shop.listItems(playerData, room) },
                { "buy", () => Shop.buyItems(playerData, room, commandOptions) },
                { "quest log", () => Quest.QuestLog(playerData) },
                { "qlog", () => Quest.QuestLog(playerData) },
                { "wake", () => Status.WakePlayer(playerData, room) },
                { "sleep", () => Status.SleepPlayer(playerData, room) },
                { "greet", () => Greet.GreetMob(playerData, room, commandOptions) },
                { "who", () => Who.Connected(playerData) },
                { "affects", () => Affect.Show(playerData) },
                { "follow", () => Follow.FollowThing(playerData, room, commandOptions) }
            };


            return(commandList);
        }
Esempio n. 14
0
 public void UpdateScore(PlayerSetup.Player player)
 {
     _hubContext.Clients.Client(player.HubGuid).updateScore(player);
 }
Esempio n. 15
0
        public void Quit(string playerId, Room.Room room)
        {
            //remove player from room and player cache

            try
            {
                var Player = Cache.getPlayer(playerId);

                if (Player?.Target != null)
                {
                    SendToClient("You can't quit during combat.", playerId);
                    return;
                }

                if (Player != null)
                {
                    using (var db = new LiteDatabase(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["database"])))
                    {
                        var col = db.GetCollection <QuitLocation>("QuitLocation");

                        var quitLoc = new QuitLocation
                        {
                            PlayerName = Player.Name,
                            RoomName   = room.title,
                            RoomId     = room.areaId
                        };

                        col.Insert(Guid.NewGuid(), quitLoc);
                    }

                    PlayerManager.RemovePlayerFromRoom(room, Player);

                    Save.SavePlayer(Player);

                    PlayerSetup.Player removedChar = null;

                    MIMHub._PlayerCache.TryRemove(Player.HubGuid, out removedChar);

                    SendToClient("Gods take note of your progress", playerId);
                    SendToClient("See you soon!", playerId);
                    BroadcastToRoom(Player.Name + " has left the realm", room.players, playerId, true);

                    try
                    {
                        _hubContext.Clients.Client(playerId).quit();
                    }
                    catch (Exception ex)
                    {
                        var log = new Error.Error
                        {
                            Date         = DateTime.Now,
                            ErrorMessage = ex.InnerException.ToString(),
                            MethodName   = "Quit"
                        };

                        Save.LogError(log);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Quit"
                };

                Save.LogError(log);
            }
        }
Esempio n. 16
0
        public static void Quit(string playerId, Room.Room room)
        {
            //remove player from room and player cache

            try
            {
                var Player = Cache.getPlayer(playerId);

                if (Player?.Target != null)
                {
                    SendToClient("You can't quit during combat.", playerId);
                    return;
                }

                var oldRoom = room;

                int playerIndex = room.players.FindIndex(x => x.HubGuid == playerId);


                room.players.RemoveAt(playerIndex);

                Cache.updateRoom(room, oldRoom);

                PlayerSetup.Player playerData = null;
                MIMHub._PlayerCache.TryRemove(playerId, out playerData);

                if (playerData != null)
                {
                    Save.UpdatePlayer(Player);

                    SendToClient("Gods take note of your progress", playerId);
                    SendToClient("See you soon!", playerId);
                    broadcastToRoom(playerData.Name + " has left the realm", room.players, playerId, true);

                    try
                    {
                        HubContext.getHubContext.Clients.Client(playerId).quit();
                    }
                    catch (Exception ex)
                    {
                        var log = new Error.Error
                        {
                            Date         = DateTime.Now,
                            ErrorMessage = ex.InnerException.ToString(),
                            MethodName   = "Quit"
                        };

                        Save.LogError(log);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Quit"
                };

                Save.LogError(log);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Command list for the game
        /// </summary>
        /// <param name="commandOptions">Everything after the 1st occurance of a space</param>
        /// <param name="commandKey">The string before the 1st occurance of a space</param>
        /// <param name="playerData">Player Data</param>
        /// <param name="room">Current room</param>
        /// <returns>Returns Dictionary of commands</returns>
        public static void Commands(string commandOptions, string commandKey, PlayerSetup.Player playerData, Room.Room room)
        {
            var context = HubContext.Instance;

            switch (commandKey)
            {
            case "north":
                Movement.Move(playerData, room, "North");
                break;

            case "east":
                Movement.Move(playerData, room, "East");
                break;

            case "south":
                Movement.Move(playerData, room, "South");
                break;

            case "west":
                Movement.Move(playerData, room, "West");
                break;

            case "up":
                Movement.Move(playerData, room, "Up");
                break;

            case "down":
                Movement.Move(playerData, room, "Down");
                break;

            case "look":
            case "look at":
            case "l at":
            case "search":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "look");
                break;

            case "l in":
            case "search in":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "look in");
                break;

            case "examine":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "examine");
                break;

            case "touch":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "touch");
                break;

            case "smell":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "smell");
                break;

            case "taste":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "taste");
                break;

            case "score":
                Score.ReturnScore(playerData);
                break;

            case "inventory":
                Inventory.ReturnInventory(playerData.Inventory, playerData);
                break;

            case "eq":
            case "equip":
            case "equipment":
            case "garb":
                Equipment.ShowEquipment(playerData);
                break;

            case "loot":
            case "get":
            case "take":
                ManipulateObject.GetItem(room, playerData, commandOptions, commandKey, "item");
                break;

            case "plunder":
                ManipulateObject.GetItem(room, playerData, "all " + commandOptions, commandKey, "item");
                break;

            case "drop":
            case "put":
                ManipulateObject.DropItem(room, playerData, commandOptions, commandKey);
                break;

            case "give":
                ManipulateObject.GiveItem(room, playerData, commandOptions, commandKey, "killable");
                break;

            case "save":
                Save.SavePlayer(playerData);
                break;

            case "say":
            case "'":
                Communicate.Say(commandOptions, playerData, room);
                break;

            case "sayto":
            case ">":
                Communicate.SayTo(commandOptions, room, playerData);
                break;

            case "newbie":
                Communicate.NewbieChannel(commandOptions, playerData);
                break;

            case "gossip":
                Communicate.GossipChannel(commandOptions, playerData);
                break;

            case "ooc":
                Communicate.OocChannel(commandOptions, playerData);
                break;

            case "yes":
                Communicate.Say("Yes", playerData, room);
                break;

            case "no":
                Communicate.Say("No", playerData, room);
                break;

            case "yell":
                Communicate.Yell(commandOptions, room, playerData);
                break;

            case "talkto":
                Talk.TalkTo(commandOptions, room, playerData);
                break;

            case "emote":
                Emote.EmoteActionToRoom(commandOptions, playerData);
                break;

            case "use":
            case "wear":
            case "wield":
                Equipment.WearItem(playerData, commandOptions);
                break;

            case "remove":
            case "doff":
            case "unwield":
                Equipment.RemoveItem(playerData, commandOptions);
                break;

            case "hit":
            case "kill":
            case "attack":
                Fight2.PerpareToFight(playerData, room, commandOptions);
                break;

            case "flee":
                Flee.fleeCombat(playerData, room);
                break;

            case "sacrifice":
            case "harvest":
                Harvest.Body(playerData, room, commandOptions);
                break;

            case "peek":
                Peak.DoPeak(context, playerData, room, commandOptions);
                break;

            case "steal":
                Steal.DoSteal(context, playerData, room, commandOptions);
                break;

            case "pick":
                LockPick.DoLockPick(context, playerData, room, commandOptions);
                break;

            case "c magic missile":
            case "cast magic missile":
                MagicMissile.StartMagicMissile(playerData, room, commandOptions);
                break;

            case "c armour":
            case "cast armour":
            case "c armor":
            case "cast armor":
                new Armour().StartArmour(playerData, room, commandOptions);
                break;

            case "c continual light":
            case "cast continual light":
                ContinualLight.StarContinualLight(playerData, room, commandOptions);
                break;

            case "c invis":
            case "cast invis":
                Invis.StartInvis(playerData, room, commandOptions);
                break;

            case "c weaken":
            case "cast weaken":
                Weaken.StartWeaken(playerData, room, commandOptions);
                break;

            case "c chill touch":
            case "cast chill touch":
                ChillTouch.StartChillTouch(playerData, room, commandOptions);
                break;

            case "c fly":
            case "cast fly":
                Fly.StartFly(playerData, room, commandOptions);
                break;

            case "c refresh":
            case "cast refresh":
                Refresh.StartRefresh(playerData, room, commandOptions);
                break;

            case "c faerie fire":
            case "cast faerie fire":
                FaerieFire.StartFaerieFire(playerData, room, commandOptions);
                break;

            case "c teleport":
            case "cast teleport":
                Teleport.StartTeleport(playerData, room);
                break;

            case "c blindness":
            case "cast blindness":
                Blindness.StartBlind(playerData, room, commandOptions);
                break;

            case "c haste":
            case "cast haste":
                Haste.StartHaste(playerData, room, commandOptions);
                break;

            case "c create spring":
            case "cast create spring":
                CreateSpring.StartCreateSpring(playerData, room);
                break;

            case "c shocking grasp":
            case "cast shocking grasp":
                new ShockingGrasp().StartShockingGrasp(playerData, room, commandOptions);
                break;

            case "c cause light":
            case "cast cause light":
                new CauseLight().StartCauseLight(context, playerData, room, commandOptions);
                break;

            case "c cure light":
            case "cast cure light":
                new CureLight().StartCureLight(context, playerData, room, commandOptions);
                break;

            case "c cure blindness":
                new CureBlindness().StartCureBlindness(context, playerData, room, commandOptions);
                break;

            case "c detect invis":
            case "cast detect invis":
                DetectInvis.DoDetectInvis(context, playerData, room);
                break;

            case "forage":
                new Foraging().StartForaging(playerData, room);
                break;

            case "fish":
            case "angle":
            case "line":
            case "trawl":
            case "lure":
                new Fishing().StartFishing(playerData, room);
                break;

            case "reel":
                Fishing.GetFish(playerData, room);
                break;

            case "dirt kick":
                new DirtKick().StartDirtKick(context, playerData, room, commandOptions);
                break;

            case "bash":
                new Bash().StartBash(context, playerData, room, commandOptions);
                break;

            case "shield bash":
                new ShieldBash().StartBash(context, playerData, room, commandOptions);
                break;

            case "punch":
                Punch.StartPunch(playerData, room);
                break;

            case "kick":
                new Kick().StartKick(context, playerData, room, commandOptions);
                break;

            case "spin kick":
                new SpinKick().StartKick(context, playerData, room, commandOptions);
                break;

            case "rescue":
                new Rescue().StartRescue(context, playerData, room, commandOptions);
                break;

            case "lunge":
                new Lunge().StartLunge(context, playerData, room, commandOptions);
                break;

            case "disarm":
                new Disarm().StartDisarm(context, playerData, room);
                break;

            case "backstab":
                new Backstab().StartBackstab(context, playerData, room, commandOptions);
                break;

            case "feint":
                new Feint().StartFeint(context, playerData, room, commandOptions);
                break;

            case "mount":
            case "ride":
                Mount.StartMount(playerData, room, commandOptions);
                break;

            case "dismount":
                Mount.Dismount(playerData, room, commandOptions);
                break;

            case "trip":
                new Trip().StartTrip(context, playerData, room, commandOptions);
                break;

            case "sneak":
                Sneak.DoSneak(context, playerData);
                break;

            case "hide":
                Hide.DoHide(context, playerData);
                break;

            case "lore":
                Lore.DoLore(context, playerData, commandOptions);
                break;

            case "unlock":
                ManipulateObject.UnlockItem(room, playerData, commandOptions, commandKey);
                break;

            case "lock":
                ManipulateObject.LockItem(room, playerData, commandOptions, commandKey);
                break;

            case "close":
            case "shut":
                ManipulateObject.Close(room, playerData, commandOptions, commandKey);
                break;

            case "drink":
                ManipulateObject.Drink(room, playerData, commandOptions, commandKey);
                break;

            case "help":
            case "/help":
            case "?":
            case "commands":
                Help.ShowHelp(commandOptions, playerData);
                break;

            case "time":
            case "clock":
                Update.Time.ShowTime();
                break;

            case "skills":
            case "spells":
            case "skills all":
                ShowSkills.ShowPlayerSkills(playerData, commandOptions);
                break;

            case "practice":
                Trainer.Practice(playerData, room, commandOptions);
                break;

            case "list":
                Shop.listItems(playerData, room);
                break;

            case "buy":
                Shop.buyItems(playerData, room, commandOptions);
                break;

            case "sell":
                Shop.sellItems(playerData, room, commandOptions);
                break;

            case "quest log":
            case "qlog":
                Quest.QuestLog(playerData);
                break;

            case "wake":
                Status.WakePlayer(context, playerData, room);
                break;

            case "sleep":
                Status.SleepPlayer(context, playerData, room);
                break;

            case "rest":
            case "sit":
                Status.RestPlayer(context, playerData, room);
                break;

            case "stand":
                Status.StandPlayer(context, playerData, room);
                break;

            case "greet":
                Greet.GreetMob(playerData, room, commandOptions);
                break;

            case "who":
                Who.Connected(playerData);
                break;

            case "affects":
                Effect.Show(playerData);
                break;

            case "follow":
                Follow.FollowThing(playerData, room, commandOptions);
                break;

            case "nofollow":
                Follow.FollowThing(playerData, room, "noFollow");
                break;

            case "quit":
                HubContext.Instance.Quit(playerData.HubGuid, room);
                break;

            case "craft":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Craft);
                break;

            case "chop":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Chop);
                break;

            case "cook":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Cook);
                break;

            case "brew":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Brew);
                break;

            case "forge":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Forge);
                break;

            case "carve":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Carve);
                break;

            case "knit":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Knitting);
                break;

            case "make":
            case "build":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Craft);
                break;

            case "show crafts":
            case "craftlist":
                Craft.CraftList(playerData);
                break;

            case "set up camp":
                Camp.SetUpCamp(playerData, room);
                break;

            case "repair":
                Events.Repair.RepairItem(playerData, room, commandOptions);
                break;

            case "/debug":
                PlayerSetup.Player.DebugPlayer(playerData);
                break;

            case "/setGold":
                PlayerSetup.Player.SetGold(playerData, commandOptions);
                break;

            case "/setAc":
                PlayerSetup.Player.SetAC(playerData, commandOptions);
                break;

            case "/map":
                SigmaMap.DrawMap(playerData.HubGuid);     //not what you think it does
                break;

            default:
                HubContext.Instance.SendToClient("Sorry you can't do that. Try help commands or ask on the discord channel.", playerData.HubGuid);
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = commandKey + " " + commandOptions,
                    MethodName   = "Wrong command"
                };

                Save.LogError(log);
                break;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Handles matching and calling the commands
        /// </summary>
        /// <param name="input">What the player typed in</param>
        /// <param name="playerData">Player Data</param>
        /// <param name="room">Current Room</param>
        public static void ParseCommand(string input, PlayerSetup.Player playerData, Room.Room room = null)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            if (string.IsNullOrEmpty(input.Trim()))
            {
                HubContext.Instance.SendToClient("You need to enter a command, type help if you need it.", playerData.HubGuid);
                return;
            }

            if (playerData.Effects?.FirstOrDefault(x => x.Name.Equals("Hidden", StringComparison.CurrentCultureIgnoreCase)) != null)
            {
                playerData.Effects.Remove(
                    playerData.Effects?.FirstOrDefault(
                        x => x.Name.Equals("Hidden", StringComparison.CurrentCultureIgnoreCase)));

                Score.UpdateUiAffects(playerData);
            }

            //testing
            string enteredCommand = input;

            string[] commands   = enteredCommand.Split(' ');
            string   commandKey = commands[0];


            string commandOptions = string.Empty;

            // testing

            if (commands.Length >= 2)
            {
                if ((commands[1].Equals("in", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("at", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("up", StringComparison.InvariantCultureIgnoreCase)))
                {
                    commandKey     = commands[0] + " " + commands[1];
                    commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal)).Trim();
                }
                else if (commandKey.Equals("c", StringComparison.InvariantCultureIgnoreCase) || commandKey.Equals("cast", StringComparison.InvariantCultureIgnoreCase) && commands.Length > 1)
                {
                    commandKey = commands[0] + " " + commands[1] + " ";

                    var reg   = new Regex("'.*?'");
                    var match = reg.Match(enteredCommand);

                    if (match.Success)
                    {
                        commandKey = commands[0] + " " + commands[1].Replace("'", "") + " " +
                                     commands[2].Replace("'", "");

                        var hasTarget = commands.Length >= 4;

                        commandOptions =
                            enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal))
                            .Trim();
                    }
                    else
                    {
                        commandOptions =
                            enteredCommand.Substring(enteredCommand.IndexOf(commands[0], StringComparison.Ordinal))
                            .Trim();
                    }
                }
                else
                {
                    commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(' ', 1)).Trim();
                }
            }

            var command = Startup.CommandKey.FirstOrDefault(x => x.Key.StartsWith(commandKey.Trim(), StringComparison.InvariantCultureIgnoreCase));

            Command.Commands(commandOptions, command.Value, playerData, room);

            playerData.LastCommandTime = DateTime.Now;

            // Score.UpdateUiPrompt(playerData);

            stopwatch.Stop();
            System.Diagnostics.Debug.WriteLine("Process command " + stopwatch.Elapsed);
        }
Esempio n. 19
0
        //public static Dictionary<string, Action> commandList { get; set; }
        public static Dictionary <string, Action> Commands(string commandOptions, string commandKey, PlayerSetup.Player playerData, Room.Room room)
        {
            var commandList = new Dictionary <String, Action>();

            commandList.Add("north", () => Movement.Move(playerData, room, "North"));
            commandList.Add("south", () => Movement.Move(playerData, room, "South"));
            commandList.Add("east", () => Movement.Move(playerData, room, "East"));
            commandList.Add("west", () => Movement.Move(playerData, room, "West"));
            commandList.Add("down", () => Movement.Move(playerData, room, "Down"));
            commandList.Add("up", () => Movement.Move(playerData, room, "Up"));
            //commandList.Add("look at", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look"));
            commandList.Add("look", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look"));
            commandList.Add("l in", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look in"));
            commandList.Add("look in", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "look in"));
            commandList.Add("examine", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "examine"));
            commandList.Add("touch", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "touch"));
            commandList.Add("smell", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "smell"));
            commandList.Add("taste", () => LoadRoom.ReturnRoom(playerData, room, commandOptions, "taste"));
            commandList.Add("score", () => Score.ReturnScore(playerData));
            commandList.Add("inventory", () => Inventory.ReturnInventory(playerData.Inventory, playerData));
            commandList.Add("equipment", () => Equipment.ShowEquipment(playerData));
            commandList.Add("garb", () => Equipment.ShowEquipment(playerData));
            commandList.Add("get", () => ManipulateObject.GetItem(room, playerData, commandOptions, commandKey, "item"));
            commandList.Add("take", () => ManipulateObject.GetItem(room, playerData, commandOptions, commandKey, "item"));
            commandList.Add("drop", () => ManipulateObject.DropItem(room, playerData, commandOptions, commandKey));
            commandList.Add("put", () => ManipulateObject.DropItem(room, playerData, commandOptions, commandKey));
            commandList.Add("save", () => Save.UpdatePlayer(playerData));
            commandList.Add("'", () => Communicate.Say(commandOptions, playerData, room));
            commandList.Add("say", () => Communicate.Say(commandOptions, playerData, room));
            commandList.Add("sayto", () => Communicate.SayTo(commandOptions, room, playerData));
            commandList.Add(">", () => Communicate.SayTo(commandOptions, room, playerData));
            commandList.Add("quit", () => HubContext.Quit(playerData.HubGuid, room));
            commandList.Add("wear", () => Equipment.WearItem(playerData, commandOptions));
            commandList.Add("remove", () => Equipment.RemoveItem(playerData, commandOptions));
            commandList.Add("wield", () => Equipment.WearItem(playerData, commandOptions, true));
            commandList.Add("unwield", () => Equipment.RemoveItem(playerData, commandOptions, false, true));
            commandList.Add("kill", () => Fight2.PerpareToFight(playerData, room, commandOptions));
            commandList.Add("flee", () => Flee.fleeCombat(playerData, room));
            commandList.Add("unlock", () => ManipulateObject.UnlockItem(room, playerData, commandOptions, commandKey));
            commandList.Add("lock", () => ManipulateObject.LockItem(room, playerData, commandOptions, commandKey));
            commandList.Add("open", () => ManipulateObject.Open(room, playerData, commandOptions, commandKey));
            commandList.Add("close", () => ManipulateObject.Close(room, playerData, commandOptions, commandKey));
            commandList.Add("punch", () => Punch.StartPunch(playerData, room));
            commandList.Add("help", () => Help.ShowHelp(commandOptions, playerData));
            commandList.Add("time", Update.Time.ShowTime);
            commandList.Add("clock", Update.Time.ShowTime);
            return(commandList);
        }