Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// If our connection doesn't have a Player yet, everything is sent here to handle
        /// login and Player creation.
        /// </summary>
        /// <param name="conn">The TelnetConnection the input is coming from</param>
        /// <param name="line">The input string</param>
        static public void LoginInterpret(TelnetConnection conn, string line)
        {
            Player player = new Player();

            player.MaxHealth     = 200;
            player.Health        = 200;
            player.PhysicalPower = 10;
            player.MagicPower    = 10;
            player.Name          = line;
            player.HandlingName  = line;
            player.Connection    = conn;

            foreach (Skill skill in Global.SkillTable.Values)
            {
                if (skill.Name == "Autoattack")
                {
                    continue;
                }
                player.Skills.Add(skill.Name, new SkillInstance(skill));
            }

            player.SkillSlots.Insert(0, player.Skills["Backstab"]);
            player.SkillSlots.Insert(1, player.Skills["Flurry"]);
            player.SkillSlots.Insert(2, player.Skills["Savage Strike"]);
            conn.SetPlayer(player);

            DynamicMenu menu = new DynamicMenu(player, "HandleClientMenu");

            menu.List.Add("telnet", new Command("telnet", "", false, "Sets your client type as a telnet connection (telnet, terminal, MUD client)"));
            menu.List.Add("full", new Command("full", "", false, "Sets your client type as the official rich client"));
            menu.List.Add("android", new Command("android", "", false, "Sets your client type as an Android phone"));
            player.Menu = menu;
            player.SendMessage("Please select your client type:\n\r- telnet\n\r- full\n\r- android\n\r");
        }
Ejemplo n.º 3
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 (Thing thing in Global.Things)
                    {
                        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 = user.Room.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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Password input dialog displayed immediately on login.
        /// </summary>
        /// <param name="command"></param>
        public void HandlePasswordInput(string command)
        {
            Argument arg1 = Parser.GetArgument(command, 1);

            if (!Authenticate(arg1.Text))
            {
                // disconnect bad password
                SendMessage("That's a bad password young man!\n\r");
                return;
            }

            DynamicMenu nextMenu = new DynamicMenu(this, "HandleClientMenu",
                                                   "Please select your client type:\n\r- telnet\n\r- full\n\r- android\n\r");

            nextMenu.List.Add("telnet", new Command("telnet", "", false, "Sets your client type as a telnet connection (telnet, terminal, MUD client)"));
            nextMenu.List.Add("full", new Command("full", "", false, "Sets your client type as the official rich client"));
            nextMenu.List.Add("android", new Command("android", "", false, "Sets your client type as an Android phone"));
            Menu = nextMenu;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
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?");
                 * }
                 */
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Password input dialog displayed immediately on login.
        /// </summary>
        /// <param name="command"></param>
        public void HandlePasswordInput(string command)
        {
            Argument arg1 = Parser.GetArgument(command, 1);

            if (!Authenticate(arg1.Text))
            {
                // disconnect bad password
                SendMessage("That's a bad password young man!\n\r");
                return;
            }

            DynamicMenu nextMenu = new DynamicMenu(this, "HandleClientMenu",
                "Please select your client type:\n\r- telnet\n\r- full\n\r- android\n\r");
            nextMenu.List.Add("telnet", new Command("telnet", "", false, "Sets your client type as a telnet connection (telnet, terminal, MUD client)"));
            nextMenu.List.Add("full", new Command("full", "", false, "Sets your client type as the official rich client"));
            nextMenu.List.Add("android", new Command("android", "", false, "Sets your client type as an Android phone"));
            Menu = nextMenu;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// If our connection doesn't have a Player yet, everything is sent here to handle 
        /// login and Player creation.
        /// </summary>
        /// <param name="conn">The TelnetConnection the input is coming from</param>
        /// <param name="line">The input string</param>
        public static void LoginInterpret(TelnetConnection conn, string line)
        {
            Player player = new Player();
            player.MaxHealth = 200;
            player.Health = 200;
            player.PhysicalPower = 10;
            player.MagicPower = 10;
            player.Name = line;
            player.HandlingName = line;
            player.Connection = conn;

            foreach (Skill skill in Global.SkillTable.Values)
            {
                if (skill.Name == "Autoattack")
                    continue;
                player.Skills.Add(skill.Name, new SkillInstance(skill));
            }

            player.SkillSlots.Insert(0, player.Skills["Backstab"]);
            player.SkillSlots.Insert(1, player.Skills["Flurry"]);
            player.SkillSlots.Insert(2, player.Skills["Savage Strike"]);
            conn.SetPlayer(player);

            DynamicMenu menu = new DynamicMenu(player, "HandleClientMenu");
            menu.List.Add("telnet", new Command("telnet", "", false, "Sets your client type as a telnet connection (telnet, terminal, MUD client)"));
            menu.List.Add("full", new Command("full", "", false, "Sets your client type as the official rich client"));
            menu.List.Add("android", new Command("android", "", false, "Sets your client type as an Android phone"));
            player.Menu = menu;
            player.SendMessage("Please select your client type:\n\r- telnet\n\r- full\n\r- android\n\r");
        }