Пример #1
0
        public bool CommandMoveUp(Player user, Command command, string text)
        {
            if (((Room)user.Location).Exits.ContainsKey(Directions.Up))
            {
                user.Move(Global.GetRoom(((Room)user.Location).Exits[Directions.Up].ToRoom), "up");
            }
            else
            {
                user.SendMessage("You cannot go that way!\n\r", "t=err~id=100\n\r");
                return false;
            }

            return true;
        }
Пример #2
0
        public bool CommandAload(Player user, Command command, string text)
        {
            text = Parser.GetStringArgument(text, 2).Text;

            Area area = new Area();
            area.Load(text);

            return true;
        }
Пример #3
0
        public bool CommandWho(Player user, Command command, string text)
        {
            int count = 0;
            foreach (Player player in Global.Players)
            {
                user.SendMessage("[" + String.Format("{0:00}", player.Level) + "] " + player.Name + " has no title!\n\r", "dupe");
                count++;
            }
            user.SendMessage("\n\r");
            user.SendMessage("Total players: " + count + "\n\r", "dupe");

            return true;
        }
Пример #4
0
        public bool CommandTestAct(Player user, Command command, string text)
        {
            Type type = typeof(Mob);
            Argument arg1 = Parser.GetArgument(text, 2, user, type, SearchLocations.Room);
            if (arg1.Reference == null)
            {
                //user.SendMessage("They aren't here!\n\r");
                type = typeof(Player);
                arg1 = Parser.GetArgument(text, 2, user, type, SearchLocations.Room);
                if (arg1.Reference == null)
                {
                    user.SendMessage("They aren't here!\n\r");
                    return false;
                }
            }

            Mob target = (Mob)arg1.Reference;

            Communications.DeliverMessage
                (user, target, MessageVector.Character, "You test the NarrateAction method!  $N picks $S nose!\n\r", "");
            Communications.DeliverMessage
                (user, target, MessageVector.Target, "$n tests the NarrateAction method!  You pick your nose!\n\r", "");
            Communications.DeliverMessage
                (user, target, MessageVector.ThirdParty, "$n tests the NarrateAction method!  $N picks $S nose!\n\r", "");

            return true;
        }
Пример #5
0
        public bool CommandSkill(Player user, Command command, string text)
        {
            string skill = command.Text;

            //TODO: Make this execute skills with the generic "skill" command so that we don't have to have a verb for
            //      every skill for debugging purposes
            if (skill == "skill")
            {
                skill = Parser.GetArgument(text, 2).Text;
                text = text.Substring(6);
            }

            bool found = false;
            string literalKey = "";

            foreach (string key in user.Skills.Keys)
            {
                if (key.ToLower().StartsWith(skill))
                {
                    found = true;
                    literalKey = key;
                    break;
                }
            }
            if (found)
            {
                user.Skills[literalKey].Skill.Action(user, text);
            }
            else
            {
                user.SendMessage("You don't know that skill!\n\r");
            }
            return true;
        }
Пример #6
0
        public bool CommandScreen(Player user, Command command, string text)
        {
            if (Parser.GetArgument(text, 2).Text == "turnbattle")
            {
                if (user.Battle != null && user.CombatType == CombatType.Realtime)
                {
                    Mob mob = null;
                    foreach (Mob batmob in user.Battle.Participants)
                    {
                        if (!(batmob is Player))
                        {
                            mob = batmob;
                        }
                    }

                    user.SendMobileMessage(
                        "t=screen" +
                        "~ename=" + mob.Name +
                        "~erace=" + mob.Race.ToString() +
                        "~ehp=" + mob.Health +
                        "~emhp=" + mob.MaxHealth +
                        "~name=" + user.Name +
                        "~race=" + user.Race.ToString() +
                        "~hp=" + user.Health +
                        "~mhp=" + user.MaxHealth +
                        "\n\r");
                }
            }

            return true;
        }
Пример #7
0
        public bool CommandScore(Player user, Command command, string text)
        {
            user.SendMessage("   " + user.Name + "\n\r");
            user.SendMessage(Colors.BRIGHT_RED + "Health: " + user.Health + "/" + user.MaxHealth + "\n\r");
            //user.SendMessage(Colors.BRIGHT_BLUE + "Mana:   " + user.Mana + "/" + user.MaxMana + "\n\r");
            user.SendMessage("Experience:   " + user.Experience + "/" + user.ExperienceToLevel + "\n\r");
            user.SendMessage("Physical:     " + user.PhysicalPower + "\n\r");
            user.SendMessage("Magical:      " + user.MagicPower + "\n\r");
            //user.SendMessage("Vitality:     " + user.Vitality + "\n\r");
            //user.SendMessage("Dexterity:    " + user.Dexterity + "\n\r");

            user.SendMobileMessage("t=stats~name=" + user.Name + "~hp=" + user.Health + "~mhp=" + user.MaxHealth +
                "~exp=" + user.Experience + "~exptnl=" + user.ExperienceToLevel + /*"~str=" + user.Strength +
                "~int=" + user.Intelligence + "~vit=" + user.Vitality + "~dex=" + user.Dexterity +*/ "\n\r");

            return true;
        }
Пример #8
0
        public bool CommandSay(Player user, Command command, string text)
        {
            text = Parser.GetStringArgument(text, 2).Text;

            foreach (Player player in ((Room)user.Location).Contents)
            {
                player.SendMessage(Colors.GREEN + user.Name + " says '" + text + "'\n\r", "dupe");
            }

            return true;
        }
Пример #9
0
        public bool CommandLook(Player user, Command command, string text)
        {
            if (Parser.GetArgument(text, 2).Text != "")
            {
                // do some crap for arguments here
            }
            ((Room)user.Location).Display(user);

            return true;
        }
Пример #10
0
        public bool CommandKill(Player user, Command command, string text)
        {
            Type type = typeof(Mob);
            Argument arg1 = Parser.GetArgument(text, 2, user, type, SearchLocations.Room);
            if (arg1.Reference == null)
            {
                user.SendMessage("They aren't here!\n\r");
                return false;
            }

            Mob target = (Mob)arg1.Reference;

            user.WaitPulses += Global.RoundDuration;

            if (user.TargetEnemy == null)
                user.TargetEnemy = target;

            Combat.OneHit(user, target);

            return true;
        }
Пример #11
0
        public bool CommandDb(Player user, Command command, string text)
        {
            if (Parser.GetArgument(text, 2).Text == "entities")
            {
                if (Parser.GetArgument(text, 3).Text == "list")
                {
                    int count = 1;
                    foreach (Entity thing in Global.Entites)
                    {
                        user.SendMessage(count + ".  " + "[" + thing.Name + "] #" + thing.IndexNumber + "; type: " + thing.GetType() + "\n\r");
                        count++;
                    }
                }
            }
            if (Parser.GetArgument(text, 2).Text == "menu")
            {
                DynamicMenu menu = new DynamicMenu(user, "HandleMenu");
                menu.List.Add("waffle", new Command("waffle", "", false, "Menu item 1"));
                menu.List.Add("carrot", new Command("carrot", "", false, "Menu item 2"));
                menu.List.Add("apple", new Command("apple", "", false, "Menu item 3"));
                user.Menu = menu;
                user.SendMessage("Please select from the following: waffle, carrot, apple\n\r");
            }
            if (Parser.GetArgument(text, 2).Text == "littleman")
            {
                AreaLittleMan littleMan = new AreaLittleMan(300, 7);
                Area area = littleMan.Generate();
                Room room = area.Rooms[0];
                Instance instance = InstanceManager.NewInstance(user, Convert.ToInt32(Parser.GetArgument(text, 3).Text));
                instance.Area = area;
                user.Move(room);
            }
            if (Parser.GetArgument(text, 2).Text == "map")
            {
                Area area = ((Room)user.Location).Area;

            }
            if (Parser.GetArgument(text, 2).Text == "instance")
            {
                InstanceManager.NewInstance(user, Convert.ToInt32(Parser.GetArgument(text, 3).Text));

            }
            if (Parser.GetArgument(text, 2).Text == "killinstance")
            {
                InstanceManager.RemoveInstance(user);
            }
            if (Parser.GetArgument(text, 2).Text == "bat")
            {
                Mob mob = new Mob();
                mob.Name = "test mob #" + Combat.Random.Next(0, 9);
                mob.Skills.Add("Autoattack", new SkillInstance(Global.SkillTable["Autoattack"], new SkillAI()));
            }

            return true;
        }
Пример #12
0
        public bool CommandBattle(Player user, Command command, string text)
        {
            if (user.ClientType != ClientType.Android)
                user.SendMessage("Hey, you're not supposed to be using this combat system!\n\rI'll let it slide, this time...\n\r", "dupe");
            Type type = typeof(Mob);
            Argument arg1 = Parser.GetArgument(text, 2, user, type, SearchLocations.Room);
            if (arg1.Reference == null)
            {
                user.SendMessage("They aren't here!\n\r");
                return false;
            }

            Mob target = (Mob)arg1.Reference;

            Combat.StartTurnCombat(user, target);

            DynamicMenu menu = new DynamicMenu(user, "HandleTurnBattleMenu");
            menu.List.Add("skill1", new Command("skill1", "", false, "Use skill slot #"));
            menu.List.Add("skill2", new Command("skill2", "", false, "Use skill slot #"));
            menu.List.Add("skill3", new Command("skill3", "", false, "Use skill slot #"));
            menu.List.Add("skill4", new Command("skill4", "", false, "Use skill slot #"));
            menu.List.Add("skill5", new Command("skill5", "", false, "Use skill slot #"));
            menu.List.Add("skill6", new Command("skill6", "", false, "Use skill slot #"));
            menu.List.Add("flee", new Command("flee", "", false, "Run away from the fight"));
            user.Menu = menu;

            return true;
        }
Пример #13
0
        /// <summary>
        /// Thread-safe callback from each TelnetConnection, parsing input.
        /// This function is timed internally by PulseTimer().
        /// </summary>
        /// <param name="conn">The TelnetConnection the input is coming from</param>
        /// <param name="line">The input string</param>
        static public void Interpret(TelnetConnection conn, string line)
        {
            // If the connection doesn't have a Player yet, it must be a new connection.
            // Forward it to LoginInterpret().
            if (conn.GetPlayer() == null)
            {
                LoginInterpret(conn, line);
            }
            else
            {
                Player player      = conn.GetPlayer();
                string commandText = GetArgument(line, 1).Text;

                if (commandText == "" || line == "")
                {
                    return;
                }

                if (player.Menu == null)
                {
                    // Mosey through all the commands
                    foreach (KeyValuePair <string, Command> pair in Global.Commands.List)
                    {
                        // Match the command, allowing shorthand abbreviation (e.g. south = so = s)
                        // Note: Commands are parsed in the order they are added to the list in
                        //   Commands.cs, to give commands priority, add them to the top of the
                        //   list. (e.g. s will always match south, because it always comes before
                        //   score)
                        if (pair.Key.StartsWith(commandText.ToLower()))
                        {
                            Command command = pair.Value;

                            player.SendMessage("Command debug: " + GetArgument(line, 1).Text + "|" + GetArgument(line, 2).Text + "|" + GetArgument(line, 3).Text + "|" + GetArgument(line, 4).Text + "\n\r");
                            if (command != null)
                            {
                                // Voodoo reflection magic to execute the method that the command
                                //   wants to execute. Passes the Player itself, as well as the
                                //   input string to that method.
                                // TODO: This could be improved for effeciency by retrieving the
                                //   method once on load and storing it as a reference - possibly
                                //   a delegate? I'm not too sure. -DWE 2009/08/04
                                MethodInfo method = typeof(Commands).GetMethod(command.Method);
                                method.Invoke(Global.Commands, new object[] { player, pair.Value, line });
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (player.Menu is DynamicMenu)
                    {
                        // Mosey through all the commands
                        DynamicMenu menu = (DynamicMenu)player.Menu;
                        foreach (KeyValuePair <string, Command> pair in menu.List)
                        {
                            // Match the command, allowing shorthand abbreviation (e.g. south = so = s)
                            // Note: Commands are parsed in the order they are added to the list in
                            //   Commands.cs, to give commands priority, add them to the top of the
                            //   list. (e.g. s will always match south, because it always comes before
                            //   score)
                            if (pair.Key.StartsWith(commandText.ToLower()))
                            {
                                Command command = pair.Value;
                                if (command != null)
                                {
                                    // Voodoo reflection magic to execute the method that the command
                                    //   wants to execute. Passes the Player itself, as well as the
                                    //   input string to that method.
                                    // TODO: This could be improved for effeciency by retrieving the
                                    //   method once on load and storing it as a reference - possibly
                                    //   a delegate? I'm not too sure. -DWE 2009/08/04
                                    Type       type   = player.Menu.Caller.GetType();
                                    MethodInfo method = type.GetMethod(player.Menu.CallbackMethod);
                                    method.Invoke(player.Menu.Caller, new object[] { line });
                                    return;
                                }
                            }
                        }
                    }
                    else if (player.Menu is InputNumberMenu)
                    {
                        double number;
                        bool   valid = double.TryParse(commandText, out number);
                        if (valid)
                        {
                            Type       type   = player.Menu.Caller.GetType();
                            MethodInfo method = type.GetMethod(player.Menu.CallbackMethod);
                            method.Invoke(player.Menu.Caller, new object[] { line });
                            return;
                        }
                        else
                        {
                            conn.GetPlayer().SendMessage("That is not a valid number.\n\r");
                            return;
                        }
                    }
                    else if (player.Menu is InputStringMenu)
                    {
                        Type       type   = player.Menu.Caller.GetType();
                        MethodInfo method = type.GetMethod(player.Menu.CallbackMethod);
                        method.Invoke(player.Menu.Caller, new object[] { line });
                        return;
                    }


                    if (player.Menu.DisplayMessage != "" && player.Menu.Caller is Player)
                    {
                        ((Player)player.Menu.Caller).SendMessage(player.Menu.DisplayMessage);
                    }
                    return;
                }

                conn.GetPlayer().SendMessage("Huh? \"" + commandText + "\" isn't a command!\n\r");

                // Nifty argument debugger, uncomment to see arguments as they are being parsed
                //  - SUPER spammy, sends globally for all input

                /*
                 * for (int x = 1; x <= 10; x++)
                 * {
                 *      Argument arg = GetArgument(line, x);
                 *
                 *      if(arg != null)
                 *              Global.Server.SendToAll(arg.Index + ".  " + arg.Count + "*  " + arg.Text);
                 *      else
                 *              Global.Server.SendToAll("Huh?");
                 * }
                 */
            }
        }