コード例 #1
0
ファイル: Reload.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!RELOAD"),
                    MustMatch("It helps if you give me a path.",
                        Path("TARGET"))))
                .Manual("Given a path, it attempts to recompile that object. The object will be replaced in-place if possible.")
                .ProceduralRule((match, actor) =>
                {
                    var target = match["TARGET"].ToString();
                    var newObject = Core.Database.ReloadObject(target);
                    if (newObject == null) MudObject.SendMessage(actor, "Failed to reload " + target);
                    else MudObject.SendMessage(actor, "Reloaded " + target);
                    return PerformResult.Continue;
                });

            Parser.AddCommand(
                 Sequence(
                     RequiredRank(500),
                     KeyWord("!RESET"),
                     MustMatch("It helps if you give me a path.",
                         Path("TARGET"))))
                 .Manual("Given a path, it attempts to reset that object without reloading or recompiling. The object will be replaced in-place if possible.")
                 .ProceduralRule((match, actor) =>
                 {
                     var target = match["TARGET"].ToString();
                     if (Core.Database.ResetObject(target) == null)
                         MudObject.SendMessage(actor, "Failed to reset " + target);
                     else MudObject.SendMessage(actor, "Reset " + target);
                     return PerformResult.Continue;
                 });
        }
コード例 #2
0
ファイル: Whisper.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             Or(
                 KeyWord("WHISPER"),
                 KeyWord("TELL")),
             OptionalKeyWord("TO"),
             MustMatch("Whom?",
                 Object("PLAYER", new ConnectedPlayersObjectSource(), ObjectMatcherSettings.None)),
             MustMatch("Tell them what?", Rest("SPEECH"))))
         .Manual("Sends a private message to the player of your choice.")
         .ProceduralRule((match, actor) =>
         {
             if (System.Object.ReferenceEquals(actor, match["PLAYER"]))
             {
                 MudObject.SendMessage(actor, "Talking to yourself?");
                 return PerformResult.Stop;
             }
             return PerformResult.Continue;
         })
         .ProceduralRule((match, actor) =>
         {
             var player = match["PLAYER"] as Actor;
             MudObject.SendMessage(player, "[privately " + DateTime.Now + "] ^<the0> : \"" + match["SPEECH"].ToString() + "\"", actor);
             MudObject.SendMessage(actor, "[privately to <the0>] ^<the1> : \"" + match["SPEECH"].ToString() + "\"", player, actor);
             if (player.ConnectedClient is NetworkClient && (player.ConnectedClient as NetworkClient).IsAfk)
                 MudObject.SendMessage(actor, "^<the0> is afk : " + player.ConnectedClient.Player.GetProperty<Account>("account").AFKMessage, player);
             return PerformResult.Continue;
         });
 }
コード例 #3
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             RequiredRank(500),
             KeyWord("!RULES"),
             Optional(Object("OBJECT", InScope)),
             Optional(Rest("BOOK-NAME"))))
     .Manual("Lists rules and rulebooks. Both arguments are optional. If no object is supplied, it will list global rules. If no book name is supplied, it will list books rather than listing rules.")
     .ProceduralRule((match, actor) =>
     {
         if (match.ContainsKey("OBJECT"))
         {
             if (match.ContainsKey("BOOK-NAME"))
             {
                 DisplaySingleBook(actor, (match["OBJECT"] as MudObject).Rules, match["BOOK-NAME"].ToString());
             }
             else
             {
                 DisplayBookList(actor, (match["OBJECT"] as MudObject).Rules);
             }
         }
         else if (match.ContainsKey("BOOK-NAME"))
         {
             DisplaySingleBook(actor, Core.GlobalRules.Rules, match["BOOK-NAME"].ToString());
         }
         else
         {
             DisplayBookList(actor, Core.GlobalRules.Rules);
         }
         return(PerformResult.Continue);
     });
 }
コード例 #4
0
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    KeyWord("LOGIN"),
                    MustMatch("You must supply a username.",
                              SingleWord("USERNAME"))))
            .Manual("If you got this far, you know how to login.")
            .ProceduralRule((match, actor) =>
            {
                var client = actor.GetProperty <Client>("client");
                if (client == null)
                {
                    return(PerformResult.Stop);
                }

                if (client is NetworkClient && (client as NetworkClient).IsLoggedOn)
                {
                    Core.SendMessage(actor, "You are already logged in.");
                    return(PerformResult.Stop);
                }

                var userName = match["USERNAME"].ToString();

                actor.SetProperty("command handler", new PasswordCommandHandler(actor, Authenticate, userName));
                return(PerformResult.Continue);
            });
        }
コード例 #5
0
ファイル: Kick.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("KICK"),
                    Or(
                        Object("PLAYER", new ConnectedPlayersObjectSource(), ObjectMatcherSettings.None),
                        SingleWord("MASK"))))
                .Manual("Makes bad people go away.")
                .ProceduralRule((match, actor) =>
                {
                    if (match.ContainsKey("PLAYER"))
                        KickPlayer(match["PLAYER"] as Actor, actor);
                    else
                    {
                        var mask = match["MASK"].ToString();
                        var maskRegex = new System.Text.RegularExpressions.Regex(ProscriptionList.ConvertGlobToRegex(mask), System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                        //Iterate over local copy because kicking modifies ConnectedClients.
                        foreach (var client in new List<Client>(Clients.ConnectedClients))
                        {
                            var netClient = client as NetworkClient;
                            if (netClient != null && netClient.IsLoggedOn && maskRegex.Matches(netClient.IPString).Count > 0)
                            {
                                Core.MarkLocaleForUpdate(client.Player);
                                KickPlayer(client.Player, actor);
                            }
                        }
                    }

                    return PerformResult.Continue;
                });
        }
コード例 #6
0
ファイル: Set.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!SET"),
                    MustMatch("I don't see that here.",
                              Object("OBJECT", InScope)),
                    SingleWord("PROPERTY"),
                    Rest("VALUE")))
            .Manual("Set the value of a property on an object.")
            .ProceduralRule((match, actor) =>
            {
                var _object       = match["OBJECT"] as MudObject;
                var property_name = match["PROPERTY"].ToString();
                var stringValue   = match["VALUE"].ToString();

                var propertyInfo = PropertyManifest.GetPropertyInformation(property_name);

                if (propertyInfo == null)
                {
                    Core.SendMessage(actor, "That property does not exist.");
                    return(PerformResult.Stop);
                }

                var realValue = propertyInfo.Converter.ConvertFromString(stringValue);

                _object.SetProperty(property_name, realValue);

                Core.SendMessage(actor, "Property set.");
                return(PerformResult.Continue);
            });
        }
コード例 #7
0
ファイル: Move.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!MOVE"),
                    MustMatch("I don't see that here.",
                        Object("OBJECT", InScope)),
                    OptionalKeyWord("TO"),
                    MustMatch("You have to specify the path of the destination.",
                        Path("DESTINATION"))))
                .Manual("An administrative command to move objects from one place to another. This command entirely ignores all rules that might prevent moving an object.")
                .ProceduralRule((match, actor) =>
                {
                    var destination = MudObject.GetObject(match["DESTINATION"].ToString());
                    if (destination != null)
                    {
                        var target = match["OBJECT"] as MudObject;
                        Core.MarkLocaleForUpdate(target);
                        MudObject.Move(target, destination);
                        Core.MarkLocaleForUpdate(destination);

                        MudObject.SendMessage(actor, "Success.");
                    }
                    else
                        MudObject.SendMessage(actor, "I could not find the destination.");
                    return PerformResult.Continue;
                });
        }
コード例 #8
0
ファイル: Whisper.cs プロジェクト: Blecki/RMUDReboot
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             Or(
                 KeyWord("WHISPER"),
                 KeyWord("TELL")),
             OptionalKeyWord("TO"),
             MustMatch("Whom?",
                       Object("PLAYER", new ConnectedPlayersObjectSource(), ObjectMatcherSettings.None)),
             MustMatch("Tell them what?", Rest("SPEECH"))))
     .Manual("Sends a private message to the player of your choice.")
     .ProceduralRule((match, actor) =>
     {
         if (System.Object.ReferenceEquals(actor, match["PLAYER"]))
         {
             Core.SendMessage(actor, "Talking to yourself?");
             return(PerformResult.Stop);
         }
         return(PerformResult.Continue);
     })
     .ProceduralRule((match, actor) =>
     {
         var player = match["PLAYER"] as MudObject;
         Core.SendMessage(player, "[privately " + DateTime.Now + "] ^<the0> : \"" + match["SPEECH"].ToString() + "\"", actor);
         Core.SendMessage(actor, "[privately to <the0>] ^<the1> : \"" + match["SPEECH"].ToString() + "\"", player, actor);
         var client = player.GetProperty <Client>("client");
         if (client is NetworkClient && (client as NetworkClient).IsAfk)
         {
             Core.SendMessage(actor, "^<the0> is afk : " + player.GetProperty <Account>("account").AFKMessage, player);
         }
         return(PerformResult.Continue);
     });
 }
コード例 #9
0
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!MOVE"),
                    MustMatch("I don't see that here.",
                              Object("OBJECT", InScope)),
                    OptionalKeyWord("TO"),
                    MustMatch("You have to specify the path of the destination.",
                              Path("DESTINATION"))))
            .Manual("An administrative command to move objects from one place to another. This command entirely ignores all rules that might prevent moving an object.")
            .ProceduralRule((match, actor) =>
            {
                var destination = Core.GetObject(match["DESTINATION"].ToString());
                if (destination != null)
                {
                    var target = match["OBJECT"] as MudObject;
                    Core.MarkLocaleForUpdate(target);
                    Core.Move(target, destination);
                    Core.MarkLocaleForUpdate(destination);

                    Core.SendMessage(actor, "Success.");
                }
                else
                {
                    Core.SendMessage(actor, "I could not find the destination.");
                }
                return(PerformResult.Continue);
            });
        }
コード例 #10
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             Or(
                 KeyWord("GET"),
                 KeyWord("TAKE")),
             BestScore("SUBJECT",
                       MustMatch("@not here",
                                 Object("SUBJECT", InScope, (actor, item) =>
     {
         if (Core.GlobalRules.ConsiderCheckRuleSilently("can take?", actor, item) != CheckResult.Allow)
         {
             return(MatchPreference.Unlikely);
         }
         return(MatchPreference.Plausible);
     })))))
     .ID("StandardActions:Take")
     .Manual("Takes an item and adds it to your inventory.")
     .Check("can take?", "ACTOR", "SUBJECT")
     .BeforeActing()
     .Perform("take", "ACTOR", "SUBJECT")
     .AfterActing()
     .MarkLocaleForUpdate();
 }
コード例 #11
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             RequiredRank(500),
             KeyWord("!INSTANCE"),
             MustMatch("It helps if you give me a path.",
                       Path("PATH"))))
     .Manual("Given a path, create a new instance of an object.")
     .ProceduralRule((match, actor) =>
     {
         var path      = match["PATH"].ToString();
         var newObject = Core.GetObject(path + "@" + Guid.NewGuid().ToString());
         if (newObject == null)
         {
             Core.SendMessage(actor, "Failed to instance " + path + ".");
         }
         else
         {
             Core.Move(newObject, actor);
             Core.SendMessage(actor, "Instanced " + path + ".");
         }
         return(PerformResult.Continue);
     });
 }
コード例 #12
0
ファイル: ReadLog.cs プロジェクト: Blecki/RMUDReboot
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("!LOG"),
             Path("FILENAME"),
             Optional(Number("COUNT"))))
     .Manual("Displays the last COUNT lines of a log file. If no count is provided, 20 lines are displayed.")
     .ProceduralRule((match, actor) =>
     {
         int count = 20;
         if (match.ContainsKey("COUNT"))
         {
             count = (match["COUNT"] as int?).Value;
         }
         var filename = match["FILENAME"].ToString() + ".log";
         if (System.IO.File.Exists(filename))
         {
             foreach (var line in new ReverseLineReader(filename).Take(count).Reverse())
             {
                 Core.SendMessage(actor, line);
             }
         }
         else
         {
             Core.SendMessage(actor, "I could not find that log file.");
         }
         return(PerformResult.Continue);
     });
 }
コード例 #13
0
ファイル: UseableThings.cs プロジェクト: Blecki/GaSiProMo
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Or(
             Sequence(
                 KeyWord("USE"),
                 BestScore("SUBJECT",
                     MustMatch("@not here",
                     Object("SUBJECT", InScope, (actor, thing) =>
                     {
                         // Prefer objects we can actually use.
                         var canUse = Core.GlobalRules.ConsiderCheckRuleSilently("can use?", actor, thing);
                         if (canUse == SharpRuleEngine.CheckResult.Allow)
                             return MatchPreference.Likely;
                         return MatchPreference.Unlikely;
                     })))),
             // We would also like to match when the player types the name of a thing that is
             // useable. Here we just check the 'useable?' property, so that things where
             // 'can use?' fails will still be matched.
             Generic((m, c) =>
             {
                 return new List<RMUD.PossibleMatch>(
                     Object("SUBJECT", InScope)
                         .Match(m, c)
                         .Where(
                         _ => (_["SUBJECT"] as MudObject).GetBooleanProperty("useable?")));
             }, "[A USEABLE ITEM]")))
         .ID("USE")
         .Manual("Use a useable thing. You can also just enter the name of the thing.")
         .Check("can use?", "ACTOR", "SUBJECT")
         .BeforeActing()
         .Perform("used", "ACTOR", "SUBJECT")
         .AfterActing();
 }
コード例 #14
0
ファイル: Alias.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    KeyWord("ALIAS"),
                    SingleWord("NAME"),
                    Rest("RAW-COMMAND")))
            .Manual("Create an alias for another command, or a series of them.")
            .ProceduralRule((match, actor) =>
            {
                if (!actor.HasProperty("aliases"))
                {
                    actor.SetProperty("aliases", new Dictionary <String, String>());
                }
                var aliases = actor.GetProperty <Dictionary <String, String> >("aliases");
                aliases.Add(match["NAME"].ToString().ToUpper(), match["RAW-COMMAND"].ToString());
                Core.SendMessage(actor, "Alias added.");
                return(PerformResult.Continue);
            });

            Parser.AddCommand(
                Generic((match, context) =>
            {
                var r = new List <PossibleMatch>();
                if (!context.ExecutingActor.HasProperty("aliases"))
                {
                    return(r);
                }
                var aliases = context.ExecutingActor.GetProperty <Dictionary <String, String> >("aliases");
                if (aliases.ContainsKey(match.Next.Value.ToUpper()))
                {
                    r.Add(match.AdvanceWith("ALIAS", aliases[match.Next.Value.ToUpper()]));
                }
                return(r);
            }, "<ALIAS NAME>"))
            .Manual("Execute an alias.")
            .ProceduralRule((match, actor) =>
            {
                var commands = match["ALIAS"].ToString().Split(';');
                foreach (var command in commands)
                {
                    Core.EnqueuActorCommand(actor, command);
                }
                return(PerformResult.Continue);
            });
        }
コード例 #15
0
ファイル: Say.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Or(
                    Sequence(
                        Or(
                            KeyWord("SAY"),
                            KeyWord("'")),
                        MustMatch("@say what", Rest("SPEECH"))),
                    Generic((pm, context) =>
            {
                var r = new List <PossibleMatch>();
                if (pm.Next == null || pm.Next.Value.Length <= 1 || pm.Next.Value[0] != '\'')
                {
                    return(r);
                }

                pm.Next.Value = pm.Next.Value.Substring(1);         //remove the leading '

                var builder = new StringBuilder();
                var node    = pm.Next;
                for (; node != null; node = node.Next)
                {
                    builder.Append(node.Value);
                    builder.Append(" ");
                }

                builder.Remove(builder.Length - 1, 1);
                r.Add(pm.EndWith("SPEECH", builder.ToString()));
                return(r);
            }, "'[TEXT => SPEECH]")))
            .ID("StandardActions:Say")
            .Manual("Speak within your locale.")
            .Perform("speak", "ACTOR", "SPEECH");


            Parser.AddCommand(
                Sequence(
                    Or(
                        KeyWord("EMOTE"),
                        KeyWord("\"")),
                    MustMatch("@emote what", Rest("SPEECH"))))
            .ID("StandardActions:Emote")
            .Manual("Perform an action, visible within your locale.")
            .Perform("emote", "ACTOR", "SPEECH");
        }
コード例 #16
0
ファイル: Reload.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!RELOAD"),
                    MustMatch("It helps if you give me a path.",
                              Path("TARGET"))))
            .Manual("Given a path, it attempts to recompile that object. The object will be replaced in-place if possible.")
            .ProceduralRule((match, actor) =>
            {
                var target    = match["TARGET"].ToString();
                var newObject = Core.Database.ReloadObject(target);
                if (newObject == null)
                {
                    Core.SendMessage(actor, "Failed to reload " + target);
                }
                else
                {
                    Core.SendMessage(actor, "Reloaded " + target);
                }
                return(PerformResult.Continue);
            });

            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!RESET"),
                    MustMatch("It helps if you give me a path.",
                              Path("TARGET"))))
            .Manual("Given a path, it attempts to reset that object without reloading or recompiling. The object will be replaced in-place if possible.")
            .ProceduralRule((match, actor) =>
            {
                var target = match["TARGET"].ToString();
                if (Core.Database.ResetObject(target) == null)
                {
                    Core.SendMessage(actor, "Failed to reset " + target);
                }
                else
                {
                    Core.SendMessage(actor, "Reset " + target);
                }
                return(PerformResult.Continue);
            });
        }
コード例 #17
0
ファイル: Examine.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(Or(KeyWord("EXAMINE"), KeyWord("X")))
                .Manual("Take a detailed look at your surroundings.")
                .Perform("examine", "ACTOR");

            Parser.AddCommand(
                Sequence(
                    Or(
                        Or(KeyWord("EXAMINE"), KeyWord("X")),
                        Sequence(
                            Or(KeyWord("LOOK"), KeyWord("L")),
                            KeyWord("AT"))),
                    MustMatch("@dont see that", Object("OBJECT", InScope))))
                .Manual("Take a close look at an object.")
                .Check("can examine?", "ACTOR", "OBJECT")
                .Perform("describe", "ACTOR", "OBJECT");
        }
コード例 #18
0
ファイル: Force.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!FORCE"),
                    MustMatch("Whom do you wish to command?",
                        FirstOf(
                            Object("OBJECT", InScope),
                            Path("PATH"))),
                    Rest("RAW-COMMAND")))
                .Manual("An administrative command that allows you to execute a command as if you were another actor or player. The other entity will see all output from the command, and rules restricting their access to the command are considered.")
                .ProceduralRule((match, actor) =>
                    {
                        if (match.ContainsKey("PATH"))
                        {
                            var target = MudObject.GetObject(match["PATH"].ToString());
                            if (target == null)
                            {
                                MudObject.SendMessage(actor, "I can't find whomever it is you want to submit to your foolish whims.");
                                return PerformResult.Stop;
                            }
                            match.Upsert("OBJECT", target);
                        }
                        return PerformResult.Continue;
                    }, "Convert path to object rule.")
                .ProceduralRule((match, actor) =>
                {
                    MudObject target = match["OBJECT"] as MudObject;

                    var targetActor = target as Actor;
                    if (targetActor == null)
                    {
                        MudObject.SendMessage(actor, "You can order inanimate objects about as much as you like, they aren't going to listen.");
                        return PerformResult.Stop;
                    }

                    var command = match["RAW-COMMAND"].ToString();
                    var matchedCommand = Core.DefaultParser.ParseCommand(new PendingCommand { RawCommand = command, Actor = targetActor });

                    if (matchedCommand != null)
                    {
                        if (matchedCommand.Matches.Count > 1)
                            MudObject.SendMessage(actor, "The command was ambigious.");
                        else
                        {
                            MudObject.SendMessage(actor, "Enacting your will.");
                            Core.ProcessPlayerCommand(matchedCommand.Command, matchedCommand.Matches[0], targetActor);
                        }
                    }
                    else
                        MudObject.SendMessage(actor, "The command did not match.");

                    return PerformResult.Continue;
                });
        }
コード例 #19
0
ファイル: Inventory.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Or(
             KeyWord("INVENTORY"),
             KeyWord("INV"),
             KeyWord("I")))
         .Manual("Displays what you are wearing and carrying.")
         .Perform("inventory", "ACTOR");
 }
コード例 #20
0
ファイル: Force.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!FORCE"),
                    MustMatch("Whom do you wish to command?",
                              FirstOf(
                                  Object("OBJECT", InScope),
                                  Path("PATH"))),
                    Rest("RAW-COMMAND")))
            .Manual("An administrative command that allows you to execute a command as if you were another actor or player. The other entity will see all output from the command, and rules restricting their access to the command are considered.")
            .ProceduralRule((match, actor) =>
            {
                if (match.ContainsKey("PATH"))
                {
                    var target = Core.GetObject(match["PATH"].ToString());
                    if (target == null)
                    {
                        Core.SendMessage(actor, "I can't find whomever it is you want to submit to your foolish whims.");
                        return(PerformResult.Stop);
                    }
                    match.Upsert("OBJECT", target);
                }
                return(PerformResult.Continue);
            }, "Convert path to object rule.")
            .ProceduralRule((match, actor) =>
            {
                MudObject target = match["OBJECT"] as MudObject;

                var command        = match["RAW-COMMAND"].ToString();
                var matchedCommand = Core.DefaultParser.ParseCommand(new PendingCommand {
                    RawCommand = command, Actor = target
                });

                if (matchedCommand != null)
                {
                    if (matchedCommand.Matches.Count > 1)
                    {
                        Core.SendMessage(actor, "The command was ambigious.");
                    }
                    else
                    {
                        Core.SendMessage(actor, "Enacting your will.");
                        Core.ProcessPlayerCommand(matchedCommand.Command, matchedCommand.Matches[0], target);
                    }
                }
                else
                {
                    Core.SendMessage(actor, "The command did not match.");
                }

                return(PerformResult.Continue);
            });
        }
コード例 #21
0
ファイル: Ban.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                KeyWord("BANS"))
            .Manual("Lists all active bans.")
            .ProceduralRule((match, actor) =>
            {
                Core.SendMessage(actor, "~~~ ALL SET BANS ~~~");
                foreach (var proscription in Clients.ProscriptionList.Proscriptions)
                {
                    Core.SendMessage(actor, proscription.Glob + " : " + proscription.Reason);
                }
                return(PerformResult.Continue);
            });

            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("BAN"),
                    MustMatch("You must supply an ip mask.", SingleWord("GLOB")),
                    MustMatch("You must supply a reason.", Rest("REASON"))))
            .Manual("Ban every player who's ip matches the mask.")
            .ProceduralRule((match, actor) =>
            {
                Clients.ProscriptionList.Ban(match["GLOB"].ToString(), match["REASON"].ToString());
                Clients.SendGlobalMessage("^<the0> has banned " + match["GLOB"].ToString(), actor);
                return(PerformResult.Continue);
            });

            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("UNBAN"),
                    MustMatch("You must supply an ip mask.", SingleWord("GLOB"))))
            .Manual("Remove an existing ban.")
            .ProceduralRule((match, actor) =>
            {
                Clients.ProscriptionList.RemoveBan(match["GLOB"].ToString());
                Clients.SendGlobalMessage("^<the0> removes the ban on " + match["GLOB"].ToString(), actor);
                return(PerformResult.Continue);
            });
        }
コード例 #22
0
ファイル: Inventory.cs プロジェクト: Blecki/RMUDReboot
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Or(
             KeyWord("INVENTORY"),
             KeyWord("INV"),
             KeyWord("I")))
     .ID("StandardActions:Inventory")
     .Manual("Displays what you are wearing and carrying.")
     .Perform("inventory", "ACTOR");
 }
コード例 #23
0
ファイル: Say.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Or(
                    Sequence(
                        Or(
                            KeyWord("SAY"),
                            KeyWord("'")),
                        MustMatch("@say what", Rest("SPEECH"))),
                    Generic((pm, context) =>
                    {
                        var r = new List<PossibleMatch>();
                        if (pm.Next == null || pm.Next.Value.Length <= 1 || pm.Next.Value[0] != '\'')
                            return r;

                        pm.Next.Value = pm.Next.Value.Substring(1); //remove the leading '

                        var builder = new StringBuilder();
                        var node = pm.Next;
                        for (; node != null; node = node.Next)
                        {
                            builder.Append(node.Value);
                            builder.Append(" ");
                        }

                        builder.Remove(builder.Length - 1, 1);
                        r.Add(pm.EndWith("SPEECH", builder.ToString()));
                        return r;
                    }, "'[TEXT => SPEECH]")))
                .Manual("Speak within your locale.")
                .Perform("speak", "ACTOR", "SPEECH");

            Parser.AddCommand(
                Sequence(
                    Or(
                        KeyWord("EMOTE"),
                        KeyWord("\"")),
                    MustMatch("@emote what", Rest("SPEECH"))))
                .Manual("Perform an action, visible within your locale.")
                .Perform("emote", "ACTOR", "SPEECH");
        }
コード例 #24
0
ファイル: Ban.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                KeyWord("BANS"))
                .Manual("Lists all active bans.")
                .ProceduralRule((match, actor) =>
                {
                    MudObject.SendMessage(actor, "~~~ ALL SET BANS ~~~");
                    foreach (var proscription in Clients.ProscriptionList.Proscriptions)
                        MudObject.SendMessage(actor, proscription.Glob + " : " + proscription.Reason);
                    return PerformResult.Continue;
                });

            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("BAN"),
                    MustMatch("You must supply an ip mask.", SingleWord("GLOB")),
                    MustMatch("You must supply a reason.", Rest("REASON"))))
                .Manual("Ban every player who's ip matches the mask.")
                .ProceduralRule((match, actor) =>
                {
                    Clients.ProscriptionList.Ban(match["GLOB"].ToString(), match["REASON"].ToString());
                    Clients.SendGlobalMessage("^<the0> has banned " + match["GLOB"].ToString(), actor);
                    return PerformResult.Continue;
                });

            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("UNBAN"),
                    MustMatch("You must supply an ip mask.", SingleWord("GLOB"))))
                .Manual("Remove an existing ban.")
                .ProceduralRule((match, actor) =>
                {
                    Clients.ProscriptionList.RemoveBan(match["GLOB"].ToString());
                    Clients.SendGlobalMessage("^<the0> removes the ban on " + match["GLOB"].ToString(), actor);
                    return PerformResult.Continue;
                });
        }
コード例 #25
0
ファイル: LookUnderOrBehind.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             Or(
                 KeyWord("LOOK"),
                 KeyWord("L")),
             RelativeLocation("RELLOC"),
             Object("OBJECT", InScope)))
         .Manual("Lists object that are in, on, under, or behind the object specified.")
         .Check("can look relloc?", "ACTOR", "OBJECT", "RELLOC")
         .Perform("look relloc", "ACTOR", "OBJECT", "RELLOC");
 }
コード例 #26
0
ファイル: Alias.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    KeyWord("ALIAS"),
                    SingleWord("NAME"),
                    Rest("RAW-COMMAND")))
                .Manual("Create an alias for another command, or a series of them.")
                .ProceduralRule((match, actor) =>
                {
                    if (!actor.HasProperty<Dictionary<String, String>>("aliases"))
                        actor.SetProperty("aliases", new Dictionary<String, String>());
                    var aliases = actor.GetProperty<Dictionary<String, String>>("aliases");
                    aliases.Add(match["NAME"].ToString().ToUpper(), match["RAW-COMMAND"].ToString());
                    MudObject.SendMessage(actor, "Alias added.");
                    return PerformResult.Continue;
                });

            Parser.AddCommand(
                Generic((match, context) =>
                {
                    var r = new List<PossibleMatch>();
                    if (!context.ExecutingActor.HasProperty<Dictionary<String, String>>("aliases"))
                        return r;
                    var aliases = context.ExecutingActor.GetProperty<Dictionary<String, String>>("aliases");
                    if (aliases.ContainsKey(match.Next.Value.ToUpper()))
                        r.Add(match.AdvanceWith("ALIAS", aliases[match.Next.Value.ToUpper()]));
                    return r;
                }, "<ALIAS NAME>"))
                .Manual("Execute an alias.")
                .ProceduralRule((match, actor) =>
                {
                    var commands = match["ALIAS"].ToString().Split(';');
                    foreach (var command in commands)
                        Core.EnqueuActorCommand(actor, command);
                    return PerformResult.Continue;
                });
        }
コード例 #27
0
ファイル: Wear.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("WEAR"),
             BestScore("OBJECT",
                 MustMatch("@clothing wear what",
                     Object("OBJECT", InScope, PreferHeld)))))
         .Manual("Cover your disgusting flesh.")
         .Check("can wear?", "ACTOR", "OBJECT")
         .BeforeActing()
         .Perform("worn", "ACTOR", "OBJECT")
         .AfterActing();
 }
コード例 #28
0
ファイル: Drop.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("DROP"),
             BestScore("SUBJECT",
                 MustMatch("@dont have that",
                     Object("SUBJECT", InScope, PreferHeld)))))
         .Manual("Drop a held item. This can also be used to remove and drop a worn item.")
         .Check("can drop?", "ACTOR", "SUBJECT")
         .BeforeActing()
         .Perform("drop", "ACTOR", "SUBJECT")
         .AfterActing();
 }
コード例 #29
0
ファイル: Scope.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             RequiredRank(500),
             KeyWord("!SCOPE")))
         .Manual("List all of the objects in scope")
         .ProceduralRule((match, actor) =>
         {
             foreach (var thing in MudObject.EnumerateVisibleTree(MudObject.FindLocale(actor)))
                 MudObject.SendMessage(actor, thing.Short + " - " + thing.GetType().Name);
             return PerformResult.Continue;
         }, "List all the damn things in scope rule.");
 }
コード例 #30
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         KeyWord("!DUMPMESSAGES"))
     .Manual("Dump defined messages to messages.txt")
     .ProceduralRule((match, actor) =>
     {
         var builder = new StringBuilder();
         Core.DumpMessagesForCustomization(builder);
         System.IO.File.WriteAllText("messages.txt", builder.ToString());
         Core.SendMessage(actor, "Messages dumped to messages.txt.");
         return(PerformResult.Continue);
     });
 }
コード例 #31
0
ファイル: Remove.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("REMOVE"),
             BestScore("OBJECT",
                 MustMatch("@clothing remove what",
                     Object("OBJECT", InScope, PreferWorn)))))
         .Manual("Expose your amazingly supple flesh.")
         .Check("can remove?", "ACTOR", "OBJECT")
         .BeforeActing()
         .Perform("removed", "ACTOR", "OBJECT")
         .AfterActing();
 }
コード例 #32
0
ファイル: Sonar.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(KeyWord("SONAR"))
                .ProceduralRule((match, actor) =>
                {

                    var builder = new System.Text.StringBuilder();

                    var mapGrid = new int[MapWidth, MapHeight];
                    for (int y = 0; y < MapHeight; ++y)
                        for (int x = 0; x < MapWidth; ++x)
                            mapGrid[x, y] = ' ';

                    for (int y = 1; y < MapHeight - 1; ++y)
                    {
                        mapGrid[0, y] = '|';
                        mapGrid[MapWidth - 1, y] = '|';
                    }

                    for (int x = 1; x < MapWidth - 1; ++x)
                    {
                        mapGrid[x, 0] = '-';
                        mapGrid[x, MapHeight - 1] = '-';
                    }

                    mapGrid[0, 0] = '+';
                    mapGrid[0, MapHeight - 1] = '+';
                    mapGrid[MapWidth - 1, 0] = '+';
                    mapGrid[MapWidth - 1, MapHeight - 1] = '+';

                    var roomLegend = new Dictionary<int, String>();

                    if (actor.Location is RMUD.Room)
                        MapLocation(mapGrid, roomLegend, (MapWidth / 2), (MapHeight / 2), actor.Location as RMUD.Room, '@');

                    for (int y = 0; y < MapHeight; ++y)
                    {
                        for (int x = 0; x < MapWidth; ++x)
                            builder.Append((char)mapGrid[x, y]);
                        builder.Append("\r\n");
                    }

                    foreach (var entry in roomLegend)
                        builder.Append((char)entry.Key + " - " + entry.Value + "\r\n");

                    MudObject.SendMessage(actor, builder.ToString());
                    return RMUD.PerformResult.Continue;
                }, "Implement sonar device rule.");
        }
コード例 #33
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("WIELD"),
             BestScore("OBJECT",
                       MustMatch("@kill what",
                                 Object("OBJECT", InScope, PreferHeld)))))
     .ID("Combat:Wield")
     .Manual("Arm thyself.")
     .Check("can wield?", "ACTOR", "OBJECT")
     .BeforeActing()
     .Perform("wield", "ACTOR", "OBJECT")
     .AfterActing();
 }
コード例 #34
0
ファイル: Remove.cs プロジェクト: Blecki/RMUDReboot
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("REMOVE"),
             BestScore("OBJECT",
                       MustMatch("@clothing remove what",
                                 Object("OBJECT", InScope, PreferWorn)))))
     .ID("Clothing:Remove")
     .Manual("Expose your amazingly supple flesh.")
     .Check("can remove?", "ACTOR", "OBJECT")
     .BeforeActing()
     .Perform("removed", "ACTOR", "OBJECT")
     .AfterActing();
 }
コード例 #35
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("DROP"),
             BestScore("SUBJECT",
                       MustMatch("@dont have that",
                                 Object("SUBJECT", InScope, PreferHeld)))))
     .ID("StandardActions:Drop")
     .Manual("Drop a held item. This can also be used to remove and drop a worn item.")
     .Check("can drop?", "ACTOR", "SUBJECT")
     .BeforeActing()
     .Perform("drop", "ACTOR", "SUBJECT")
     .AfterActing();
 }
コード例 #36
0
ファイル: Wear.cs プロジェクト: Blecki/RMUDReboot
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("WEAR"),
             BestScore("OBJECT",
                       MustMatch("@clothing wear what",
                                 Object("OBJECT", InScope, PreferHeld)))))
     .ID("Clothing:Wear")
     .Manual("Cover your disgusting flesh.")
     .Check("can wear?", "ACTOR", "OBJECT")
     .BeforeActing()
     .Perform("worn", "ACTOR", "OBJECT")
     .AfterActing();
 }
コード例 #37
0
ファイル: Inspect.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!INSPECT"),
                    MustMatch("I don't see that here.",
                              Or(
                                  Object("OBJECT", InScope),
                                  KeyWord("HERE")))))
            .Manual("Take a peek at the internal workings of any mud object.")
            .ProceduralRule((match, actor) =>
            {
                if (!match.ContainsKey("OBJECT"))
                {
                    match.Upsert("OBJECT", actor.Location);
                }
                return(PerformResult.Continue);
            }, "Convert locale option to standard form rule.")
            .ProceduralRule((match, actor) =>
            {
                var target = match["OBJECT"] as MudObject;

                Core.SendMessage(actor, "*** INSPECT LISTING ***");
                Core.SendMessage(actor, "Path: <s0>", target.Path);
                Core.SendMessage(actor, "Instance: <s0>", target.Instance);
                Core.SendMessage(actor, "Persistent: <s0>", target.IsPersistent.ToString());
                if (!target.Location.HasValue(out var loc))
                {
                    Core.SendMessage(actor, "Location: NOWHERE");
                }
                else
                {
                    Core.SendMessage(actor, "Location: <s0>", loc.GetFullName());
                }
                Core.SendMessage(actor, "*** DYNAMIC PROPERTIES ***");

                foreach (var property in target.Properties)
                {
                    var info = PropertyManifest.GetPropertyInformation(property.Key);
                    Core.SendMessage(actor, "<s0>: <s1>", property.Key, info.Converter.ConvertToString(property.Value));
                }

                Core.SendMessage(actor, "*** END OF LISTING ***");

                return(PerformResult.Continue);
            }, "List all the damn things rule.");
        }
コード例 #38
0
		public LoginCommandHandler()
		{
			Parser = new CommandParser();

			Parser.AddCommand(
				new Sequence(new KeyWord("LOGIN", false), new SingleWord("NAME")),
				new CommandProcessorWrapper((m, a) =>
				{
					a.Short = m.Arguments["NAME"].ToString();
					a.ConnectedClient.CommandHandler = Mud.ParserCommandHandler;
					a.Rank = 500; //Everyone is a wizard! 
					Thing.Move(a, Mud.GetObject("dummy"));
					Mud.EnqueuClientCommand(a.ConnectedClient, "look");
				}),
				"Login to an existing account.");
		}
コード例 #39
0
ファイル: Afk.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("AFK"),
             MustMatch("You have to supply an afk message.",
                 Rest("MESSAGE"))))
         .Manual("Sets your afk message. This message is displayed after 5 minutes of inactivity on the WHO list, and to any player who attempts to whisper to you.")
         .ProceduralRule((match, actor) =>
         {
             if (actor.ConnectedClient != null)
                 actor.ConnectedClient.Player.GetProperty<Account>("account").AFKMessage = match["MESSAGE"].ToString();
             MudObject.SendMessage(actor, "AFK message set.");
             return PerformResult.Continue;
         });
 }
コード例 #40
0
        public LoginCommandHandler()
        {
            Parser = new CommandParser();

            Parser.AddCommand(
                new Sequence(new KeyWord("LOGIN", false), new SingleWord("NAME")),
                new CommandProcessorWrapper((m, a) =>
            {
                a.Short = m.Arguments["NAME"].ToString();
                a.ConnectedClient.CommandHandler = Mud.ParserCommandHandler;
                a.Rank = 500;                         //Everyone is a wizard!
                Thing.Move(a, Mud.GetObject("dummy"));
                Mud.EnqueuClientCommand(a.ConnectedClient, "look");
            }),
                "Login to an existing account.");
        }
コード例 #41
0
ファイル: Scope.cs プロジェクト: Blecki/RMUDReboot
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             RequiredRank(500),
             KeyWord("!SCOPE")))
     .Manual("List all of the objects in scope")
     .ProceduralRule((match, actor) =>
     {
         foreach (var thing in Core.EnumerateVisibleTree(Core.FindLocale(actor)))
         {
             Core.SendMessage(actor, thing.GetProperty <String>("short") + " - " + thing.GetType().Name);
         }
         return(PerformResult.Continue);
     }, "List all the damn things in scope rule.");
 }
コード例 #42
0
ファイル: Quit.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         KeyWord("QUIT"))
         .Manual("Disconnect from the game immediately.")
         .ProceduralRule((match, actor) =>
         {
             if (actor != null && actor.ConnectedClient != null)
                 match.Upsert("CLIENT", actor.ConnectedClient);
             if (match.ContainsKey("CLIENT"))
             {
                 (match["CLIENT"] as Client).Send("Goodbye...\r\n");
                 (match["CLIENT"] as Client).Disconnect();
             }
             return PerformResult.Continue;
         });
 }
コード例 #43
0
ファイル: Inspect.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!INSPECT"),
                    MustMatch("I don't see that here.",
                        Or(
                            Object("OBJECT", InScope),
                            KeyWord("HERE")))))
                .Manual("Take a peek at the internal workings of any mud object.")
                .ProceduralRule((match, actor) =>
                    {
                        if (!match.ContainsKey("OBJECT"))
                            match.Upsert("OBJECT", actor.Location);
                        return PerformResult.Continue;
                    }, "Convert locale option to standard form rule.")
                .ProceduralRule((match, actor) =>
                {
                    var target = match["OBJECT"] as MudObject;
                    MudObject.SendMessage(actor, target.GetType().Name);

                    foreach (var @interface in target.GetType().GetInterfaces())
                        MudObject.SendMessage(actor, "Implements " + @interface.Name);

                    foreach (var field in target.GetType().GetFields())
                        MudObject.SendMessage(actor, "field " + field.FieldType.Name + " " + field.Name + " = " + WriteValue(field.GetValue(target)));

                    foreach (var property in target.GetType().GetProperties())
                    {
                        var s = (property.CanWrite ? "property " : "readonly ") + property.PropertyType.Name + " " + property.Name;
                        if (property.CanRead)
                        {
                            s += " = ";
                            try
                            {
                                s += WriteValue(property.GetValue(target, null));
                            }
                            catch (Exception) { s += "[Error reading value]"; }
                        }
                        MudObject.SendMessage(actor, s);
                    }

                    return PerformResult.Continue;
                }, "List all the damn things rule.");
        }
コード例 #44
0
ファイル: Quit.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                KeyWord("QUIT"))
            .Manual("Disconnect from the game immediately.")
            .ProceduralRule((match, actor) =>
            {
                var client = actor.GetProperty <Client>("client");
                if (client != null)
                {
                    client.Send("Goodbye...\r\n");
                    client.Disconnect();
                }

                return(PerformResult.Continue);
            });
        }
コード例 #45
0
ファイル: Properties.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!PROPERTIES")))
            .Manual("List all properties that have been registered.")
            .ProceduralRule((match, actor) =>
            {
                foreach (var prop in PropertyManifest.GetAllPropertyInformation())
                {
                    Core.SendMessage(actor, "<s0> (<s1>) : <s2>", prop.Key, prop.Value.Type.ToString(), prop.Value.Converter.ConvertToString(prop.Value.DefaultValue));
                }

                return(PerformResult.Continue);
            });
        }
コード例 #46
0
ファイル: Tape.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         BestScore("SUBJECT",
             Sequence(
                 KeyWord("TAPE"),
                 MustMatch("@not here",
                     Object("SUBJECT", InScope, PreferHeld)),
                 OptionalKeyWord("TO"),
                 MustMatch("@not here",
                     Object("OBJECT", InScope)))))
         .Manual("Tape one thing to another")
         .Check("can tape to?", "ACTOR", "SUBJECT", "OBJECT")
         .BeforeActing()
         .Perform("taped to", "ACTOR", "SUBJECT", "OBJECT")
         .AfterActing();
 }
コード例 #47
0
ファイル: Lock.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         BestScore("KEY",
             BestScore("SUBJECT",
                 Sequence(
                     KeyWord("LOCK"),
                     MustMatch("@not here",
                         Object("SUBJECT", InScope)),
                     OptionalKeyWord("WITH"),
                     MustMatch("@not here",
                         Object("KEY", InScope, PreferHeld))))))
         .Manual("Lock the subject with a key.")
         .Check("can lock?", "ACTOR", "SUBJECT", "KEY")
         .BeforeActing()
         .Perform("locked", "ACTOR", "SUBJECT", "KEY")
         .AfterActing();
 }
コード例 #48
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             Or(
                 KeyWord("KILL"),
                 KeyWord("ATTACK")
                 ),
             BestScore("OBJECT",
                       MustMatch("@kill what",
                                 Object("OBJECT", InScope, PreferValidTargets)))))
     .ID("Combat:Kill")
     .Manual("Murder. Death. Kill.")
     .Check("can attack?", "ACTOR", "OBJECT")
     .BeforeActing()
     .Perform("attack", "ACTOR", "OBJECT")
     .AfterActing();
 }
コード例 #49
0
ファイル: Unlock.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("UNLOCK"),
             BestScore("ITEM",
                 MustMatch("@not here",
                     Object("ITEM", InScope))),
             OptionalKeyWord("WITH"),
             BestScore("KEY",
                 MustMatch("@not here",
                     Object("KEY", InScope, PreferHeld)))))
         .Manual("Use the KEY to unlock the ITEM.")
         .Check("can lock?", "ACTOR", "ITEM", "KEY")
         .BeforeActing()
         .Perform("unlocked", "ACTOR", "ITEM", "KEY")
         .AfterActing();
 }
コード例 #50
0
ファイル: Close.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("CLOSE"),
             BestScore("SUBJECT",
                 MustMatch("@not here",
                     Object("SUBJECT", InScope, (actor, thing) =>
                         {
                             if (Core.GlobalRules.ConsiderCheckRuleSilently("can close?", actor, thing) == CheckResult.Allow) return MatchPreference.Likely;
                             return MatchPreference.Unlikely;
                         })))))
         .Manual("Closes a thing.")
         .Check("can close?", "ACTOR", "SUBJECT")
         .BeforeActing()
         .Perform("close", "ACTOR", "SUBJECT")
         .AfterActing();
 }
コード例 #51
0
ファイル: AcceptQuest.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    KeyWord("ACCEPT"),
                    KeyWord("QUEST")))
            .Name("ACCEPT QUEST")
            .Manual("When an NPC offers you a quest, you will be prompted to accept the quest. Accepting a quest abandons any quest you already have active.")
            .ProceduralRule((match, actor) =>
            {
                if (actor.GetProperty <MudObject>("offered-quest") == null)
                {
                    Core.SendMessage(actor, "Nobody has offered you a quest.");
                    return(PerformResult.Stop);
                }
                else
                {
                    match.Upsert("QUEST", actor.GetProperty <MudObject>("offered-quest"));
                    return(PerformResult.Continue);
                }
            }, "the must have been offered a quest, and bookeeping rule.")
            .ProceduralRule((match, actor) =>
            {
                if (!Core.GlobalRules.ConsiderValueRule <bool>("quest available?", actor, actor.GetProperty <MudObject>("offered-quest")))
                {
                    Core.SendMessage(actor, "The quest is no longer available.");
                    actor.SetProperty("offered-quest", null);
                    return(PerformResult.Stop);
                }
                return(PerformResult.Continue);
            }, "the quest must be available rule.")
            .ProceduralRule((match, actor) =>
            {
                if (actor.GetProperty <MudObject>("active-quest") != null)
                {
                    Core.GlobalRules.ConsiderPerformRule("quest abandoned", actor, actor.GetProperty <MudObject>("active-quest"));
                }

                actor.SetProperty("active-quest", actor.GetProperty <MudObject>("offered-quest"));
                actor.SetProperty("offered-quest", null);
                return(PerformResult.Continue);
            }, "the any active quest must be abandoned rule.")
            .Perform("quest accepted", "ACTOR", "QUEST");
        }
コード例 #52
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("PUT"),
             BestScore("SUBJECT",
                       MustMatch("@dont have that",
                                 Object("SUBJECT", InScope, PreferHeld))),
             Optional(RelativeLocation("RELLOC")),
             BestScore("OBJECT",
                       MustMatch("@not here",
                                 Object("OBJECT", InScope, (actor, thing) =>
     {
         //Prefer objects that are actually containers. No means curently to prefer
         //objects that actually support the relloc we matched previously.
         if (thing.GetProperty <bool>("container?"))
         {
             return(MatchPreference.Likely);
         }
         return(MatchPreference.Plausible);
     })))))
     .ID("StandardActions:Put")
     .Manual("This commands allows you to put things on other things. While dropping just deposits the object into your current location, putting is much more specific.")
     .ProceduralRule((match, actor) =>
     {
         if (!match.ContainsKey("RELLOC"))
         {
             if ((match["OBJECT"] as MudObject).GetProperty <bool>("container?"))
             {
                 match.Upsert("RELLOC", (match["OBJECT"] as MudObject).DefaultContentLocation);
             }
             else
             {
                 match.Upsert("RELLOC", RelativeLocations.ON);
             }
         }
         return(PerformResult.Continue);
     }, "Supply default for optional relloc procedural rule.")
     .Check("can put?", "ACTOR", "SUBJECT", "OBJECT", "RELLOC")
     .BeforeActing()
     .Perform("put", "ACTOR", "SUBJECT", "OBJECT", "RELLOC")
     .AfterActing()
     .MarkLocaleForUpdate();
 }
コード例 #53
0
ファイル: Cons.cs プロジェクト: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Core.StandardMessage("cons", "Results of consistency check:");
            Core.StandardMessage("cons no results", "I found nothing wrong.");

            Parser.AddCommand(
                Sequence(
                    KeyWord("!CONS"),
                    Optional(KeyWord("LOCAL"), "LOCAL")))
            .ID("Meta:Cons")
            .Manual("Scan all defined commands for ommissions, then scan loaded objects for omissions.")
            .ProceduralRule((match, actor) =>
            {
                var localScan = false;
                if (match.ContainsKey("LOCAL"))
                {
                    localScan = (match["LOCAL"] as bool?).Value;
                }

                var resultsFound = 0;

                Core.SendMessage(actor, "@cons");

                if (!localScan)
                {
                    foreach (var command in Core.DefaultParser.EnumerateCommands())
                    {
                        if (String.IsNullOrEmpty(command.GetID()))
                        {
                            resultsFound += 1;
                            Core.SendMessage(actor, "Command has no ID set: " + command.ManualName + " from " + command.SourceModule);
                        }
                    }
                }

                if (resultsFound == 0)
                {
                    Core.SendMessage(actor, "@cons no results");
                }


                return(PerformResult.Continue);
            });
        }
コード例 #54
0
ファイル: Who.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         KeyWord("WHO"))
         .Manual("Displays a list of current logged in players.")
         .ProceduralRule((match, actor) =>
         {
             var clients = Clients.ConnectedClients.Where(c => c is NetworkClient && (c as NetworkClient).IsLoggedOn);
             MudObject.SendMessage(actor, "~~ THESE PLAYERS ARE ONLINE NOW ~~");
             foreach (NetworkClient client in clients)
                 MudObject.SendMessage(actor,
                     "[" + Core.SettingsObject.GetNameForRank(client.Player.Rank) + "] <a0> ["
                     + client.ConnectionDescription + "]"
                     + (client.IsAfk ? (" afk: " + client.Player.GetProperty<Account>("account").AFKMessage) : "")
                     + (client.Player.Location != null ? (" -- " + client.Player.Location.Path) : ""),
                     client.Player);
             return PerformResult.Continue;
         });
 }
コード例 #55
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         BestScore("KEY",
                   BestScore("SUBJECT",
                             Sequence(
                                 KeyWord("LOCK"),
                                 MustMatch("@not here",
                                           Object("SUBJECT", InScope)),
                                 OptionalKeyWord("WITH"),
                                 MustMatch("@not here",
                                           Object("KEY", InScope, PreferHeld))))))
     .ID("StandardActions:Lock")
     .Manual("Lock the subject with a key.")
     .Check("can lock?", "ACTOR", "SUBJECT", "KEY")
     .BeforeActing()
     .Perform("locked", "ACTOR", "SUBJECT", "KEY")
     .AfterActing();
 }
コード例 #56
0
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("UNLOCK"),
             BestScore("ITEM",
                       MustMatch("@not here",
                                 Object("ITEM", InScope))),
             OptionalKeyWord("WITH"),
             BestScore("KEY",
                       MustMatch("@not here",
                                 Object("KEY", InScope, PreferHeld)))))
     .ID("StandardActions:Unlock")
     .Manual("Use the KEY to unlock the ITEM.")
     .Check("can lock?", "ACTOR", "ITEM", "KEY")
     .BeforeActing()
     .Perform("unlocked", "ACTOR", "ITEM", "KEY")
     .AfterActing();
 }
コード例 #57
0
ファイル: AcceptQuest.cs プロジェクト: Reddit-Mud/RMUD
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    KeyWord("ACCEPT"),
                    KeyWord("QUEST")))
                .Name("ACCEPT QUEST")
                .Manual("When an NPC offers you a quest, you will be prompted to accept the quest. Accepting a quest abandons any quest you already have active.")
                .ProceduralRule((match, actor) =>
                {
                    if (actor.GetProperty<MudObject>("offered-quest") == null)
                    {
                        MudObject.SendMessage(actor, "Nobody has offered you a quest.");
                        return PerformResult.Stop;
                    }
                    else
                    {
                        match.Upsert("QUEST", actor.GetProperty<MudObject>("offered-quest"));
                        return PerformResult.Continue;
                    }
                }, "the must have been offered a quest, and bookeeping rule.")
                .ProceduralRule((match, actor) =>
                {
                    var player = actor as Player;
                    if (!Core.GlobalRules.ConsiderValueRule<bool>("quest available?", player, player.GetProperty<MudObject>("offered-quest")))
                    {
                        MudObject.SendMessage(actor, "The quest is no longer available.");
                        player.RemoveProperty("offered-quest");
                        return PerformResult.Stop;
                    }
                    return PerformResult.Continue;
                }, "the quest must be available rule.")
                .ProceduralRule((match, actor) =>
                {
                    if (actor.GetProperty<MudObject>("active-quest") != null)
                        Core.GlobalRules.ConsiderPerformRule("quest abandoned", actor, actor.GetProperty<MudObject>("active-quest"));

                    actor.SetProperty("active-quest", actor.GetProperty<MudObject>("offered-quest"));
                    actor.RemoveProperty("offered-quest");
                    return PerformResult.Continue;
                }, "the any active quest must be abandoned rule.")
                .Perform("quest accepted", "ACTOR", "QUEST");
        }
コード例 #58
0
ファイル: Stats.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             RequiredRank(500),
             KeyWord("!STATS"),
             Optional(SingleWord("TYPE"))))
         .Manual("Displays various stats about the server. Type the command with no argument to get a list of available options.")
         .ProceduralRule((match, actor) =>
         {
             if (!match.ContainsKey("TYPE"))
             {
                 MudObject.SendMessage(actor, "Try one of these stats options");
                 Core.GlobalRules.ConsiderPerformRule("enumerate-stats", actor);
             }
             else
                 Core.GlobalRules.ConsiderPerformRule("stats", actor, match["TYPE"].ToString().ToUpper());
             return PerformResult.Continue;
         });
 }
コード例 #59
0
ファイル: Pull.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             KeyWord("PULL"),
             BestScore("SUBJECT",
                 MustMatch("@not here",
                     Object("SUBJECT", InScope, (actor, item) =>
                     {
                         if (Core.GlobalRules.ConsiderCheckRuleSilently("can pull?", actor, item) != CheckResult.Allow)
                             return MatchPreference.Unlikely;
                         return MatchPreference.Plausible;
                     })))))
         .Manual("Pull an item. By default, this does nothing.")
         .Check("can pull?", "ACTOR", "SUBJECT")
         .BeforeActing()
         .Perform("pull", "ACTOR", "SUBJECT")
         .AfterActing()
         .MarkLocaleForUpdate();
 }
コード例 #60
0
ファイル: Dump.cs プロジェクト: Reddit-Mud/RMUD
 public override void Create(CommandParser Parser)
 {
     Parser.AddCommand(
         Sequence(
             RequiredRank(500),
             KeyWord("!DUMP"),
             MustMatch("It helps if you supply a path.",
                 Path("TARGET"))))
         .Manual("Display the source of a database object.")
         .ProceduralRule((match, actor) =>
         {
             var target = match["TARGET"].ToString();
                 var source = Core.Database.LoadSourceFile(target);
                 if (!source.Item1)
                     MudObject.SendMessage(actor, "Could not display source: " + source.Item2);
                 else
                     MudObject.SendMessage(actor, "Source of " + target + "\n" + source.Item2);
             return PerformResult.Continue;
         });
 }