コード例 #1
0
ファイル: Pathfind.cs プロジェクト: xeryax/proxymud
        private bool CanUsePortal(Exit p, Pathfinder x)
        {
            if (!p.HasFlag("recallmechanic"))
            {
                if (!x.CanUsePortals)
                {
                    return(false);
                }
            }
            else
            {
                if (!x.CanUseRecalls)
                {
                    return(false);
                }
            }

            if (p.MinLevel > x.CharacterLevel + x.CharacterTier * 10 ||
                p.MaxLevel < x.CharacterLevel)
            {
                return(false);
            }

            if (p.HasFlag("nogq") && x.IsGlobalQuest)
            {
                return(false);
            }

            if (x.SkipPortals != null && x.SkipPortals.Contains(p))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
ファイル: Edit.cs プロジェクト: xeryax/proxymud
        private bool CommandExit(InputData i)
        {
            //      1        2          3      4
            // @"^(help)?(room\s+\d+)?(\d+)?(\s+.+)?"
            if (i.Arguments.Groups[1].Length != 0)
            {
                World.Instance.SendMessage("@wSyntax:", i.ClientMask);
                World.Instance.SendMessage(string.Format("{0,-20}", "map exit") + " - show exits in current room.", i.ClientMask);
                World.Instance.SendMessage(string.Format("{0,-20}", "map exit help") + " - show this message.", i.ClientMask);
                World.Instance.SendMessage(string.Format("{0,-20}", "map exit room <room ID>") + " - show exits in room.", i.ClientMask);
                World.Instance.SendMessage(string.Format("{0,-20}", "map exit <ID> [option] [value]") + " - change exit options / show information by exit ID.", i.ClientMask);
                World.Instance.SendMessage("", i.ClientMask);
                World.Instance.SendMessage("@wAvailable options for exit:", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "addflag") + " @w- Add a flag to exit.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "removeflag") + " @w- Remove a flag from exit.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "command") + " @w- Change command that activates exit.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "doorcommand") + " @w- Change command that we use to open door, for example '@Wopen altar@w'. Use clear to remove this field.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "cost") + " @w- Change cost of using exit.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "minlevel") + " @w- Minimum level required to use exit.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "maxlevel") + " @w- Maximum level allowed to use exit.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "delete confirm") + " @w- Delete the exit.", i.ClientMask);
                World.Instance.SendMessage("", i.ClientMask);
                World.Instance.SendMessage("@wAvailable default flags:", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "recallmechanic") + " @w- This exit uses recall mechanic, can't use in norecall (for portals).", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "door") + " @w- This exit has a door.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "nogq") + " @w- Don't use this exit on a global quest (for regular chaos portals).", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "disabled") + " @w- Don't use this exit ever.", i.ClientMask);
                //World.Instance.SendMessage("@W" + string.Format("{0,-15}", "nopass") + " @w- The door is nopass.", i.ClientMask);
                //World.Instance.SendMessage("@W" + string.Format("{0,-15}", "locked") + " @w- The door is locked.", i.ClientMask);
                //World.Instance.SendMessage("@W" + string.Format("{0,-15}", "pickable") + " @w- Door can be pick locked or bashdoor.", i.ClientMask);
                World.Instance.SendMessage("@wNote: there may be custom flags that are implemented by other plugins / scripts that aren't listed here.", i.ClientMask);
                return(true);
            }

            if (i.Arguments.Groups[2].Length != 0 || (i.Arguments.Groups[2].Length == 0 && i.Arguments.Groups[1].Length == 0 && i.Arguments.Groups[3].Length == 0))
            {
                uint roomId;
                if (i.Arguments.Groups[2].Length != 0)
                {
                    string str = i.Arguments.Groups[2].Value.Substring(4).Trim();
                    if (!uint.TryParse(str, out roomId))
                    {
                        World.Instance.SendMessage("@wInvalid room ID given. Type '@Wmap exit help@w' for syntax.",
                                                   i.ClientMask);
                        return(true);
                    }
                }
                else
                {
                    roomId = CurrentRoomId;
                    if (roomId == uint.MaxValue)
                    {
                        World.Instance.SendMessage("@wYou are in an unknown room.", i.ClientMask);
                        return(true);
                    }
                }

                Room r = GetRoom(roomId);
                if (r == null)
                {
                    World.Instance.SendMessage("@wNo such room in database (@R" + roomId + "@w).", i.ClientMask);
                    return(true);
                }

                World.Instance.SendMessage("@wExits in '@G" + r.Name + "@w' [@Y" + r.Entry + "@w]:", i.ClientMask);
                if (r.exits.Count == 0)
                {
                    World.Instance.SendMessage("@wNo exits found.", i.ClientMask);
                }
                else
                {
                    World.Instance.SendMessage("@WEntry  Command              To", i.ClientMask);
                    World.Instance.SendMessage("@G====== ==================== ========================", i.ClientMask);
                    foreach (Exit e in r.exits)
                    {
                        World.Instance.SendMessage("@Y" + string.Format("{0,-6}", e.Entry) + " @W" + string.Format("{0,-20}", e.Command) + " @w[@Y" + string.Format("{0,6}", e.To.Entry) + "@w] @G" + e.To.Name, i.ClientMask);
                    }
                    World.Instance.SendMessage("", i.ClientMask);
                    World.Instance.SendMessage("@wType '@Wmap exit <exit ID>@w' for more information about an exit.", i.ClientMask);
                    World.Instance.SendMessage("@wOr '@Wmap exit help@w' for syntax.", i.ClientMask);
                }
                return(true);
            }

            if (i.Arguments.Groups[3].Length != 0)
            {
                uint exitId;
                if (!uint.TryParse(i.Arguments.Groups[3].Value, out exitId))
                {
                    World.Instance.SendMessage("@wInvalid exit ID given. Type '@Wmap exit help@w' for syntax.", i.ClientMask);
                    return(true);
                }

                Exit e = GetExit(exitId);
                if (e == null && IPortals.ContainsKey(exitId))
                {
                    e = IPortals[exitId];
                }
                if (e == null)
                {
                    World.Instance.SendMessage("@wNo such exit in database (@R" + exitId + "@w).", i.ClientMask);
                    return(true);
                }

                if (i.Arguments.Groups[4].Length != 0)
                {
                    string key, val;
                    string str = i.Arguments.Groups[4].Value.Trim();
                    if (str.Contains(' '))
                    {
                        key = str.Substring(0, str.IndexOf(' ')).ToLower();
                        val = str.Substring(key.Length).Trim();

                        switch (key)
                        {
                        case "addflag":
                            e.AddFlag(val);
                            break;

                        case "removeflag":
                            e.RemoveFlag(val);
                            break;

                        case "command":
                            val       = val.ToLower();
                            e.Command = PathfindResult.IsDirectionCommand(val) != 'x' ?
                                        PathfindResult.IsDirectionCommand(val).ToString() :
                                        val;
                            break;

                        case "doorcommand":
                            val           = val.ToLower();
                            e.DoorCommand = val != "clear" ? val : null;
                            break;

                        case "cost":
                        {
                            uint u;
                            if (uint.TryParse(val, out u))
                            {
                                e.Cost = u;
                            }
                        } break;

                        case "minlevel":
                        {
                            int lvl;
                            if (int.TryParse(val, out lvl))
                            {
                                e.MinLevel = lvl;
                            }
                        } break;

                        case "maxlevel":
                        {
                            int lvl;
                            if (int.TryParse(val, out lvl))
                            {
                                e.MaxLevel = lvl;
                            }
                        } break;

                        case "delete":
                        {
                            if (val == "confirm")
                            {
                                if (e.HasFlag("portal"))
                                {
                                    IPortals.Remove(e.Entry);
                                    e.To.Area.Portals.Remove(e);
                                }
                                else
                                {
                                    IExits.Remove(e.Entry);
                                    e.From.exits.Remove(e);
                                }
                                World.Instance.SendMessage("@wDeleted exit or portal (@R" + e.Entry + "@w).",
                                                           i.ClientMask);
                                return(true);
                            }
                            World.Instance.SendMessage("@wEnter '@Wmap exit <num> delete confirm@w' to remove the exit.", i.ClientMask);
                        } break;

                        default:
                            World.Instance.SendMessage("@wInvalid key value pair entered '@R" + key + " " + val + "@w'.", i.ClientMask);
                            World.Instance.SendMessage("@wUse '@Wmap exit help@w' to see syntax.", i.ClientMask);
                            break;
                        }
                    }
                }

                World.Instance.SendMessage("@w+----------------------------------------------------------------------+", i.ClientMask);
                World.Instance.SendMessage("@w| @WEntry       @w: @Y" + string.Format("{0,-55}", e.Entry) + "@w|", i.ClientMask);
                if (!e.HasFlag("portal"))
                {
                    World.Instance.SendMessage("@w| @WFrom        @w: @w[@Y" + string.Format("{0,6}", e.From.Entry) + "@w] @G" + Utility.FormatColoredString(!string.IsNullOrEmpty(e.From.Name) ? e.From.Name : "Unknown", -46) + "@w|", i.ClientMask);
                }
                World.Instance.SendMessage("@w| @WTo          @w: @w[@Y" + string.Format("{0,6}", e.To.Entry) + "@w] @G" + Utility.FormatColoredString(!string.IsNullOrEmpty(e.To.Name) ? e.To.Name : "Unknown", -46) + "@w|", i.ClientMask);
                World.Instance.SendMessage("@w| @WCommand     @w: @c" + string.Format("{0,-55}", e.Command) + "@w|", i.ClientMask);
                World.Instance.SendMessage("@w| @WDoor command@w: @c" + string.Format("{0,-55}", !string.IsNullOrEmpty(e.DoorCommand) ? e.DoorCommand : "none") + "@w|", i.ClientMask);
                World.Instance.SendMessage("@w| @WCost        @w: @C" + string.Format("{0,-55}", e.Cost) + "@w|", i.ClientMask);
                StringBuilder strFlags = new StringBuilder();
                if (e.IFlags != null)
                {
                    foreach (string x in e.IFlags)
                    {
                        if (strFlags.Length > 0)
                        {
                            strFlags.Append(", ");
                        }
                        strFlags.Append(x);
                    }
                }

                string[] spl = Utility.WrapColored(strFlags.ToString(), 54, 0);
                for (int j = 0; j < spl.Length; j++)
                {
                    if (j == 0)
                    {
                        World.Instance.SendMessage("@w| @WFlags       @w: " + string.Format("{0,-55}", spl[j]) + "@w|", i.ClientMask);
                    }
                    else
                    {
                        World.Instance.SendMessage("@w|             : " + string.Format("{0,-55}", spl[j]) + "@w|", i.ClientMask);
                    }
                }

                World.Instance.SendMessage("@w| @WMin level   @w: @W" + string.Format("{0,-55}", e.MinLevel) + "@w|", i.ClientMask);
                World.Instance.SendMessage("@w| @WMax level   @w: @W" + string.Format("{0,-55}", e.MaxLevel) + "@w|", i.ClientMask);
                World.Instance.SendMessage("@w+----------------------------------------------------------------------+", i.ClientMask);
                if (i.Arguments.Groups[4].Length == 0)
                {
                    World.Instance.SendMessage("@wSee '@Wmap exit help@w' for information on how to edit this exit.", i.ClientMask);
                }
                return(true);
            }

            World.Instance.SendMessage("0", i.ClientMask);
            return(true);
        }