From f14b32b67109f27b51be9e99d924819a4dc6ef4b Mon Sep 17 00:00:00 2001 From: Blecki Date: Sun, 24 May 2015 19:38:06 -0400 Subject: [PATCH 01/20] Testing fork --- Akkoteaque/Areas/Lighthouse/Rooms.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Akkoteaque/Areas/Lighthouse/Rooms.cs b/Akkoteaque/Areas/Lighthouse/Rooms.cs index f7e1d4d..204b19a 100644 --- a/Akkoteaque/Areas/Lighthouse/Rooms.cs +++ b/Akkoteaque/Areas/Lighthouse/Rooms.cs @@ -37,6 +37,7 @@ public class LowerStair : RMUD.Room { public override void Initialize() { + RoomType = RMUD.RoomType.Interior; Short = "Lower Stairway"; OpenLink(Direction.DOWN, "Areas.Lighthouse.Base"); From 44d79ac750927b1746edae87cddce466a8ecdbe7 Mon Sep 17 00:00:00 2001 From: Blecki Date: Mon, 25 May 2015 15:01:11 -0400 Subject: [PATCH 02/20] Converted to sharp rule engine hosted on nuget --- AdminModule/AdminModule.csproj | 6 + AdminModule/Dump.cs | 2 +- AdminModule/Force.cs | 8 +- AdminModule/Inspect.cs | 4 +- AdminModule/Instance.cs | 2 +- AdminModule/Move.cs | 2 +- AdminModule/ReadLog.cs | 2 +- AdminModule/Reload.cs | 4 +- AdminModule/Rules.cs | 1 + AdminModule/Save.cs | 2 +- AdminModule/Scope.cs | 2 +- AdminModule/Sonar.cs | 2 +- AdminModule/Stats.cs | 2 +- AdminModule/packages.config | 4 + Akkoteaque/Akkoteaque.csproj | 6 + Akkoteaque/Areas/Prologue/Car.cs | 2 +- Akkoteaque/Areas/Prologue/Henrico.cs | 4 +- Akkoteaque/Areas/Prologue/Player.cs | 2 +- Akkoteaque/Areas/Prologue/Watch.cs | 4 +- Akkoteaque/Game.cs | 6 +- Akkoteaque/HeavyThings.cs | 1 + Akkoteaque/packages.config | 4 + AliasModule/Alias.cs | 4 +- AliasModule/AliasModule.csproj | 6 + AliasModule/packages.config | 4 + ChatModule/ChatChannelRules.cs | 8 +- ChatModule/ChatModule.csproj | 6 + ChatModule/Commands.cs | 1 + ChatModule/packages.config | 4 + ClothingModule/ClothingModule.csproj | 6 + ClothingModule/Remove.cs | 3 +- ClothingModule/Rules.cs | 3 +- ClothingModule/Wear.cs | 3 +- ClothingModule/packages.config | 4 + ConversationModule/Commands.cs | 1 + ConversationModule/ConversationModule.csproj | 6 + ConversationModule/NPCExtension.cs | 1 + ConversationModule/Rules.cs | 3 +- ConversationModule/TopicObjectSource.cs | 2 +- ConversationModule/packages.config | 4 + Core/Core.csproj | 55 +- Core/Core/ExecuteCommand.cs | 1 + Core/Core/Heartbeat.cs | 2 +- Core/Core/IsVisibleTo.cs | 1 + Core/Core/MarkForUpdate.cs | 4 +- Core/Core/Meta/DumpMessages.cs | 2 +- Core/Core/Meta/Man.cs | 2 +- Core/Core/Meta/Version.cs | 2 +- Core/Core/MudCore.cs | 2 +- Core/Core/Parser/CommandEntry.cs | 1 + Core/Core/Parser/CommandParser.cs | 2 +- Core/Core/Parser/ParserCommandHandler.cs | 2 +- Core/Core/Rules/MudObjectAddRuleGen.cs | 96 ---- Core/Core/Rules/MudObjectAddRuleGen.tt | 54 -- Core/Core/Rules/Rule.cs | 52 -- Core/Core/Rules/RuleBook.cs | 180 ------ Core/Core/Rules/RuleBuilderGen.cs | 516 ------------------ Core/Core/Rules/RuleBuilderGen.tt | 199 ------- Core/Core/Rules/RuleDelegatesGen.cs | 144 ----- Core/Core/Rules/RuleDelegatesGen.tt | 79 --- Core/Core/Rules/RuleEngine.cs | 204 +------ Core/Core/Rules/RuleEngineAddRuleGen.cs | 191 ------- Core/Core/Rules/RuleEngineAddRuleGen.tt | 92 ---- Core/Core/Rules/RuleGen.t4 | 24 - Core/Core/Rules/RuleResult.cs | 20 - Core/Core/Rules/RuleSet.cs | 97 ---- Core/Core/Rules/RuleSetAddRuleGen.cs | 45 -- Core/Core/Rules/RuleSetAddRuleGen.tt | 33 -- Core/Core/Rules/RuleSource.cs | 26 - Core/Core/Startup.cs | 2 +- Core/WorldModel/BasicDoor.cs | 1 + Core/WorldModel/LockedDoor.cs | 1 + Core/WorldModel/MudObject.cs | 11 +- Core/WorldModel/RoomLightingRules.cs | 1 + Core/packages.config | 1 + IntroductionModule/Implementation.cs | 3 +- IntroductionModule/IntroductionModule.csproj | 6 + IntroductionModule/packages.config | 4 + NetworkModule/Afk.cs | 2 +- NetworkModule/Ban.cs | 6 +- NetworkModule/Kick.cs | 2 +- NetworkModule/Login.cs | 6 +- NetworkModule/NetworkModule.csproj | 3 + NetworkModule/Quit.cs | 2 +- NetworkModule/Register.cs | 4 +- NetworkModule/Stats.cs | 4 +- NetworkModule/Whisper.cs | 6 +- NetworkModule/Who.cs | 2 +- NetworkModule/packages.config | 1 + Play/PlayAkko.csproj | 5 + Play/packages.config | 4 + QuestModule/AcceptQuest.cs | 10 +- QuestModule/QuestModule.csproj | 6 + QuestModule/QuestRules.cs | 4 +- QuestModule/packages.config | 4 + RMUD/RMUD.csproj | 4 + RMUD/packages.config | 4 + SillyModule/Silly.cs | 3 +- SillyModule/SillyModule.csproj | 6 + SillyModule/packages.config | 4 + SinglePlayer/Akkoteaque/Fishing/Rod.cs | 4 +- SinglePlayer/Akkoteaque/Jetty.cs | 2 +- SinglePlayer/Akkoteaque/Settings.cs | 6 +- SinglePlayer/CloakOfDarkness/Bar.cs | 8 +- SinglePlayer/CloakOfDarkness/Cloak.cs | 8 +- SinglePlayer/CloakOfDarkness/Cloakroom.cs | 2 +- SinglePlayer/CloakOfDarkness/Foyer.cs | 2 +- SinglePlayer/CloakOfDarkness/settings.cs | 6 +- SinglePlayer/SinglePlayer.csproj | 4 + SinglePlayer/Wells/Thrad.cs | 4 +- SinglePlayer/packages.config | 4 + .../SinglePlayerMinimumGame.csproj | 6 + SinglePlayerMinimumGame/packages.config | 4 + Space/Cargo.cs | 2 +- Space/ControlPanel.cs | 8 +- Space/DanConversation0.cs | 1 + Space/Game.cs | 12 +- Space/Hatch.cs | 20 +- Space/Hit.cs | 4 +- Space/Locker.cs | 1 + Space/Player.cs | 2 +- Space/Room.cs | 2 +- Space/Space.csproj | 6 + Space/Tape.cs | 10 +- Space/packages.config | 4 + StandardActionsModule/Close.cs | 3 +- StandardActionsModule/DescribeRules.cs | 3 +- StandardActionsModule/Drop.cs | 3 +- StandardActionsModule/Examine.cs | 4 +- StandardActionsModule/Go.cs | 3 +- StandardActionsModule/Inventory.cs | 2 +- StandardActionsModule/Lock.cs | 6 +- StandardActionsModule/Look.cs | 26 +- StandardActionsModule/LookUnderOrBehind.cs | 8 +- StandardActionsModule/MiscRules.cs | 2 +- StandardActionsModule/Open.cs | 8 +- StandardActionsModule/Pull.cs | 8 +- StandardActionsModule/PushBetweenRooms.cs | 3 +- StandardActionsModule/Put.cs | 5 +- StandardActionsModule/Say.cs | 4 +- .../StandardActionsModule.csproj | 6 + StandardActionsModule/Take.cs | 3 +- StandardActionsModule/Unlock.cs | 2 +- StandardActionsModule/packages.config | 4 + WpfConsole/WpfConsole.csproj | 5 + WpfConsole/packages.config | 4 + 146 files changed, 370 insertions(+), 2265 deletions(-) create mode 100644 AdminModule/packages.config create mode 100644 Akkoteaque/packages.config create mode 100644 AliasModule/packages.config create mode 100644 ChatModule/packages.config create mode 100644 ClothingModule/packages.config create mode 100644 ConversationModule/packages.config delete mode 100644 Core/Core/Rules/MudObjectAddRuleGen.cs delete mode 100644 Core/Core/Rules/MudObjectAddRuleGen.tt delete mode 100644 Core/Core/Rules/Rule.cs delete mode 100644 Core/Core/Rules/RuleBook.cs delete mode 100644 Core/Core/Rules/RuleBuilderGen.cs delete mode 100644 Core/Core/Rules/RuleBuilderGen.tt delete mode 100644 Core/Core/Rules/RuleDelegatesGen.cs delete mode 100644 Core/Core/Rules/RuleDelegatesGen.tt delete mode 100644 Core/Core/Rules/RuleEngineAddRuleGen.cs delete mode 100644 Core/Core/Rules/RuleEngineAddRuleGen.tt delete mode 100644 Core/Core/Rules/RuleGen.t4 delete mode 100644 Core/Core/Rules/RuleResult.cs delete mode 100644 Core/Core/Rules/RuleSet.cs delete mode 100644 Core/Core/Rules/RuleSetAddRuleGen.cs delete mode 100644 Core/Core/Rules/RuleSetAddRuleGen.tt delete mode 100644 Core/Core/Rules/RuleSource.cs create mode 100644 IntroductionModule/packages.config create mode 100644 Play/packages.config create mode 100644 QuestModule/packages.config create mode 100644 RMUD/packages.config create mode 100644 SillyModule/packages.config create mode 100644 SinglePlayer/packages.config create mode 100644 SinglePlayerMinimumGame/packages.config create mode 100644 Space/packages.config create mode 100644 StandardActionsModule/packages.config create mode 100644 WpfConsole/packages.config diff --git a/AdminModule/AdminModule.csproj b/AdminModule/AdminModule.csproj index f836ce4..e244ee4 100644 --- a/AdminModule/AdminModule.csproj +++ b/AdminModule/AdminModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -63,6 +66,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/AdminModule/Dump.cs b/AdminModule/Dump.cs index 827c743..0b6cf56 100644 --- a/AdminModule/Dump.cs +++ b/AdminModule/Dump.cs @@ -25,7 +25,7 @@ public override void Create(CommandParser Parser) MudObject.SendMessage(actor, "Could not display source: " + source.Item2); else MudObject.SendMessage(actor, "Source of " + target + "\n" + source.Item2); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AdminModule/Force.cs b/AdminModule/Force.cs index c59ac23..fc765b3 100644 --- a/AdminModule/Force.cs +++ b/AdminModule/Force.cs @@ -28,11 +28,11 @@ public override void Create(CommandParser Parser) if (target == null) { MudObject.SendMessage(actor, "I can't find whomever it is you want to submit to your foolish whims."); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; } match.Upsert("OBJECT", target); } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "Convert path to object rule.") .ProceduralRule((match, actor) => { @@ -42,7 +42,7 @@ public override void Create(CommandParser Parser) 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; + return SharpRuleEngine.PerformResult.Stop; } var command = match["RAW-COMMAND"].ToString(); @@ -61,7 +61,7 @@ public override void Create(CommandParser Parser) else MudObject.SendMessage(actor, "The command did not match."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AdminModule/Inspect.cs b/AdminModule/Inspect.cs index a66b234..7ae6b56 100644 --- a/AdminModule/Inspect.cs +++ b/AdminModule/Inspect.cs @@ -23,7 +23,7 @@ public override void Create(CommandParser Parser) { if (!match.ContainsKey("OBJECT")) match.Upsert("OBJECT", actor.Location); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "Convert locale option to standard form rule.") .ProceduralRule((match, actor) => { @@ -51,7 +51,7 @@ public override void Create(CommandParser Parser) MudObject.SendMessage(actor, s); } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "List all the damn things rule."); } diff --git a/AdminModule/Instance.cs b/AdminModule/Instance.cs index d44febf..6765c69 100644 --- a/AdminModule/Instance.cs +++ b/AdminModule/Instance.cs @@ -27,7 +27,7 @@ public override void Create(CommandParser Parser) MudObject.Move(newObject, actor); MudObject.SendMessage(actor, "Instanced " + path + "."); } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AdminModule/Move.cs b/AdminModule/Move.cs index b061ce9..60d745a 100644 --- a/AdminModule/Move.cs +++ b/AdminModule/Move.cs @@ -34,7 +34,7 @@ public override void Create(CommandParser Parser) } else MudObject.SendMessage(actor, "I could not find the destination."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AdminModule/ReadLog.cs b/AdminModule/ReadLog.cs index 70a29bc..8cfe840 100644 --- a/AdminModule/ReadLog.cs +++ b/AdminModule/ReadLog.cs @@ -28,7 +28,7 @@ public override void Create(CommandParser Parser) } else MudObject.SendMessage(actor, "I could not find that log file."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AdminModule/Reload.cs b/AdminModule/Reload.cs index 2bc625e..adeb9e0 100644 --- a/AdminModule/Reload.cs +++ b/AdminModule/Reload.cs @@ -23,7 +23,7 @@ public override void Create(CommandParser Parser) 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; + return SharpRuleEngine.PerformResult.Continue; }); Parser.AddCommand( @@ -39,7 +39,7 @@ public override void Create(CommandParser Parser) if (Core.Database.ResetObject(target) == null) MudObject.SendMessage(actor, "Failed to reset " + target); else MudObject.SendMessage(actor, "Reset " + target); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/AdminModule/Rules.cs b/AdminModule/Rules.cs index 0075f53..46dea77 100644 --- a/AdminModule/Rules.cs +++ b/AdminModule/Rules.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace AdminModule { diff --git a/AdminModule/Save.cs b/AdminModule/Save.cs index 76cc8ea..18fc273 100644 --- a/AdminModule/Save.cs +++ b/AdminModule/Save.cs @@ -26,7 +26,7 @@ public override void Create(CommandParser Parser) //TODO MudObject.SendGlobalMessage("The database has been saved."); MudObject.SendMessage(actor, String.Format("I saved {0} persistent objects.", saved)); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AdminModule/Scope.cs b/AdminModule/Scope.cs index 5dc48a6..c44c580 100644 --- a/AdminModule/Scope.cs +++ b/AdminModule/Scope.cs @@ -19,7 +19,7 @@ public override void Create(CommandParser Parser) { foreach (var thing in MudObject.EnumerateVisibleTree(MudObject.FindLocale(actor))) MudObject.SendMessage(actor, thing.Short + " - " + thing.GetType().Name); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "List all the damn things in scope rule."); } } diff --git a/AdminModule/Sonar.cs b/AdminModule/Sonar.cs index da421b8..1099290 100644 --- a/AdminModule/Sonar.cs +++ b/AdminModule/Sonar.cs @@ -56,7 +56,7 @@ public override void Create(CommandParser Parser) builder.Append((char)entry.Key + " - " + entry.Value + "\r\n"); MudObject.SendMessage(actor, builder.ToString()); - return RMUD.PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "Implement sonar device rule."); } diff --git a/AdminModule/Stats.cs b/AdminModule/Stats.cs index a70b53d..83d40ff 100644 --- a/AdminModule/Stats.cs +++ b/AdminModule/Stats.cs @@ -25,7 +25,7 @@ public override void Create(CommandParser Parser) } else Core.GlobalRules.ConsiderPerformRule("stats", actor, match["TYPE"].ToString().ToUpper()); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/AdminModule/packages.config b/AdminModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/AdminModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Akkoteaque/Akkoteaque.csproj b/Akkoteaque/Akkoteaque.csproj index 17a1edd..ec558ca 100644 --- a/Akkoteaque/Akkoteaque.csproj +++ b/Akkoteaque/Akkoteaque.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -78,6 +81,9 @@ StandardActionsModule + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/Akkoteaque/Areas/Prologue/Car.cs b/Akkoteaque/Areas/Prologue/Car.cs index 1fc1282..e0be796 100644 --- a/Akkoteaque/Areas/Prologue/Car.cs +++ b/Akkoteaque/Areas/Prologue/Car.cs @@ -31,7 +31,7 @@ public override void Initialize() Check("can go?").Do((actor, link) => { SendMessage(actor, "The car is moving. Rather fast, actually. You're going to stay put."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); } diff --git a/Akkoteaque/Areas/Prologue/Henrico.cs b/Akkoteaque/Areas/Prologue/Henrico.cs index b88cde7..529b286 100644 --- a/Akkoteaque/Areas/Prologue/Henrico.cs +++ b/Akkoteaque/Areas/Prologue/Henrico.cs @@ -13,7 +13,7 @@ public override void Initialize() Perform("describe in locale").Do((actor, item) => { SendMessage(actor, "Mr. Henrico is driving the car."); - return RMUD.PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); Long = "Mr. Henrico is a balding, middle aged man with a moustache and a squinty face. The combination thereof makes it seem like he's captured a squirrel under his nose and is squeezing it as tightly as possible to avoid it escaping. He's been rather kind to you, or at least, kinder than you expected after the series of social workers you had to deal with before him."; @@ -27,7 +27,7 @@ public override void Initialize() .Do((actor, npc, topic) => { conversationCounter += 1; - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); #region Primary Conversation diff --git a/Akkoteaque/Areas/Prologue/Player.cs b/Akkoteaque/Areas/Prologue/Player.cs index 367771f..35a394e 100644 --- a/Akkoteaque/Areas/Prologue/Player.cs +++ b/Akkoteaque/Areas/Prologue/Player.cs @@ -14,7 +14,7 @@ public override void Initialize() this.PerformDescribe().Do((viewer, player) => { SendMessage(viewer, ChooseAtRandom("You're kind of frumpy, aren't you?", "You suspect that you are perfectly, entirely, and very dissapointingly, average.", "You aren't like other girls. This is probably not a bad thing.")); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); Move(GetObject("Areas.Prologue.Watch"), this, RelativeLocations.Held); diff --git a/Akkoteaque/Areas/Prologue/Watch.cs b/Akkoteaque/Areas/Prologue/Watch.cs index f5420b0..b85e206 100644 --- a/Akkoteaque/Areas/Prologue/Watch.cs +++ b/Akkoteaque/Areas/Prologue/Watch.cs @@ -13,13 +13,13 @@ public override void Initialize() this.CheckCanDrop().Do((actor, item) => { MudObject.SendMessage(actor, "That is all you've got left of your father. You don't want to lose it."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); this.PerformDescribe().First.Do((viewer, thing) => { thing.SetProperty("has-been-viewed", true); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/Akkoteaque/Game.cs b/Akkoteaque/Game.cs index 47878d1..8c8b733 100644 --- a/Akkoteaque/Game.cs +++ b/Akkoteaque/Game.cs @@ -30,7 +30,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Perform("list topics") .When(player => SuppressTopics) - .Do(player => RMUD.PerformResult.Stop); + .Do(player => SharpRuleEngine.PerformResult.Stop); GlobalRules.Perform("singleplayer game started") .First @@ -49,8 +49,8 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) //Player.SetProperty("interlocutor", RMUD.MudObject.GetObject("Areas.Prologue.Henrico")); //RMUD.Core.EnqueuActorCommand(Player, "topics"); //BlockingConversation = true; - - return RMUD.PerformResult.Stop; + + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/Akkoteaque/HeavyThings.cs b/Akkoteaque/HeavyThings.cs index 614a73e..d513c45 100644 --- a/Akkoteaque/HeavyThings.cs +++ b/Akkoteaque/HeavyThings.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace Akko { diff --git a/Akkoteaque/packages.config b/Akkoteaque/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/Akkoteaque/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/AliasModule/Alias.cs b/AliasModule/Alias.cs index c2ef3f1..3d61933 100644 --- a/AliasModule/Alias.cs +++ b/AliasModule/Alias.cs @@ -23,7 +23,7 @@ public override void Create(CommandParser Parser) var aliases = actor.GetProperty>("aliases"); aliases.Add(match["NAME"].ToString().ToUpper(), match["RAW-COMMAND"].ToString()); MudObject.SendMessage(actor, "Alias added."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); Parser.AddCommand( @@ -43,7 +43,7 @@ public override void Create(CommandParser Parser) var commands = match["ALIAS"].ToString().Split(';'); foreach (var command in commands) Core.EnqueuActorCommand(actor, command); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/AliasModule/AliasModule.csproj b/AliasModule/AliasModule.csproj index d8a744e..a2fc526 100644 --- a/AliasModule/AliasModule.csproj +++ b/AliasModule/AliasModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -50,6 +53,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/AliasModule/packages.config b/AliasModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/AliasModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ChatModule/ChatChannelRules.cs b/ChatModule/ChatChannelRules.cs index 6344c96..3060878 100644 --- a/ChatModule/ChatChannelRules.cs +++ b/ChatModule/ChatChannelRules.cs @@ -13,7 +13,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.DeclareCheckRuleBook("can access channel?", "[Client, Channel] : Can the client access the chat channel?", "actor", "channel"); GlobalRules.Check("can access channel?") - .Do((client, channel) => CheckResult.Allow) + .Do((client, channel) => SharpRuleEngine.CheckResult.Allow) .Name("Default allow channel access rule."); GlobalRules.Perform("player joined") @@ -21,7 +21,7 @@ public static void AtStartup(RuleEngine GlobalRules) { foreach (var c in ChatChannel.ChatChannels.Where(c => c.Short == "OOC")) c.Subscribers.Add(player); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Subscribe new players to OOC rule."); @@ -29,7 +29,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do(player => { ChatChannel.RemoveFromAllChannels(player); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Unsubscribe players from all channels when they leave rule."); @@ -43,7 +43,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor, channel) => { MudObject.SendMessage(actor, "You must have a rank of 100 or greater to access this channel."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); ChatChannel.ChatChannels.Add(senate); } diff --git a/ChatModule/ChatModule.csproj b/ChatModule/ChatModule.csproj index f708f6a..1c3cf6c 100644 --- a/ChatModule/ChatModule.csproj +++ b/ChatModule/ChatModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -53,6 +56,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/ChatModule/Commands.cs b/ChatModule/Commands.cs index bac05fb..b3d7eba 100644 --- a/ChatModule/Commands.cs +++ b/ChatModule/Commands.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace ChatModule { diff --git a/ChatModule/packages.config b/ChatModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/ChatModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ClothingModule/ClothingModule.csproj b/ClothingModule/ClothingModule.csproj index c0252be..e318dec 100644 --- a/ClothingModule/ClothingModule.csproj +++ b/ClothingModule/ClothingModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -55,6 +58,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/ClothingModule/Remove.cs b/ClothingModule/Remove.cs index d6c5567..67a9e39 100644 --- a/ClothingModule/Remove.cs +++ b/ClothingModule/Remove.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace ClothingModule { @@ -23,7 +24,7 @@ public override void Create(CommandParser Parser) .AfterActing(); } - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.DeclareCheckRuleBook("can remove?", "[Actor, Item] : Can the actor remove the item?", "actor", "item"); GlobalRules.DeclarePerformRuleBook("removed", "[Actor, Item] : Handle the actor removing the item.", "actor", "item"); diff --git a/ClothingModule/Rules.cs b/ClothingModule/Rules.cs index f08cb5c..bf4e3eb 100644 --- a/ClothingModule/Rules.cs +++ b/ClothingModule/Rules.cs @@ -4,12 +4,13 @@ using System.Text; using System.Threading.Tasks; using RMUD; +using SharpRuleEngine; namespace ClothingModule { public class ClothingRules { - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform("inventory") .Do(a => diff --git a/ClothingModule/Wear.cs b/ClothingModule/Wear.cs index f4be0f5..a2a46f1 100644 --- a/ClothingModule/Wear.cs +++ b/ClothingModule/Wear.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace ClothingModule { @@ -23,7 +24,7 @@ public override void Create(CommandParser Parser) .AfterActing(); } - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.DeclareCheckRuleBook("can wear?", "[Actor, Item] : Can the actor wear the item?", "actor", "item"); GlobalRules.DeclarePerformRuleBook("worn", "[Actor, Item] : Handle the actor wearing the item.", "actor", "item"); diff --git a/ClothingModule/packages.config b/ClothingModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/ClothingModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ConversationModule/Commands.cs b/ConversationModule/Commands.cs index ee3800d..a4401ef 100644 --- a/ConversationModule/Commands.cs +++ b/ConversationModule/Commands.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace ConversationModule { diff --git a/ConversationModule/ConversationModule.csproj b/ConversationModule/ConversationModule.csproj index 9074e14..905304e 100644 --- a/ConversationModule/ConversationModule.csproj +++ b/ConversationModule/ConversationModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -54,6 +57,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/ConversationModule/NPCExtension.cs b/ConversationModule/NPCExtension.cs index 0fd4418..fcc007c 100644 --- a/ConversationModule/NPCExtension.cs +++ b/ConversationModule/NPCExtension.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace ConversationModule { diff --git a/ConversationModule/Rules.cs b/ConversationModule/Rules.cs index 6b10799..92090aa 100644 --- a/ConversationModule/Rules.cs +++ b/ConversationModule/Rules.cs @@ -3,12 +3,13 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace ConversationModule { public class ConversationRules { - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { Core.StandardMessage("convo topic prompt", "Suggested topics: "); Core.StandardMessage("convo cant converse", "You can't converse with that."); diff --git a/ConversationModule/TopicObjectSource.cs b/ConversationModule/TopicObjectSource.cs index 23f5d6e..e3103ca 100644 --- a/ConversationModule/TopicObjectSource.cs +++ b/ConversationModule/TopicObjectSource.cs @@ -26,7 +26,7 @@ public List GetObjects(PossibleMatch State, MatchContext Context) if (source != null) if (source.HasProperty>("conversation-topics")) - return new List(source.GetProperty>("conversation-topics").Where(t => Core.GlobalRules.ConsiderCheckRuleSilently("topic available?", Context.ExecutingActor, source, t) == CheckResult.Allow)); + return new List(source.GetProperty>("conversation-topics").Where(t => Core.GlobalRules.ConsiderCheckRuleSilently("topic available?", Context.ExecutingActor, source, t) == SharpRuleEngine.CheckResult.Allow)); return new List(); } diff --git a/ConversationModule/packages.config b/ConversationModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/ConversationModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Core/Core.csproj b/Core/Core.csproj index d269054..e474531 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -39,6 +39,10 @@ False ..\packages\Octokit.0.6.2\lib\net45\Octokit.dll + + False + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -58,31 +62,6 @@ - - - - True - True - RuleBuilderGen.tt - - - True - True - RuleDelegatesGen.tt - - - True - True - RuleEngineAddRuleGen.tt - - - - - True - True - RuleSetAddRuleGen.tt - - @@ -123,11 +102,6 @@ - - MudObjectAddRuleGen.tt - True - True - @@ -179,27 +153,6 @@ - - TextTemplatingFileGenerator - MudObjectAddRuleGen.cs - - - TextTemplatingFileGenerator - RuleBuilderGen.cs - - - TextTemplatingFileGenerator - RuleDelegatesGen.cs - - - TextTemplatingFileGenerator - RuleEngineAddRuleGen.cs - - - - TextTemplatingFileGenerator - RuleSetAddRuleGen.cs - diff --git a/Core/Core/ExecuteCommand.cs b/Core/Core/ExecuteCommand.cs index 3780557..467ba59 100644 --- a/Core/Core/ExecuteCommand.cs +++ b/Core/Core/ExecuteCommand.cs @@ -4,6 +4,7 @@ using System.Text; using System.Threading; using System.Reflection; +using SharpRuleEngine; namespace RMUD { diff --git a/Core/Core/Heartbeat.cs b/Core/Core/Heartbeat.cs index 89f24a7..e244074 100644 --- a/Core/Core/Heartbeat.cs +++ b/Core/Core/Heartbeat.cs @@ -16,7 +16,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Perform("heartbeat").Do(() => { MudObject.TimeOfDay += Core.SettingsObject.ClockAdvanceRate; - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }).Name("Advance clock on heartbeat rule"); } } diff --git a/Core/Core/IsVisibleTo.cs b/Core/Core/IsVisibleTo.cs index 41ffd6e..914e41a 100644 --- a/Core/Core/IsVisibleTo.cs +++ b/Core/Core/IsVisibleTo.cs @@ -5,6 +5,7 @@ using System.CodeDom.Compiler; using System.Diagnostics; using System.Reflection; +using SharpRuleEngine; namespace RMUD { diff --git a/Core/Core/MarkForUpdate.cs b/Core/Core/MarkForUpdate.cs index 656262b..62092d0 100644 --- a/Core/Core/MarkForUpdate.cs +++ b/Core/Core/MarkForUpdate.cs @@ -18,7 +18,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { Core.UpdateMarkedObjects(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Update marked objects at end of turn rule."); @@ -27,7 +27,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { Core.SendPendingMessages(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Send pending messages at end of turn rule."); } diff --git a/Core/Core/Meta/DumpMessages.cs b/Core/Core/Meta/DumpMessages.cs index fae0c59..f6e93f0 100644 --- a/Core/Core/Meta/DumpMessages.cs +++ b/Core/Core/Meta/DumpMessages.cs @@ -18,7 +18,7 @@ public override void Create(CommandParser Parser) Core.DumpMessagesForCustomization(builder); System.IO.File.WriteAllText("messages.txt", builder.ToString()); MudObject.SendMessage(actor, "Messages dumped to messages.txt."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/Core/Core/Meta/Man.cs b/Core/Core/Meta/Man.cs index e369c68..3b8cc7d 100644 --- a/Core/Core/Meta/Man.cs +++ b/Core/Core/Meta/Man.cs @@ -49,7 +49,7 @@ public override void Create(CommandParser Parser) MudObject.SendMessage(actor, "@no help topic"); } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/Core/Core/Meta/Version.cs b/Core/Core/Meta/Version.cs index 8f613a8..f24e769 100644 --- a/Core/Core/Meta/Version.cs +++ b/Core/Core/Meta/Version.cs @@ -32,7 +32,7 @@ public override void Create(CommandParser Parser) foreach (var module in Core.IntegratedModules) MudObject.SendMessage(actor, module.Info.Description); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/Core/Core/MudCore.cs b/Core/Core/MudCore.cs index 611a675..4dee84f 100644 --- a/Core/Core/MudCore.cs +++ b/Core/Core/MudCore.cs @@ -20,7 +20,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { MudObject.Move(actor, MudObject.GetObject(Core.SettingsObject.NewPlayerStartRoom)); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Move to start room rule."); } diff --git a/Core/Core/Parser/CommandEntry.cs b/Core/Core/Parser/CommandEntry.cs index 12bafcb..80dab83 100644 --- a/Core/Core/Parser/CommandEntry.cs +++ b/Core/Core/Parser/CommandEntry.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using SharpRuleEngine; namespace RMUD { diff --git a/Core/Core/Parser/CommandParser.cs b/Core/Core/Parser/CommandParser.cs index 1233af5..3bca7c6 100644 --- a/Core/Core/Parser/CommandParser.cs +++ b/Core/Core/Parser/CommandParser.cs @@ -84,7 +84,7 @@ public MatchedCommand ParseCommand(PendingCommand Command) new CommandEntry().ProceduralRule((match, actor) => { MudObject.SendMessage(actor, ma.Message); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }), // We need a fake match just so it can be passed to the procedural rule. new PossibleMatch[] { new PossibleMatch(null) }); diff --git a/Core/Core/Parser/ParserCommandHandler.cs b/Core/Core/Parser/ParserCommandHandler.cs index d4d14f6..ee7f72b 100644 --- a/Core/Core/Parser/ParserCommandHandler.cs +++ b/Core/Core/Parser/ParserCommandHandler.cs @@ -52,7 +52,7 @@ public void HandleCommand(PendingCommand Command) { // Display all the rules invoked while executing this command. Command.RawCommand = Command.RawCommand.Substring("@RULES ".Length); - Core.GlobalRules.LogRules(Command.Actor); + Core.GlobalRules.LogRules(s => MudObject.SendMessage(Command.Actor, s)); } else { diff --git a/Core/Core/Rules/MudObjectAddRuleGen.cs b/Core/Core/Rules/MudObjectAddRuleGen.cs deleted file mode 100644 index 51a4f33..0000000 --- a/Core/Core/Rules/MudObjectAddRuleGen.cs +++ /dev/null @@ -1,96 +0,0 @@ -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - public partial class MudObject - { - public RuleBuilder Perform(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Value(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Check(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Perform(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Value(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Check(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - public RuleBuilder Perform(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Value(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Check(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - public RuleBuilder Perform(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Value(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Check(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - public RuleBuilder Perform(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Value(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Check(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - } -} diff --git a/Core/Core/Rules/MudObjectAddRuleGen.tt b/Core/Core/Rules/MudObjectAddRuleGen.tt deleted file mode 100644 index fa364fd..0000000 --- a/Core/Core/Rules/MudObjectAddRuleGen.tt +++ /dev/null @@ -1,54 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".cs" #> -<#@ include file="RuleGen.t4" #> -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - public partial class MudObject - { - public RuleBuilder Perform(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Value(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - - public RuleBuilder Check(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule(Name).Associate(this); - } - -<#for (var i = 1; i < 5; ++i){#> - public RuleBuilder<<#Args(i);#>, PerformResult> Perform<<#Args(i);#>>(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule<<#Args(i);#>, PerformResult>(Name).Associate(this); - } - - public RuleBuilder<<#Args(i);#>, RT> Value<<#Args(i);#>, RT>(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule<<#Args(i);#>, RT>(Name).Associate(this); - } - - public RuleBuilder<<#Args(i);#>, CheckResult> Check<<#Args(i);#>>(String Name) - { - if (Rules == null) Rules = new RuleSet(GlobalRules); - return Rules.AddRule<<#Args(i);#>, CheckResult>(Name).Associate(this); - } -<#}#> - } -} diff --git a/Core/Core/Rules/Rule.cs b/Core/Core/Rules/Rule.cs deleted file mode 100644 index 48172c2..0000000 --- a/Core/Core/Rules/Rule.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace RMUD -{ - public enum RulePriority - { - First = 0, - Neutral = 1, - Last = 2, - Delete = 3 - } - - public class Rule - { - public String DescriptiveName; - public String ID; - public RuleDelegateWrapper WhenClause; - public RulePriority Priority = RulePriority.Neutral; - - public bool CheckWhenClause(Object[] Arguments) - { - if (WhenClause == null) return true; - return WhenClause.Invoke(Arguments); - } - - public virtual Type[] GetArgumentTypes() - { - throw new NotImplementedException(); - } - } - - public class Rule : Rule - { - public RuleDelegateWrapper BodyClause; - - public bool AreArgumentsCompatible(Object[] Arguments) - { - if (BodyClause == null) return false; - return BodyClause.AreArgumentsCompatible(Arguments); - } - - public override Type[] GetArgumentTypes() - { - if (BodyClause == null) return new Type[]{}; - var genericTypes = BodyClause.GetType().GetGenericArguments(); - return genericTypes.Take(genericTypes.Length - 1).ToArray(); - } - } -} diff --git a/Core/Core/Rules/RuleBook.cs b/Core/Core/Rules/RuleBook.cs deleted file mode 100644 index dfeea7c..0000000 --- a/Core/Core/Rules/RuleBook.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace RMUD -{ - public class RuleComparer : System.Collections.Generic.IComparer - { - public int Compare(Rule x, Rule y) - { - var typesA = x.GetArgumentTypes(); - var typesB = y.GetArgumentTypes(); - if (typesA.Length != typesB.Length) return 0; - - for (int i = 0; i < typesA.Length; ++i) - { - if (typesA[i] != typesB[i]) - { - if (typesA[i].IsSubclassOf(typesB[i])) return -1; - else if (typesB[i].IsSubclassOf(typesA[i])) return 1; - } - } - - return 0; - } - } - - public class RuleBook - { - public String Name; - public String Description; - public int ArgumentCount = 0; - public Type ResultType; - public RuleSet Owner; - public List Rules = new List(); - private bool NeedsSort = false; - - public RuleBook(RuleSet Owner) - { - this.Owner = Owner; - } - - public virtual void CheckRule(Rule Rule) { throw new NotImplementedException(); } - - public void AddRule(Rule Rule) - { - CheckRule(Rule); - Rules.Add(Rule); - NeedsSort = true; - } - - protected void SortRules() - { - if (!NeedsSort) return; - - var newList = new List[]{ new List(), new List(), new List() }; - foreach (var rule in Rules) - if (rule.Priority != RulePriority.Delete) - newList[(int)rule.Priority].Add(rule); - - Rules.Clear(); - foreach (var sublist in newList) - { - sublist.Sort(new RuleComparer()); - Rules.AddRange(sublist); - } - - NeedsSort = false; - } - - public void DeleteRule(string ID) - { - foreach (var rule in Rules) - if (rule.ID == ID) rule.Priority = RulePriority.Delete; - NeedsSort = true; - } - - protected void LogRule(Rule Rule) - { - if (Owner.GlobalRules.LogTo != null && Owner.GlobalRules.LogTo.ConnectedClient != null) - { - Owner.GlobalRules.LogTo.ConnectedClient.Send(Name + "<" + String.Join(", ", Rule.GetArgumentTypes().Select(t => t.Name)) + "> -> " + ResultType.Name + " : " + (String.IsNullOrEmpty(Rule.DescriptiveName) ? "NONAME" : Rule.DescriptiveName) + "\r\n"); - } - } - } - - public class CheckRuleBook : RuleBook - { - public CheckRuleBook(RuleSet Owner) - : base(Owner) - { - ResultType = typeof(CheckResult); - } - - public CheckResult Consider(params Object[] Args) - { - SortRules(); - - foreach (var _rule in Rules) - { - var rule = _rule as Rule; - if (rule.AreArgumentsCompatible(Args) && rule.CheckWhenClause(Args)) - { - LogRule(rule); - var r = rule.BodyClause == null ? CheckResult.Continue : rule.BodyClause.Invoke(Args); - if (r != CheckResult.Continue) return r; - } - } - return CheckResult.Continue; - } - - public override void CheckRule(Rule Rule) - { - if (!(Rule is Rule)) throw new InvalidOperationException(); - } - } - - public class PerformRuleBook : RuleBook - { - public PerformRuleBook(RuleSet Owner) : base(Owner) - { - ResultType = typeof(PerformResult); - } - - public PerformResult Consider(params Object[] Args) - { - SortRules(); - - foreach (var _rule in Rules) - { - var rule = _rule as Rule; - if (rule.AreArgumentsCompatible(Args) && rule.CheckWhenClause(Args)) - { - LogRule(rule); - var r = rule.BodyClause == null ? PerformResult.Continue : rule.BodyClause.Invoke(Args); - if (r != PerformResult.Continue) return r; - } - } - return PerformResult.Continue; - } - - public override void CheckRule(Rule Rule) - { - if (!(Rule is Rule)) throw new InvalidOperationException(); - } - } - - public class ValueRuleBook : RuleBook - { - public ValueRuleBook(RuleSet Owner) - : base(Owner) - { - ResultType = typeof(RT); - } - - public RT Consider(out bool ValueReturned, params Object[] Args) - { - SortRules(); - - ValueReturned = false; - foreach (var _rule in Rules) - { - var rule = _rule as Rule; - if (rule.AreArgumentsCompatible(Args) && rule.CheckWhenClause(Args)) - { - LogRule(rule); - ValueReturned = true; - return rule.BodyClause.Invoke(Args); - } - } - return default(RT); - } - - public override void CheckRule(Rule Rule) - { - if (!(Rule is Rule)) throw new InvalidOperationException(); - } - } -} diff --git a/Core/Core/Rules/RuleBuilderGen.cs b/Core/Core/Rules/RuleBuilderGen.cs deleted file mode 100644 index ffef5fd..0000000 --- a/Core/Core/Rules/RuleBuilderGen.cs +++ /dev/null @@ -1,516 +0,0 @@ -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - - public class RuleBuilder - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder When(Func Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func(() => { - return oldClause.Invoke(null) && Clause(); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Do(Func Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - private class WrappedBoolean { public bool Value = false; } - - public RuleBuilder FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When(() => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - - public class RuleBuilder - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder When(Func Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func((P0) => { - return oldClause.Invoke(new Object[]{P0}) && Clause(P0); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Do(Func Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - /// - /// Add a when clause that passes only if the associated object is one of the arguments to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly() - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - return this.When((P0) => - { - if (System.Object.ReferenceEquals(P0, AssociatedObject)) return true; - - return false; - }); - } - - /// - /// Add a when clause that passes only if the associated object is the Nth argument to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly(int N) - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - if (N < 0 || N >= 1) throw new IndexOutOfRangeException(); - return this.When((P0) => - { - var pArray = new Object[]{P0}; - return System.Object.ReferenceEquals(AssociatedObject, pArray[N]); - }); - } - - private class WrappedBoolean { public bool Value = false; } - - /// - /// Add a when clause that passes the first time it is queried, and fails all subsequent times. - /// - public RuleBuilder FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When((P0) => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - - public class RuleBuilder - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder When(Func Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func((P0, P1) => { - return oldClause.Invoke(new Object[]{P0, P1}) && Clause(P0, P1); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Do(Func Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - /// - /// Add a when clause that passes only if the associated object is one of the arguments to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly() - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - return this.When((P0, P1) => - { - if (System.Object.ReferenceEquals(P0, AssociatedObject)) return true; - if (System.Object.ReferenceEquals(P1, AssociatedObject)) return true; - - return false; - }); - } - - /// - /// Add a when clause that passes only if the associated object is the Nth argument to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly(int N) - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - if (N < 0 || N >= 2) throw new IndexOutOfRangeException(); - return this.When((P0, P1) => - { - var pArray = new Object[]{P0, P1}; - return System.Object.ReferenceEquals(AssociatedObject, pArray[N]); - }); - } - - private class WrappedBoolean { public bool Value = false; } - - /// - /// Add a when clause that passes the first time it is queried, and fails all subsequent times. - /// - public RuleBuilder FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When((P0, P1) => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - - public class RuleBuilder - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder When(Func Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func((P0, P1, P2) => { - return oldClause.Invoke(new Object[]{P0, P1, P2}) && Clause(P0, P1, P2); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Do(Func Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - /// - /// Add a when clause that passes only if the associated object is one of the arguments to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly() - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - return this.When((P0, P1, P2) => - { - if (System.Object.ReferenceEquals(P0, AssociatedObject)) return true; - if (System.Object.ReferenceEquals(P1, AssociatedObject)) return true; - if (System.Object.ReferenceEquals(P2, AssociatedObject)) return true; - - return false; - }); - } - - /// - /// Add a when clause that passes only if the associated object is the Nth argument to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly(int N) - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - if (N < 0 || N >= 3) throw new IndexOutOfRangeException(); - return this.When((P0, P1, P2) => - { - var pArray = new Object[]{P0, P1, P2}; - return System.Object.ReferenceEquals(AssociatedObject, pArray[N]); - }); - } - - private class WrappedBoolean { public bool Value = false; } - - /// - /// Add a when clause that passes the first time it is queried, and fails all subsequent times. - /// - public RuleBuilder FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When((P0, P1, P2) => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - - public class RuleBuilder - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder When(Func Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func((P0, P1, P2, P3) => { - return oldClause.Invoke(new Object[]{P0, P1, P2, P3}) && Clause(P0, P1, P2, P3); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Do(Func Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - /// - /// Add a when clause that passes only if the associated object is one of the arguments to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly() - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - return this.When((P0, P1, P2, P3) => - { - if (System.Object.ReferenceEquals(P0, AssociatedObject)) return true; - if (System.Object.ReferenceEquals(P1, AssociatedObject)) return true; - if (System.Object.ReferenceEquals(P2, AssociatedObject)) return true; - if (System.Object.ReferenceEquals(P3, AssociatedObject)) return true; - - return false; - }); - } - - /// - /// Add a when clause that passes only if the associated object is the Nth argument to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder ThisOnly(int N) - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - if (N < 0 || N >= 4) throw new IndexOutOfRangeException(); - return this.When((P0, P1, P2, P3) => - { - var pArray = new Object[]{P0, P1, P2, P3}; - return System.Object.ReferenceEquals(AssociatedObject, pArray[N]); - }); - } - - private class WrappedBoolean { public bool Value = false; } - - /// - /// Add a when clause that passes the first time it is queried, and fails all subsequent times. - /// - public RuleBuilder FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When((P0, P1, P2, P3) => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - -} diff --git a/Core/Core/Rules/RuleBuilderGen.tt b/Core/Core/Rules/RuleBuilderGen.tt deleted file mode 100644 index c7531a0..0000000 --- a/Core/Core/Rules/RuleBuilderGen.tt +++ /dev/null @@ -1,199 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".cs" #> -<#@ include file="RuleGen.t4" #> -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - - public class RuleBuilder - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder When(Func Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func(() => { - return oldClause.Invoke(null) && Clause(); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Do(Func Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - private class WrappedBoolean { public bool Value = false; } - - public RuleBuilder FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When(() => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - -<#for (var i = 1; i < 5; ++i){#> - public class RuleBuilder<<# Args(i); #>, TR> - { - public Rule Rule; - - //The associated object is set by the MudObject rule factory functions and used to - // implement useful shortcuts on the rule builder types. - public MudObject AssociatedObject = null; - - public RuleBuilder<<#Args(i);#>, TR> When(Func<<#Args(i);#>, bool> Clause) - { - if (Rule.WhenClause != null) - { - var oldClause = Rule.WhenClause; - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper( - new Func<<#Args(i);#>, bool>((<#Parms(i);#>) => { - return oldClause.Invoke(new Object[]{<#Parms(i);#>}) && Clause(<#Parms(i);#>); - }) - ); - } - else - Rule.WhenClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder<<#Args(i);#>, TR> Do(Func<<#Args(i);#>, TR> Clause) - { - Rule.BodyClause = RuleDelegateWrapper.MakeWrapper(Clause); - return this; - } - - public RuleBuilder<<#Args(i);#>, TR> Name(String Name) - { - Rule.DescriptiveName = Name; - return this; - } - - public RuleBuilder<<#Args(i);#>, TR> ID(String ID) - { - Rule.ID = ID; - return this; - } - - public RuleBuilder<<#Args(i);#>, TR> First { - get { - Rule.Priority = RulePriority.First; - return this; - }} - - public RuleBuilder<<#Args(i);#>, TR> Last { - get { - Rule.Priority = RulePriority.Last; - return this; - }} - - public RuleBuilder<<#Args(i);#>, TR> Associate(MudObject Object) - { - this.AssociatedObject = Object; - return this; - } - - /// - /// Add a when clause that passes only if the associated object is one of the arguments to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder<<#Args(i);#>, TR> ThisOnly() - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - return this.When((<#Parms(i);#>) => - { - <#for (var x = 0; x < i; ++x){#>if (System.Object.ReferenceEquals(P<#=x#>, AssociatedObject)) return true; - <#}#> - - return false; - }); - } - - /// - /// Add a when clause that passes only if the associated object is the Nth argument to the rule. - /// This is only valid if the rule was generated by a mud object factory function. - /// - public RuleBuilder<<#Args(i);#>, TR> ThisOnly(int N) - { - if (AssociatedObject == null) throw new InvalidOperationException("ThisOnly is only valid for rules created by a MudObject factory function."); - if (N < 0 || N >= <#=i#>) throw new IndexOutOfRangeException(); - return this.When((<#Parms(i);#>) => - { - var pArray = new Object[]{<#Parms(i);#>}; - return System.Object.ReferenceEquals(AssociatedObject, pArray[N]); - }); - } - - private class WrappedBoolean { public bool Value = false; } - - /// - /// Add a when clause that passes the first time it is queried, and fails all subsequent times. - /// - public RuleBuilder<<#Args(i);#>, TR> FirstTimeOnly - {get{ - var beenCalled = new WrappedBoolean(); - return this.When((<#Parms(i);#>) => - { - if (beenCalled.Value) return false; - beenCalled.Value = true; - return true; - }); - }} - } - -<#}#> -} diff --git a/Core/Core/Rules/RuleDelegatesGen.cs b/Core/Core/Rules/RuleDelegatesGen.cs deleted file mode 100644 index 9c2fabb..0000000 --- a/Core/Core/Rules/RuleDelegatesGen.cs +++ /dev/null @@ -1,144 +0,0 @@ -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - public class RuleDelegateWrapper - { - public virtual TR Invoke(Object[] Arguments) - { - throw new NotImplementedException(); - } - - public static RuleDelegateWrapper MakeWrapper(Func Delegate) - { - return new RuleDelegateWrapperImpl { Delegate = Delegate }; - } - - public virtual bool AreArgumentsCompatible(Object[] Arguments) - { - throw new NotImplementedException(); - } - - - public static RuleDelegateWrapper MakeWrapper(Func Delegate) - { - return new RuleDelegateWrapperImpl { Delegate = Delegate }; - } - - public static RuleDelegateWrapper MakeWrapper(Func Delegate) - { - return new RuleDelegateWrapperImpl { Delegate = Delegate }; - } - - public static RuleDelegateWrapper MakeWrapper(Func Delegate) - { - return new RuleDelegateWrapperImpl { Delegate = Delegate }; - } - - public static RuleDelegateWrapper MakeWrapper(Func Delegate) - { - return new RuleDelegateWrapperImpl { Delegate = Delegate }; - } - } - - public class RuleDelegateWrapperImpl : RuleDelegateWrapper - { - internal Func Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - return Arguments.Length == 0; - } - } - - - public class RuleDelegateWrapperImpl : RuleDelegateWrapper - { - internal Func Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - if (Arguments.Length != 1) return false; - - if (Arguments[0] != null && !typeof(T0).IsAssignableFrom(Arguments[0].GetType())) return false; - - return true; - } - } - - public class RuleDelegateWrapperImpl : RuleDelegateWrapper - { - internal Func Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - if (Arguments.Length != 2) return false; - - if (Arguments[0] != null && !typeof(T0).IsAssignableFrom(Arguments[0].GetType())) return false; - if (Arguments[1] != null && !typeof(T1).IsAssignableFrom(Arguments[1].GetType())) return false; - - return true; - } - } - - public class RuleDelegateWrapperImpl : RuleDelegateWrapper - { - internal Func Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - if (Arguments.Length != 3) return false; - - if (Arguments[0] != null && !typeof(T0).IsAssignableFrom(Arguments[0].GetType())) return false; - if (Arguments[1] != null && !typeof(T1).IsAssignableFrom(Arguments[1].GetType())) return false; - if (Arguments[2] != null && !typeof(T2).IsAssignableFrom(Arguments[2].GetType())) return false; - - return true; - } - } - - public class RuleDelegateWrapperImpl : RuleDelegateWrapper - { - internal Func Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - if (Arguments.Length != 4) return false; - - if (Arguments[0] != null && !typeof(T0).IsAssignableFrom(Arguments[0].GetType())) return false; - if (Arguments[1] != null && !typeof(T1).IsAssignableFrom(Arguments[1].GetType())) return false; - if (Arguments[2] != null && !typeof(T2).IsAssignableFrom(Arguments[2].GetType())) return false; - if (Arguments[3] != null && !typeof(T3).IsAssignableFrom(Arguments[3].GetType())) return false; - - return true; - } - } - -} diff --git a/Core/Core/Rules/RuleDelegatesGen.tt b/Core/Core/Rules/RuleDelegatesGen.tt deleted file mode 100644 index 105dbb3..0000000 --- a/Core/Core/Rules/RuleDelegatesGen.tt +++ /dev/null @@ -1,79 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".cs" #> -<#@ include file="RuleGen.t4" #> -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - public class RuleDelegateWrapper - { - public virtual TR Invoke(Object[] Arguments) - { - throw new NotImplementedException(); - } - - public static RuleDelegateWrapper MakeWrapper(Func Delegate) - { - return new RuleDelegateWrapperImpl { Delegate = Delegate }; - } - - public virtual bool AreArgumentsCompatible(Object[] Arguments) - { - throw new NotImplementedException(); - } - -<#for (var i = 1; i < 5; ++i){#> - - public static RuleDelegateWrapper MakeWrapper<<#Args(i);#>>(Func<<#Args(i);#>, TR> Delegate) - { - return new RuleDelegateWrapperImpl<<#Args(i);#>, TR> { Delegate = Delegate }; - } -<#}#> - } - - public class RuleDelegateWrapperImpl : RuleDelegateWrapper - { - internal Func Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - return Arguments.Length == 0; - } - } - -<#for (var i = 1; i < 5; ++i){#> - - public class RuleDelegateWrapperImpl<<#Args(i);#>, TR> : RuleDelegateWrapper - { - internal Func<<#Args(i);#>, TR> Delegate; - - public override TR Invoke(Object[] Arguments) - { - return (TR)Delegate.DynamicInvoke(Arguments); - } - - public override bool AreArgumentsCompatible(Object[] Arguments) - { - if (Arguments.Length != <#=i#>) return false; - -<#for (var x = 0; x < i; ++x){#> - if (Arguments[<#=x#>] != null && !typeof(T<#=x#>).IsAssignableFrom(Arguments[<#=x#>].GetType())) return false; -<#}#> - - return true; - } - } -<#}#> - -} diff --git a/Core/Core/Rules/RuleEngine.cs b/Core/Core/Rules/RuleEngine.cs index 3b62d90..4ffdf8b 100644 --- a/Core/Core/Rules/RuleEngine.cs +++ b/Core/Core/Rules/RuleEngine.cs @@ -2,165 +2,21 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using SharpRuleEngine; namespace RMUD { - public enum NewRuleQueueingMode + public partial class RuleEngine : SharpRuleEngine.RuleEngine { - QueueNewRules, - ImmediatelyAddNewRules - } - - public partial class RuleEngine - { - internal Actor LogTo = null; - internal void LogRules(Actor To) { LogTo = To; } - - public RuleSet Rules; - internal NewRuleQueueingMode QueueingMode = NewRuleQueueingMode.ImmediatelyAddNewRules; - internal List NewRuleQueue = new List(); - - public RuleEngine(NewRuleQueueingMode QueueingMode) - { - this.QueueingMode = QueueingMode; - Rules = new RuleSet(this); - } - - /// - /// After all initial rule setup has completed, call this to empty the new rule queue and process all - /// the added rules. - /// - public void FinalizeNewRules() - { - if (QueueingMode != NewRuleQueueingMode.QueueNewRules) return; - QueueingMode = NewRuleQueueingMode.ImmediatelyAddNewRules; - foreach (var act in NewRuleQueue) act(); - NewRuleQueue.Clear(); - } - - private void CreateNewRule(Action act) - { - if (QueueingMode == NewRuleQueueingMode.QueueNewRules) NewRuleQueue.Add(act); - else act(); - } - - /// - /// Do the types supplied match the types defined on an already declared global rulebook? - /// Derived types 'match' their ancestor for the purposes of this function. - /// - /// - /// - /// - /// - internal bool TypesAgreeWithDeclaredGlobalRuleBook(String Name, Type ResultType, int ArgumentCount) - { - if (Rules == null) return true; // This means that rules were declared before global rulebooks were discovered. Queueing prevents this from happening. - - var book = Rules.FindRuleBook(Name); - if (book == null) return true; - - if (book.ResultType != ResultType) return false; - if (book.ArgumentCount != ArgumentCount) return false; + public RuleEngine() + : base(NewRuleQueueingMode.QueueNewRules) + { } - return true; - } - - public void DeleteRule(String RuleBookName, String RuleID) - { - Rules.DeleteRule(RuleBookName, RuleID); - } - - /// - /// Given an array of Object, enumerate any and all of them that happen to be RuleSources. If they are a - /// RuleSource, include their LinkedRuleSet, if any, in the enumeration as well. - /// - /// - /// - private IEnumerable EnumerateRuleSets(Object[] Arguments) + private IEnumerable EnumerateMatchRules(PossibleMatch Match) { - if (Arguments != null) - { - // Avoid enumerating rules from the same object twice. - var objectsExamined = new List(); - - foreach (var arg in Arguments) - if (arg is RuleSource - && !objectsExamined.Contains(arg as RuleSource) - && (arg as RuleSource).Rules != null) - { - objectsExamined.Add(arg as RuleSource); - yield return (arg as RuleSource).Rules; - } - - // Loop again, so that all linked rules are enumerated after all parent rules. - foreach (var arg in Arguments) - if (arg is RuleSource) - if ((arg as RuleSource).LinkedRuleSource != null) - if (!objectsExamined.Contains((arg as RuleSource).LinkedRuleSource)) - if ((arg as RuleSource).LinkedRuleSource.Rules != null) - { - objectsExamined.Add((arg as RuleSource).LinkedRuleSource); - yield return (arg as RuleSource).LinkedRuleSource.Rules; - } - } - } - - /// - /// Consider a perform rulebook. First, check every argument for matching rules. Finally, check global rules. - /// A perform rulebook continues execution until a rule returns PerformResult.Stop. - /// - /// - /// - /// - public PerformResult ConsiderPerformRule(String Name, params Object[] Arguments) - { - //A single null value passed to a params argument is interpretted by C# as a null Object[] - //reference, not as an array with a single element that is null. - if (Arguments == null) Arguments = new Object[] { null }; - - foreach (var ruleset in EnumerateRuleSets(Arguments)) - if (ruleset.ConsiderPerformRule(Name, Arguments) == PerformResult.Stop) - return PerformResult.Stop; - - if (Rules == null) throw new InvalidOperationException(); - return Rules.ConsiderPerformRule(Name, Arguments); - } - - /// - /// Consider a check rulebook. First check each argument for applicable rules, then check for global rules. - /// A check rulebook continues until a rule returns CheckResult.Allow or CheckResult.Disallow. - /// - /// - /// - /// - public CheckResult ConsiderCheckRule(String Name, params Object[] Arguments) - { - if (Arguments == null) Arguments = new Object[] { null }; - - foreach (var ruleset in EnumerateRuleSets(Arguments)) - { - var r = ruleset.ConsiderCheckRule(Name, Arguments); - if (r != CheckResult.Continue) return r; - } - - if (Rules == null) throw new InvalidOperationException(); - return Rules.ConsiderCheckRule(Name, Arguments); - } - - public RT ConsiderValueRule(String Name, params Object[] Arguments) - { - if (Arguments == null) Arguments = new Object[] { null }; - - bool valueReturned = false; - - foreach (var ruleset in EnumerateRuleSets(Arguments)) - { - var r = ruleset.ConsiderValueRule(Name, out valueReturned, Arguments); - if (valueReturned) return r; - } - - if (Rules == null) throw new InvalidOperationException(); - return Rules.ConsiderValueRule(Name, out valueReturned, Arguments); + foreach (var arg in Match) + if (arg.Value is MudObject && (arg.Value as MudObject).Rules != null) + yield return (arg.Value as MudObject).Rules; } /// @@ -173,13 +29,7 @@ public RT ConsiderValueRule(String Name, params Object[] Arguments) /// public PerformResult ConsiderMatchBasedPerformRule(String Name, PossibleMatch Match, Actor Actor) { - foreach (var arg in Match) - if (arg.Value is MudObject && (arg.Value as MudObject).Rules != null) - if ((arg.Value as MudObject).Rules.ConsiderPerformRule(Name, Match, Actor) == PerformResult.Stop) - return PerformResult.Stop; - - if (Rules == null) throw new InvalidOperationException(); - return Rules.ConsiderPerformRule(Name, Match, Actor); + return ConsiderPerformRule(Name, EnumerateMatchRules(Match), Match, Actor); } /// @@ -206,38 +56,4 @@ public CheckResult ConsiderCheckRuleSilently(String Name, params Object[] Argume } } - public partial class MudObject - { - public static RuleEngine GlobalRules { get { return Core.GlobalRules; } } - - public static PerformResult ConsiderPerformRule(String Name, params Object[] Arguments) - { - return GlobalRules.ConsiderPerformRule(Name, Arguments); - } - - public static CheckResult ConsiderCheckRule(String Name, params Object[] Arguments) - { - return GlobalRules.ConsiderCheckRule(Name, Arguments); - } - - public static RT ConsiderValueRule(String Name, params Object[] Arguments) - { - return GlobalRules.ConsiderValueRule(Name, Arguments); - } - - public static CheckResult ConsiderCheckRuleSilently(String Name, params Object[] Arguments) - { - return GlobalRules.ConsiderCheckRuleSilently(Name, Arguments); - } - - public void DeleteRule(String RuleBookName, String RuleID) - { - if (Rules != null) Rules.DeleteRule(RuleBookName, RuleID); - } - - public void DeleteAllRules(String RuleID) - { - if (Rules != null) Rules.DeleteAll(RuleID); - } - } } diff --git a/Core/Core/Rules/RuleEngineAddRuleGen.cs b/Core/Core/Rules/RuleEngineAddRuleGen.cs deleted file mode 100644 index 3410412..0000000 --- a/Core/Core/Rules/RuleEngineAddRuleGen.cs +++ /dev/null @@ -1,191 +0,0 @@ -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; -using System.Collections.Generic; - -namespace RMUD -{ - public partial class RuleEngine - { - public void DeclarePerformRuleBook(String Name, String Description) - { - Rules.FindOrCreateRuleBook(Name, 0).Description = Description; - } - - public void DeclareValueRuleBook(String Name, String Description) - { - Rules.FindOrCreateRuleBook(Name, 0).Description = Description; - } - - public void DeclareCheckRuleBook(String Name, String Description) - { - Rules.FindOrCreateRuleBook(Name, 0).Description = Description; - } - - public RuleBuilder Perform(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 0).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Value(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 0).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Check(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 0).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public void DeclarePerformRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 1).Description = Description; - } - - public void DeclareValueRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 1).Description = Description; - } - - public void DeclareCheckRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 1).Description = Description; - } - - public RuleBuilder Perform(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 1).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Value(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 1).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Check(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 1).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public void DeclarePerformRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 2).Description = Description; - } - - public void DeclareValueRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 2).Description = Description; - } - - public void DeclareCheckRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 2).Description = Description; - } - - public RuleBuilder Perform(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 2).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Value(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 2).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Check(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 2).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public void DeclarePerformRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 3).Description = Description; - } - - public void DeclareValueRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 3).Description = Description; - } - - public void DeclareCheckRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 3).Description = Description; - } - - public RuleBuilder Perform(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 3).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Value(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 3).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Check(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 3).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public void DeclarePerformRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 4).Description = Description; - } - - public void DeclareValueRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 4).Description = Description; - } - - public void DeclareCheckRuleBook(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, 4).Description = Description; - } - - public RuleBuilder Perform(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 4).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Value(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 4).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Check(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 4).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - } -} diff --git a/Core/Core/Rules/RuleEngineAddRuleGen.tt b/Core/Core/Rules/RuleEngineAddRuleGen.tt deleted file mode 100644 index db9cec9..0000000 --- a/Core/Core/Rules/RuleEngineAddRuleGen.tt +++ /dev/null @@ -1,92 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".cs" #> -<#@ include file="RuleGen.t4" #> -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; -using System.Collections.Generic; - -namespace RMUD -{ - public partial class RuleEngine - { - public void DeclarePerformRuleBook(String Name, String Description) - { - Rules.FindOrCreateRuleBook(Name, 0).Description = Description; - } - - public void DeclareValueRuleBook(String Name, String Description) - { - Rules.FindOrCreateRuleBook(Name, 0).Description = Description; - } - - public void DeclareCheckRuleBook(String Name, String Description) - { - Rules.FindOrCreateRuleBook(Name, 0).Description = Description; - } - - public RuleBuilder Perform(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 0).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Value(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 0).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder Check(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, 0).AddRule(rule); }); - return new RuleBuilder { Rule = rule }; - } - -<#for (var i = 1; i < ac; ++i){#> - public void DeclarePerformRuleBook<<#Args(i);#>>(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, <#=i#>).Description = Description; - } - - public void DeclareValueRuleBook<<#Args(i);#>, RT>(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, <#=i#>).Description = Description; - } - - public void DeclareCheckRuleBook<<#Args(i);#>>(String Name, String Description, params String[] ArgumentNames) - { - Rules.FindOrCreateRuleBook(Name, <#=i#>).Description = Description; - } - - public RuleBuilder<<#Args(i);#>, PerformResult> Perform<<#Args(i);#>>(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, <#=i#>).AddRule(rule); }); - return new RuleBuilder<<#Args(i);#>, PerformResult> { Rule = rule }; - } - - public RuleBuilder<<#Args(i);#>, RT> Value<<#Args(i);#>, RT>(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, <#=i#>).AddRule(rule); }); - return new RuleBuilder<<#Args(i);#>, RT> { Rule = rule }; - } - - public RuleBuilder<<#Args(i);#>, CheckResult> Check<<#Args(i);#>>(String Name) - { - var rule = new Rule(); - CreateNewRule(() => { Rules.FindOrCreateRuleBook(Name, <#=i#>).AddRule(rule); }); - return new RuleBuilder<<#Args(i);#>, CheckResult> { Rule = rule }; - } - -<#}#> - } -} diff --git a/Core/Core/Rules/RuleGen.t4 b/Core/Core/Rules/RuleGen.t4 deleted file mode 100644 index 4cbdbd3..0000000 --- a/Core/Core/Rules/RuleGen.t4 +++ /dev/null @@ -1,24 +0,0 @@ -<#+ - int ac = 5; - - void Args(int x) - { - for (int i = 0; i < x; ++i) - { -#>T<#=i #><#= (i == (x-1) ? "" : ", ")#><#+ - } - } - - void Parms(int x) - { - for (int i = 0; i < x; ++i) - { -#>P<#=i #><#= (i == (x-1) ? "" : ", ")#><#+ - } - } - - void TypeOfs(int i) - { - for (var x = 0; x < i; ++x){#>typeof(T<#=x#>)<#= x == i - 1 ? "" : ", "#><#+} - } -#> \ No newline at end of file diff --git a/Core/Core/Rules/RuleResult.cs b/Core/Core/Rules/RuleResult.cs deleted file mode 100644 index 79fa70b..0000000 --- a/Core/Core/Rules/RuleResult.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace RMUD -{ - public enum PerformResult - { - Continue = 1, - Stop = 2, - } - - public enum CheckResult - { - Allow = 0, - Continue = 1, - Disallow = 2 - } -} diff --git a/Core/Core/Rules/RuleSet.cs b/Core/Core/Rules/RuleSet.cs deleted file mode 100644 index e77594e..0000000 --- a/Core/Core/Rules/RuleSet.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace RMUD -{ - public partial class RuleSet - { - public RuleEngine GlobalRules; - public List RuleBooks = new List(); - - public RuleSet(RuleEngine GlobalRules) - { - this.GlobalRules = GlobalRules; - } - - public RuleBook FindRuleBook(String Name) - { - return RuleBooks.FirstOrDefault(r => r.Name == Name); - } - - internal RuleBook FindOrCreateRuleBook(String Name, int ArgCount) - { - var r = FindRuleBook(Name); - - if (r == null) - { - if (typeof(RT) == typeof(PerformResult)) - r = new PerformRuleBook(this) { Name = Name, ArgumentCount = ArgCount }; - else if (typeof(RT) == typeof(CheckResult)) - r = new CheckRuleBook(this) { Name = Name, ArgumentCount = ArgCount }; - else - r = new ValueRuleBook(this) { Name = Name, ArgumentCount = ArgCount }; - - RuleBooks.Add(r); - } - - return r; - } - - public void DeleteRule(String RuleBookName, String RuleID) - { - var book = FindRuleBook(RuleBookName); - if (book != null) book.DeleteRule(RuleID); - } - - public void DeleteAll(String RuleID) - { - foreach (var book in RuleBooks) - book.DeleteRule(RuleID); - } - - public RT ConsiderValueRule(String Name, out bool ValueReturned, params Object[] Args) - { - ValueReturned = false; - var book = FindRuleBook(Name); - if (book != null) - { - //if (!book.CheckArgumentTypes(typeof(RT), Args.Select(o => o.GetType()).ToArray())) - // throw new InvalidOperationException(); - var valueBook = book as ValueRuleBook; - if (valueBook == null) throw new InvalidOperationException(); - return valueBook.Consider(out ValueReturned, Args); - } - return default(RT); - } - - public PerformResult ConsiderPerformRule(String Name, params Object[] Args) - { - var book = FindRuleBook(Name); - if (book != null) - { - //if (!book.CheckArgumentTypes(typeof(PerformResult), Args.Select(o => o.GetType()).ToArray())) - // throw new InvalidOperationException(); - var actionBook = book as PerformRuleBook; - if (actionBook == null) throw new InvalidOperationException(); - return actionBook.Consider(Args); - } - return PerformResult.Continue; - } - - public CheckResult ConsiderCheckRule(String Name, params Object[] Args) - { - var book = FindRuleBook(Name); - if (book != null) - { - //if (!book.CheckArgumentTypes(typeof(CheckResult), Args.Select(o => o.GetType()).ToArray())) - // throw new InvalidOperationException(); - var actionBook = book as CheckRuleBook; - if (actionBook == null) throw new InvalidOperationException(); - return actionBook.Consider(Args); - } - return CheckResult.Continue; - } - } -} diff --git a/Core/Core/Rules/RuleSetAddRuleGen.cs b/Core/Core/Rules/RuleSetAddRuleGen.cs deleted file mode 100644 index b003b37..0000000 --- a/Core/Core/Rules/RuleSetAddRuleGen.cs +++ /dev/null @@ -1,45 +0,0 @@ -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - public partial class RuleSet - { - public RuleBuilder AddRule(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, 0).AddRule(rule); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder AddRule(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, 1).AddRule(rule); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder AddRule(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, 2).AddRule(rule); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder AddRule(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, 3).AddRule(rule); - return new RuleBuilder { Rule = rule }; - } - - public RuleBuilder AddRule(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, 4).AddRule(rule); - return new RuleBuilder { Rule = rule }; - } - - } -} diff --git a/Core/Core/Rules/RuleSetAddRuleGen.tt b/Core/Core/Rules/RuleSetAddRuleGen.tt deleted file mode 100644 index 2203fc7..0000000 --- a/Core/Core/Rules/RuleSetAddRuleGen.tt +++ /dev/null @@ -1,33 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ output extension=".cs" #> -<#@ include file="RuleGen.t4" #> -//This is generated code. Do not modify this file; modify the template that produces it. - -using System; - -namespace RMUD -{ - public partial class RuleSet - { - public RuleBuilder AddRule(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, 0).AddRule(rule); - return new RuleBuilder { Rule = rule }; - } - -<#for (var i = 1; i < 5; ++i){#> - public RuleBuilder<<#Args(i);#>, RT> AddRule<<#Args(i);#>, RT>(String Name) - { - var rule = new Rule(); - FindOrCreateRuleBook(Name, <#=i#>).AddRule(rule); - return new RuleBuilder<<#Args(i);#>, RT> { Rule = rule }; - } - -<#}#> - } -} diff --git a/Core/Core/Rules/RuleSource.cs b/Core/Core/Rules/RuleSource.cs deleted file mode 100644 index 111cf1c..0000000 --- a/Core/Core/Rules/RuleSource.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RMUD -{ - /// - /// Anything that might supply rules for consideration must implement RuleSource. Any object implementing RuleSource - /// passed as an argument to a consider or value rule function will have it's rules considered when executing the - /// rulebook. - /// - public interface RuleSource - { - RuleSet Rules { get; } - - /// - /// Another rule source that this rule source is related to. After all rule source arguments to a rulebook have - /// been examined for applicable rules, their linked rule sources will be examined. This mechanism is what - /// allows rooms to define rules that affect actions that only involve their contents. MudObject's are implemented - /// such that their location is their linked rule source. - /// - RuleSource LinkedRuleSource { get; } - } -} diff --git a/Core/Core/Startup.cs b/Core/Core/Startup.cs index aadace2..c8dc5e5 100644 --- a/Core/Core/Startup.cs +++ b/Core/Core/Startup.cs @@ -57,7 +57,7 @@ public static bool Start(StartupFlags Flags, WorldDataService Database, params M try { // Setup the rule engine and some basic rules. - GlobalRules = new RuleEngine(NewRuleQueueingMode.QueueNewRules); + GlobalRules = new RuleEngine(); GlobalRules.DeclarePerformRuleBook("at startup", "[] : Considered when the engine is started."); GlobalRules.DeclarePerformRuleBook("singleplayer game started", "Considered when a single player game is begun"); diff --git a/Core/WorldModel/BasicDoor.cs b/Core/WorldModel/BasicDoor.cs index 1ca79f2..5061f44 100644 --- a/Core/WorldModel/BasicDoor.cs +++ b/Core/WorldModel/BasicDoor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using SharpRuleEngine; namespace RMUD { diff --git a/Core/WorldModel/LockedDoor.cs b/Core/WorldModel/LockedDoor.cs index 9db3a22..fc0b927 100644 --- a/Core/WorldModel/LockedDoor.cs +++ b/Core/WorldModel/LockedDoor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using SharpRuleEngine; namespace RMUD { diff --git a/Core/WorldModel/MudObject.cs b/Core/WorldModel/MudObject.cs index e0db294..5a30101 100644 --- a/Core/WorldModel/MudObject.cs +++ b/Core/WorldModel/MudObject.cs @@ -5,8 +5,10 @@ namespace RMUD { - public partial class MudObject : RuleSource + public partial class MudObject : SharpRuleEngine.RuleObject { + public override SharpRuleEngine.RuleEngine GlobalRules { get { return Core.GlobalRules; } } + public ObjectState State = ObjectState.Unitialized; public String Path { get; set; } public String Instance { get; set; } @@ -30,11 +32,10 @@ public override string ToString() public String Long = "undescribed object"; public String Article = "a"; public NounList Nouns { get; set; } + public MudObject Location { get; set; } + public override SharpRuleEngine.RuleObject LinkedRuleSource { get { return Location; } } - public RuleSet Rules { get; private set; } - public RuleSource LinkedRuleSource { get { return Location; } } - #region Properties // Every MudObject has a set of generic properties. Modules use these properties to store values on MudObjects. @@ -89,7 +90,6 @@ public MudObject() Nouns = new NounList(); State = ObjectState.Alive; IsPersistent = false; - Rules = null; } public MudObject(String Short, String Long) @@ -106,7 +106,6 @@ public MudObject(String Short, String Long) State = ObjectState.Alive; IsPersistent = false; - Rules = null; } public void SimpleName(String Short, params String[] Synonyms) diff --git a/Core/WorldModel/RoomLightingRules.cs b/Core/WorldModel/RoomLightingRules.cs index 4cc21b1..f10b76e 100644 --- a/Core/WorldModel/RoomLightingRules.cs +++ b/Core/WorldModel/RoomLightingRules.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using SharpRuleEngine; namespace RMUD { diff --git a/Core/packages.config b/Core/packages.config index 41ffbd3..9b329db 100644 --- a/Core/packages.config +++ b/Core/packages.config @@ -2,4 +2,5 @@ + \ No newline at end of file diff --git a/IntroductionModule/Implementation.cs b/IntroductionModule/Implementation.cs index 7af2099..14efbdc 100644 --- a/IntroductionModule/Implementation.cs +++ b/IntroductionModule/Implementation.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace IntroductionModule { @@ -39,7 +40,7 @@ public override void Create(CommandParser Parser) .AfterActing(); } - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.DeclareCheckRuleBook("can introduce?", "[Actor A, Actor B] : Can A introduce B?", "actor", "itroductee"); diff --git a/IntroductionModule/IntroductionModule.csproj b/IntroductionModule/IntroductionModule.csproj index 1568ebf..a9965a4 100644 --- a/IntroductionModule/IntroductionModule.csproj +++ b/IntroductionModule/IntroductionModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -50,6 +53,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/IntroductionModule/packages.config b/IntroductionModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/IntroductionModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/NetworkModule/Afk.cs b/NetworkModule/Afk.cs index 02b38a9..11ddad6 100644 --- a/NetworkModule/Afk.cs +++ b/NetworkModule/Afk.cs @@ -21,7 +21,7 @@ public override void Create(CommandParser Parser) if (actor.ConnectedClient != null) actor.ConnectedClient.Player.GetProperty("account").AFKMessage = match["MESSAGE"].ToString(); MudObject.SendMessage(actor, "AFK message set."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/Ban.cs b/NetworkModule/Ban.cs index 5d70bb4..6d2550c 100644 --- a/NetworkModule/Ban.cs +++ b/NetworkModule/Ban.cs @@ -18,7 +18,7 @@ public override void Create(CommandParser Parser) MudObject.SendMessage(actor, "~~~ ALL SET BANS ~~~"); foreach (var proscription in Clients.ProscriptionList.Proscriptions) MudObject.SendMessage(actor, proscription.Glob + " : " + proscription.Reason); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); Parser.AddCommand( @@ -32,7 +32,7 @@ public override void Create(CommandParser Parser) { Clients.ProscriptionList.Ban(match["GLOB"].ToString(), match["REASON"].ToString()); Clients.SendGlobalMessage("^ has banned " + match["GLOB"].ToString(), actor); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); Parser.AddCommand( @@ -45,7 +45,7 @@ public override void Create(CommandParser Parser) { Clients.ProscriptionList.RemoveBan(match["GLOB"].ToString()); Clients.SendGlobalMessage("^ removes the ban on " + match["GLOB"].ToString(), actor); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/Kick.cs b/NetworkModule/Kick.cs index aed9af7..a4af36d 100644 --- a/NetworkModule/Kick.cs +++ b/NetworkModule/Kick.cs @@ -39,7 +39,7 @@ public override void Create(CommandParser Parser) } } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/NetworkModule/Login.cs b/NetworkModule/Login.cs index 00a2cee..891aade 100644 --- a/NetworkModule/Login.cs +++ b/NetworkModule/Login.cs @@ -18,18 +18,18 @@ public override void Create(CommandParser Parser) .Manual("If you got this far, you know how to login.") .ProceduralRule((match, actor) => { - if (actor.ConnectedClient == null) return PerformResult.Stop; + if (actor.ConnectedClient == null) return SharpRuleEngine.PerformResult.Stop; if (actor.ConnectedClient is NetworkClient && (actor.ConnectedClient as NetworkClient).IsLoggedOn) { MudObject.SendMessage(actor, "You are already logged in."); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; } var userName = match["USERNAME"].ToString(); actor.CommandHandler = new PasswordCommandHandler(actor, Authenticate, userName); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/NetworkModule/NetworkModule.csproj b/NetworkModule/NetworkModule.csproj index d6a3a81..ba64ffa 100644 --- a/NetworkModule/NetworkModule.csproj +++ b/NetworkModule/NetworkModule.csproj @@ -34,6 +34,9 @@ ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + diff --git a/NetworkModule/Quit.cs b/NetworkModule/Quit.cs index 6ca421f..c01cb25 100644 --- a/NetworkModule/Quit.cs +++ b/NetworkModule/Quit.cs @@ -22,7 +22,7 @@ public override void Create(CommandParser Parser) (match["CLIENT"] as Client).Send("Goodbye...\r\n"); (match["CLIENT"] as Client).Disconnect(); } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/Register.cs b/NetworkModule/Register.cs index 35a4938..8f03451 100644 --- a/NetworkModule/Register.cs +++ b/NetworkModule/Register.cs @@ -21,13 +21,13 @@ public override void Create(CommandParser Parser) if (actor.ConnectedClient is NetworkClient && (actor.ConnectedClient as NetworkClient).IsLoggedOn) { MudObject.SendMessage(actor, "You are already logged in."); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; } var userName = match["USERNAME"].ToString(); actor.CommandHandler = new PasswordCommandHandler(actor, Authenticate, userName); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/NetworkModule/Stats.cs b/NetworkModule/Stats.cs index 5e6ffb0..b39a81b 100644 --- a/NetworkModule/Stats.cs +++ b/NetworkModule/Stats.cs @@ -15,7 +15,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Do((actor) => { MudObject.SendMessage(actor, "CLIENTS"); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("stats") @@ -28,7 +28,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) MudObject.SendMessage(actor, (client as NetworkClient).ConnectionDescription + (client.Player == null ? "" : (" - " + client.Player.Short))); else MudObject.SendMessage(actor, "local " + (client.Player == null ? "" : (" - " + client.Player.Short))); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/NetworkModule/Whisper.cs b/NetworkModule/Whisper.cs index 39abd09..13adf09 100644 --- a/NetworkModule/Whisper.cs +++ b/NetworkModule/Whisper.cs @@ -25,9 +25,9 @@ public override void Create(CommandParser Parser) if (System.Object.ReferenceEquals(actor, match["PLAYER"])) { MudObject.SendMessage(actor, "Talking to yourself?"); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .ProceduralRule((match, actor) => { @@ -36,7 +36,7 @@ public override void Create(CommandParser Parser) MudObject.SendMessage(actor, "[privately to ] ^ : \"" + match["SPEECH"].ToString() + "\"", player, actor); if (player.ConnectedClient is NetworkClient && (player.ConnectedClient as NetworkClient).IsAfk) MudObject.SendMessage(actor, "^ is afk : " + player.ConnectedClient.Player.GetProperty("account").AFKMessage, player); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/Who.cs b/NetworkModule/Who.cs index 8dbffff..b5d3ec6 100644 --- a/NetworkModule/Who.cs +++ b/NetworkModule/Who.cs @@ -24,7 +24,7 @@ public override void Create(CommandParser Parser) + (client.IsAfk ? (" afk: " + client.Player.GetProperty("account").AFKMessage) : "") + (client.Player.Location != null ? (" -- " + client.Player.Location.Path) : ""), client.Player); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/packages.config b/NetworkModule/packages.config index af70bc8..1536cfc 100644 --- a/NetworkModule/packages.config +++ b/NetworkModule/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/Play/PlayAkko.csproj b/Play/PlayAkko.csproj index 13d4800..ccbcb21 100644 --- a/Play/PlayAkko.csproj +++ b/Play/PlayAkko.csproj @@ -33,6 +33,10 @@ 4 + + False + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -47,6 +51,7 @@ + diff --git a/Play/packages.config b/Play/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/Play/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/QuestModule/AcceptQuest.cs b/QuestModule/AcceptQuest.cs index 806ff50..34d44a5 100644 --- a/QuestModule/AcceptQuest.cs +++ b/QuestModule/AcceptQuest.cs @@ -21,12 +21,12 @@ public override void Create(CommandParser Parser) if (actor.GetProperty("offered-quest") == null) { MudObject.SendMessage(actor, "Nobody has offered you a quest."); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; } else { match.Upsert("QUEST", actor.GetProperty("offered-quest")); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; } }, "the must have been offered a quest, and bookeeping rule.") .ProceduralRule((match, actor) => @@ -36,9 +36,9 @@ public override void Create(CommandParser Parser) { MudObject.SendMessage(actor, "The quest is no longer available."); player.RemoveProperty("offered-quest"); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "the quest must be available rule.") .ProceduralRule((match, actor) => { @@ -47,7 +47,7 @@ public override void Create(CommandParser Parser) actor.SetProperty("active-quest", actor.GetProperty("offered-quest")); actor.RemoveProperty("offered-quest"); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "the any active quest must be abandoned rule.") .Perform("quest accepted", "ACTOR", "QUEST"); } diff --git a/QuestModule/QuestModule.csproj b/QuestModule/QuestModule.csproj index 8a4e384..76fb360 100644 --- a/QuestModule/QuestModule.csproj +++ b/QuestModule/QuestModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -52,6 +55,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/QuestModule/QuestRules.cs b/QuestModule/QuestRules.cs index f0b765c..e33b5a6 100644 --- a/QuestModule/QuestRules.cs +++ b/QuestModule/QuestRules.cs @@ -10,7 +10,7 @@ namespace QuestModule { public class QuestProceduralRules { - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform("after acting") .Do((match, actor) => @@ -31,7 +31,7 @@ public static void AtStartup(RuleEngine GlobalRules) } } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Check quest status after acting rule."); diff --git a/QuestModule/packages.config b/QuestModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/QuestModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RMUD/RMUD.csproj b/RMUD/RMUD.csproj index 5b0b556..06dc15e 100644 --- a/RMUD/RMUD.csproj +++ b/RMUD/RMUD.csproj @@ -39,6 +39,9 @@ false + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -115,6 +118,7 @@ + diff --git a/RMUD/packages.config b/RMUD/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/RMUD/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SillyModule/Silly.cs b/SillyModule/Silly.cs index 524365d..a938c71 100644 --- a/SillyModule/Silly.cs +++ b/SillyModule/Silly.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using RMUD; +using SharpRuleEngine; namespace SillyModule { @@ -40,7 +41,7 @@ Leave the real one far behind .Perform("dance", "ACTOR"); } - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.DeclareValueRuleBook("silly?", "[Thing -> bool] : Determine if an object is silly.", "item"); GlobalRules.Value("silly?").Last.Do((thing) => false).Name("Things are serious by default rule."); diff --git a/SillyModule/SillyModule.csproj b/SillyModule/SillyModule.csproj index 52bfce5..4298921 100644 --- a/SillyModule/SillyModule.csproj +++ b/SillyModule/SillyModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -50,6 +53,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/SillyModule/packages.config b/SillyModule/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/SillyModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/Rod.cs b/SinglePlayer/Akkoteaque/Fishing/Rod.cs index bf5145d..a7d1571 100644 --- a/SinglePlayer/Akkoteaque/Fishing/Rod.cs +++ b/SinglePlayer/Akkoteaque/Fishing/Rod.cs @@ -19,7 +19,7 @@ public override void Initialize() .Do((actor, item, container, location) => { SendMessage(actor, "There doesn't seem to be any way to attach that to the fishing rod."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); Perform("put") @@ -38,7 +38,7 @@ public override void Initialize() else SendMessage(actor, "You put on the hook.", item); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/SinglePlayer/Akkoteaque/Jetty.cs b/SinglePlayer/Akkoteaque/Jetty.cs index 3a6b466..3c3627f 100644 --- a/SinglePlayer/Akkoteaque/Jetty.cs +++ b/SinglePlayer/Akkoteaque/Jetty.cs @@ -12,7 +12,7 @@ public override void Initialize() .When((actor, item) => item == this ) .Do((actor, item) => { SendMessage(actor, "A narrow stone jetty juts into the sea, the waves slapping against it's sides and occasionally flowing up and over the stone. Smalls pools form where the water has worn away at the rock, and the cracks between the stones are full of creeping green life."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/SinglePlayer/Akkoteaque/Settings.cs b/SinglePlayer/Akkoteaque/Settings.cs index 4065a9a..49bcaf7 100644 --- a/SinglePlayer/Akkoteaque/Settings.cs +++ b/SinglePlayer/Akkoteaque/Settings.cs @@ -14,7 +14,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Perform("singleplayer game started") .Do((actor) => { - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("before command") @@ -22,7 +22,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((match, actor) => { Console.WriteLine(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("after every command") @@ -30,7 +30,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { Console.WriteLine(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/SinglePlayer/CloakOfDarkness/Bar.cs b/SinglePlayer/CloakOfDarkness/Bar.cs index 5599d71..e1a6797 100644 --- a/SinglePlayer/CloakOfDarkness/Bar.cs +++ b/SinglePlayer/CloakOfDarkness/Bar.cs @@ -57,7 +57,7 @@ end the game saying "You have lost". SendMessage(actor, "YOU HAVE WON!"); Core.Shutdown(); } - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); /* @@ -71,10 +71,10 @@ end the game saying "You have lost". .Do((match, actor) => { if (match.TypedValue("COMMAND").IsNamed("GO")) - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; messageScuffed = true; SendMessage(actor, "In the dark? You could easily disturb something."); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); /* @@ -90,7 +90,7 @@ end the game saying "You have lost". { messageScuffed = true; SendMessage(actor, "Blundering around in the dark isn't a good idea!"); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/SinglePlayer/CloakOfDarkness/Cloak.cs b/SinglePlayer/CloakOfDarkness/Cloak.cs index 78b9207..50997c5 100644 --- a/SinglePlayer/CloakOfDarkness/Cloak.cs +++ b/SinglePlayer/CloakOfDarkness/Cloak.cs @@ -30,7 +30,7 @@ Its blackness is so deep that it almost seems to suck light from the room." //Carry out taking the cloak: // now the bar is dark. - Perform("take").Do((actor, thing) => { GetObject("Bar").AmbientLighting = LightingLevel.Dark; return PerformResult.Continue; }); + Perform("take").Do((actor, thing) => { GetObject("Bar").AmbientLighting = LightingLevel.Dark; return SharpRuleEngine.PerformResult.Continue; }); //Carry out putting the unhung cloak on something in the cloakroom: // now the cloak is hung; @@ -43,13 +43,13 @@ Its blackness is so deep that it almost seems to suck light from the room." // now the bar is lit. Perform("put") .When((actor, item, container, relloc) => actor.Location is Cloakroom) - .Do((actor, item, container, relloc) => { GetObject("Bar").AmbientLighting = LightingLevel.Bright; return PerformResult.Continue; }); + .Do((actor, item, container, relloc) => { GetObject("Bar").AmbientLighting = LightingLevel.Bright; return SharpRuleEngine.PerformResult.Continue; }); //Carry out dropping the cloak in the cloakroom: // now the bar is lit. Perform("drop") .When((actor, item) => actor.Location is Cloakroom) - .Do((actor, item) => { GetObject("Bar").AmbientLighting = LightingLevel.Bright; return PerformResult.Continue; }); + .Do((actor, item) => { GetObject("Bar").AmbientLighting = LightingLevel.Bright; return SharpRuleEngine.PerformResult.Continue; }); //Instead of dropping or putting the cloak on when the player is not in the cloakroom: // say "This isn't the best place to leave a smart cloak lying around." @@ -59,7 +59,7 @@ Its blackness is so deep that it almost seems to suck light from the room." .Do((actor, item) => { SendMessage(actor, "This isn't the best place to leave a smart cloak lying around."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); } } diff --git a/SinglePlayer/CloakOfDarkness/Cloakroom.cs b/SinglePlayer/CloakOfDarkness/Cloakroom.cs index 5c552b0..d10be4e 100644 --- a/SinglePlayer/CloakOfDarkness/Cloakroom.cs +++ b/SinglePlayer/CloakOfDarkness/Cloakroom.cs @@ -50,7 +50,7 @@ public override void Initialize() .Do((actor, item) => { SendMessage(actor, "It's screwed into the wall."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); } } diff --git a/SinglePlayer/CloakOfDarkness/Foyer.cs b/SinglePlayer/CloakOfDarkness/Foyer.cs index 0de3f1f..f5717dc 100644 --- a/SinglePlayer/CloakOfDarkness/Foyer.cs +++ b/SinglePlayer/CloakOfDarkness/Foyer.cs @@ -30,7 +30,7 @@ the weather outside seems to be getting worse." .Do((actor, link) => { MudObject.SendMessage(actor, "You've only just arrived, and besides, the weather outside seems to be getting worse."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); } } diff --git a/SinglePlayer/CloakOfDarkness/settings.cs b/SinglePlayer/CloakOfDarkness/settings.cs index 3b21bf3..0c85a31 100644 --- a/SinglePlayer/CloakOfDarkness/settings.cs +++ b/SinglePlayer/CloakOfDarkness/settings.cs @@ -14,7 +14,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { SendMessage(actor, "Hurrying through the rainswept November night, you're glad to see the bright lights of the Opera House. It's surprising that there aren't more people about but, hey, what do you expect in a cheap demo game...?"); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("before command") @@ -22,7 +22,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((match, actor) => { Console.WriteLine(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("after every command") @@ -30,7 +30,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { Console.WriteLine(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/SinglePlayer/SinglePlayer.csproj b/SinglePlayer/SinglePlayer.csproj index 800adab..6c6e3ca 100644 --- a/SinglePlayer/SinglePlayer.csproj +++ b/SinglePlayer/SinglePlayer.csproj @@ -33,6 +33,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -85,6 +88,7 @@ + diff --git a/SinglePlayer/Wells/Thrad.cs b/SinglePlayer/Wells/Thrad.cs index ff3f30f..d7ed71d 100644 --- a/SinglePlayer/Wells/Thrad.cs +++ b/SinglePlayer/Wells/Thrad.cs @@ -23,7 +23,7 @@ public override void Initialize() .Do((actor, item) => { SendMessage(actor, "A massive knight stands in the middle of the little room."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); @@ -45,7 +45,7 @@ public override void Initialize() { SendMessage(actor, "^ peers at you from within his incredible helmet. \"Thrad\", he says.", this); this.Introduced = true; - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); var helmet = this.Response("about his incredible helmet", "\"This?\" Thrad rumbles from inside the helmet. \"This is nothing. This is to keep my brain from splattering on walls. Instead it splatters on inside of helmet. Much easier to cleanup.\"").Available(() => who_he_is.Discussed); diff --git a/SinglePlayer/packages.config b/SinglePlayer/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/SinglePlayer/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj b/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj index 2641222..25e55d7 100644 --- a/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj +++ b/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -52,6 +55,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/SinglePlayerMinimumGame/packages.config b/SinglePlayerMinimumGame/packages.config new file mode 100644 index 0000000..abd6941 --- /dev/null +++ b/SinglePlayerMinimumGame/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Space/Cargo.cs b/Space/Cargo.cs index 5815a89..4003d93 100644 --- a/Space/Cargo.cs +++ b/Space/Cargo.cs @@ -36,7 +36,7 @@ public override void Initialize() .Do((actor, boxes) => { SendMessage(actor, "I couldn't carry even one of those."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); } } diff --git a/Space/ControlPanel.cs b/Space/ControlPanel.cs index d16b0f9..a8805d6 100644 --- a/Space/ControlPanel.cs +++ b/Space/ControlPanel.cs @@ -24,7 +24,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor, panel) => { SendMessage(actor, "I can't take it. It's firmly attached."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); GlobalRules.Perform("describe") @@ -42,7 +42,7 @@ public static void AtStartup(RuleEngine GlobalRules) } SendMessage(actor, "It's a little square panel covered in buttons. There is a light on it.", panel.Indicator.ToString()); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("describe") @@ -50,7 +50,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor, panel) => { SendMessage(actor, "It's been smashed up real good."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); GlobalRules.Perform("hit with") @@ -59,7 +59,7 @@ public static void AtStartup(RuleEngine GlobalRules) { SendMessage(player, "The panel smashed up good."); panel.Broken = true; - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } diff --git a/Space/DanConversation0.cs b/Space/DanConversation0.cs index 1a5c81e..a3d1ce9 100644 --- a/Space/DanConversation0.cs +++ b/Space/DanConversation0.cs @@ -1,5 +1,6 @@ using RMUD; using ConversationModule; +using SharpRuleEngine; namespace Space { diff --git a/Space/Game.cs b/Space/Game.cs index 4eaf3fb..9344602 100644 --- a/Space/Game.cs +++ b/Space/Game.cs @@ -20,10 +20,10 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) { var command = match["COMMAND"] as RMUD.CommandEntry; if (command.IsNamed("ASK") || command.IsNamed("HELP") || command.IsNamed("TOPICS")) - return RMUD.PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; RMUD.MudObject.SendMessage(actor, "Sal, I really need to talk about this."); RMUD.Core.EnqueuActorCommand(actor, "TOPICS"); - return RMUD.PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }) .Name("Can only converse during a blocking conversation rule."); @@ -31,13 +31,13 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Do((actor, npc, topic) => { topic.SetProperty("discussed", true); - return RMUD.PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Mark topic discussed rule."); GlobalRules.Perform("list topics") .When(player => SuppressTopics) - .Do(player => RMUD.PerformResult.Stop); + .Do(player => SharpRuleEngine.PerformResult.Stop); GlobalRules.Perform("list topics") .Do(player => @@ -48,7 +48,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) if (availableTopics.Count() == 0) BlockingConversation = false; - return RMUD.PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Unblock game if no available topics rule."); @@ -64,7 +64,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) RMUD.MudObject.Move(actor, RMUD.MudObject.GetObject("Start")); RMUD.Core.EnqueuActorCommand(actor, "look"); - return RMUD.PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/Space/Hatch.cs b/Space/Hatch.cs index c61e21c..42808f8 100644 --- a/Space/Hatch.cs +++ b/Space/Hatch.cs @@ -26,9 +26,9 @@ public Hatch() if (GetBooleanProperty("open?")) { MudObject.SendMessage(a, "@already open"); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; } - return CheckResult.Allow; + return SharpRuleEngine.CheckResult.Allow; }) .Name("Can open doors rule."); @@ -39,9 +39,9 @@ public Hatch() if (!GetBooleanProperty("open?")) { MudObject.SendMessage(a, "@already closed"); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; } - return CheckResult.Allow; + return SharpRuleEngine.CheckResult.Allow; }); Perform("opened").Do((a, b) => @@ -49,7 +49,7 @@ public Hatch() SetProperty("open?", true); var otherSide = Portal.FindOppositeSide(this); otherSide.SetProperty("open?", true); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); Perform("close").Do((a, b) => @@ -57,7 +57,7 @@ public Hatch() SetProperty("open?", false); var otherSide = Portal.FindOppositeSide(this); otherSide.SetProperty("open?", false); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); ControlPanel = new Space.ControlPanel(); @@ -74,19 +74,19 @@ public Hatch() if (thisSide.AirLevel == AirLevel.Vacuum || otherSide.AirLevel == AirLevel.Vacuum) { SendMessage(player, "That would let all the air out. That's not a good idea with this hole in my suit."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; } } - if (ControlPanel.Broken) return CheckResult.Continue; + if (ControlPanel.Broken) return SharpRuleEngine.CheckResult.Continue; if (thisSide.AirLevel != otherSide.AirLevel) { SendMessage(player, "It won't open."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; } - return CheckResult.Continue; + return SharpRuleEngine.CheckResult.Continue; }); } } diff --git a/Space/Hit.cs b/Space/Hit.cs index e002d4e..29420cc 100644 --- a/Space/Hit.cs +++ b/Space/Hit.cs @@ -43,7 +43,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Name("Object must be held rule."); GlobalRules.Check("can hit with?") - .Do((a, b, c) => CheckResult.Allow) + .Do((a, b, c) => SharpRuleEngine.CheckResult.Allow) .Name("Default allow hitting rule."); GlobalRules.DeclarePerformRuleBook("hit with", "[Actor, Subject, Object] : Handle the actor hitting the subject with the object."); @@ -51,7 +51,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Perform("hit with").Do((actor, subject, @object) => { MudObject.SendMessage(actor, "I smacked with . I don't think it did anything.", subject, @object); - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/Space/Locker.cs b/Space/Locker.cs index ae69286..fd520e4 100644 --- a/Space/Locker.cs +++ b/Space/Locker.cs @@ -1,4 +1,5 @@ using RMUD; +using SharpRuleEngine; namespace Space { diff --git a/Space/Player.cs b/Space/Player.cs index ba97b34..8b2288a 100644 --- a/Space/Player.cs +++ b/Space/Player.cs @@ -20,7 +20,7 @@ public override void Initialize() foreach (var item in tapedObjects) MudObject.SendMessage(a, " ", item); } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("List taped items in inventory rule."); } diff --git a/Space/Room.cs b/Space/Room.cs index a545a26..a1145fc 100644 --- a/Space/Room.cs +++ b/Space/Room.cs @@ -29,7 +29,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) RMUD.MudObject.SendMessage(viewer, item.Long); item.TimesViewed += 1; - return RMUD.PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }).Name("Choose brief or long description rule."); } diff --git a/Space/Space.csproj b/Space/Space.csproj index 12234f1..4b509e3 100644 --- a/Space/Space.csproj +++ b/Space/Space.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.1\lib\SharpRuleEngine.dll + @@ -83,6 +86,9 @@ + + + + \ No newline at end of file diff --git a/Delmud/Program.cs b/Delmud/Program.cs new file mode 100644 index 0000000..e3090b0 --- /dev/null +++ b/Delmud/Program.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Net.Sockets; +using System.IO; +using System.Net; +using NetworkModule.Telnet; +using RMUD; + +namespace Delmud +{ + class Program + { + static void Main(string[] args) + { + TelnetClientSource telnetListener = null; + + if (Core.Start(StartupFlags.SearchDirectory, "delmud_db/", new RuntimeDatabase())) + { + telnetListener = new TelnetClientSource(); + telnetListener.Port = Core.SettingsObject.TelnetPort; + telnetListener.Listen(); + + while (!Core.ShuttingDown) + { + //Todo: Shutdown server command breaks this loop. + } + + telnetListener.Shutdown(); + } + else + { + while (true) { } + } + } + } +} diff --git a/Delmud/Properties/AssemblyInfo.cs b/Delmud/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6b06f89 --- /dev/null +++ b/Delmud/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RMUD")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RMUD")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6caab69d-f2f1-43c9-bffb-a207443db466")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Delmud/app.config b/Delmud/app.config new file mode 100644 index 0000000..884f984 --- /dev/null +++ b/Delmud/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Delmud/delmud_db/static/player_base.cs b/Delmud/delmud_db/static/player_base.cs new file mode 100644 index 0000000..60a8c9b --- /dev/null +++ b/Delmud/delmud_db/static/player_base.cs @@ -0,0 +1,4 @@ +public class player_base : DelmudGameplay.Player +{ + +} diff --git a/Delmud/delmud_db/static/settings.cs b/Delmud/delmud_db/static/settings.cs new file mode 100644 index 0000000..bbaa061 --- /dev/null +++ b/Delmud/delmud_db/static/settings.cs @@ -0,0 +1,9 @@ +public class settings : RMUD.Settings +{ + public settings() + { + this.Banner = "~~ DELFARA ~~"; + this.NewPlayerStartRoom = "start"; + this.UseGithubDatabase = false; + } +} diff --git a/Delmud/delmud_db/static/start.cs b/Delmud/delmud_db/static/start.cs new file mode 100644 index 0000000..0f51c90 --- /dev/null +++ b/Delmud/delmud_db/static/start.cs @@ -0,0 +1,9 @@ +public class start : MudObject +{ + public override void Initialize() + { + Room(RoomType.Interior); + + SetProperty("Short", "Chamber of the swirling elements"); + } +} diff --git a/Delmud/packages.config b/Delmud/packages.config new file mode 100644 index 0000000..1b8ed0b --- /dev/null +++ b/Delmud/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/DelmudGameplay/CharacterClasses.cs b/DelmudGameplay/CharacterClasses.cs new file mode 100644 index 0000000..59dc446 --- /dev/null +++ b/DelmudGameplay/CharacterClasses.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DelmudGameplay +{ + public enum CharacterClasses + { + Bludgeon, + Magi, + Swift, + Elemental + } +} diff --git a/DelmudGameplay/DelmudGameplay.csproj b/DelmudGameplay/DelmudGameplay.csproj new file mode 100644 index 0000000..797c500 --- /dev/null +++ b/DelmudGameplay/DelmudGameplay.csproj @@ -0,0 +1,73 @@ + + + + + Debug + AnyCPU + {A911E3E5-3128-4A51-89BB-4209238F42A4} + Library + Properties + DelmudGameplay + DelmudGameplay + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + True + + + + + + + + + + + + + + + + + + + + {5c29e6ad-54e3-4105-a9f3-2aab48a17c41} + Core + + + + + + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" + + + \ No newline at end of file diff --git a/DelmudGameplay/ElementTypes.cs b/DelmudGameplay/ElementTypes.cs new file mode 100644 index 0000000..2b45f3f --- /dev/null +++ b/DelmudGameplay/ElementTypes.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DelmudGameplay +{ + public enum ElementTypes + { + Earth, + Water, + Wind, + Fire + } +} diff --git a/DelmudGameplay/ModuleInfo.cs b/DelmudGameplay/ModuleInfo.cs new file mode 100644 index 0000000..4c042d5 --- /dev/null +++ b/DelmudGameplay/ModuleInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +public class ModuleInfo : RMUD.ModuleInfo +{ + public ModuleInfo() + { + BaseNameSpace = "DelmudGameplay"; + Author = "Blecki"; + Description = "Delmud core gameplay"; + } +} diff --git a/DelmudGameplay/Player.cs b/DelmudGameplay/Player.cs new file mode 100644 index 0000000..8732130 --- /dev/null +++ b/DelmudGameplay/Player.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RMUD; +using SharpRuleEngine; + +namespace DelmudGameplay +{ + public class Player : RMUD.Player + { + [Persist] + public ElementTypes Element { get; set; } + + [Persist] + public CharacterClasses Class { get; set; } + + [Persist] + public int Attack { get; set; } + + [Persist] + public int Defense { get; set; } + + [Persist] + public int MaxHP { get; set; } + + [Persist] + public int MaxMP { get; set; } + + } +} diff --git a/DelmudGameplay/Properties/AssemblyInfo.cs b/DelmudGameplay/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..df17d40 --- /dev/null +++ b/DelmudGameplay/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DelmudGameplay")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Hewlett-Packard")] +[assembly: AssemblyProduct("DelmudGameplay")] +[assembly: AssemblyCopyright("Copyright © Hewlett-Packard 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a911e3e5-3128-4a51-89bb-4209238f42a4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DelmudGameplay/packages.config b/DelmudGameplay/packages.config new file mode 100644 index 0000000..6e0add0 --- /dev/null +++ b/DelmudGameplay/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/IntroductionModule/Implementation.cs b/IntroductionModule/Implementation.cs index 14efbdc..a8fcdd6 100644 --- a/IntroductionModule/Implementation.cs +++ b/IntroductionModule/Implementation.cs @@ -117,7 +117,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Value("printed name") .When((viewer, thing, article) => GlobalRules.ConsiderValueRule("actor knows actor?", viewer, thing)) - .Do((viewer, actor, article) => actor.Short) + .Do((viewer, actor, article) => actor.GetProperty("Short")) .Name("Name of introduced actor."); GlobalRules.Value("printed name") diff --git a/NetworkModule/Accounts.cs b/NetworkModule/Accounts.cs index 88ef9fe..19659be 100644 --- a/NetworkModule/Accounts.cs +++ b/NetworkModule/Accounts.cs @@ -11,7 +11,13 @@ namespace NetworkModule { public static class Accounts { - private static String AccountsPath = "database/accounts/"; + private static String AccountsPath + { + get + { + return Core.DatabasePath + "accounts/"; + } + } private static string GenerateRandomSalt() { @@ -60,8 +66,8 @@ public static Player GetAccountCharacter(Account Account) Core.CommandTimeoutEnabled = false; var playerObject = Core.Database.GetObject(Core.SettingsObject.PlayerBaseObject + "@" + Account.UserName) as Player; - playerObject.Short = Account.UserName; - playerObject.Nouns.Add(Account.UserName.ToUpper()); + playerObject.SetProperty("Short", Account.UserName); + playerObject.GetProperty("Nouns").Add(Account.UserName.ToUpper()); MudObject.PersistInstance(playerObject); return playerObject; } diff --git a/NetworkModule/Clients.cs b/NetworkModule/Clients.cs index 82f6c64..230898c 100644 --- a/NetworkModule/Clients.cs +++ b/NetworkModule/Clients.cs @@ -24,7 +24,9 @@ internal static void ClientDisconnected(Client client) { ClientLock.WaitOne(); ConnectedClients.Remove(client); - client.Player.GetProperty("account").LoggedInCharacter = null; + var account = client.Player.GetPropertyOrDefault("account", null); + if (account != null) + account.LoggedInCharacter = null; Core.RemovePlayer(client.Player); ClientLock.ReleaseMutex(); } diff --git a/NetworkModule/Kick.cs b/NetworkModule/Kick.cs index a4af36d..e5d6a42 100644 --- a/NetworkModule/Kick.cs +++ b/NetworkModule/Kick.cs @@ -49,9 +49,9 @@ public static void KickPlayer(Actor Player, Actor Actor) { Core.MarkLocaleForUpdate(Player); - MudObject.SendMessage(Player, Actor.Short + " has removed you from the server."); + MudObject.SendMessage(Player, Actor.GetProperty("Short") + " has removed you from the server."); Player.ConnectedClient.Disconnect(); - Clients.SendGlobalMessage(Actor.Short + " has removed " + Player.Short + " from the server."); + Clients.SendGlobalMessage(Actor.GetProperty("Short") + " has removed " + Player.GetProperty("Short") + " from the server."); } } } diff --git a/NetworkModule/Stats.cs b/NetworkModule/Stats.cs index b39a81b..fa27f63 100644 --- a/NetworkModule/Stats.cs +++ b/NetworkModule/Stats.cs @@ -25,9 +25,9 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) MudObject.SendMessage(actor, "~~ CLIENTS ~~"); foreach (var client in Clients.ConnectedClients) if (client is NetworkClient) - MudObject.SendMessage(actor, (client as NetworkClient).ConnectionDescription + (client.Player == null ? "" : (" - " + client.Player.Short))); + MudObject.SendMessage(actor, (client as NetworkClient).ConnectionDescription + (client.Player == null ? "" : (" - " + client.Player.GetProperty("Short")))); else - MudObject.SendMessage(actor, "local " + (client.Player == null ? "" : (" - " + client.Player.Short))); + MudObject.SendMessage(actor, "local " + (client.Player == null ? "" : (" - " + client.Player.GetProperty("Short")))); return SharpRuleEngine.PerformResult.Stop; }); } diff --git a/QuestModule/AcceptQuest.cs b/QuestModule/AcceptQuest.cs index 34d44a5..a7d1c05 100644 --- a/QuestModule/AcceptQuest.cs +++ b/QuestModule/AcceptQuest.cs @@ -31,11 +31,10 @@ public override void Create(CommandParser Parser) }, "the must have been offered a quest, and bookeeping rule.") .ProceduralRule((match, actor) => { - var player = actor as Player; - if (!Core.GlobalRules.ConsiderValueRule("quest available?", player, player.GetProperty("offered-quest"))) + if (!Core.GlobalRules.ConsiderValueRule("quest available?", actor, actor.GetProperty("offered-quest"))) { MudObject.SendMessage(actor, "The quest is no longer available."); - player.RemoveProperty("offered-quest"); + actor.SetProperty("offered-quest", null); return SharpRuleEngine.PerformResult.Stop; } return SharpRuleEngine.PerformResult.Continue; @@ -46,7 +45,7 @@ public override void Create(CommandParser Parser) Core.GlobalRules.ConsiderPerformRule("quest abandoned", actor, actor.GetProperty("active-quest")); actor.SetProperty("active-quest", actor.GetProperty("offered-quest")); - actor.RemoveProperty("offered-quest"); + actor.SetProperty("offered-quest", null); return SharpRuleEngine.PerformResult.Continue; }, "the any active quest must be abandoned rule.") .Perform("quest accepted", "ACTOR", "QUEST"); diff --git a/QuestModule/QuestRules.cs b/QuestModule/QuestRules.cs index e33b5a6..e8b5bba 100644 --- a/QuestModule/QuestRules.cs +++ b/QuestModule/QuestRules.cs @@ -15,18 +15,18 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Perform("after acting") .Do((match, actor) => { - if (actor.GetProperty("active-quest") != null) + if (actor.GetPropertyOrDefault("active-quest", null) != null) { var quest = actor.GetProperty("active-quest"); - + if (GlobalRules.ConsiderValueRule("quest complete?", actor, quest)) { - actor.RemoveProperty("active-quest"); + actor.SetProperty("active-quest", null); GlobalRules.ConsiderPerformRule("quest completed", actor, quest); } else if (GlobalRules.ConsiderValueRule("quest failed?", actor, quest)) { - actor.RemoveProperty("active-quest"); + actor.SetProperty("active-quest", null); GlobalRules.ConsiderPerformRule("quest failed", actor, quest); } } diff --git a/RMUD.sln b/RMUD.sln index eb130b3..2105df6 100644 --- a/RMUD.sln +++ b/RMUD.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RMUD", "RMUD\RMUD.csproj", "{A0AF04AB-7049-44B0-9496-7B2297AEE262}" EndProject @@ -27,88 +27,154 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkModule", "NetworkMod EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandardActionsModule", "StandardActionsModule\StandardActionsModule.csproj", "{1A004032-0F05-4545-88F2-3F58EFA1CE1D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Space", "Space\Space.csproj", "{75D0C5C6-EFB9-4B45-86FF-F83ABC943D78}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasModule", "AliasModule\AliasModule.csproj", "{37794C83-F94B-4B30-8E6A-DEDA0A389015}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SinglePlayerMinimumGame", "SinglePlayerMinimumGame\SinglePlayerMinimumGame.csproj", "{68D0E431-5DCA-4A25-A1B2-2F5B857821B1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akkoteaque", "Akkoteaque\Akkoteaque.csproj", "{F463DF29-1E1D-4715-85FC-6A177742AD0C}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Games", "Games", "{5695FB1B-65C3-4659-BCFE-62037DC92A81}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{84327B59-5112-4822-BF9A-5683750CA5BD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Delmud", "Delmud\Delmud.csproj", "{A0AF04AB-7049-44B0-9496-7B2297AEE263}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DelmudGameplay", "DelmudGameplay\DelmudGameplay.csproj", "{A911E3E5-3128-4A51-89BB-4209238F42A4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Debug|x86.ActiveCfg = Debug|x86 + {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Debug|x86.Build.0 = Debug|x86 {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Release|Any CPU.ActiveCfg = Release|Any CPU {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Release|Any CPU.Build.0 = Release|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Release|x86.ActiveCfg = Release|x86 + {A0AF04AB-7049-44B0-9496-7B2297AEE262}.Release|x86.Build.0 = Release|x86 {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Debug|x86.ActiveCfg = Debug|Any CPU + {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Debug|x86.Build.0 = Debug|Any CPU {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Release|Any CPU.Build.0 = Release|Any CPU + {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Release|x86.ActiveCfg = Release|Any CPU + {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}.Release|x86.Build.0 = Release|Any CPU {35448D1E-7997-4626-8D1F-4278659F60A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {35448D1E-7997-4626-8D1F-4278659F60A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35448D1E-7997-4626-8D1F-4278659F60A0}.Debug|x86.ActiveCfg = Debug|Any CPU + {35448D1E-7997-4626-8D1F-4278659F60A0}.Debug|x86.Build.0 = Debug|Any CPU {35448D1E-7997-4626-8D1F-4278659F60A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {35448D1E-7997-4626-8D1F-4278659F60A0}.Release|Any CPU.Build.0 = Release|Any CPU + {35448D1E-7997-4626-8D1F-4278659F60A0}.Release|x86.ActiveCfg = Release|Any CPU + {35448D1E-7997-4626-8D1F-4278659F60A0}.Release|x86.Build.0 = Release|Any CPU {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Debug|x86.ActiveCfg = Debug|Any CPU + {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Debug|x86.Build.0 = Debug|Any CPU {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Release|Any CPU.ActiveCfg = Release|Any CPU {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Release|Any CPU.Build.0 = Release|Any CPU + {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Release|x86.ActiveCfg = Release|Any CPU + {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41}.Release|x86.Build.0 = Release|Any CPU {8F1AF0E1-C98D-466A-A712-621493453373}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F1AF0E1-C98D-466A-A712-621493453373}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F1AF0E1-C98D-466A-A712-621493453373}.Debug|x86.ActiveCfg = Debug|Any CPU + {8F1AF0E1-C98D-466A-A712-621493453373}.Debug|x86.Build.0 = Debug|Any CPU {8F1AF0E1-C98D-466A-A712-621493453373}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F1AF0E1-C98D-466A-A712-621493453373}.Release|Any CPU.Build.0 = Release|Any CPU + {8F1AF0E1-C98D-466A-A712-621493453373}.Release|x86.ActiveCfg = Release|Any CPU + {8F1AF0E1-C98D-466A-A712-621493453373}.Release|x86.Build.0 = Release|Any CPU {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Debug|x86.ActiveCfg = Debug|Any CPU + {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Debug|x86.Build.0 = Debug|Any CPU {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Release|Any CPU.Build.0 = Release|Any CPU + {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Release|x86.ActiveCfg = Release|Any CPU + {05484D1A-47F3-4B4A-B457-AF56B197E4CB}.Release|x86.Build.0 = Release|Any CPU {1BCBACDD-8405-4373-8260-168C50932C76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1BCBACDD-8405-4373-8260-168C50932C76}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BCBACDD-8405-4373-8260-168C50932C76}.Debug|x86.ActiveCfg = Debug|Any CPU + {1BCBACDD-8405-4373-8260-168C50932C76}.Debug|x86.Build.0 = Debug|Any CPU {1BCBACDD-8405-4373-8260-168C50932C76}.Release|Any CPU.ActiveCfg = Release|Any CPU {1BCBACDD-8405-4373-8260-168C50932C76}.Release|Any CPU.Build.0 = Release|Any CPU + {1BCBACDD-8405-4373-8260-168C50932C76}.Release|x86.ActiveCfg = Release|Any CPU + {1BCBACDD-8405-4373-8260-168C50932C76}.Release|x86.Build.0 = Release|Any CPU {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Debug|x86.ActiveCfg = Debug|Any CPU + {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Debug|x86.Build.0 = Debug|Any CPU {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Release|Any CPU.Build.0 = Release|Any CPU + {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Release|x86.ActiveCfg = Release|Any CPU + {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E}.Release|x86.Build.0 = Release|Any CPU {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Debug|x86.ActiveCfg = Debug|Any CPU + {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Debug|x86.Build.0 = Debug|Any CPU {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Release|Any CPU.Build.0 = Release|Any CPU + {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Release|x86.ActiveCfg = Release|Any CPU + {DA9A47A5-83D6-440E-9008-8EA59C8446DC}.Release|x86.Build.0 = Release|Any CPU {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Debug|x86.ActiveCfg = Debug|Any CPU + {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Debug|x86.Build.0 = Debug|Any CPU {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Release|Any CPU.ActiveCfg = Release|Any CPU {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Release|Any CPU.Build.0 = Release|Any CPU + {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Release|x86.ActiveCfg = Release|Any CPU + {ADAF3782-88D1-4170-866A-9EF3479EAE97}.Release|x86.Build.0 = Release|Any CPU {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Debug|x86.ActiveCfg = Debug|Any CPU + {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Debug|x86.Build.0 = Debug|Any CPU {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Release|Any CPU.Build.0 = Release|Any CPU + {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Release|x86.ActiveCfg = Release|Any CPU + {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5}.Release|x86.Build.0 = Release|Any CPU {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Debug|x86.ActiveCfg = Debug|Any CPU + {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Debug|x86.Build.0 = Debug|Any CPU {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Release|Any CPU.Build.0 = Release|Any CPU - {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78}.Release|Any CPU.Build.0 = Release|Any CPU + {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Release|x86.ActiveCfg = Release|Any CPU + {1A004032-0F05-4545-88F2-3F58EFA1CE1D}.Release|x86.Build.0 = Release|Any CPU {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Debug|x86.ActiveCfg = Debug|Any CPU + {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Debug|x86.Build.0 = Debug|Any CPU {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Release|Any CPU.ActiveCfg = Release|Any CPU {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Release|Any CPU.Build.0 = Release|Any CPU + {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Release|x86.ActiveCfg = Release|Any CPU + {37794C83-F94B-4B30-8E6A-DEDA0A389015}.Release|x86.Build.0 = Release|Any CPU {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Debug|x86.ActiveCfg = Debug|Any CPU + {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Debug|x86.Build.0 = Debug|Any CPU {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Release|Any CPU.Build.0 = Release|Any CPU - {F463DF29-1E1D-4715-85FC-6A177742AD0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F463DF29-1E1D-4715-85FC-6A177742AD0C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F463DF29-1E1D-4715-85FC-6A177742AD0C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F463DF29-1E1D-4715-85FC-6A177742AD0C}.Release|Any CPU.Build.0 = Release|Any CPU + {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Release|x86.ActiveCfg = Release|Any CPU + {68D0E431-5DCA-4A25-A1B2-2F5B857821B1}.Release|x86.Build.0 = Release|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Debug|x86.ActiveCfg = Debug|x86 + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Debug|x86.Build.0 = Debug|x86 + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Release|Any CPU.Build.0 = Release|Any CPU + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Release|x86.ActiveCfg = Release|x86 + {A0AF04AB-7049-44B0-9496-7B2297AEE263}.Release|x86.Build.0 = Release|x86 + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Debug|x86.ActiveCfg = Debug|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Debug|x86.Build.0 = Debug|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Release|Any CPU.Build.0 = Release|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Release|x86.ActiveCfg = Release|Any CPU + {A911E3E5-3128-4A51-89BB-4209238F42A4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -124,10 +190,8 @@ Global {ADAF3782-88D1-4170-866A-9EF3479EAE97} = {84327B59-5112-4822-BF9A-5683750CA5BD} {CCE2B1D9-E0E9-48E1-9ADA-49F36E6F15C5} = {84327B59-5112-4822-BF9A-5683750CA5BD} {1A004032-0F05-4545-88F2-3F58EFA1CE1D} = {84327B59-5112-4822-BF9A-5683750CA5BD} - {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78} = {5695FB1B-65C3-4659-BCFE-62037DC92A81} {37794C83-F94B-4B30-8E6A-DEDA0A389015} = {84327B59-5112-4822-BF9A-5683750CA5BD} {68D0E431-5DCA-4A25-A1B2-2F5B857821B1} = {5695FB1B-65C3-4659-BCFE-62037DC92A81} - {F463DF29-1E1D-4715-85FC-6A177742AD0C} = {5695FB1B-65C3-4659-BCFE-62037DC92A81} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = RMUD\RMUD.csproj diff --git a/RMUD/Program.cs b/RMUD/Program.cs index 4f4405c..2eb0212 100644 --- a/RMUD/Program.cs +++ b/RMUD/Program.cs @@ -15,7 +15,7 @@ static void Main(string[] args) { TelnetClientSource telnetListener = null; - if (Core.Start(StartupFlags.SearchDirectory, new GithubDatabase())) + if (Core.Start(StartupFlags.SearchDirectory, "database/", new RuntimeDatabase())) { telnetListener = new TelnetClientSource(); telnetListener.Port = Core.SettingsObject.TelnetPort; diff --git a/SillyModule/Silly.cs b/SillyModule/Silly.cs index a938c71..248e728 100644 --- a/SillyModule/Silly.cs +++ b/SillyModule/Silly.cs @@ -86,7 +86,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) var ruleID = Guid.NewGuid(); var counter = 100; - target.Nouns.Add("silly"); + target.GetProperty("Nouns").Add("silly"); target.Value("silly?").Do((thing) => true).ID(ruleID.ToString()) .Name("Silly things are silly rule."); @@ -94,7 +94,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) target.Value("printed name") .Do((viewer, thing, article) => { - return "silly " + thing.Short; + return "silly " + thing.GetProperty("Short"); }) .Name("Silly things have silly names rule.") .ID(ruleID.ToString()); @@ -106,7 +106,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) if (counter <= 0) { MudObject.SendExternalMessage(target, "^ is serious now.", target); - target.Nouns.Remove("silly"); + target.GetProperty("Nouns").Remove("silly"); target.Rules.DeleteAll(ruleID.ToString()); GlobalRules.DeleteRule("heartbeat", ruleID.ToString()); } diff --git a/SinglePlayer/Bar.cs b/SinglePlayer/Bar.cs index e1a6797..8286a4b 100644 --- a/SinglePlayer/Bar.cs +++ b/SinglePlayer/Bar.cs @@ -3,7 +3,7 @@ namespace CloakOfDarkness { - public class Bar : RMUD.Room + public class Bar : RMUD.MudObject { public override void Initialize() { @@ -13,12 +13,11 @@ The Bar is south of the Foyer. The printed name of the bar is "Foyer Bar". after the opulence of the foyer to the north, is completely empty. There seems to be some sort of message scrawled in the sawdust on the floor." */ - - Short = "Foyer Bar"; - Long = "The bar, much rougher than you'd have guessed after the opulence of the foyer to the north, is completely empty. There seems to be some sort of message scrawled in the sawdust on the floor."; - RoomType = RMUD.RoomType.Interior; - AmbientLighting = LightingLevel.Dark; - + Room(RoomType.Interior); + + SetProperty("Short", "Foyer Bar"); + SetProperty("Long", "The bar, much rougher than you'd have guessed after the opulence of the foyer to the north, is completely empty. There seems to be some sort of message scrawled in the sawdust on the floor."); + OpenLink(Direction.NORTH, "Foyer"); // The scrawled message is scenery in the Bar. Understand "floor" or "sawdust" as the message. @@ -67,7 +66,7 @@ end the game saying "You have lost". say "In the dark? You could easily disturb something." */ Perform("before acting") - .When((match, actor) => AmbientLighting == LightingLevel.Dark) + .When((match, actor) => GetProperty("ambient light") == LightingLevel.Dark) .Do((match, actor) => { if (match.TypedValue("COMMAND").IsNamed("GO")) @@ -83,7 +82,7 @@ end the game saying "You have lost". say "Blundering around in the dark isn't a good idea!" */ Perform("before command") - .When((match, actor) => AmbientLighting == LightingLevel.Dark + .When((match, actor) => GetProperty("ambient light") == LightingLevel.Dark && match.TypedValue("COMMAND").IsNamed("GO") && (match.ValueOrDefault("DIRECTION") as Direction?).Value != Direction.NORTH) .Do((match, actor) => diff --git a/SinglePlayer/Cloak.cs b/SinglePlayer/Cloak.cs index 50997c5..c1137bf 100644 --- a/SinglePlayer/Cloak.cs +++ b/SinglePlayer/Cloak.cs @@ -24,13 +24,13 @@ Its blackness is so deep that it almost seems to suck light from the room." SetProperty("clothing part", ClothingModule.ClothingBodyPart.Cloak); SetProperty("wearable?", true); - Short = "velvet cloak"; - Nouns.Add("dark", "black", "satin", "velvet", "cloak"); - Long = "A handsome cloak, of velvet trimmed with satin, and slightly spattered with raindrops. Its blackness is so deep that it almost seems to suck light from the room."; + SetProperty("Short", "velvet cloak"); + GetProperty("Nouns").Add("dark", "black", "satin", "velvet", "cloak"); + SetProperty("Long", "A handsome cloak, of velvet trimmed with satin, and slightly spattered with raindrops. Its blackness is so deep that it almost seems to suck light from the room."); //Carry out taking the cloak: // now the bar is dark. - Perform("take").Do((actor, thing) => { GetObject("Bar").AmbientLighting = LightingLevel.Dark; return SharpRuleEngine.PerformResult.Continue; }); + Perform("take").Do((actor, thing) => { GetObject("Bar").SetProperty("ambient light", LightingLevel.Dark); return SharpRuleEngine.PerformResult.Continue; }); //Carry out putting the unhung cloak on something in the cloakroom: // now the cloak is hung; @@ -43,13 +43,13 @@ Its blackness is so deep that it almost seems to suck light from the room." // now the bar is lit. Perform("put") .When((actor, item, container, relloc) => actor.Location is Cloakroom) - .Do((actor, item, container, relloc) => { GetObject("Bar").AmbientLighting = LightingLevel.Bright; return SharpRuleEngine.PerformResult.Continue; }); + .Do((actor, item, container, relloc) => { GetObject("Bar").SetProperty("ambient light", LightingLevel.Bright); return SharpRuleEngine.PerformResult.Continue; }); //Carry out dropping the cloak in the cloakroom: // now the bar is lit. Perform("drop") .When((actor, item) => actor.Location is Cloakroom) - .Do((actor, item) => { GetObject("Bar").AmbientLighting = LightingLevel.Bright; return SharpRuleEngine.PerformResult.Continue; }); + .Do((actor, item) => { GetObject("Bar").SetProperty("ambient light", LightingLevel.Bright); return SharpRuleEngine.PerformResult.Continue; }); //Instead of dropping or putting the cloak on when the player is not in the cloakroom: // say "This isn't the best place to leave a smart cloak lying around." diff --git a/SinglePlayer/Cloakroom.cs b/SinglePlayer/Cloakroom.cs index d10be4e..04035da 100644 --- a/SinglePlayer/Cloakroom.cs +++ b/SinglePlayer/Cloakroom.cs @@ -2,7 +2,7 @@ namespace CloakOfDarkness { - public class Cloakroom : RMUD.Room + public class Cloakroom : RMUD.MudObject { public override void Initialize() { @@ -25,9 +25,10 @@ hanging on it[otherwise]screwed to the wall[end if]." [This description is general enough that, if we were to add other hangable items to the game, they would automatically be described correctly as well.] */ - - Short = "Cloakroom"; - Long = "The walls of this small room were clearly once lined with hooks, though now only one remains."; + Room(RoomType.Interior); + + SetProperty("Short", "Cloakroom"); + SetProperty("Long", "The walls of this small room were clearly once lined with hooks, though now only one remains."); OpenLink(Direction.EAST, "Foyer"); @@ -35,16 +36,17 @@ hanging on it[otherwise]screwed to the wall[end if]." } } - public class Hook : RMUD.Container + public class Hook : MudObject { public Hook() - : base(RelativeLocations.On, RelativeLocations.On) - { } + { + Container(RelativeLocations.On, RelativeLocations.On); + } public override void Initialize() { SimpleName("small brass hook", "peg"); - Long = "It's just a small brass hook."; + SetProperty("Long", "It's just a small brass hook."); Check("can take?") .Do((actor, item) => diff --git a/SinglePlayer/Foyer.cs b/SinglePlayer/Foyer.cs index f5717dc..a05d285 100644 --- a/SinglePlayer/Foyer.cs +++ b/SinglePlayer/Foyer.cs @@ -3,7 +3,7 @@ namespace CloakOfDarkness { - public class Foyer : RMUD.Room + public class Foyer : RMUD.MudObject { public override void Initialize() { @@ -16,9 +16,10 @@ public override void Initialize() the weather outside seems to be getting worse." */ + Room(RoomType.Interior); - Short = "Foyer of the Opera House"; - Long = "You are standing in a spacious hall, splendidly decorated in red and gold, with glittering chandeliers overhead."; + SetProperty("Short", "Foyer of the Opera House"); + SetProperty("Long", "You are standing in a spacious hall, splendidly decorated in red and gold, with glittering chandeliers overhead."); OpenLink(Direction.NORTH, "Outside"); OpenLink(Direction.SOUTH, "Bar"); diff --git a/SinglePlayer/Outside.cs b/SinglePlayer/Outside.cs index 4e7ad01..7204f43 100644 --- a/SinglePlayer/Outside.cs +++ b/SinglePlayer/Outside.cs @@ -2,11 +2,13 @@ namespace CloakOfDarkness { - public class Outside : RMUD.Room + public class Outside : RMUD.MudObject { public override void Initialize() { - Short = "Outside the Opera House"; + Room(RoomType.Exterior); + + SetProperty("Short", "Outside the Opera House"); } } } \ No newline at end of file diff --git a/SinglePlayer/Player.cs b/SinglePlayer/Player.cs index e56b6f1..1a2ccbf 100644 --- a/SinglePlayer/Player.cs +++ b/SinglePlayer/Player.cs @@ -6,7 +6,7 @@ public class Player : RMUD.Player { public override void Initialize() { - Short = "you"; + SetProperty("Short", "you"); Move(GetObject("Cloak"), this, RelativeLocations.Worn); } diff --git a/SinglePlayerMinimumGame/Player.cs b/SinglePlayerMinimumGame/Player.cs index 6fd22c5..3dacd77 100644 --- a/SinglePlayerMinimumGame/Player.cs +++ b/SinglePlayerMinimumGame/Player.cs @@ -6,7 +6,7 @@ public class Player : RMUD.Player { public override void Initialize() { - Short = "you"; + SetProperty("Short", "you"); } } } diff --git a/SinglePlayerMinimumGame/Start.cs b/SinglePlayerMinimumGame/Start.cs index 3955001..7299dcc 100644 --- a/SinglePlayerMinimumGame/Start.cs +++ b/SinglePlayerMinimumGame/Start.cs @@ -3,12 +3,13 @@ namespace Minimum { - public class Start : RMUD.Room + public class Start : RMUD.MudObject { public override void Initialize() { - Short = "Start Room"; - Long = "This is a game with the minimum possible objects."; + Room(RoomType.Exterior); + SetProperty("Short", "Start Room"); + SetProperty("Long", "This is a game with the minimum possible objects."); } } } \ No newline at end of file diff --git a/Space/Hatch.cs b/Space/Hatch.cs index 42808f8..67db207 100644 --- a/Space/Hatch.cs +++ b/Space/Hatch.cs @@ -13,17 +13,17 @@ public Hatch() Long = "It looks just like every other hatch."; this.Nouns.Add("HATCH"); - this.Nouns.Add("CLOSED", h => !GetBooleanProperty("open?")); - this.Nouns.Add("OPEN", h => GetBooleanProperty("open?")); + this.Nouns.Add("CLOSED", h => !GetPropertyOrDefault("open?", false)); + this.Nouns.Add("OPEN", h => GetPropertyOrDefault("open?", false)); - SetProperty("open?", false); - SetProperty("openable?", true); + UpsertProperty("open?", typeof(bool), false); + UpsertProperty("openable?", typeof(bool), true); Check("can open?") .Last .Do((a, b) => { - if (GetBooleanProperty("open?")) + if (GetPropertyOrDefault("open?", false)) { MudObject.SendMessage(a, "@already open"); return SharpRuleEngine.CheckResult.Disallow; @@ -36,7 +36,7 @@ public Hatch() .Last .Do((a, b) => { - if (!GetBooleanProperty("open?")) + if (!GetPropertyOrDefault("open?", false)) { MudObject.SendMessage(a, "@already closed"); return SharpRuleEngine.CheckResult.Disallow; diff --git a/Space/Locker.cs b/Space/Locker.cs index fd520e4..aaa939b 100644 --- a/Space/Locker.cs +++ b/Space/Locker.cs @@ -35,7 +35,7 @@ public Locker() : base(RelativeLocations.In, RelativeLocations.In) .Last .Do((a, b) => { - if (GetBooleanProperty("open?")) + if (GetPropertyOrDefault("open?", false)) { MudObject.SendMessage(a, "It's already open."); return CheckResult.Disallow; @@ -48,7 +48,7 @@ public Locker() : base(RelativeLocations.In, RelativeLocations.In) .Last .Do((a, b) => { - if (!GetBooleanProperty("open?")) + if (!GetPropertyOrDefault("open?", false)) { MudObject.SendMessage(a, "It's already closed."); return CheckResult.Disallow; diff --git a/StandardActionsModule/Close.cs b/StandardActionsModule/Close.cs index 4377ab3..93343d7 100644 --- a/StandardActionsModule/Close.cs +++ b/StandardActionsModule/Close.cs @@ -39,7 +39,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.DeclarePerformRuleBook("close", "[Actor, Item] : Handle the item being closed.", "actor", "item"); GlobalRules.Check("can close?") - .When((actor, item) => !item.GetBooleanProperty("openable?")) + .When((actor, item) => !item.GetPropertyOrDefault("openable?", false)) .Do((a, b) => { MudObject.SendMessage(a, "@not openable"); diff --git a/StandardActionsModule/DescribeRules.cs b/StandardActionsModule/DescribeRules.cs index 9891403..408f911 100644 --- a/StandardActionsModule/DescribeRules.cs +++ b/StandardActionsModule/DescribeRules.cs @@ -21,19 +21,19 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.DeclarePerformRuleBook("describe", "[Actor, Item] : Generates descriptions of the item.", "actor", "item"); GlobalRules.Perform("describe") - .When((viewer, item) => !String.IsNullOrEmpty(item.Long)) + .When((viewer, item) => !String.IsNullOrEmpty(item.GetProperty("Long"))) .Do((viewer, item) => { - MudObject.SendMessage(viewer, item.Long); + MudObject.SendMessage(viewer, item.GetProperty("Long")); return PerformResult.Continue; }) .Name("Basic description rule."); GlobalRules.Perform("describe") - .When((viewer, item) => item.GetBooleanProperty("openable?")) + .When((viewer, item) => item.GetPropertyOrDefault("openable?", false)) .Do((viewer, item) => { - if (item.GetBooleanProperty("open?")) + if (item.GetPropertyOrDefault("open?", false)) MudObject.SendMessage(viewer, "@is open", item); else MudObject.SendMessage(viewer, "@is closed", item); @@ -42,10 +42,10 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Name("Describe open or closed state rule."); GlobalRules.Perform("describe") - .When((viewer, item) => (item is Container) && ((item as Container).LocationsSupported & RelativeLocations.On) == RelativeLocations.On) + .When((viewer, item) => (item.LocationsSupported & RelativeLocations.On) == RelativeLocations.On) .Do((viewer, item) => { - var contents = (item as Container).GetContents(RelativeLocations.On); + var contents = item.GetContents(RelativeLocations.On); if (contents.Count() > 0) MudObject.SendMessage(viewer, "@describe on", item, contents); return PerformResult.Continue; @@ -55,14 +55,14 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Perform("describe") .When((viewer, item) => { - if (!(item is Container)) return false; - if (!item.GetBooleanProperty("open?")) return false; - if ((item as Container).EnumerateObjects(RelativeLocations.In).Count() == 0) return false; + if (item.GetPropertyOrDefault("container?", false)) return false; + if (!item.GetPropertyOrDefault("open?", false)) return false; + if (item.EnumerateObjects(RelativeLocations.In).Count() == 0) return false; return true; }) .Do((viewer, item) => { - var contents = (item as Container).GetContents(RelativeLocations.In); + var contents = item.GetContents(RelativeLocations.In); if (contents.Count() > 0) MudObject.SendMessage(viewer, "@describe in", item, contents); return PerformResult.Continue; diff --git a/StandardActionsModule/Examine.cs b/StandardActionsModule/Examine.cs index 65ae049..af99ae3 100644 --- a/StandardActionsModule/Examine.cs +++ b/StandardActionsModule/Examine.cs @@ -51,8 +51,8 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((actor) => { MudObject.SendMessage(actor, "A detailed account of all objects present."); - if (actor.Location != null && actor.Location is Container) - foreach (var item in (actor.Location as Container).EnumerateObjects().Where(i => !System.Object.ReferenceEquals(i, actor))) + if (actor.Location != null) + foreach (var item in actor.Location.EnumerateObjects().Where(i => !System.Object.ReferenceEquals(i, actor))) { MudObject.SendMessage(actor, "", item); } diff --git a/StandardActionsModule/Go.cs b/StandardActionsModule/Go.cs index f40f4f1..c0637b5 100644 --- a/StandardActionsModule/Go.cs +++ b/StandardActionsModule/Go.cs @@ -21,8 +21,7 @@ public override void Create(CommandParser Parser) .ProceduralRule((match, actor) => { var direction = match["DIRECTION"] as Direction?; - var location = actor.Location as Room; - var link = location.EnumerateObjects().FirstOrDefault(thing => thing.GetPropertyOrDefault("portal?", false) && thing.GetPropertyOrDefault("link direction", Direction.NOWHERE) == direction.Value); + var link = actor.Location.EnumerateObjects().FirstOrDefault(thing => thing.GetPropertyOrDefault("portal?", false) && thing.GetPropertyOrDefault("link direction", Direction.NOWHERE) == direction.Value); match.Upsert("LINK", link); return PerformResult.Continue; }, "lookup link rule") @@ -62,7 +61,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Name("No link found rule."); GlobalRules.Check("can go?") - .When((actor, link) => link != null && link.GetBooleanProperty("openable?") && !link.GetBooleanProperty("open?")) + .When((actor, link) => link != null && link.GetPropertyOrDefault("openable?", false) && !link.GetPropertyOrDefault("open?", false)) .Do((actor, link) => { MudObject.SendMessage(actor, "@first opening", link); @@ -92,7 +91,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Perform("go") .Do((actor, link) => { - var destination = MudObject.GetObject(link.GetProperty("link destination")) as Room; + var destination = MudObject.GetObject(link.GetProperty("link destination")); if (destination == null) { MudObject.SendMessage(actor, "@bad link"); diff --git a/StandardActionsModule/Lock.cs b/StandardActionsModule/Lock.cs index c1e38d6..62a0f42 100644 --- a/StandardActionsModule/Lock.cs +++ b/StandardActionsModule/Lock.cs @@ -46,7 +46,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Name("Key must be held rule."); GlobalRules.Check("can lock?") - .When((actor, item, key) => !item.GetBooleanProperty("lockable?")) + .When((actor, item, key) => !item.GetPropertyOrDefault("lockable?", false)) .Do((a, b, c) => { MudObject.SendMessage(a, "@not lockable"); diff --git a/StandardActionsModule/Look.cs b/StandardActionsModule/Look.cs index 5d1a64e..3e9fcad 100644 --- a/StandardActionsModule/Look.cs +++ b/StandardActionsModule/Look.cs @@ -35,7 +35,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Perform("describe locale") .First - .When((viewer, room) => room == null || !(room is Room)) + .When((viewer, room) => room == null) .Do((viewer, room) => { MudObject.SendMessage(viewer, "@nowhere"); @@ -56,14 +56,14 @@ public static void AtStartup(RuleEngine GlobalRules) .First .Do((viewer, room) => { - if (!String.IsNullOrEmpty(room.Short)) MudObject.SendMessage(viewer, room.Short); + if (!String.IsNullOrEmpty(room.GetProperty("Short"))) MudObject.SendMessage(viewer, room.GetProperty("Short")); return SharpRuleEngine.PerformResult.Continue; }) .Name("Display room name rule."); GlobalRules.Perform("describe locale") .First - .When((viewer, room) => (room as Room).Light == LightingLevel.Dark) + .When((viewer, room) => room.GetPropertyOrDefault("light", LightingLevel.Dark) == LightingLevel.Dark) .Do((viewer, room) => { MudObject.SendMessage(viewer, "@dark"); @@ -81,20 +81,17 @@ public static void AtStartup(RuleEngine GlobalRules) var describingLocale = false; - GlobalRules.Value("printed name") - .When((viewer, container, article) => - { - return describingLocale && (container.LocationsSupported & RelativeLocations.On) == RelativeLocations.On; - }) + GlobalRules.Value("printed name") + .When((viewer, container, article) => describingLocale && (container.LocationsSupported & RelativeLocations.On) == RelativeLocations.On) .Do((viewer, container, article) => { var subObjects = new List(container.EnumerateObjects(RelativeLocations.On) .Where(t => GlobalRules.ConsiderCheckRule("should be listed?", viewer, t) == SharpRuleEngine.CheckResult.Allow)); if (subObjects.Count > 0) - return container.Short + " " + Core.FormatMessage(viewer, Core.GetMessage("on which"), subObjects); + return container.GetProperty("Short") + " " + Core.FormatMessage(viewer, Core.GetMessage("on which"), subObjects); else - return container.Short; + return container.GetProperty("Short"); }) .Name("List contents of container after name when describing locale rule"); @@ -106,12 +103,12 @@ public static void AtStartup(RuleEngine GlobalRules) .Name("Don't list yourself rule."); GlobalRules.Check("should be listed in locale?") - .When((viewer, item) => item.GetBooleanProperty("scenery?")) + .When((viewer, item) => item.GetPropertyOrDefault("scenery?", false)) .Do((viewer, item) => SharpRuleEngine.CheckResult.Disallow) .Name("Don't list scenery objects rule."); GlobalRules.Check("should be listed in locale?") - .When((viewer, item) => item.GetBooleanProperty("portal?")) + .When((viewer, item) => item.GetPropertyOrDefault("portal?", false)) .Do((viewer, item) => SharpRuleEngine.CheckResult.Disallow) .Name("Don't list portals rule."); @@ -122,7 +119,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Perform("describe locale") .Do((viewer, room) => { - var visibleThings = (room as Room).EnumerateObjects(RelativeLocations.Contents) + var visibleThings = room.EnumerateObjects(RelativeLocations.Contents) .Where(t => GlobalRules.ConsiderCheckRule("should be listed in locale?", viewer, t) == SharpRuleEngine.CheckResult.Allow); var normalContents = new List(); @@ -149,11 +146,11 @@ public static void AtStartup(RuleEngine GlobalRules) .Last .Do((viewer, room) => { - if ((room as Room).EnumerateObjects().Where(l => l.GetBooleanProperty("portal?")).Count() > 0) + if (room.EnumerateObjects().Where(l => l.GetPropertyOrDefault("portal?",false)).Count() > 0) { MudObject.SendMessage(viewer, "@obvious exits"); - foreach (var link in (room as Room).EnumerateObjects().Where(l => l.GetBooleanProperty("portal?"))) + foreach (var link in room.EnumerateObjects().Where(l => l.GetPropertyOrDefault("portal?", false))) { var builder = new StringBuilder(); builder.Append(" ^"); @@ -162,7 +159,7 @@ public static void AtStartup(RuleEngine GlobalRules) if (!link.GetPropertyOrDefault("link anonymous?", false)) builder.Append(" " + Core.FormatMessage(viewer, Core.GetMessage("through"), link)); - var destinationRoom = MudObject.GetObject(link.GetProperty("link destination")) as Room; + var destinationRoom = MudObject.GetObject(link.GetProperty("link destination")); if (destinationRoom != null) builder.Append(" " + Core.FormatMessage(viewer, Core.GetMessage("to"), destinationRoom)); diff --git a/StandardActionsModule/LookUnderOrBehind.cs b/StandardActionsModule/LookUnderOrBehind.cs index d9b4353..13f9410 100644 --- a/StandardActionsModule/LookUnderOrBehind.cs +++ b/StandardActionsModule/LookUnderOrBehind.cs @@ -37,7 +37,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Name("Container must be visible rule."); GlobalRules.Check("can look relloc?") - .When((actor, item, relloc) => !(item is Container) || (((item as Container).LocationsSupported & relloc) != relloc)) + .When((actor, item, relloc) => (item.LocationsSupported & relloc) != relloc) .Do((actor, item, relloc) => { MudObject.SendMessage(actor, "@cant look relloc", Relloc.GetRelativeLocationName(relloc)); @@ -46,7 +46,7 @@ public static void AtStartup(RuleEngine GlobalRules) .Name("Container must support relloc rule."); GlobalRules.Check("can look relloc?") - .When((actor, item, relloc) => (relloc == RelativeLocations.In) && !item.GetBooleanProperty("open?")) + .When((actor, item, relloc) => (relloc == RelativeLocations.In) && !item.GetPropertyOrDefault("open?", false)) .Do((actor, item, relloc) => { MudObject.SendMessage(actor, "@is closed error", item); @@ -63,7 +63,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Perform("look relloc") .Do((actor, item, relloc) => { - var contents = new List((item as Container).EnumerateObjects(relloc)); + var contents = new List(item.EnumerateObjects(relloc)); if (contents.Count > 0) { diff --git a/StandardActionsModule/Open.cs b/StandardActionsModule/Open.cs index 8e14156..9bbc1f3 100644 --- a/StandardActionsModule/Open.cs +++ b/StandardActionsModule/Open.cs @@ -40,7 +40,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.DeclarePerformRuleBook("opened", "[Actor, Item] : Handle the actor opening the item.", "actor", "item"); GlobalRules.Check("can open?") - .When((actor, item) => !item.GetBooleanProperty("openable?")) + .When((actor, item) => !item.GetPropertyOrDefault("openable?", false)) .Do((a, b) => { MudObject.SendMessage(a, "@not openable"); diff --git a/StandardActionsModule/PushBetweenRooms.cs b/StandardActionsModule/PushBetweenRooms.cs index 618e1d7..9aa9f28 100644 --- a/StandardActionsModule/PushBetweenRooms.cs +++ b/StandardActionsModule/PushBetweenRooms.cs @@ -59,11 +59,10 @@ public override void Create(CommandParser Parser) { // The direction matched was stored in the match as "DIRECTION". var direction = match["DIRECTION"] as Direction?; - var location = actor.Location as Room; // Rooms have a collection of objects that are in them. Links happen to have two specific // properties set that we can use to find them: First, 'portal?' will be true, and // 'link direction' will hold the direction the link goes in. So we search for the link. - var link = location.EnumerateObjects().FirstOrDefault(thing => thing.GetPropertyOrDefault("portal?", false) && thing.GetPropertyOrDefault("link direction", Direction.NOWHERE) == direction.Value); + var link = actor.Location.EnumerateObjects().FirstOrDefault(thing => thing.GetPropertyOrDefault("portal?", false) && thing.GetPropertyOrDefault("link direction", Direction.NOWHERE) == direction.Value); // Store the link in the match, and later procedural rules will be able to find it. match.Upsert("LINK", link); // Procedural rules return PerformResults. If they return stop, the command stops right there. @@ -167,7 +166,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Perform("push direction") .Do((actor, subject, link) => { - var destination = MudObject.GetObject(link.GetProperty("link destination")) as Room; + var destination = MudObject.GetObject(link.GetProperty("link destination")); if (destination == null) { MudObject.SendMessage(actor, "@bad link"); diff --git a/StandardActionsModule/Put.cs b/StandardActionsModule/Put.cs index c5b35ac..c6124c6 100644 --- a/StandardActionsModule/Put.cs +++ b/StandardActionsModule/Put.cs @@ -24,7 +24,7 @@ public override void Create(CommandParser Parser) { //Prefer objects that are actually containers. No means curently to prefer //objects that actually support the relloc we matched previously. - if (thing is Container) return MatchPreference.Likely; + if (thing.GetPropertyOrDefault("container?", false)) return MatchPreference.Likely; return MatchPreference.Plausible; }))))) .ID("StandardActions:Put") @@ -33,8 +33,8 @@ public override void Create(CommandParser Parser) { if (!match.ContainsKey("RELLOC")) { - if (match["OBJECT"] is Container) - match.Upsert("RELLOC", (match["OBJECT"] as Container).DefaultLocation); + if ((match["OBJECT"] as MudObject).GetPropertyOrDefault("container?", false)) + match.Upsert("RELLOC", (match["OBJECT"] as MudObject).DefaultLocation); else match.Upsert("RELLOC", RelativeLocations.On); } @@ -65,7 +65,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Check("can put?") .Do((actor, item, container, relloc) => { - if (!(container is Container)) + if (!(container.GetPropertyOrDefault("container?", false))) { MudObject.SendMessage(actor, "@cant put relloc", Relloc.GetRelativeLocationName(relloc)); return CheckResult.Disallow; @@ -96,8 +96,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Check("can put?") .Do((actor, item, container, relloc) => { - var c = container as Container; - if (c == null || (c.LocationsSupported & relloc) != relloc) + if ((container.LocationsSupported & relloc) != relloc) { MudObject.SendMessage(actor, "@cant put relloc", Relloc.GetRelativeLocationName(relloc)); return CheckResult.Disallow; @@ -109,7 +108,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Check("can put?") .Do((actor, item, container, relloc) => { - if (relloc == RelativeLocations.In && !container.GetBooleanProperty("open?")) + if (relloc == RelativeLocations.In && !container.GetPropertyOrDefault("open?", false)) { MudObject.SendMessage(actor, "@is closed error", container); return CheckResult.Disallow; diff --git a/StandardActionsModule/Take.cs b/StandardActionsModule/Take.cs index d19ee84..bb2c8ce 100644 --- a/StandardActionsModule/Take.cs +++ b/StandardActionsModule/Take.cs @@ -49,7 +49,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Name("Item must be visible to take rule."); GlobalRules.Check("can take?") - .When((actor, item) => actor is Container && (actor as Container).Contains(item, RelativeLocations.Held)) + .When((actor, item) => actor.Contains(item, RelativeLocations.Held)) .Do((actor, item) => { MudObject.SendMessage(actor, "@already have that"); @@ -93,7 +93,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Check("can take?") .First - .When((actor, thing) => thing.GetBooleanProperty("scenery?")) + .When((actor, thing) => thing.GetPropertyOrDefault("scenery?", false)) .Do((actor, thing) => { MudObject.SendMessage(actor, "@cant take scenery"); From 9d0e7f6411799a201f9c17ec479300ec01241540 Mon Sep 17 00:00:00 2001 From: Blecki Date: Mon, 22 Feb 2016 00:34:10 -0500 Subject: [PATCH 16/20] Switch to central property register --- AdminModule/Force.cs | 11 +- AdminModule/Rules.cs | 6 +- AdminModule/Scope.cs | 2 +- AdminModule/Sonar.cs | 12 +- AliasModule/Alias.cs | 9 +- ChatModule/ChatChannel.cs | 10 +- ChatModule/ChatChannelRules.cs | 8 +- ChatModule/Commands.cs | 10 +- ClothingModule/Clothing.cs | 14 +- ClothingModule/NPCExtension.cs | 4 +- ClothingModule/Remove.cs | 2 +- ClothingModule/Rules.cs | 24 ++-- ClothingModule/Wear.cs | 5 +- ConversationModule/Commands.cs | 18 ++- ConversationModule/NPCExtension.cs | 4 +- ConversationModule/Rules.cs | 34 +++-- ConversationModule/Settings.cs | 4 +- ConversationModule/TopicObjectSource.cs | 10 +- Core/Core.csproj | 12 +- Core/Core/Client.cs | 2 +- Core/Core/CommandQueue.cs | 21 +-- Core/Core/ExecuteCommand.cs | 12 +- Core/Core/FindLocale.cs | 2 +- Core/Core/FormatMessage.cs | 8 +- Core/Core/MarkForUpdate.cs | 4 +- Core/Core/MudCore.cs | 18 +-- Core/Core/Parser/CommandEntry.cs | 18 +-- Core/Core/Parser/DisambigCommandHandler.cs | 6 +- Core/Core/Parser/MatchContext.cs | 2 +- Core/Core/Parser/Matchers/ObjectMatcher.cs | 27 ++-- Core/Core/Parser/Matchers/RankGate.cs | 2 +- Core/Core/Parser/ParserCommandHandler.cs | 4 +- Core/Core/Rules/RuleEngine.cs | 4 +- Core/Core/SendMessage.cs | 49 +++---- Core/Core/WorldDataService.cs | 14 +- Core/SinglePlayer/Driver.cs | 21 +-- Core/WorldModel/Actor.cs | 26 ---- Core/WorldModel/BasicDoor.cs | 10 +- Core/WorldModel/EnumerateObjectTree.cs | 2 +- Core/WorldModel/LockedDoor.cs | 2 +- Core/WorldModel/MudObject.cs | 123 +++++------------- Core/WorldModel/MudObjectProperty.cs | 32 ----- Core/WorldModel/MudObjectRules.cs | 2 +- Core/WorldModel/NPC.cs | 12 -- Core/WorldModel/NounList.cs | 20 +-- Core/WorldModel/ObjectDecorators/Actor.cs | 35 +++++ .../{ => ObjectDecorators}/Container.cs | 11 +- Core/WorldModel/ObjectDecorators/Room.cs | 45 +++++++ Core/WorldModel/ObjectDecorators/Scenery.cs | 36 +++++ Core/WorldModel/Player.cs | 55 -------- Core/WorldModel/Portal.cs | 14 +- Core/WorldModel/PropertyManifest.cs | 45 +++++++ Core/WorldModel/Room.cs | 60 --------- Core/WorldModel/RoomLightingRules.cs | 6 +- Delmud/delmud_db/static/player_base.cs | 7 +- Delmud/delmud_db/static/start.cs | 2 +- DelmudGameplay/DelmudGameplay.csproj | 1 - DelmudGameplay/Player.cs | 31 ----- IntroductionModule/Implementation.cs | 60 +++++---- NetworkModule/Account.cs | 2 +- NetworkModule/Accounts.cs | 8 +- NetworkModule/Afk.cs | 10 +- NetworkModule/Clients.cs | 8 +- NetworkModule/Kick.cs | 13 +- NetworkModule/Login.cs | 12 +- NetworkModule/LoginCommandHandler.cs | 11 +- NetworkModule/PasswordCommandHandler.cs | 8 +- NetworkModule/Quit.cs | 10 +- NetworkModule/Register.cs | 10 +- NetworkModule/Stats.cs | 4 +- NetworkModule/Whisper.cs | 7 +- NetworkModule/Who.cs | 2 +- QuestModule/QuestRules.cs | 7 +- QuestModule/TypeExtensions.cs | 9 +- SillyModule/Silly.cs | 10 +- SinglePlayer/Bar.cs | 8 +- SinglePlayer/Cloak.cs | 6 +- SinglePlayer/Cloakroom.cs | 6 +- SinglePlayer/Foyer.cs | 4 +- SinglePlayer/Game.cs | 6 +- SinglePlayer/Outside.cs | 2 +- SinglePlayer/Player.cs | 5 +- SinglePlayer/settings.cs | 6 +- SinglePlayerMinimumGame/Game.cs | 6 +- SinglePlayerMinimumGame/Player.cs | 6 +- SinglePlayerMinimumGame/Start.cs | 4 +- StandardActionsModule/Close.cs | 2 +- StandardActionsModule/DescribeRules.cs | 15 ++- StandardActionsModule/Drop.cs | 2 +- StandardActionsModule/Go.cs | 14 +- StandardActionsModule/Inventory.cs | 4 +- StandardActionsModule/Lock.cs | 4 +- StandardActionsModule/Look.cs | 24 ++-- StandardActionsModule/LookUnderOrBehind.cs | 2 +- StandardActionsModule/MiscRules.cs | 2 +- StandardActionsModule/Open.cs | 5 +- StandardActionsModule/Pull.cs | 3 +- StandardActionsModule/PushBetweenRooms.cs | 9 +- StandardActionsModule/Put.cs | 8 +- StandardActionsModule/Take.cs | 6 +- 100 files changed, 653 insertions(+), 687 deletions(-) delete mode 100644 Core/WorldModel/Actor.cs delete mode 100644 Core/WorldModel/MudObjectProperty.cs delete mode 100644 Core/WorldModel/NPC.cs create mode 100644 Core/WorldModel/ObjectDecorators/Actor.cs rename Core/WorldModel/{ => ObjectDecorators}/Container.cs (93%) create mode 100644 Core/WorldModel/ObjectDecorators/Room.cs create mode 100644 Core/WorldModel/ObjectDecorators/Scenery.cs delete mode 100644 Core/WorldModel/Player.cs create mode 100644 Core/WorldModel/PropertyManifest.cs delete mode 100644 Core/WorldModel/Room.cs delete mode 100644 DelmudGameplay/Player.cs diff --git a/AdminModule/Force.cs b/AdminModule/Force.cs index fc765b3..f99930b 100644 --- a/AdminModule/Force.cs +++ b/AdminModule/Force.cs @@ -38,15 +38,8 @@ public override void Create(CommandParser Parser) { 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 SharpRuleEngine.PerformResult.Stop; - } - var command = match["RAW-COMMAND"].ToString(); - var matchedCommand = Core.DefaultParser.ParseCommand(new PendingCommand { RawCommand = command, Actor = targetActor }); + var matchedCommand = Core.DefaultParser.ParseCommand(new PendingCommand { RawCommand = command, Actor = target }); if (matchedCommand != null) { @@ -55,7 +48,7 @@ public override void Create(CommandParser Parser) else { MudObject.SendMessage(actor, "Enacting your will."); - Core.ProcessPlayerCommand(matchedCommand.Command, matchedCommand.Matches[0], targetActor); + Core.ProcessPlayerCommand(matchedCommand.Command, matchedCommand.Matches[0], target); } } else diff --git a/AdminModule/Rules.cs b/AdminModule/Rules.cs index 46dea77..179a415 100644 --- a/AdminModule/Rules.cs +++ b/AdminModule/Rules.cs @@ -35,7 +35,7 @@ public override void Create(CommandParser Parser) }); } - private static void DisplaySingleBook(Actor Actor, RuleSet From, String BookName) + private static void DisplaySingleBook(MudObject Actor, RuleSet From, String BookName) { if (From == null || From.FindRuleBook(BookName) == null) MudObject.SendMessage(Actor, "[no rules]"); @@ -48,12 +48,12 @@ private static void DisplaySingleBook(Actor Actor, RuleSet From, String BookName } } - private static void DisplayBookHeader(Actor Actor, RuleBook Book) + private static void DisplayBookHeader(MudObject Actor, RuleBook Book) { MudObject.SendMessage(Actor, Book.Name + " -> " + Book.ResultType.Name + " : " + Book.Description); } - private static void DisplayBookList(Actor Actor, RuleSet Rules) + private static void DisplayBookList(MudObject Actor, RuleSet Rules) { if (Rules == null || Rules.RuleBooks.Count == 0) MudObject.SendMessage(Actor, "[no rules]"); diff --git a/AdminModule/Scope.cs b/AdminModule/Scope.cs index 2619fae..f9dee91 100644 --- a/AdminModule/Scope.cs +++ b/AdminModule/Scope.cs @@ -18,7 +18,7 @@ public override void Create(CommandParser Parser) .ProceduralRule((match, actor) => { foreach (var thing in MudObject.EnumerateVisibleTree(MudObject.FindLocale(actor))) - MudObject.SendMessage(actor, thing.GetProperty("Short") + " - " + thing.GetType().Name); + MudObject.SendMessage(actor, thing.GetProperty("short") + " - " + thing.GetType().Name); return SharpRuleEngine.PerformResult.Continue; }, "List all the damn things in scope rule."); } diff --git a/AdminModule/Sonar.cs b/AdminModule/Sonar.cs index c173629..3fa44eb 100644 --- a/AdminModule/Sonar.cs +++ b/AdminModule/Sonar.cs @@ -69,11 +69,11 @@ private static int FindSymbol(RMUD.MudObject Location) { if (Location == null) return '?'; - var spacer = Location.GetProperty("Short").LastIndexOf('-'); - if (spacer > 0 && spacer < Location.GetProperty("Short").Length - 2) - return Location.GetProperty("Short").ToUpper()[spacer + 2]; + var spacer = Location.GetProperty("short").LastIndexOf('-'); + if (spacer > 0 && spacer < Location.GetProperty("short").Length - 2) + return Location.GetProperty("short").ToUpper()[spacer + 2]; else - return Location.GetProperty("Short").ToUpper()[0]; + return Location.GetProperty("short").ToUpper()[0]; } private static void MapLocation(int[,] MapGrid, Dictionary RoomLegend, int X, int Y, RMUD.MudObject Location, int Symbol) @@ -84,7 +84,7 @@ private static void MapLocation(int[,] MapGrid, Dictionary RoomLege if (Symbol == ' ') Symbol = FindSymbol(Location); - if (Location != null) RoomLegend.Upsert(Symbol, Location.GetProperty("Short")); + if (Location != null) RoomLegend.Upsert(Symbol, Location.GetProperty("short")); PlaceSymbol(MapGrid, X, Y, Symbol); PlaceSymbol(MapGrid, X - 2, Y - 1, '+'); @@ -108,7 +108,7 @@ private static void MapLocation(int[,] MapGrid, Dictionary RoomLege { var destinationName = link.GetProperty("link destination"); var destination = MudObject.GetObject(destinationName); - var direction = link.GetPropertyOrDefault("link direction", RMUD.Direction.NORTH); + var direction = link.GetPropertyOrDefault("link direction"); if (direction == Direction.UP) { diff --git a/AliasModule/Alias.cs b/AliasModule/Alias.cs index 3d61933..fba3566 100644 --- a/AliasModule/Alias.cs +++ b/AliasModule/Alias.cs @@ -8,6 +8,11 @@ namespace AliasModule { internal class Alias : CommandFactory { + public static void AtStartup(RMUD.RuleEngine GlobalRules) + { + PropertyManifest.RegisterProperty("aliases", typeof(Dictionary), null); + } + public override void Create(CommandParser Parser) { Parser.AddCommand( @@ -18,7 +23,7 @@ public override void Create(CommandParser Parser) .Manual("Create an alias for another command, or a series of them.") .ProceduralRule((match, actor) => { - if (!actor.HasProperty>("aliases")) + if (!actor.HasProperty("aliases")) actor.SetProperty("aliases", new Dictionary()); var aliases = actor.GetProperty>("aliases"); aliases.Add(match["NAME"].ToString().ToUpper(), match["RAW-COMMAND"].ToString()); @@ -30,7 +35,7 @@ public override void Create(CommandParser Parser) Generic((match, context) => { var r = new List(); - if (!context.ExecutingActor.HasProperty>("aliases")) + if (!context.ExecutingActor.HasProperty("aliases")) return r; var aliases = context.ExecutingActor.GetProperty>("aliases"); if (aliases.ContainsKey(match.Next.Value.ToUpper())) diff --git a/ChatModule/ChatChannel.cs b/ChatModule/ChatChannel.cs index e40fecb..7770687 100644 --- a/ChatModule/ChatChannel.cs +++ b/ChatModule/ChatChannel.cs @@ -8,11 +8,11 @@ namespace ChatModule { public class ChatChannel : MudObject { - public List Subscribers = new List(); + public List Subscribers = new List(); public ChatChannel(String Short) : base(Short, "") { - SetProperty("Article", ""); + SetProperty("article", ""); } internal static List ChatChannels = new List(); @@ -28,12 +28,12 @@ public static void SendChatMessage(ChatChannel Channel, String Message) { var realMessage = String.Format("{0} : {1}", DateTime.Now, Message); - var chatLogFilename = ChatChannel.ChatLogsPath + Channel.GetProperty("Short") + ".txt"; + var chatLogFilename = ChatChannel.ChatLogsPath + Channel.GetProperty("short") + ".txt"; System.IO.Directory.CreateDirectory(ChatChannel.ChatLogsPath); System.IO.File.AppendAllText(chatLogFilename, realMessage + "\n"); - foreach (var client in Channel.Subscribers.Where(c => c.ConnectedClient != null)) - MudObject.SendMessage(client, realMessage); + foreach (var client in Channel.Subscribers) + SendMessage(client, realMessage); } } } diff --git a/ChatModule/ChatChannelRules.cs b/ChatModule/ChatChannelRules.cs index 43f37e0..4898296 100644 --- a/ChatModule/ChatChannelRules.cs +++ b/ChatModule/ChatChannelRules.cs @@ -16,16 +16,16 @@ public static void AtStartup(RuleEngine GlobalRules) .Do((client, channel) => SharpRuleEngine.CheckResult.Allow) .Name("Default allow channel access rule."); - GlobalRules.Perform("player joined") + GlobalRules.Perform("player joined") .Do(player => { - foreach (var c in ChatChannel.ChatChannels.Where(c => c.GetProperty("Short") == "OOC")) + foreach (var c in ChatChannel.ChatChannels.Where(c => c.GetProperty("short") == "OOC")) c.Subscribers.Add(player); return SharpRuleEngine.PerformResult.Continue; }) .Name("Subscribe new players to OOC rule."); - GlobalRules.Perform("player left") + GlobalRules.Perform("player left") .Do(player => { ChatChannel.RemoveFromAllChannels(player); @@ -39,7 +39,7 @@ public static void AtStartup(RuleEngine GlobalRules) var senate = new ChatChannel("SENATE"); senate.Check("can access channel?") - .When((actor, channel) => !(actor is Actor) || (actor as Actor).Rank < 100) + .When((actor, channel) => actor.GetPropertyOrDefault("rank") < 100) .Do((actor, channel) => { MudObject.SendMessage(actor, "You must have a rank of 100 or greater to access this channel."); diff --git a/ChatModule/Commands.cs b/ChatModule/Commands.cs index 5bfd2fa..a7f8a01 100644 --- a/ChatModule/Commands.cs +++ b/ChatModule/Commands.cs @@ -36,7 +36,7 @@ public override void Create(CommandParser Parser) .ProceduralRule((match, actor) => { var channel = match.ValueOrDefault("CHANNEL") as ChatChannel; - channel.Subscribers.RemoveAll(c => System.Object.ReferenceEquals(c, actor.ConnectedClient)); + channel.Subscribers.RemoveAll(c => System.Object.ReferenceEquals(c, actor)); MudObject.SendMessage(actor, "You are now unsubscribed from .", channel); return PerformResult.Continue; }); @@ -48,7 +48,7 @@ public override void Create(CommandParser Parser) { MudObject.SendMessage(actor, "~~ CHANNELS ~~"); foreach (var channel in ChatChannel.ChatChannels) - MudObject.SendMessage(actor, (channel.Subscribers.Contains(actor) ? "*" : "") + channel.GetProperty("Short")); + MudObject.SendMessage(actor, (channel.Subscribers.Contains(actor) ? "*" : "") + channel.GetProperty("short")); return PerformResult.Continue; }); @@ -60,7 +60,6 @@ public override void Create(CommandParser Parser) .Manual("Chat on a chat channel.") .ProceduralRule((match, actor) => { - if (actor.ConnectedClient == null) return PerformResult.Stop; var channel = match.ValueOrDefault("CHANNEL") as ChatChannel; if (!channel.Subscribers.Contains(actor)) { @@ -76,7 +75,7 @@ public override void Create(CommandParser Parser) { var message = match["TEXT"].ToString(); var channel = match.ValueOrDefault("CHANNEL") as ChatChannel; - ChatChannel.SendChatMessage(channel, "[" + channel.GetProperty("Short") + "] " + actor.GetProperty("Short") + + ChatChannel.SendChatMessage(channel, "[" + channel.GetProperty("short") + "] " + actor.GetProperty("short") + (message.StartsWith("\"") ? (" " + message.Substring(1).Trim()) : (": \"" + message + "\""))); @@ -94,13 +93,12 @@ public override void Create(CommandParser Parser) .Check("can access channel?", "ACTOR", "CHANNEL") .ProceduralRule((match, actor) => { - if (actor.ConnectedClient == null) return PerformResult.Stop; var channel = match.ValueOrDefault("CHANNEL") as ChatChannel; int count = 20; if (match.ContainsKey("COUNT")) count = (match["COUNT"] as int?).Value; - var logFilename = ChatChannel.ChatLogsPath + channel.GetProperty("Short") + ".txt"; + var logFilename = ChatChannel.ChatLogsPath + channel.GetProperty("short") + ".txt"; if (System.IO.File.Exists(logFilename)) foreach (var line in (new RMUD.ReverseLineReader(logFilename)).Take(count).Reverse()) MudObject.SendMessage(actor, line); diff --git a/ClothingModule/Clothing.cs b/ClothingModule/Clothing.cs index e0d8488..9de13cd 100644 --- a/ClothingModule/Clothing.cs +++ b/ClothingModule/Clothing.cs @@ -39,12 +39,18 @@ public static RMUD.MudObject Create(String Short, ClothingLayer Layer, ClothingB return r; } - public static void Clothing(this RMUD.MudObject MudObject, ClothingLayer Layer, ClothingBodyPart BodyPart) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { - MudObject.UpsertProperty("clothing layer", Layer); - MudObject.UpsertProperty("clothing part", BodyPart); - MudObject.UpsertProperty("wearable?", true); + RMUD.PropertyManifest.RegisterProperty("clothing layer", typeof(ClothingLayer), ClothingLayer.Outer); + RMUD.PropertyManifest.RegisterProperty("clothing part", typeof(ClothingBodyPart), ClothingBodyPart.Cloak); + RMUD.PropertyManifest.RegisterProperty("wearable?", typeof(bool), false); + } + public static void Clothing(this RMUD.MudObject MudObject, ClothingLayer Layer, ClothingBodyPart BodyPart) + { + MudObject.SetProperty("clothing layer", Layer); + MudObject.SetProperty("clothing part", BodyPart); + MudObject.SetProperty("wearable?", true); } } } diff --git a/ClothingModule/NPCExtension.cs b/ClothingModule/NPCExtension.cs index cf67d89..2c5c4b9 100644 --- a/ClothingModule/NPCExtension.cs +++ b/ClothingModule/NPCExtension.cs @@ -8,12 +8,12 @@ namespace ClothingModule { public static class NPCExtension { - public static void Wear(this NPC NPC, MudObject Item) + public static void Wear(this MudObject NPC, MudObject Item) { MudObject.Move(Item, NPC, RelativeLocations.Worn); } - public static void Wear(this NPC NPC, String Short, ClothingLayer Layer, ClothingBodyPart BodyPart) + public static void Wear(this MudObject NPC, String Short, ClothingLayer Layer, ClothingBodyPart BodyPart) { Wear(NPC, Factory.Create(Short, Layer, BodyPart)); } diff --git a/ClothingModule/Remove.cs b/ClothingModule/Remove.cs index 67a9e39..299b199 100644 --- a/ClothingModule/Remove.cs +++ b/ClothingModule/Remove.cs @@ -30,7 +30,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.DeclarePerformRuleBook("removed", "[Actor, Item] : Handle the actor removing the item.", "actor", "item"); GlobalRules.Check("can remove?") - .When((a, b) => !(a is Actor) || !(a as Actor).Contains(b, RelativeLocations.Worn)) + .When((a, b) => !a.Contains(b, RelativeLocations.Worn)) .Do((actor, item) => { MudObject.SendMessage(actor, "@clothing not wearing"); diff --git a/ClothingModule/Rules.cs b/ClothingModule/Rules.cs index 51845cb..e0f223c 100644 --- a/ClothingModule/Rules.cs +++ b/ClothingModule/Rules.cs @@ -12,10 +12,10 @@ public class ClothingRules { public static void AtStartup(RMUD.RuleEngine GlobalRules) { - GlobalRules.Perform("inventory") + GlobalRules.Perform("inventory") .Do(a => { - var wornObjects = (a as Actor).GetContents(RelativeLocations.Worn); + var wornObjects = a.GetContents(RelativeLocations.Worn); if (wornObjects.Count == 0) MudObject.SendMessage(a, "@nude"); else { @@ -27,13 +27,14 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) }) .Name("List worn items in inventory rule."); - GlobalRules.Check("can wear?") + GlobalRules.Check("can wear?") + .When((actor, item) => actor.GetPropertyOrDefault("actor?")) .Do((actor, item) => { - var layer = item.GetPropertyOrDefault("clothing layer", ClothingLayer.Assecories); - var part = item.GetPropertyOrDefault("clothing part", ClothingBodyPart.Cloak); + var layer = item.GetPropertyOrDefault("clothing layer"); + var part = item.GetPropertyOrDefault("clothing part"); foreach (var wornItem in actor.EnumerateObjects(RelativeLocations.Worn)) - if (wornItem.GetPropertyOrDefault("clothing layer", ClothingLayer.Assecories) == layer && wornItem.GetPropertyOrDefault("clothing part", ClothingBodyPart.Cloak) == part) + if (wornItem.GetPropertyOrDefault("clothing layer") == layer && wornItem.GetPropertyOrDefault("clothing part") == part) { MudObject.SendMessage(actor, "@clothing remove first", wornItem); return CheckResult.Disallow; @@ -42,13 +43,13 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) }) .Name("Check clothing layering before wearing rule."); - GlobalRules.Check("can remove?") + GlobalRules.Check("can remove?") .Do((actor, item) => { - var layer = item.GetPropertyOrDefault("clothing layer", ClothingLayer.Assecories); - var part = item.GetPropertyOrDefault("clothing part", ClothingBodyPart.Cloak); + var layer = item.GetPropertyOrDefault("clothing layer"); + var part = item.GetPropertyOrDefault("clothing part"); foreach (var wornItem in actor.EnumerateObjects(RelativeLocations.Worn)) - if (wornItem.GetPropertyOrDefault("clothing layer", ClothingLayer.Assecories) < layer && wornItem.GetPropertyOrDefault("clothing part", ClothingBodyPart.Cloak) == part) + if (wornItem.GetPropertyOrDefault("clothing layer") < layer && wornItem.GetPropertyOrDefault("clothing part") == part) { MudObject.SendMessage(actor, "@clothing remove first", wornItem); return CheckResult.Disallow; @@ -58,8 +59,9 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .Name("Can't remove items under other items rule."); - GlobalRules.Perform("describe") + GlobalRules.Perform("describe") .First + .When((viewer, actor) => actor.GetPropertyOrDefault("actor?")) .Do((viewer, actor) => { var wornItems = actor.GetContents(RelativeLocations.Worn); diff --git a/ClothingModule/Wear.cs b/ClothingModule/Wear.cs index a2a46f1..cb0def6 100644 --- a/ClothingModule/Wear.cs +++ b/ClothingModule/Wear.cs @@ -38,7 +38,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) }); GlobalRules.Check("can wear?") - .When((a, b) => a is Actor && (a as Actor).RelativeLocationOf(b) == RelativeLocations.Worn) + .When((a, b) => a.RelativeLocationOf(b) == RelativeLocations.Worn) .Do((a, b) => { MudObject.SendMessage(a, "@clothing already wearing"); @@ -46,7 +46,8 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) }); GlobalRules.Check("can wear?") - .When((actor, item) => !item.GetPropertyOrDefault("wearable?", false)) + .When((actor, item) => !item.GetPropertyOrDefault("wearable?")) + .When((actor, item) => !actor.GetPropertyOrDefault("actor?")) .Do((actor, item) => { MudObject.SendMessage(actor, "@clothing cant wear"); diff --git a/ConversationModule/Commands.cs b/ConversationModule/Commands.cs index 8ec8a75..ea95133 100644 --- a/ConversationModule/Commands.cs +++ b/ConversationModule/Commands.cs @@ -19,7 +19,7 @@ public override void Create(CommandParser Parser) MustMatch("@convo greet whom", Object("LOCUTOR", InScope, (actor, thing) => { - if (thing is NPC) return MatchPreference.VeryLikely; + if (thing.GetPropertyOrDefault("actor?")) return MatchPreference.VeryLikely; else return MatchPreference.VeryUnlikely; })))) .ID("Conversation:Greet") @@ -30,8 +30,7 @@ public override void Create(CommandParser Parser) .AfterActing() .ProceduralRule((match, actor) => { - if (actor is Player) - actor.SetProperty("interlocutor", match["LOCUTOR"] as NPC); + actor.SetProperty("interlocutor", match["LOCUTOR"] as MudObject); return PerformResult.Continue; }, "Set current interlocutor rule.") .Perform("list topics", "ACTOR"); @@ -46,8 +45,8 @@ public override void Create(CommandParser Parser) Sequence( Object("NEW-LOCUTOR", InScope, (actor, thing) => { - if (actor is Player && System.Object.ReferenceEquals(thing, actor.GetProperty("interlocutor"))) return MatchPreference.VeryLikely; - if (thing is NPC) return MatchPreference.Likely; + if (System.Object.ReferenceEquals(thing, actor.GetPropertyOrDefault("interlocutor"))) return MatchPreference.VeryLikely; + if (thing.GetPropertyOrDefault("actor?")) return MatchPreference.Likely; return MatchPreference.VeryUnlikely; }), OptionalKeyWord("ABOUT"), @@ -60,23 +59,22 @@ public override void Create(CommandParser Parser) .BeforeActing() .ProceduralRule((match, actor) => { - if (!(actor is Player)) return PerformResult.Stop; if (match.ContainsKey("NEW-LOCUTOR")) { var newLocutor = match["NEW-LOCUTOR"] as MudObject; if (Core.GlobalRules.ConsiderCheckRule("can converse?", actor, newLocutor) == CheckResult.Disallow) return PerformResult.Stop; - if (!System.Object.ReferenceEquals(newLocutor, actor.GetProperty("interlocutor"))) + if (!System.Object.ReferenceEquals(newLocutor, actor.GetPropertyOrDefault("interlocutor"))) { Core.GlobalRules.ConsiderPerformRule("greet", actor, newLocutor); - actor.SetProperty("interlocutor", newLocutor as NPC); + actor.SetProperty("interlocutor", newLocutor); } } - match.Upsert("LOCUTOR", actor.GetProperty("interlocutor")); + match.Upsert("LOCUTOR", actor.GetProperty("interlocutor")); return PerformResult.Continue; }, "Implicitly greet new locutors rule.") .ProceduralRule((match, actor) => { - if (actor.GetProperty("interlocutor") == null) + if (actor.GetPropertyOrDefault("interlocutor") == null) { MudObject.SendMessage(actor, "@convo nobody"); return PerformResult.Stop; diff --git a/ConversationModule/NPCExtension.cs b/ConversationModule/NPCExtension.cs index 8155367..0e09f1e 100644 --- a/ConversationModule/NPCExtension.cs +++ b/ConversationModule/NPCExtension.cs @@ -11,7 +11,7 @@ public class Topic : MudObject { public Topic() { - SetProperty("Article", ""); + SetProperty("article", ""); } public Topic Available(Func Func, String Name = "") @@ -32,7 +32,7 @@ public Topic Available(Func Func, String Name = "") public bool Discussed { - get { return this.GetPropertyOrDefault("topic-discussed", false); } + get { return this.GetPropertyOrDefault("topic-discussed"); } } public Topic Follows(Topic Previous) diff --git a/ConversationModule/Rules.cs b/ConversationModule/Rules.cs index 1c8ce33..40f731f 100644 --- a/ConversationModule/Rules.cs +++ b/ConversationModule/Rules.cs @@ -11,6 +11,10 @@ public class ConversationRules { public static void AtStartup(RMUD.RuleEngine GlobalRules) { + PropertyManifest.RegisterProperty("interlocutor", typeof(MudObject), null); + PropertyManifest.RegisterProperty("conversation-topics", typeof(List), new List()); + PropertyManifest.RegisterProperty("topic-discussed", typeof(bool), false); + Core.StandardMessage("convo topic prompt", "Suggested topics: "); Core.StandardMessage("convo cant converse", "You can't converse with that."); Core.StandardMessage("convo greet whom", "Whom did you want to greet?"); @@ -21,7 +25,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.DeclareCheckRuleBook("can converse?", "[Actor, Item] : Can the actor converse with the item?", "actor", "item"); GlobalRules.Check("can converse?") - .When((actor, item) => !(item is NPC)) + .When((actor, item) => !item.GetPropertyOrDefault("actor?")) .Do((actor, item) => { MudObject.SendMessage(actor, "@convo cant converse"); @@ -43,7 +47,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.DeclarePerformRuleBook("list topics", "[Actor] : List conversation topics available to the actor.", "actor"); GlobalRules.Perform("list topics") - .When(actor => !(actor is Player) || actor.GetProperty("interlocutor") == null) + .When(actor => actor.GetPropertyOrDefault("interlocutor") == null) .Do(actor => { MudObject.SendMessage(actor, "@convo nobody"); @@ -54,21 +58,23 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Perform("list topics") .Do(actor => { - if (!(actor is Player)) return PerformResult.Stop; - var npc = actor.GetProperty("interlocutor"); - var suggestedTopics = npc.GetPropertyOrDefault>("conversation-topics", new List()).AsEnumerable(); + var npc = actor.GetPropertyOrDefault("interlocutor"); + if (npc != null) + { + var suggestedTopics = npc.GetPropertyOrDefault>("conversation-topics").AsEnumerable(); - if (!Settings.ListDiscussedTopics) - suggestedTopics = suggestedTopics.Where(obj => !obj.GetPropertyOrDefault("topic-discussed", false)); + if (!Settings.ListDiscussedTopics) + suggestedTopics = suggestedTopics.Where(obj => !obj.GetPropertyOrDefault("topic-discussed")); - suggestedTopics = suggestedTopics.Where(topic => GlobalRules.ConsiderCheckRule("topic available?", actor, npc, topic) == CheckResult.Allow); + suggestedTopics = suggestedTopics.Where(topic => GlobalRules.ConsiderCheckRule("topic available?", actor, npc, topic) == CheckResult.Allow); - var enumeratedSuggestedTopics = new List(suggestedTopics); + var enumeratedSuggestedTopics = new List(suggestedTopics); - if (enumeratedSuggestedTopics.Count != 0) - MudObject.SendMessage(actor, "@convo topic prompt", enumeratedSuggestedTopics); - else - GlobalRules.ConsiderPerformRule("no topics to discuss", actor, npc); + if (enumeratedSuggestedTopics.Count != 0) + MudObject.SendMessage(actor, "@convo topic prompt", enumeratedSuggestedTopics); + else + GlobalRules.ConsiderPerformRule("no topics to discuss", actor, npc); + } return PerformResult.Continue; }) @@ -109,7 +115,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) GlobalRules.Check("topic available?") .First - .When((actor, npc, topic) => (topic != null) && (Settings.AllowRepeats == false) && topic.GetPropertyOrDefault("topic-discussed", false)) + .When((actor, npc, topic) => (topic != null) && (Settings.AllowRepeats == false) && topic.GetPropertyOrDefault("topic-discussed")) .Do((actor, npc, topic) => CheckResult.Disallow) .Name("Already discussed topics unavailable when repeats disabled rule."); diff --git a/ConversationModule/Settings.cs b/ConversationModule/Settings.cs index 45cade5..449df7a 100644 --- a/ConversationModule/Settings.cs +++ b/ConversationModule/Settings.cs @@ -8,7 +8,7 @@ namespace ConversationModule { public class Settings { - public static bool ListDiscussedTopics;// = true; - public static bool AllowRepeats;// = true; + public static bool ListDiscussedTopics = true; + public static bool AllowRepeats = true; } } diff --git a/ConversationModule/TopicObjectSource.cs b/ConversationModule/TopicObjectSource.cs index e3103ca..a439b31 100644 --- a/ConversationModule/TopicObjectSource.cs +++ b/ConversationModule/TopicObjectSource.cs @@ -18,14 +18,14 @@ public TopicSource(String LocutorArgument) public List GetObjects(PossibleMatch State, MatchContext Context) { - NPC source = null; + MudObject source = null; if (!String.IsNullOrEmpty(LocutorArgument)) - source = State[LocutorArgument] as NPC; - else if (Context.ExecutingActor.HasProperty("interlocutor")) - source = Context.ExecutingActor.GetProperty("interlocutor"); + source = State[LocutorArgument] as MudObject; + else if (Context.ExecutingActor.HasProperty("interlocutor")) + source = Context.ExecutingActor.GetProperty("interlocutor"); if (source != null) - if (source.HasProperty>("conversation-topics")) + if (source.HasProperty("conversation-topics")) return new List(source.GetProperty>("conversation-topics").Where(t => Core.GlobalRules.ConsiderCheckRuleSilently("topic available?", Context.ExecutingActor, source, t) == SharpRuleEngine.CheckResult.Allow)); return new List(); diff --git a/Core/Core.csproj b/Core/Core.csproj index 8fb7ec9..ef358f8 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -133,23 +133,22 @@ - + - + - - - + - + + @@ -164,6 +163,7 @@ + + --> \ No newline at end of file diff --git a/Delmud/delmud_db/static/area/beginning/secondroom.cs b/Delmud/delmud_db/static/area/beginning/secondroom.cs new file mode 100644 index 0000000..3b4fe75 --- /dev/null +++ b/Delmud/delmud_db/static/area/beginning/secondroom.cs @@ -0,0 +1,13 @@ +public class secondroom : MudObject +{ + public override void Initialize() + { + Room(RoomType.Interior); + + SetProperty("short", "The Second Room"); + SetProperty("ambient light", LightingLevel.Bright); + OpenLink(Direction.SOUTH, "start"); + OpenLink(Direction.NORTH, "area/beginning/thirdroom"); + + } +} \ No newline at end of file diff --git a/Delmud/delmud_db/static/area/beginning/thirdroom.cs b/Delmud/delmud_db/static/area/beginning/thirdroom.cs new file mode 100644 index 0000000..84dc7ea --- /dev/null +++ b/Delmud/delmud_db/static/area/beginning/thirdroom.cs @@ -0,0 +1,12 @@ +public class thirdroom : MudObject +{ + public override void Initialize() + { + Room(RoomType.Interior); + + SetProperty("short", "The Second Room"); + SetProperty("ambient light", LightingLevel.Bright); + OpenLink(Direction.SOUTH, "area/beginning/secondroom"); + + } +} \ No newline at end of file diff --git a/Delmud/delmud_db/static/start.cs b/Delmud/delmud_db/static/start.cs index 5d99876..4cde529 100644 --- a/Delmud/delmud_db/static/start.cs +++ b/Delmud/delmud_db/static/start.cs @@ -6,6 +6,7 @@ public override void Initialize() SetProperty("short", "Chamber of the swirling elements"); SetProperty("ambient light", LightingLevel.Bright); + OpenLink(Direction.NORTH, "area/beginning/secondroom"); MudObject.Move(new target(), this); }