コード例 #1
0
ファイル: Login.cs プロジェクト: ramseur/PolaMUD
        /// <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);

            InputStringMenu strMenu = new InputStringMenu(player, "HandlePasswordInput");
            player.Menu = strMenu;
            player.SendMessage("Password: ");
        }
コード例 #2
0
 public Instance(Player owner, Area area, int indexStart, int indexEnd)
 {
     Owner = owner;
     Area = area;
     IndexStart = indexStart;
     IndexEnd = indexEnd;
 }
コード例 #3
0
ファイル: MovementCommands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #4
0
        /// <summary>
        /// Creates a new Instance belonging to the specified Player with the specified Quantity of indexes reserved.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public static Instance NewInstance(Player player, int quantity)
        {
            if (Instances.ContainsKey(player))
            {
                Global.Error("Tried to assign a new instance to " + player.Name + " but one exists\n\r");
                return null;
            }

            int indexStart = 0;

            // TODO: check CPU usage
            int consecutiveCount = 0;
            for(int i = 0; i < FullInstanceIndexStart; i++)
            {
                if (InstanceTable[i] == false)
                {
                    if (indexStart == 0)
                        indexStart = i;

                    consecutiveCount++;
                }
                else
                {
                    consecutiveCount = 0;
                    indexStart = 0;
                }

                if (consecutiveCount >= quantity)
                    break;
            }

            int count = 0;
            for (int i = 0; i < quantity; i++)
            {
                InstanceTable[indexStart + i] = true;
                Global.Log("#" + (indexStart + i) + " marked, ");
                count++;
            }
            Global.Log("\n\r" + count + " total");

            Instance instance = new Instance(player, indexStart + 100000, indexStart + 100000 + quantity);
            Instances.Add(player, instance);
            return instance;
        }
コード例 #5
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #6
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #7
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #8
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #9
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #10
0
        /// <summary>
        /// Removes the Instance belonging to Player, freeing all indexes belonging to the instance
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public static bool RemoveInstance(Player player)
        {
            if (Instances.ContainsKey(player))
            {
                Instance instance = Instances[player];

                int count = 0;
                for (int i = instance.IndexStart - 100000; i <= instance.IndexEnd - instance.IndexStart; i++)
                {
                    InstanceTable[i] = false;
                    Global.Log("#" + i + " released, ");
                    count++;
                }
                Global.Log("\n\r" + count + " total");

                Instances.Remove(player);

                return true;
            }

            return false;
        }
コード例 #11
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #12
0
ファイル: Parser.cs プロジェクト: Entroper/PolaMUD
        /// <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");
        }
コード例 #13
0
ファイル: Room.cs プロジェクト: ramseur/PolaMUD
        /// <summary>
        /// Show the Room to Player, including all contents.
        /// </summary>
        /// <param name="player"></param>
        public void Display(Player player)
        {
            player.SendMessage(Colors.BRIGHT_WHITE + Name + " [Room " + IndexNumber + "]\n\r");
            player.SendMessage("  " + Description + "\n\r\n\r");

            player.SendMessage("[Exits:");

            player.SendMobileMessage("t=room~name=" + Name + "~id=" + IndexNumber + "~exit=");

            if (Exits.ContainsKey(Directions.North))
            {
                player.SendMessage(" north");
                player.SendMobileMessage("n");
            }
            if (Exits.ContainsKey(Directions.South))
            {
                player.SendMessage(" south");
                player.SendMobileMessage("s");
            }
            if (Exits.ContainsKey(Directions.West))
            {
                player.SendMessage(" west");
                player.SendMobileMessage("w");
            }
            if (Exits.ContainsKey(Directions.East))
            {
                player.SendMessage(" east");
                player.SendMobileMessage("e");
            }
            if (Exits.ContainsKey(Directions.Up))
            {
                player.SendMessage(" up");
                player.SendMobileMessage("u");
            }
            if (Exits.ContainsKey(Directions.Down))
            {
                player.SendMessage(" down");
                player.SendMobileMessage("d");
            }

            /*foreach (KeyValuePair<Directions, Exit> exit in Exits)
            {
                switch (exit.Key)
                {
                    case Directions.North:
                        player.SendMessage(" north");
                        player.SendMobileMessage("n");
                        break;
                    case Directions.South:
                        player.SendMessage(" south");
                        player.SendMobileMessage("s");
                        break;
                    case Directions.West:
                        player.SendMessage(" west");
                        player.SendMobileMessage("w");
                        break;
                    case Directions.East:
                        player.SendMessage(" east");
                        player.SendMobileMessage("e");
                        break;
                    case Directions.Up:
                        player.SendMessage(" up");
                        player.SendMobileMessage("u");
                        break;
                    case Directions.Down:
                        player.SendMessage(" down");
                        player.SendMobileMessage("d");
                        break;
                }
            }*/

            player.SendMessage("]\n\r\n\r");
            player.SendMobileMessage("~\n\r");

            player.SendMobileMessage("t=roomcontents=");
            foreach (Entity thing in Contents)
            {
                if (thing is Mob)
                {
                    Mob mob = (Mob)thing;
                    player.SendMessage(mob.Name + " is here.\n\r");
                    player.SendMobileMessage(mob.Name + "|");
                }
                else if (thing is Player)
                {
                }
            }
            player.SendMobileMessage("~\n\r");
        }
コード例 #14
0
 public Instance(Player owner, int indexStart, int indexEnd)
 {
     Owner = owner;
     IndexStart = indexStart;
     IndexEnd = indexEnd;
 }
コード例 #15
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #16
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #17
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }
コード例 #18
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        public bool CommandAload(Player user, Command command, string text)
        {
            text = Parser.GetStringArgument(text, 2).Text;

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

            return true;
        }
コード例 #19
0
ファイル: Commands.cs プロジェクト: ramseur/PolaMUD
        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;
        }