Пример #1
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);
        }
Пример #2
0
        public static void ParseCommand(string input, PlayerSetup.Player playerData, Room.Room room = null)
        {
            //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
                {
                    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);
            }

            //  Prompt.ShowPrompt(playerData);
            Score.UpdateUiPrompt(playerData);
        }
Пример #3
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());

                    HubContext.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));
            eventList.Add("AnkerIdiot", () => VilliageIdiot.Annoy(player, mob, room));

            return(eventList);
        }
Пример #4
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);
        }
Пример #5
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
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = commandOptions + " " + commandKey,
                    MethodName   = "Wrong command"
                };

                Save.LogError(log);

                HubContext.SendToClient("Sorry you can't do that.", playerData.HubGuid);
            }

            playerData.LastCommandTime = DateTime.UtcNow;

            Score.UpdateUiPrompt(playerData);
        }