diff --git a/AdminModule/AdminModule.csproj b/AdminModule/AdminModule.csproj index f836ce4..19a5eaf 100644 --- a/AdminModule/AdminModule.csproj +++ b/AdminModule/AdminModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -40,8 +43,12 @@ + + + + @@ -57,6 +64,9 @@ + + + {5c29e6ad-54e3-4105-a9f3-2aab48a17c41} diff --git a/AdminModule/Cons.cs b/AdminModule/Cons.cs new file mode 100644 index 0000000..9ecabdd --- /dev/null +++ b/AdminModule/Cons.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RMUD; + +namespace AdminModule +{ + internal class Cons : CommandFactory + { + public override void Create(CommandParser Parser) + { + Core.StandardMessage("cons", "Results of consistency check:"); + Core.StandardMessage("cons no results", "I found nothing wrong."); + + Parser.AddCommand( + Sequence( + KeyWord("!CONS"), + Optional(KeyWord("LOCAL"), "LOCAL"))) + .ID("Meta:Cons") + .Manual("Scan all defined commands for ommissions, then scan loaded objects for omissions.") + .ProceduralRule((match, actor) => + { + var localScan = false; + if (match.ContainsKey("LOCAL")) + localScan = (match["LOCAL"] as bool?).Value; + + var resultsFound = 0; + + MudObject.SendMessage(actor, "@cons"); + + if (!localScan) + foreach (var command in Core.DefaultParser.EnumerateCommands()) + { + if (String.IsNullOrEmpty(command.GetID())) + { + resultsFound += 1; + MudObject.SendMessage(actor, "Command has no ID set: " + command.ManualName + " from " + command.SourceModule); + } + } + + if (resultsFound == 0) + MudObject.SendMessage(actor, "@cons no results"); + + + return SharpRuleEngine.PerformResult.Continue; + }); + + } + } +} 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/Core/Core/Meta/DumpMessages.cs b/AdminModule/DumpMessages.cs similarity index 87% rename from Core/Core/Meta/DumpMessages.cs rename to AdminModule/DumpMessages.cs index fae0c59..7e4d729 100644 --- a/Core/Core/Meta/DumpMessages.cs +++ b/AdminModule/DumpMessages.cs @@ -2,8 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using RMUD; -namespace RMUD.Modules.Meta +namespace AdminModule { internal class DumpMessages : CommandFactory { @@ -18,7 +19,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/AdminModule/Force.cs b/AdminModule/Force.cs index c59ac23..f99930b 100644 --- a/AdminModule/Force.cs +++ b/AdminModule/Force.cs @@ -28,25 +28,18 @@ 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) => { MudObject target = match["OBJECT"] as MudObject; - var targetActor = target as Actor; - if (targetActor == null) - { - MudObject.SendMessage(actor, "You can order inanimate objects about as much as you like, they aren't going to listen."); - return PerformResult.Stop; - } - var command = match["RAW-COMMAND"].ToString(); - var matchedCommand = Core.DefaultParser.ParseCommand(new PendingCommand { RawCommand = command, Actor = targetActor }); + var matchedCommand = Core.DefaultParser.ParseCommand(new PendingCommand { RawCommand = command, Actor = target }); if (matchedCommand != null) { @@ -55,13 +48,13 @@ 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 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..b880909 100644 --- a/AdminModule/Inspect.cs +++ b/AdminModule/Inspect.cs @@ -23,72 +23,32 @@ 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) => { var target = match["OBJECT"] as MudObject; - MudObject.SendMessage(actor, target.GetType().Name); - foreach (var @interface in target.GetType().GetInterfaces()) - MudObject.SendMessage(actor, "Implements " + @interface.Name); + MudObject.SendMessage(actor, "*** INSPECT LISTING ***"); + MudObject.SendMessage(actor, "Path: ", target.Path); + MudObject.SendMessage(actor, "Instance: ", target.Instance); + MudObject.SendMessage(actor, "Persistent: ", target.IsPersistent.ToString()); + if (target.Location == null) + MudObject.SendMessage(actor, "Location: NOWHERE"); + else + MudObject.SendMessage(actor, "Location: ", target.Location.GetFullName()); + MudObject.SendMessage(actor, "*** DYNAMIC PROPERTIES ***"); - foreach (var field in target.GetType().GetFields()) - MudObject.SendMessage(actor, "field " + field.FieldType.Name + " " + field.Name + " = " + WriteValue(field.GetValue(target))); - - foreach (var property in target.GetType().GetProperties()) + foreach (var property in target.Properties) { - var s = (property.CanWrite ? "property " : "readonly ") + property.PropertyType.Name + " " + property.Name; - if (property.CanRead) - { - s += " = "; - try - { - s += WriteValue(property.GetValue(target, null)); - } - catch (Exception) { s += "[Error reading value]"; } - } - MudObject.SendMessage(actor, s); + var info = PropertyManifest.GetPropertyInformation(property.Key); + MudObject.SendMessage(actor, ": ", property.Key, info.Converter.ConvertToString(property.Value)); } - return PerformResult.Continue; - }, "List all the damn things rule."); - } + MudObject.SendMessage(actor, "*** END OF LISTING ***"); - private static String WriteValue(Object Value, int indent = 1) - { - if (Value == null) - return "NULL"; - else if (Value is String) - return "\"" + Value + "\""; - else if (Value is MudObject) - { - return (Value as MudObject).GetFullName(); - } - else if (Value is KeyValuePair) - { - var v = (Value as KeyValuePair?).Value; - return v.Key + ": " + WriteValue(v.Value, indent + 1); - } - else if (Value is KeyValuePair>) //Containers.. - { - var v = (Value as KeyValuePair>?).Value; - return v.Key + ": " + WriteValue(v.Value, indent + 1); - } - else if (Value is System.Collections.IEnumerable) - { - var r = "[ "; - bool first = true; - foreach (var sub in (Value as System.Collections.IEnumerable)) - { - if (!first) r += "\n" + new String(' ', indent * 2); - first = false; - r += WriteValue(sub, indent + 1); - } - r += " ] "; - return r; - } - else return Value.ToString(); + 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/Properties.cs b/AdminModule/Properties.cs new file mode 100644 index 0000000..9acb191 --- /dev/null +++ b/AdminModule/Properties.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RMUD; +using SharpRuleEngine; + +namespace AdminModule +{ + internal class Properties : CommandFactory + { + public override void Create(CommandParser Parser) + { + Parser.AddCommand( + Sequence( + RequiredRank(500), + KeyWord("!PROPERTIES"))) + .Manual("List all properties that have been registered.") + .ProceduralRule((match, actor) => + { + foreach (var prop in PropertyManifest.GetAllPropertyInformation()) + { + MudObject.SendMessage(actor, " () : ", prop.Key, prop.Value.Type.ToString(), prop.Value.Converter.ConvertToString(prop.Value.DefaultValue)); + } + + return PerformResult.Continue; + }); + } + + } +} \ No newline at end of file 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..179a415 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 { @@ -34,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]"); @@ -47,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/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..f9dee91 100644 --- a/AdminModule/Scope.cs +++ b/AdminModule/Scope.cs @@ -18,8 +18,8 @@ public override void Create(CommandParser Parser) .ProceduralRule((match, actor) => { foreach (var thing in MudObject.EnumerateVisibleTree(MudObject.FindLocale(actor))) - MudObject.SendMessage(actor, thing.Short + " - " + thing.GetType().Name); - return PerformResult.Continue; + 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/Set.cs b/AdminModule/Set.cs new file mode 100644 index 0000000..4ed1a16 --- /dev/null +++ b/AdminModule/Set.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RMUD; + +namespace AdminModule +{ + internal class Set : CommandFactory + { + public override void Create(CommandParser Parser) + { + Parser.AddCommand( + Sequence( + RequiredRank(500), + KeyWord("!SET"), + MustMatch("I don't see that here.", + Object("OBJECT", InScope)), + SingleWord("PROPERTY"), + Rest("VALUE"))) + .Manual("Set the value of a property on an object.") + .ProceduralRule((match, actor) => + { + var _object = match["OBJECT"] as MudObject; + var property_name = match["PROPERTY"].ToString(); + var stringValue = match["VALUE"].ToString(); + + var propertyInfo = PropertyManifest.GetPropertyInformation(property_name); + + if (propertyInfo == null) + { + MudObject.SendMessage(actor, "That property does not exist."); + return SharpRuleEngine.PerformResult.Stop; + } + + var realValue = propertyInfo.Converter.ConvertFromString(stringValue); + + _object.SetProperty(property_name, realValue); + + MudObject.SendMessage(actor, "Property set."); + return SharpRuleEngine.PerformResult.Continue; + }); + } + } +} \ No newline at end of file diff --git a/AdminModule/Sonar.cs b/AdminModule/Sonar.cs index da421b8..f596fbb 100644 --- a/AdminModule/Sonar.cs +++ b/AdminModule/Sonar.cs @@ -42,8 +42,7 @@ public override void Create(CommandParser Parser) var roomLegend = new Dictionary(); - if (actor.Location is RMUD.Room) - MapLocation(mapGrid, roomLegend, (MapWidth / 2), (MapHeight / 2), actor.Location as RMUD.Room, '@'); + MapLocation(mapGrid, roomLegend, (MapWidth / 2), (MapHeight / 2), actor.Location, '@'); for (int y = 0; y < MapHeight; ++y) { @@ -56,7 +55,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."); } @@ -66,16 +65,18 @@ private static void PlaceSymbol(int[,] MapGrid, int X, int Y, int Symbol) MapGrid[X, Y] = Symbol; } - private static int FindSymbol(RMUD.Room Location) + private static int FindSymbol(RMUD.MudObject Location) { - var spacer = Location.Short.LastIndexOf('-'); - if (spacer > 0 && spacer < Location.Short.Length - 2) - return Location.Short.ToUpper()[spacer + 2]; + 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]; else - return Location.Short.ToUpper()[0]; + return Location.GetProperty("short").ToUpper()[0]; } - private static void MapLocation(int[,] MapGrid, Dictionary RoomLegend, int X, int Y, RMUD.Room Location, int Symbol) + private static void MapLocation(int[,] MapGrid, Dictionary RoomLegend, int X, int Y, RMUD.MudObject Location, int Symbol) { if (X < 1 || X >= MapWidth - 1 || Y < 1 || Y >= MapHeight - 1) return; @@ -83,7 +84,7 @@ private static void MapLocation(int[,] MapGrid, Dictionary RoomLege if (Symbol == ' ') Symbol = FindSymbol(Location); - RoomLegend.Upsert(Symbol, Location.Short); + if (Location != null) RoomLegend.Upsert(Symbol, Location.GetProperty("short")); PlaceSymbol(MapGrid, X, Y, Symbol); PlaceSymbol(MapGrid, X - 2, Y - 1, '+'); @@ -100,30 +101,33 @@ private static void MapLocation(int[,] MapGrid, Dictionary RoomLege PlaceSymbol(MapGrid, X - 0, Y + 1, '-'); PlaceSymbol(MapGrid, X + 1, Y + 1, '-'); PlaceSymbol(MapGrid, X + 2, Y + 1, '+'); - - foreach (var link in Location.EnumerateObjects().Where(t => t.HasProperty("link direction"))) - { - var destinationName = link.GetProperty("link destination"); - var destination = MudObject.GetObject(destinationName) as RMUD.Room; - var direction = link.GetPropertyOrDefault("link direction", RMUD.Direction.NORTH); - if (direction == Direction.UP) - { - PlaceSymbol(MapGrid, X + 1, Y - 2, ':'); - PlaceSymbol(MapGrid, X + 1, Y - 3, FindSymbol(destination)); - } - else if (direction == Direction.DOWN) - { - PlaceSymbol(MapGrid, X - 1, Y + 2, ':'); - PlaceSymbol(MapGrid, X - 1, Y + 3, FindSymbol(destination)); - } - else + if (Location != null) + { + foreach (var link in Location.EnumerateObjects().Where(t => t.HasProperty("link direction"))) { - var directionVector = RMUD.Link.GetAsVector(direction); - PlaceEdge(MapGrid, X + directionVector.X * 3, Y + directionVector.Y * 2, direction); + var destinationName = link.GetProperty("link destination"); + var destination = MudObject.GetObject(destinationName); + var direction = link.GetProperty("link direction"); - //if (destination.RoomType == Location.RoomType) - MapLocation(MapGrid, RoomLegend, X + (directionVector.X * 7), Y + (directionVector.Y * 5), destination, ' '); + if (direction == Direction.UP) + { + PlaceSymbol(MapGrid, X + 1, Y - 2, ':'); + PlaceSymbol(MapGrid, X + 1, Y - 3, FindSymbol(destination)); + } + else if (direction == Direction.DOWN) + { + PlaceSymbol(MapGrid, X - 1, Y + 2, ':'); + PlaceSymbol(MapGrid, X - 1, Y + 3, FindSymbol(destination)); + } + else + { + var directionVector = RMUD.Link.GetAsVector(direction); + PlaceEdge(MapGrid, X + directionVector.X * 3, Y + directionVector.Y * 2, direction); + + //if (destination.RoomType == Location.RoomType) + MapLocation(MapGrid, RoomLegend, X + (directionVector.X * 7), Y + (directionVector.Y * 5), destination, ' '); + } } } } 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..ec6597f --- /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..cc51685 100644 --- a/Akkoteaque/Akkoteaque.csproj +++ b/Akkoteaque/Akkoteaque.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {F463DF29-1E1D-4715-85FC-6A177742AD0C} - Library + Exe Properties Akkoteaque Akkoteaque @@ -30,7 +30,13 @@ prompt 4 + + + + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -51,6 +57,7 @@ + @@ -78,6 +85,9 @@ StandardActionsModule + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" 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"); 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..df4594a 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 @@ -40,7 +40,7 @@ public override void Initialize() #region Secondary Conversation Topics - this.Response("about your watch", "\"Are you still carrying that around?\" Mr Henrico asks. He drives in silence for a moment. \"I've spoken to you so many times about closure.\"").Available(() => GetObject("Areas.Prologue.Watch").GetBooleanProperty("has-been-viewed"), "Watch response is available after watch examined rule."); + this.Response("about your watch", "\"Are you still carrying that around?\" Mr Henrico asks. He drives in silence for a moment. \"I've spoken to you so many times about closure.\"").Available(() => GetObject("Areas.Prologue.Watch").GetPropertyOrDefault("has-been-viewed", false), "Watch response is available after watch examined rule."); #endregion 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..62f4b30 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 { @@ -10,7 +11,7 @@ public static class HeavyThings { public static bool IsHeavy(MudObject Object) { - return Object.GetBooleanProperty("heavy?"); + return Object.GetPropertyOrDefault("heavy?", false); } public static bool HasHeavyThing(MudObject Object) diff --git a/Akkoteaque/Program.cs b/Akkoteaque/Program.cs new file mode 100644 index 0000000..f083dcc --- /dev/null +++ b/Akkoteaque/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; + +class Program +{ + static void Main(string[] args) + { + var driver = new RMUD.SinglePlayer.Driver(); + driver.Start(typeof(Akko.Game).Assembly, Console.Write); + while (driver.IsRunning) + driver.Input(Console.ReadLine()); + Console.WriteLine("[Press any key to exit..]"); + Console.ReadKey(); + } +} \ No newline at end of file diff --git a/Akkoteaque/packages.config b/Akkoteaque/packages.config new file mode 100644 index 0000000..ec6597f --- /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..b692595 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, new DefaultSerializer()); + } + public override void Create(CommandParser Parser) { Parser.AddCommand( @@ -18,19 +23,19 @@ 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()); MudObject.SendMessage(actor, "Alias added."); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); Parser.AddCommand( 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())) @@ -43,7 +48,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..af5da0d 100644 --- a/AliasModule/AliasModule.csproj +++ b/AliasModule/AliasModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\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..ec6597f --- /dev/null +++ b/AliasModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ChatModule/ChatChannel.cs b/ChatModule/ChatChannel.cs index 95e1bcf..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, "") { - 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.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 6344c96..8902d24 100644 --- a/ChatModule/ChatChannelRules.cs +++ b/ChatModule/ChatChannelRules.cs @@ -13,23 +13,23 @@ 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") + GlobalRules.Perform("player joined") .Do(player => { - foreach (var c in ChatChannel.ChatChannels.Where(c => c.Short == "OOC")) + foreach (var c in ChatChannel.ChatChannels.Where(c => c.GetProperty("short") == "OOC")) c.Subscribers.Add(player); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Subscribe new players to OOC rule."); - GlobalRules.Perform("player left") + GlobalRules.Perform("player left") .Do(player => { ChatChannel.RemoveFromAllChannels(player); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Unsubscribe players from all channels when they leave rule."); @@ -39,11 +39,11 @@ 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.GetProperty("rank") < 100) .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..6c6e259 100644 --- a/ChatModule/ChatModule.csproj +++ b/ChatModule/ChatModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\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..a7f8a01 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 { @@ -35,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; }); @@ -47,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.Short); + MudObject.SendMessage(actor, (channel.Subscribers.Contains(actor) ? "*" : "") + channel.GetProperty("short")); return PerformResult.Continue; }); @@ -59,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)) { @@ -75,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.Short + "] " + actor.Short + + ChatChannel.SendChatMessage(channel, "[" + channel.GetProperty("short") + "] " + actor.GetProperty("short") + (message.StartsWith("\"") ? (" " + message.Substring(1).Trim()) : (": \"" + message + "\""))); @@ -93,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.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/ChatModule/packages.config b/ChatModule/packages.config new file mode 100644 index 0000000..ec6597f --- /dev/null +++ b/ChatModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ClothingModule/Clothing.cs b/ClothingModule/Clothing.cs index 7c414d3..06d8861 100644 --- a/ClothingModule/Clothing.cs +++ b/ClothingModule/Clothing.cs @@ -28,14 +28,8 @@ public enum ClothingBodyPart Cloak, } - public static class Clothing// : RMUD.MudObject + public static class Factory// : RMUD.MudObject { - //public ClothingLayer Layer = ClothingLayer.Outer; - //public ClothingBodyPart BodyPart = ClothingBodyPart.Torso; - - //public Clothing() : base() { } - //public Clothing(String Short, String Long) : base(Short, Long) { } - public static RMUD.MudObject Create(String Short, ClothingLayer Layer, ClothingBodyPart BodyPart) { var r = new RMUD.MudObject(Short, "This is a generic " + Short + ". Layer: " + Layer + " BodyPart: " + BodyPart); @@ -44,5 +38,19 @@ public static RMUD.MudObject Create(String Short, ClothingLayer Layer, ClothingB r.SetProperty("wearable?", true); return r; } + + public static void AtStartup(RMUD.RuleEngine GlobalRules) + { + RMUD.PropertyManifest.RegisterProperty("clothing layer", typeof(ClothingLayer), ClothingLayer.Outer, new RMUD.EnumSerializer()); + RMUD.PropertyManifest.RegisterProperty("clothing part", typeof(ClothingBodyPart), ClothingBodyPart.Cloak, new RMUD.EnumSerializer()); + RMUD.PropertyManifest.RegisterProperty("wearable?", typeof(bool), false, new RMUD.BoolSerializer()); + } + + 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/ClothingModule.csproj b/ClothingModule/ClothingModule.csproj index c0252be..8331fdc 100644 --- a/ClothingModule/ClothingModule.csproj +++ b/ClothingModule/ClothingModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -55,6 +58,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/ClothingModule/NPCExtension.cs b/ClothingModule/NPCExtension.cs index 2e038c6..2c5c4b9 100644 --- a/ClothingModule/NPCExtension.cs +++ b/ClothingModule/NPCExtension.cs @@ -8,14 +8,14 @@ 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, Clothing.Create(Short, Layer, BodyPart)); + Wear(NPC, Factory.Create(Short, Layer, BodyPart)); } } } diff --git a/ClothingModule/Remove.cs b/ClothingModule/Remove.cs index d6c5567..299b199 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,13 +24,13 @@ 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"); 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 f08cb5c..d6d24c2 100644 --- a/ClothingModule/Rules.cs +++ b/ClothingModule/Rules.cs @@ -4,17 +4,18 @@ 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") + 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 { @@ -26,13 +27,14 @@ public static void AtStartup(RuleEngine GlobalRules) }) .Name("List worn items in inventory rule."); - GlobalRules.Check("can wear?") + GlobalRules.Check("can wear?") + .When((actor, item) => actor.GetProperty("actor?")) .Do((actor, item) => { - var layer = item.GetPropertyOrDefault("clothing layer", ClothingLayer.Assecories); - var part = item.GetPropertyOrDefault("clothing part", ClothingBodyPart.Cloak); + var layer = item.GetProperty("clothing layer"); + var part = item.GetProperty("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.GetProperty("clothing layer") == layer && wornItem.GetProperty("clothing part") == part) { MudObject.SendMessage(actor, "@clothing remove first", wornItem); return CheckResult.Disallow; @@ -41,13 +43,13 @@ public static void AtStartup(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.GetProperty("clothing layer"); + var part = item.GetProperty("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.GetProperty("clothing layer") < layer && wornItem.GetProperty("clothing part") == part) { MudObject.SendMessage(actor, "@clothing remove first", wornItem); return CheckResult.Disallow; @@ -57,13 +59,14 @@ public static void AtStartup(RuleEngine GlobalRules) .Name("Can't remove items under other items rule."); - GlobalRules.Perform("describe") + GlobalRules.Perform("describe") .First + .When((viewer, actor) => actor.GetProperty("actor?")) .Do((viewer, actor) => { - var wornItems = new List(actor.EnumerateObjects(RelativeLocations.Worn)); + var wornItems = actor.GetContents(RelativeLocations.Worn); if (wornItems.Count == 0) - MudObject.SendMessage(viewer, "@clothing they are naked", actor); + MudObject.SendMessage(viewer, "@clothing they are nude", actor); else MudObject.SendMessage(viewer, "@clothing they are wearing", actor, wornItems); return PerformResult.Continue; diff --git a/ClothingModule/Wear.cs b/ClothingModule/Wear.cs index f4be0f5..0a98047 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"); @@ -37,7 +38,7 @@ public static void AtStartup(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"); @@ -45,7 +46,8 @@ public static void AtStartup(RuleEngine GlobalRules) }); GlobalRules.Check("can wear?") - .When((actor, item) => !item.GetPropertyOrDefault("wearable?", false)) + .When((actor, item) => !item.GetProperty("wearable?")) + .When((actor, item) => !actor.GetProperty("actor?")) .Do((actor, item) => { MudObject.SendMessage(actor, "@clothing cant wear"); diff --git a/ClothingModule/packages.config b/ClothingModule/packages.config new file mode 100644 index 0000000..ec6597f --- /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..24cbc3b 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 { @@ -18,9 +19,10 @@ public override void Create(CommandParser Parser) MustMatch("@convo greet whom", Object("LOCUTOR", InScope, (actor, thing) => { - if (thing is NPC) return MatchPreference.VeryLikely; + if (thing.GetProperty("actor?")) return MatchPreference.VeryLikely; else return MatchPreference.VeryUnlikely; })))) + .ID("Conversation:Greet") .Manual("Initiates a conversation with the npc.") .Check("can converse?", "ACTOR", "LOCUTOR") .BeforeActing() @@ -28,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"); @@ -44,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.GetProperty("interlocutor"))) return MatchPreference.VeryLikely; + if (thing.GetProperty("actor?")) return MatchPreference.Likely; return MatchPreference.VeryUnlikely; }), OptionalKeyWord("ABOUT"), @@ -53,26 +54,27 @@ public override void Create(CommandParser Parser) Object("TOPIC", new TopicSource("NEW-LOCUTOR")), Rest("STRING-TOPIC"))), Rest("STRING-TOPIC")))) + .ID("Conversation:DiscussTopic") .Manual("Discusses the topic with whomever you are talking too.") + .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.GetProperty("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.GetProperty("interlocutor") == null) { MudObject.SendMessage(actor, "@convo nobody"); return PerformResult.Stop; @@ -81,10 +83,12 @@ public override void Create(CommandParser Parser) }, "Must be talking to someone rule.") .Check("can converse?", "ACTOR", "LOCUTOR") .Perform("discuss topic", "ACTOR", "LOCUTOR", "TOPIC") + .AfterActing() .Perform("list topics", "ACTOR"); Parser.AddCommand( KeyWord("TOPICS")) + .ID("Conversation:Topic") .Manual("Lists topics currently available.") .Perform("list topics", "ACTOR"); } diff --git a/ConversationModule/ConversationModule.csproj b/ConversationModule/ConversationModule.csproj index 9074e14..6b0d0c2 100644 --- a/ConversationModule/ConversationModule.csproj +++ b/ConversationModule/ConversationModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\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..45474e3 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 { @@ -10,7 +11,7 @@ public class Topic : MudObject { public Topic() { - Article = ""; + SetProperty("article", ""); } public Topic Available(Func Func, String Name = "") @@ -31,7 +32,7 @@ public Topic Available(Func Func, String Name = "") public bool Discussed { - get { return this.GetBooleanProperty("topic-discussed"); } + get { return this.GetProperty("topic-discussed"); } } public Topic Follows(Topic Previous) @@ -42,6 +43,17 @@ public Topic Follows(Topic Previous) public static class ResponseExtensionMethods { + public static List InitializeConversationTopics(this MudObject To) + { + var topics = To.GetProperty>("conversation-topics"); + if (topics == null) + { + topics = new List(); + To.SetProperty("conversation-topics", topics); + } + return topics; + } + public static Topic Response(this MudObject To, String Topic, String StringResponse) { return Response(To, Topic, (actor, npc, topic) => @@ -53,12 +65,7 @@ public static Topic Response(this MudObject To, String Topic, String StringRespo public static Topic Response(this MudObject To, String Topic, Func FuncResponse) { - var topics = To.GetProperty>("conversation-topics"); - if (topics == null) - { - topics = new List(); - To.SetProperty("conversation-topics", topics); - } + var topics = To.InitializeConversationTopics(); var response = new Topic(); topics.Add(response); @@ -69,6 +76,8 @@ public static Topic Response(this MudObject To, String Topic, Func FuncResponse) { + To.InitializeConversationTopics(); + To.Perform("topic response").When((actor, npc, topic) => topic == null).Do(FuncResponse); } @@ -80,5 +89,22 @@ public static void DefaultResponse(this MudObject To, String StringResponse) return PerformResult.Stop; }); } + + public static RuleBuilder PerformNoTopicsToDiscuss(this MudObject To) + { + To.InitializeConversationTopics(); + + return To.Perform("no topics to discuss").ThisOnly(1); + } + + public static RuleBuilder CheckCanConverse(this MudObject To) + { + return To.Check("can converse?").ThisOnly(1); + } + + public static RuleBuilder PerformGreet(this MudObject To) + { + return To.Perform("greet").ThisOnly(1); + } } } diff --git a/ConversationModule/Rules.cs b/ConversationModule/Rules.cs index 6b10799..8f9e7b7 100644 --- a/ConversationModule/Rules.cs +++ b/ConversationModule/Rules.cs @@ -3,13 +3,18 @@ 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) { + PropertyManifest.RegisterProperty("interlocutor", typeof(MudObject), null, new DefaultSerializer()); + PropertyManifest.RegisterProperty("conversation-topics", typeof(List), new List(), new DefaultSerializer()); + PropertyManifest.RegisterProperty("topic-discussed", typeof(bool), false, new BoolSerializer()); + 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?"); @@ -20,7 +25,7 @@ public static void AtStartup(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.GetProperty("actor?")) .Do((actor, item) => { MudObject.SendMessage(actor, "@convo cant converse"); @@ -42,7 +47,7 @@ public static void AtStartup(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.GetProperty("interlocutor") == null) .Do(actor => { MudObject.SendMessage(actor, "@convo nobody"); @@ -53,26 +58,38 @@ public static void AtStartup(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.GetProperty("interlocutor"); + if (npc != null) + { + var suggestedTopics = npc.GetProperty>("conversation-topics").AsEnumerable(); - if (!Settings.ListDiscussedTopics) - suggestedTopics = suggestedTopics.Where(obj => !obj.GetBooleanProperty("topic-discussed")); + if (!Settings.ListDiscussedTopics) + suggestedTopics = suggestedTopics.Where(obj => !obj.GetProperty("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 - MudObject.SendMessage(actor, "@convo no topics"); + if (enumeratedSuggestedTopics.Count != 0) + MudObject.SendMessage(actor, "@convo topic prompt", enumeratedSuggestedTopics); + else + GlobalRules.ConsiderPerformRule("no topics to discuss", actor, npc); + } return PerformResult.Continue; }) .Name("List un-discussed available topics rule."); + GlobalRules.DeclarePerformRuleBook("no topics to discuss", "[Actor, NPC] : Handle there being no topics to list."); + + GlobalRules.Perform("no topics to discuss") + .Do((actor, npc) => + { + MudObject.SendMessage(actor, "@convo no topics"); + return PerformResult.Continue; + }) + .Name("Default report no topics to discuss rule."); + GlobalRules.DeclarePerformRuleBook("discuss topic", "[Actor, NPC, Topic] : Handle the actor discussing the topic with the npc."); GlobalRules.Perform("discuss topic") @@ -98,7 +115,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.Check("topic available?") .First - .When((actor, npc, topic) => (topic != null) && (Settings.AllowRepeats == false) && topic.GetBooleanProperty("topic-discussed")) + .When((actor, npc, topic) => (topic != null) && (Settings.AllowRepeats == false) && topic.GetProperty("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 23f5d6e..a439b31 100644 --- a/ConversationModule/TopicObjectSource.cs +++ b/ConversationModule/TopicObjectSource.cs @@ -18,15 +18,15 @@ 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")) - return new List(source.GetProperty>("conversation-topics").Where(t => Core.GlobalRules.ConsiderCheckRuleSilently("topic available?", Context.ExecutingActor, source, t) == CheckResult.Allow)); + 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/ConversationModule/packages.config b/ConversationModule/packages.config new file mode 100644 index 0000000..ec6597f --- /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..1f528e5 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + ExtendedDesignGuidelineRules.ruleset pdbonly @@ -39,6 +40,10 @@ False ..\packages\Octokit.0.6.2\lib\net45\Octokit.dll + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + True + @@ -54,35 +59,9 @@ - - - - - True - True - RuleBuilderGen.tt - - - True - True - RuleDelegatesGen.tt - - - True - True - RuleEngineAddRuleGen.tt - - - - - True - True - RuleSetAddRuleGen.tt - - @@ -123,33 +102,27 @@ - - MudObjectAddRuleGen.tt - True - True - - - - - - - - - - - - - + + + + + + + + + + + @@ -158,9 +131,9 @@ - + - + @@ -168,38 +141,23 @@ - + + + + + + - + - + + - - TextTemplatingFileGenerator - MudObjectAddRuleGen.cs - - - TextTemplatingFileGenerator - RuleBuilderGen.cs - - - TextTemplatingFileGenerator - RuleDelegatesGen.cs - - - TextTemplatingFileGenerator - RuleEngineAddRuleGen.cs - - - - TextTemplatingFileGenerator - RuleSetAddRuleGen.cs - @@ -209,6 +167,7 @@ + + \ 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/_void.cs b/Delmud/delmud_db/static/_void.cs new file mode 100644 index 0000000..93316be --- /dev/null +++ b/Delmud/delmud_db/static/_void.cs @@ -0,0 +1,12 @@ +public class _void : MudObject +{ + public override void Initialize() + { + Room(RoomType.Interior); + + SetProperty("short", "The Endless Void"); + SetProperty("ambient light", LightingLevel.Bright); + + OpenLink(RMUD.Direction.NORTH, "start"); + } +} 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/player_base.cs b/Delmud/delmud_db/static/player_base.cs new file mode 100644 index 0000000..c953c5d --- /dev/null +++ b/Delmud/delmud_db/static/player_base.cs @@ -0,0 +1,7 @@ +public class player_base : DelmudGameplay.Player +{ + public override void Initialize() + { + base.Initialize(); + } +} 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..4cde529 --- /dev/null +++ b/Delmud/delmud_db/static/start.cs @@ -0,0 +1,26 @@ +public class start : MudObject +{ + public override void Initialize() + { + Room(RoomType.Interior); + + SetProperty("short", "Chamber of the swirling elements"); + SetProperty("ambient light", LightingLevel.Bright); + OpenLink(Direction.NORTH, "area/beginning/secondroom"); + + MudObject.Move(new target(), this); + } +} + +public class target : Monster +{ + public target() + { + Actor(); + SimpleName("mob"); + SetProperty("current-hp", 10); + + base.Initialize(); + } +} + 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/Attack.cs b/DelmudGameplay/Attack.cs new file mode 100644 index 0000000..3d5f01a --- /dev/null +++ b/DelmudGameplay/Attack.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RMUD; + +namespace DelmudGameplay +{ + public class Attack : RMUD.CommandFactory + { + public override void Create(CommandParser Parser) + { + Parser.AddCommand( + Sequence( + Or( + KeyWord("ATTACK"), + KeyWord("KILL")), + Optional( + Object("OBJECT", InScope, (actor, item) => + { + if (item.GetProperty("actor?")) return MatchPreference.Likely; + else return MatchPreference.Unlikely; + })))) + .ID("Delmud:Attack") + .Manual("Attack an enemy.") + .ProceduralRule((match, actor) => + { + if (!match.ContainsKey("OBJECT")) + match.Upsert("OBJECT", actor.GetProperty("combatant")); + return SharpRuleEngine.PerformResult.Continue; + }, "Attack current combantant by default rule.") + .Check("can attack?", "ACTOR", "OBJECT") + .ProceduralRule((match, actor) => + { + var combatant = match["OBJECT"] as MudObject; + + if (combatant == null) + { + MudObject.SendMessage(actor, "@combat nobody"); + return SharpRuleEngine.PerformResult.Stop; + } + + actor.SetProperty("combatant", combatant); + return SharpRuleEngine.PerformResult.Continue; + + }, "Set actor combatant rule.") + .BeforeActing() + .Perform("attack", "ACTOR", "OBJECT") + .AfterActing() + .MarkLocaleForUpdate(); + + } + + public static void AtStartup(RMUD.RuleEngine GlobalRules) + { + RMUD.PropertyManifest.RegisterProperty("combatant", typeof(MudObject), null, new DefaultSerializer()); + + RMUD.Core.StandardMessage("combat nobody", "I can't find who you want to attack."); + RMUD.Core.StandardMessage("combat cant attack", "You can't attack that."); + Core.StandardMessage("combat show damage", " hits for damage!"); + Core.StandardMessage("combat show damage self", "You hit for damage!"); + + GlobalRules.DeclareCheckRuleBook("can attack?", "[Aggresor, Victim] : Can the aggresor attack the victim?"); + + GlobalRules.Check("can attack?") + .When((actor, item) => !item.GetProperty("actor?")) + .Do((actor, item) => + { + MudObject.SendMessage(actor, "@combat cant attack"); + return SharpRuleEngine.CheckResult.Disallow; + }) + .Name("Can only attack actors rule"); + + GlobalRules.Check("can attack?") + .Do((actor, victim) => MudObject.CheckIsVisibleTo(actor, victim)) + .Name("Victim must be visible rule."); + + GlobalRules.Check("can attack?") + .Last + .Do((actor, victim) => SharpRuleEngine.CheckResult.Allow) + .Name("Let the violence commence rule."); + + + GlobalRules.DeclarePerformRuleBook("attack", "[Aggresor, Victim] : Handle the aggresor attacking the victim."); + + GlobalRules.Perform("attack") + .Do((actor, victim) => + { + var attackPower = 0; + + // Check for weapons. + + // No weapons, unarmed strike. + attackPower = actor.GetProperty("strength"); + + // Display how much damage was done. + MudObject.SendExternalMessage(actor, "@combat show damage", actor, victim, attackPower); + MudObject.SendMessage(actor, "@combat show damage self", actor, victim, attackPower); + + // Apply attack power to health of victim - use 'damage' rulebook + // No need to account for defense here - let the damage taking rulebook handle absorbant armor. + GlobalRules.ConsiderPerformRule("damage", actor, victim, attackPower); + + return SharpRuleEngine.PerformResult.Continue; + }); + + + GlobalRules.DeclarePerformRuleBook("damage", "[Attacker, Target, Damage] : Handle the Attacker dealing Damage damage to the Target."); + + GlobalRules.Perform("damage") + .Do((attacker, target, damage) => + { + var hp = target.GetProperty("current-hp"); + hp = Math.Max(0, hp - damage); + target.SetProperty("current-hp", hp); + + if (hp == 0) + GlobalRules.ConsiderPerformRule("killed", target, attacker); + + return SharpRuleEngine.PerformResult.Continue; + }) + .Name("Apply damage to actor rule."); + } + } +} 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/CombatStats.cs b/DelmudGameplay/CombatStats.cs new file mode 100644 index 0000000..35a3db5 --- /dev/null +++ b/DelmudGameplay/CombatStats.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RMUD; + +namespace DelmudGameplay +{ + public class CombatStats : RMUD.CommandFactory + { + public static void AtStartup() + { + RMUD.PropertyManifest.RegisterProperty("strength", typeof(int), 0, new IntSerializer()); + RMUD.PropertyManifest.RegisterProperty("accuracy", typeof(int), 0, new IntSerializer()); + RMUD.PropertyManifest.RegisterProperty("power", typeof(int), 0, new IntSerializer()); + + RMUD.PropertyManifest.RegisterProperty("class", typeof(CharacterClasses), CharacterClasses.Bludgeon, new EnumSerializer()); + RMUD.PropertyManifest.RegisterProperty("element", typeof(ElementTypes), ElementTypes.Earth, new EnumSerializer()); + + RMUD.PropertyManifest.RegisterProperty("max-hp", typeof(int), 0, new IntSerializer()); + RMUD.PropertyManifest.RegisterProperty("max-mp", typeof(int), 0, new IntSerializer()); + RMUD.PropertyManifest.RegisterProperty("current-hp", typeof(int), 0, new IntSerializer()); + RMUD.PropertyManifest.RegisterProperty("current-mp", typeof(int), 0, new IntSerializer()); + } + + public override void Create(CommandParser Parser) + { + Parser.AddCommand( + Sequence( + KeyWord("SCORE"))) + .ID("Delmud:Score") + .Manual("Display stats about the current player.") + .ProceduralRule((match, actor) => + { + MudObject.SendMessage(actor, "Your stats :"); + MudObject.SendMessage(actor, "Strength: ", actor.GetProperty("strength")); + MudObject.SendMessage(actor, "Accuracy: ", actor.GetProperty("accuracy")); + MudObject.SendMessage(actor, "Power: ", actor.GetProperty("power")); + MudObject.SendMessage(actor, "Class: ", actor.GetProperty("class")); + MudObject.SendMessage(actor, "Element: ", actor.GetProperty("element")); + MudObject.SendMessage(actor, "HP: / ", actor.GetProperty("current-hp"), actor.GetProperty("max-hp")); + MudObject.SendMessage(actor, "MP: / ", actor.GetProperty("current-mp"), actor.GetProperty("max-mp")); + + return SharpRuleEngine.PerformResult.Continue; + }); + } + } +} diff --git a/DelmudGameplay/DelmudGameplay.csproj b/DelmudGameplay/DelmudGameplay.csproj new file mode 100644 index 0000000..514308d --- /dev/null +++ b/DelmudGameplay/DelmudGameplay.csproj @@ -0,0 +1,76 @@ + + + + + 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/Monster.cs b/DelmudGameplay/Monster.cs new file mode 100644 index 0000000..16734e4 --- /dev/null +++ b/DelmudGameplay/Monster.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RMUD; + +namespace DelmudGameplay +{ + public class Monster : MudObject + { + public override void Initialize() + { + Actor(); + + Perform("killed") + .Do((me, attacker) => + { + SendLocaleMessage(me, "^ killed !", attacker, me); + + Move(me, null); + + return SharpRuleEngine.PerformResult.Continue; + }); + + Perform("attack") + .When((actor, victim) => Object.ReferenceEquals(victim, this)) + .When((actor, victim) => actor.State == ObjectState.Alive && victim.State == ObjectState.Alive) + .Do((actor, victim) => + { + // Now actor is an aggressor. + victim.SetProperty("combatant", actor); + Core.AddTimer(TimeSpan.FromSeconds(2), () => ConsiderPerformRule("attack", victim, actor)); + return SharpRuleEngine.PerformResult.Continue; + }) + .Name("Fight back rule"); + + Perform("attack") + .When((actor, victim) => Object.ReferenceEquals(actor, this)) + .When((actor, victim) => actor.State == ObjectState.Alive && victim.State == ObjectState.Alive) + .Do((actor, victim) => + { + actor.SetProperty("combatant", victim); + Core.AddTimer(TimeSpan.FromSeconds(2), () => ConsiderPerformRule("attack", actor, victim)); + return SharpRuleEngine.PerformResult.Continue; + }) + .Name("Keep attacking rule."); + } + } +} diff --git a/DelmudGameplay/Player.cs b/DelmudGameplay/Player.cs new file mode 100644 index 0000000..638c51f --- /dev/null +++ b/DelmudGameplay/Player.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RMUD; + +namespace DelmudGameplay +{ + public class Player : MudObject + { + public override void Initialize() + { + Actor(); + + Perform("killed") + .Do((me, attacker) => + { + SendLocaleMessage(me, "^ killed !", attacker, me); + SendMessage(me, "You have died."); + + Move(me, GetObject("_void")); + + return SharpRuleEngine.PerformResult.Continue; + }); + } + } +} 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 7af2099..5492f98 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 { @@ -29,7 +30,7 @@ public override void Create(CommandParser Parser) MustMatch("Introduce whom?", Object("OBJECT", InScope, (actor, item) => { - if (item is Actor) return MatchPreference.Likely; + if (item.GetProperty("actor?")) return MatchPreference.Likely; return MatchPreference.Unlikely; })))) .Manual("Introduces someone you know to everyone present. Now they will know them, too.") @@ -39,12 +40,14 @@ public override void Create(CommandParser Parser) .AfterActing(); } - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { + PropertyManifest.RegisterProperty("introduction memory", typeof(Dictionary), null, new DefaultSerializer()); + GlobalRules.DeclareCheckRuleBook("can introduce?", "[Actor A, Actor B] : Can A introduce B?", "actor", "itroductee"); GlobalRules.Check("can introduce?") - .When((a, b) => !(b is Actor)) + .When((a, b) => !b.GetProperty("actor?")) .Do((a, b) => { MudObject.SendMessage(a, "That just sounds silly."); @@ -65,12 +68,12 @@ public static void AtStartup(RuleEngine GlobalRules) }) .Name("Can't introduce who you don't know rule."); - GlobalRules.Perform("describe") + GlobalRules.Perform("describe") .First .When((viewer, actor) => GlobalRules.ConsiderValueRule("actor knows actor?", viewer, actor)) .Do((viewer, actor) => { - MudObject.SendMessage(viewer, "^, a " + (actor.Gender == Gender.Male ? "man." : "woman."), actor); + MudObject.SendMessage(viewer, "^, a " + (actor.GetProperty("gender") == Gender.Male ? "man." : "woman."), actor); return PerformResult.Continue; }) .Name("Report gender of known actors rule."); @@ -84,7 +87,7 @@ public static void AtStartup(RuleEngine GlobalRules) { var locale = MudObject.FindLocale(introductee); if (locale != null) - foreach (var player in MudObject.EnumerateObjectTree(locale).Where(o => o is Player).Select(o => o as Player)) + foreach (var player in MudObject.EnumerateObjectTree(locale).Where(o => o.GetProperty("actor?"))) GlobalRules.ConsiderPerformRule("introduce to", introductee, player); MudObject.SendExternalMessage(actor, "^ introduces .", actor, introductee); @@ -93,14 +96,14 @@ public static void AtStartup(RuleEngine GlobalRules) }) .Name("Report introduction rule."); - GlobalRules.DeclarePerformRuleBook("introduce self", "[Introductee] : Introduce the introductee"); + GlobalRules.DeclarePerformRuleBook("introduce self", "[Introductee] : Introduce the introductee"); - GlobalRules.Perform("introduce self") + GlobalRules.Perform("introduce self") .Do((introductee) => { var locale = MudObject.FindLocale(introductee); if (locale != null) - foreach (var player in MudObject.EnumerateObjectTree(locale).Where(o => o is Player).Select(o => o as Player)) + foreach (var player in MudObject.EnumerateObjectTree(locale).Where(o => o.GetProperty("actor?"))) GlobalRules.ConsiderPerformRule("introduce to", introductee, player); MudObject.SendExternalMessage(introductee, "^ introduces themselves.", introductee); @@ -114,18 +117,21 @@ public static void AtStartup(RuleEngine GlobalRules) #region Printed name rules - GlobalRules.Value("printed name") + GlobalRules.Value("printed name") + .When((viewer, thing, article) => thing.GetProperty("actor?")) .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") - .When((viewer, thing, article) => thing is Actor && (thing as Actor).Gender == Gender.Male) + .When((viewer, thing, article) => thing.GetProperty("actor?")) + .When((viewer, thing, article) => thing.GetProperty("gender") == Gender.Male) .Do((viewer, actor, article) => article + " man") .Name("Default name for unintroduced male actor."); GlobalRules.Value("printed name") - .When((viewer, thing, article) => thing is Actor && (thing as Actor).Gender == Gender.Female) + .When((viewer, thing, article) => thing.GetProperty("actor?")) + .When((viewer, thing, article) => thing.GetProperty("gender") == Gender.Female) .Do((viewer, actor, article) => article + " woman") .Name("Default name for unintroduced female actor."); @@ -133,27 +139,40 @@ public static void AtStartup(RuleEngine GlobalRules) #region Knowledge management rules - GlobalRules.DeclareValueRuleBook("actor knows actor?", "[Player, Whom] : Does the player know the actor?"); + GlobalRules.DeclareValueRuleBook("actor knows actor?", "[Player, Whom] : Does the player know the actor?"); - GlobalRules.Value("actor knows actor?") - .Do((player, whom) => player.Recall(whom, "knows")) + GlobalRules.Value("actor knows actor?") + .Do((player, whom) => RecallActor(player, whom)) .Name("Use player memory to recall actors rule."); - GlobalRules.Value("actor knows actor?") - .Do((player, whom) => false) - .Name("Actors that aren't players don't know anybody rule."); - - GlobalRules.DeclarePerformRuleBook("introduce to", "[Introductee, ToWhom] : Introduce the introductee to someone"); + GlobalRules.DeclarePerformRuleBook("introduce to", "[Introductee, ToWhom] : Introduce the introductee to someone"); - GlobalRules.Perform("introduce to") + GlobalRules.Perform("introduce to") .Do((introductee, player) => { - player.Remember(introductee, "knows", true); + RememberActor(player, introductee); return PerformResult.Continue; }) .Name("Players remember actors rule."); #endregion } + + private static void RememberActor(MudObject Player, MudObject Actor) + { + if (String.IsNullOrEmpty(Actor.Path)) return; // Don't remember unimportant mobs. + if (!Player.HasProperty("introduction memory")) + Player.SetProperty("introduction memory", new Dictionary()); + Player.GetProperty>("introduction memory").Upsert(Actor.Path, true); + } + + private static bool RecallActor(MudObject Player, MudObject Actor) + { + if (String.IsNullOrEmpty(Actor.Path)) return false; // Some mob. + if (!Player.HasProperty("introduction memory")) return false; + var memory = Player.GetProperty>("introduction memory"); + if (!memory.ContainsKey(Actor.Path)) return false; + return memory[Actor.Path]; + } } } diff --git a/IntroductionModule/IntroductionModule.csproj b/IntroductionModule/IntroductionModule.csproj index 1568ebf..82b26f6 100644 --- a/IntroductionModule/IntroductionModule.csproj +++ b/IntroductionModule/IntroductionModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\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..ec6597f --- /dev/null +++ b/IntroductionModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/NetworkModule/Account.cs b/NetworkModule/Account.cs index d98250b..ad6f341 100644 --- a/NetworkModule/Account.cs +++ b/NetworkModule/Account.cs @@ -11,6 +11,6 @@ public class Account public String AFKMessage = "AFK"; [Newtonsoft.Json.JsonIgnore] - public Actor LoggedInCharacter; + public MudObject LoggedInCharacter; } } diff --git a/NetworkModule/Accounts.cs b/NetworkModule/Accounts.cs index 88ef9fe..a4bfcf5 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() { @@ -55,13 +61,13 @@ internal static Account CreateAccount(String UserName, String Password) return newAccount; } - public static Player GetAccountCharacter(Account Account) + public static MudObject GetAccountCharacter(Account Account) { Core.CommandTimeoutEnabled = false; - var playerObject = Core.Database.GetObject(Core.SettingsObject.PlayerBaseObject + "@" + Account.UserName) as Player; + var playerObject = Core.Database.GetObject(Core.SettingsObject.PlayerBaseObject + "@" + Account.UserName); - 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/Afk.cs b/NetworkModule/Afk.cs index 02b38a9..8093047 100644 --- a/NetworkModule/Afk.cs +++ b/NetworkModule/Afk.cs @@ -18,10 +18,14 @@ public override void Create(CommandParser Parser) .Manual("Sets your afk message. This message is displayed after 5 minutes of inactivity on the WHO list, and to any player who attempts to whisper to you.") .ProceduralRule((match, actor) => { - if (actor.ConnectedClient != null) - actor.ConnectedClient.Player.GetProperty("account").AFKMessage = match["MESSAGE"].ToString(); - MudObject.SendMessage(actor, "AFK message set."); - return PerformResult.Continue; + var account = actor.GetProperty("account"); + if (account != null) + { + account.AFKMessage = match["MESSAGE"].ToString(); + MudObject.SendMessage(actor, "AFK message set."); + } + + 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/Clients.cs b/NetworkModule/Clients.cs index 82f6c64..c5ba6de 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.GetProperty("account"); + if (account != null) + account.LoggedInCharacter = null; Core.RemovePlayer(client.Player); ClientLock.ReleaseMutex(); } @@ -40,8 +42,9 @@ internal static ClientAcceptanceStatus ClientConnected(NetworkClient Client) ClientLock.WaitOne(); - var dummyPlayer = new Actor(); - dummyPlayer.CommandHandler = new LoginCommandHandler(); + var dummyPlayer = new MudObject(); + dummyPlayer.Actor(); + dummyPlayer.SetProperty("command handler", new LoginCommandHandler()); Core.TiePlayerToClient(Client, dummyPlayer); MudObject.SendMessage(Client, Core.SettingsObject.Banner); @@ -59,6 +62,7 @@ internal static ClientAcceptanceStatus ClientConnected(NetworkClient Client) public static void AtStartup(RuleEngine GlobalRules) { ProscriptionList = new ProscriptionList("proscriptions.txt"); + PropertyManifest.RegisterProperty("account", typeof(Account), null, new DefaultSerializer()); } public static void SendGlobalMessage(String Message, params MudObject[] MentionedObjects) diff --git a/NetworkModule/Kick.cs b/NetworkModule/Kick.cs index aed9af7..bba1eda 100644 --- a/NetworkModule/Kick.cs +++ b/NetworkModule/Kick.cs @@ -21,7 +21,7 @@ public override void Create(CommandParser Parser) .ProceduralRule((match, actor) => { if (match.ContainsKey("PLAYER")) - KickPlayer(match["PLAYER"] as Actor, actor); + KickPlayer(match["PLAYER"] as MudObject, actor); else { var mask = match["MASK"].ToString(); @@ -39,19 +39,20 @@ public override void Create(CommandParser Parser) } } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } - public static void KickPlayer(Actor Player, Actor Actor) + public static void KickPlayer(MudObject Player, MudObject Actor) { - if (Player.ConnectedClient != null) + var client = Player.GetProperty("client"); + if (client != null) { Core.MarkLocaleForUpdate(Player); - MudObject.SendMessage(Player, Actor.Short + " has removed you from the server."); - Player.ConnectedClient.Disconnect(); - Clients.SendGlobalMessage(Actor.Short + " has removed " + Player.Short + " from the server."); + MudObject.SendMessage(Player, Actor.GetProperty("short") + " has removed you from the server."); + client.Disconnect(); + Clients.SendGlobalMessage(Actor.GetProperty("short") + " has removed " + Player.GetProperty("short") + " from the server."); } } } diff --git a/NetworkModule/Login.cs b/NetworkModule/Login.cs index 00a2cee..eab634d 100644 --- a/NetworkModule/Login.cs +++ b/NetworkModule/Login.cs @@ -18,22 +18,23 @@ 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; + var client = actor.GetProperty("client"); + if (client == null) return SharpRuleEngine.PerformResult.Stop; - if (actor.ConnectedClient is NetworkClient && (actor.ConnectedClient as NetworkClient).IsLoggedOn) + if (client is NetworkClient && (client 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; + actor.SetProperty("command handler", new PasswordCommandHandler(actor, Authenticate, userName)); + return SharpRuleEngine.PerformResult.Continue; }); } - public void Authenticate(Actor Actor, String UserName, String Password) + public void Authenticate(MudObject Actor, String UserName, String Password) { var existingAccount = Accounts.LoadAccount(UserName); if (existingAccount == null || Accounts.VerifyAccount(existingAccount, Password) == false) @@ -42,7 +43,8 @@ public void Authenticate(Actor Actor, String UserName, String Password) return; } - LoginCommandHandler.LogPlayerIn(Actor.ConnectedClient as NetworkClient, existingAccount); + var client = Actor.GetProperty("client"); + LoginCommandHandler.LogPlayerIn(client as NetworkClient, existingAccount); } } } diff --git a/NetworkModule/LoginCommandHandler.cs b/NetworkModule/LoginCommandHandler.cs index ce313ee..8faf355 100644 --- a/NetworkModule/LoginCommandHandler.cs +++ b/NetworkModule/LoginCommandHandler.cs @@ -18,11 +18,12 @@ public static void LogPlayerIn(NetworkClient Client, Account Account) if (Account.LoggedInCharacter != null) { //Connect to the existing session - if (Account.LoggedInCharacter.ConnectedClient != null) + var existingClient = Account.LoggedInCharacter.GetProperty("client"); + if (existingClient != null) { - Account.LoggedInCharacter.ConnectedClient.Player = null; - Account.LoggedInCharacter.ConnectedClient.Send("You are being disconnected because you have logged into this account from another connection.\r\n"); - Account.LoggedInCharacter.ConnectedClient.Disconnect(); + existingClient.Player = null; + existingClient.Send("You are being disconnected because you have logged into this account from another connection.\r\n"); + existingClient.Disconnect(); } Client.Send("You were already logged in. You are being connected to that session.\r\n"); Client.Player = Account.LoggedInCharacter; @@ -36,7 +37,7 @@ public static void LogPlayerIn(NetworkClient Client, Account Account) Client.Player.SetProperty("account", Account); Client.IsLoggedOn = true; - Client.Player.CommandHandler = Core.ParserCommandHandler; + Client.Player.SetProperty("command handler", Core.ParserCommandHandler); Account.LoggedInCharacter = Client.Player; Core.TiePlayerToClient(Client, Client.Player); diff --git a/NetworkModule/NetworkModule.csproj b/NetworkModule/NetworkModule.csproj index d6a3a81..42e9193 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.5\lib\SharpRuleEngine.dll + diff --git a/NetworkModule/PasswordCommandHandler.cs b/NetworkModule/PasswordCommandHandler.cs index e02c0cd..709e9c6 100644 --- a/NetworkModule/PasswordCommandHandler.cs +++ b/NetworkModule/PasswordCommandHandler.cs @@ -11,11 +11,11 @@ public class PasswordCommandHandler : ClientCommandHandler { public ClientCommandHandler ParentHandler; public String UserName; - public Action AuthenticatingCommand; + public Action AuthenticatingCommand; - public PasswordCommandHandler(Actor Actor, Action AuthenticatingCommand, String UserName) + public PasswordCommandHandler(MudObject Actor, Action AuthenticatingCommand, String UserName) { - this.ParentHandler = Actor.CommandHandler; + this.ParentHandler = Actor.GetProperty("command handler"); this.AuthenticatingCommand = AuthenticatingCommand; this.UserName = UserName; @@ -24,7 +24,7 @@ public PasswordCommandHandler(Actor Actor, Action Authent public void HandleCommand(PendingCommand Command) { - Command.Actor.CommandHandler = ParentHandler; + Command.Actor.SetProperty("command handler", ParentHandler); AuthenticatingCommand(Command.Actor, UserName, Command.RawCommand); } } diff --git a/NetworkModule/Quit.cs b/NetworkModule/Quit.cs index 6ca421f..ed91a40 100644 --- a/NetworkModule/Quit.cs +++ b/NetworkModule/Quit.cs @@ -15,14 +15,14 @@ public override void Create(CommandParser Parser) .Manual("Disconnect from the game immediately.") .ProceduralRule((match, actor) => { - if (actor != null && actor.ConnectedClient != null) - match.Upsert("CLIENT", actor.ConnectedClient); - if (match.ContainsKey("CLIENT")) + var client = actor.GetProperty("client"); + if (client != null) { - (match["CLIENT"] as Client).Send("Goodbye...\r\n"); - (match["CLIENT"] as Client).Disconnect(); + client.Send("Goodbye...\r\n"); + client.Disconnect(); } - return PerformResult.Continue; + + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/Register.cs b/NetworkModule/Register.cs index 35a4938..bed183b 100644 --- a/NetworkModule/Register.cs +++ b/NetworkModule/Register.cs @@ -18,20 +18,21 @@ public override void Create(CommandParser Parser) .Manual("If you got this far, you know how to register.") .ProceduralRule((match, actor) => { - if (actor.ConnectedClient is NetworkClient && (actor.ConnectedClient as NetworkClient).IsLoggedOn) + var client = actor.GetProperty("client"); + if (client is NetworkClient && (client 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; + actor.SetProperty("command handler", new PasswordCommandHandler(actor, Authenticate, userName)); + return SharpRuleEngine.PerformResult.Continue; }); } - public void Authenticate(Actor Actor, String UserName, String Password) + public void Authenticate(MudObject Actor, String UserName, String Password) { var existingAccount = Accounts.LoadAccount(UserName); if (existingAccount != null) @@ -47,7 +48,8 @@ public void Authenticate(Actor Actor, String UserName, String Password) return; } - LoginCommandHandler.LogPlayerIn(Actor.ConnectedClient as NetworkClient, newAccount); + var client = Actor.GetProperty("client"); + LoginCommandHandler.LogPlayerIn(client as NetworkClient, newAccount); } } } diff --git a/NetworkModule/Stats.cs b/NetworkModule/Stats.cs index 5e6ffb0..235fba7 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") @@ -25,10 +25,10 @@ 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))); - return PerformResult.Stop; + MudObject.SendMessage(actor, "local " + (client.Player == null ? "" : (" - " + client.Player.GetProperty("short")))); + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/NetworkModule/Whisper.cs b/NetworkModule/Whisper.cs index 39abd09..204cfd1 100644 --- a/NetworkModule/Whisper.cs +++ b/NetworkModule/Whisper.cs @@ -25,18 +25,19 @@ 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) => { - var player = match["PLAYER"] as Actor; + var player = match["PLAYER"] as MudObject; MudObject.SendMessage(player, "[privately " + DateTime.Now + "] ^ : \"" + match["SPEECH"].ToString() + "\"", actor); 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; + var client = player.GetProperty("client"); + if (client is NetworkClient && (client as NetworkClient).IsAfk) + MudObject.SendMessage(actor, "^ is afk : " + player.GetProperty("account").AFKMessage, player); + return SharpRuleEngine.PerformResult.Continue; }); } } diff --git a/NetworkModule/Who.cs b/NetworkModule/Who.cs index 8dbffff..3cd2485 100644 --- a/NetworkModule/Who.cs +++ b/NetworkModule/Who.cs @@ -19,12 +19,12 @@ public override void Create(CommandParser Parser) MudObject.SendMessage(actor, "~~ THESE PLAYERS ARE ONLINE NOW ~~"); foreach (NetworkClient client in clients) MudObject.SendMessage(actor, - "[" + Core.SettingsObject.GetNameForRank(client.Player.Rank) + "] [" + "[" + Core.SettingsObject.GetNameForRank(client.Player.GetProperty("rank")) + "] [" + client.ConnectionDescription + "]" + (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..9ee4a99 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..a7d1c05 100644 --- a/QuestModule/AcceptQuest.cs +++ b/QuestModule/AcceptQuest.cs @@ -21,24 +21,23 @@ 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) => { - 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"); - return PerformResult.Stop; + actor.SetProperty("offered-quest", null); + return SharpRuleEngine.PerformResult.Stop; } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }, "the quest must be available rule.") .ProceduralRule((match, actor) => { @@ -46,8 +45,8 @@ 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"); - return PerformResult.Continue; + 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/QuestModule.csproj b/QuestModule/QuestModule.csproj index 8a4e384..4c53ac1 100644 --- a/QuestModule/QuestModule.csproj +++ b/QuestModule/QuestModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\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..d843e2b 100644 --- a/QuestModule/QuestRules.cs +++ b/QuestModule/QuestRules.cs @@ -10,28 +10,31 @@ namespace QuestModule { public class QuestProceduralRules { - public static void AtStartup(RuleEngine GlobalRules) + public static void AtStartup(RMUD.RuleEngine GlobalRules) { - GlobalRules.Perform("after acting") + PropertyManifest.RegisterProperty("active-quest", typeof(MudObject), null, new DefaultSerializer()); + PropertyManifest.RegisterProperty("offered-quest", typeof(MudObject), null, new DefaultSerializer()); + + GlobalRules.Perform("after acting") .Do((match, actor) => { if (actor.GetProperty("active-quest") != 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); } } - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }) .Name("Check quest status after acting rule."); diff --git a/QuestModule/TypeExtensions.cs b/QuestModule/TypeExtensions.cs index 34e1d33..a71e28e 100644 --- a/QuestModule/TypeExtensions.cs +++ b/QuestModule/TypeExtensions.cs @@ -10,15 +10,14 @@ namespace QuestModule { public static class Extensions { - public static void OfferQuest(this MudObject This, Actor Actor, MudObject Quest) + public static void OfferQuest(this MudObject This, MudObject Actor, MudObject Quest) { - var player = Actor as Player; - if (player != null) + if (Actor != null) { MudObject.SendMessage(Actor, "[To accept this quest, enter the command 'accept quest'.]"); - if (player.GetProperty("active-quest") != null) + if (Actor.GetProperty("active-quest") != null) MudObject.SendMessage(Actor, "[Accepting this quest will abandon your active quest.]"); - player.SetProperty("offered-quest", Quest); + Actor.SetProperty("offered-quest", Quest); } } diff --git a/QuestModule/packages.config b/QuestModule/packages.config new file mode 100644 index 0000000..ec6597f --- /dev/null +++ b/QuestModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RMUD.sln b/RMUD.sln index ce34643..2105df6 100644 --- a/RMUD.sln +++ b/RMUD.sln @@ -1,20 +1,11 @@  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 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SinglePlayer", "SinglePlayer\SinglePlayer.csproj", "{A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfConsole", "WpfConsole\WpfConsole.csproj", "{F430938B-D039-4B18-9D91-3A1819CA0CD5}" - ProjectSection(ProjectDependencies) = postProject - {35448D1E-7997-4626-8D1F-4278659F60A0} = {35448D1E-7997-4626-8D1F-4278659F60A0} - {1A004032-0F05-4545-88F2-3F58EFA1CE1D} = {1A004032-0F05-4545-88F2-3F58EFA1CE1D} - {ADAF3782-88D1-4170-866A-9EF3479EAE97} = {ADAF3782-88D1-4170-866A-9EF3479EAE97} - {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41} = {5C29E6AD-54E3-4105-A9F3-2AAB48A17C41} - {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78} = {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78} - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloakOfDarkness", "SinglePlayer\CloakOfDarkness.csproj", "{A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConversationModule", "ConversationModule\ConversationModule.csproj", "{35448D1E-7997-4626-8D1F-4278659F60A0}" EndProject @@ -36,98 +27,172 @@ 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}" +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}") = "PlayAkko", "Play\PlayAkko.csproj", "{660E7522-3209-426D-9009-ABC4F8E881B0}" +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 - {F430938B-D039-4B18-9D91-3A1819CA0CD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F430938B-D039-4B18-9D91-3A1819CA0CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F430938B-D039-4B18-9D91-3A1819CA0CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F430938B-D039-4B18-9D91-3A1819CA0CD5}.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 - {660E7522-3209-426D-9009-ABC4F8E881B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {660E7522-3209-426D-9009-ABC4F8E881B0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {660E7522-3209-426D-9009-ABC4F8E881B0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {660E7522-3209-426D-9009-ABC4F8E881B0}.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 EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A8EA5CC5-9C0A-47E3-A68C-9E8367CEF1FC} = {5695FB1B-65C3-4659-BCFE-62037DC92A81} + {35448D1E-7997-4626-8D1F-4278659F60A0} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {8F1AF0E1-C98D-466A-A712-621493453373} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {05484D1A-47F3-4B4A-B457-AF56B197E4CB} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {1BCBACDD-8405-4373-8260-168C50932C76} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {FD03FCF2-E4F6-4132-A50F-C66B1B9A409E} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {DA9A47A5-83D6-440E-9008-8EA59C8446DC} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {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} + {37794C83-F94B-4B30-8E6A-DEDA0A389015} = {84327B59-5112-4822-BF9A-5683750CA5BD} + {68D0E431-5DCA-4A25-A1B2-2F5B857821B1} = {5695FB1B-65C3-4659-BCFE-62037DC92A81} + EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = RMUD\RMUD.csproj Policies = $0 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/RMUD/RMUD.csproj b/RMUD/RMUD.csproj index 5b0b556..26a886e 100644 --- a/RMUD/RMUD.csproj +++ b/RMUD/RMUD.csproj @@ -39,6 +39,10 @@ false + + False + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -115,6 +119,7 @@ + diff --git a/RMUD/database/static/palantine/antechamber.cs b/RMUD/database/static/palantine/antechamber.cs index fc87510..2a15173 100644 --- a/RMUD/database/static/palantine/antechamber.cs +++ b/RMUD/database/static/palantine/antechamber.cs @@ -40,7 +40,7 @@ public override void Initialize() } } -public class Jupiter : RMUD.Scenery +public class Jupiter : RMUD.MudObject { public Jupiter() { @@ -48,6 +48,8 @@ public Jupiter() Long = "Jupiter holds in his left hand a gleaming thunderbolt. It glows bright enough to light the entire chamber. In his right, he holds a chisel."; Value("light level").Do(a => RMUD.LightingLevel.Bright); + + SetProperty("scenery?", true); // We could also add a 'should be listed in locale?' rule to Jupiter. } } @@ -65,10 +67,10 @@ public Table() : base(RMUD.RelativeLocations.On | RMUD.RelativeLocations.Under, Check("can take?").Do((actor, thing) => { SendMessage(actor, "It's far too heavy."); - return RMUD.CheckResult.Disallow; + return CheckResult.Disallow; }); - this.CheckCanPushDirection().Do((actor, subject, link) => RMUD.CheckResult.Allow); + this.CheckCanPushDirection().Do((actor, subject, link) => CheckResult.Allow); //Value("printed name").When((viewer, thing, article) => thing == this).Do((viewer, thing, article) => "an ancient table"); } diff --git a/RMUD/database/static/palantine/ball.cs b/RMUD/database/static/palantine/ball.cs index bf47984..52fe00e 100644 --- a/RMUD/database/static/palantine/ball.cs +++ b/RMUD/database/static/palantine/ball.cs @@ -9,7 +9,7 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) .ProceduralRule((match, actor) => { SendMessage(actor, "Database defined commands appear to work."); - return RMUD.PerformResult.Continue; + return PerformResult.Continue; }); } } \ No newline at end of file diff --git a/RMUD/database/static/palantine/cave.cs b/RMUD/database/static/palantine/cave.cs index 719ca5b..fe532c8 100644 --- a/RMUD/database/static/palantine/cave.cs +++ b/RMUD/database/static/palantine/cave.cs @@ -1,10 +1,10 @@ -public class cave : RMUD.Room +public class cave : Room { public override void Initialize() { - RoomType = RMUD.RoomType.Exterior; + RoomType = RoomType.Exterior; Short = "Palantine Villa - Cave"; - OpenLink(RMUD.Direction.UP, "palantine\\garden"); + OpenLink(Direction.UP, "palantine\\garden"); } } \ No newline at end of file diff --git a/RMUD/database/static/palantine/dark_room.cs b/RMUD/database/static/palantine/dark_room.cs index b718d3e..da70b34 100644 --- a/RMUD/database/static/palantine/dark_room.cs +++ b/RMUD/database/static/palantine/dark_room.cs @@ -1,11 +1,11 @@ -public class dark_room : RMUD.Room +public class dark_room : Room { public override void Initialize() { - RoomType = RMUD.RoomType.Interior; + RoomType = RoomType.Interior; Short = "Palantine Villa - Soul Chamber"; Long = "It does not matter how bright a light you carry, it cannot banish the shadows from your soul."; - OpenLink(RMUD.Direction.WEST, "palantine\\disambig", GetObject("palantine\\disambig_red_door@outside")); + OpenLink(Direction.WEST, "palantine\\disambig", GetObject("palantine\\disambig_red_door@outside")); } } diff --git a/RMUD/database/static/palantine/entrail_quest.cs b/RMUD/database/static/palantine/entrail_quest.cs index f1509ec..582f3b2 100644 --- a/RMUD/database/static/palantine/entrail_quest.cs +++ b/RMUD/database/static/palantine/entrail_quest.cs @@ -1,4 +1,4 @@ -class entrail_quest : RMUD.MudObject +class entrail_quest : MudObject { public override void Initialize() { @@ -6,47 +6,47 @@ public override void Initialize() bool Active = false; - Value("quest available?").Do((actor, quest) => !Active && IsVisibleTo(actor, RMUD.MudObject.GetObject("palantine/soranus"))); + Value("quest available?").Do((actor, quest) => !Active && IsVisibleTo(actor, MudObject.GetObject("palantine/soranus"))); - Value("quest complete?").Do((actor, quest) => + Value("quest complete?").Do((actor, quest) => { var wolf = GetObject("palantine/wolf"); return ConsiderValueRule("entrail-quest-is-fed", wolf); }); - Value("quest failed?").Do((actor, quest) => !ObjectContainsObject(actor, GetObject("palantine/entrails"))); + Value("quest failed?").Do((actor, quest) => !ObjectContainsObject(actor, GetObject("palantine/entrails"))); - Perform("quest accepted").Do((questor, quest) => + Perform("quest accepted").Do((questor, quest) => { Active = true; SendMessage(questor, "You have accepted the entrail quest."); var entrails = GetObject("palantine/entrails"); - if ((GetObject("palantine/soranus") as RMUD.Actor).Contains(entrails, RMUD.RelativeLocations.Worn)) + if ((GetObject("palantine/soranus") as Actor).Contains(entrails, RelativeLocations.Worn)) { Move(entrails, questor); SendMessage(questor, "^ gives you some entrails.", GetObject("palantine/soranus")); } - return RMUD.PerformResult.Continue; + return PerformResult.Continue; }); - Perform("quest completed").Do((questor, quest) => + Perform("quest completed").Do((questor, quest) => { SendMessage(questor, "Entrail quest completed."); this.ResetQuestObject(GetObject("palantine/wolf")); this.ResetQuestObject(GetObject("palantine/soranus")); Active = false; - return RMUD.PerformResult.Continue; + return PerformResult.Continue; }); - Perform("quest failed").Do((questor, quest) => + Perform("quest failed").Do((questor, quest) => { SendMessage(questor, "Entrail quest failed."); this.ResetQuestObject(GetObject("palantine/wolf")); this.ResetQuestObject(GetObject("palantine/soranus")); - Move(GetObject("palantine/entrails"), GetObject("palantine/soranus"), RMUD.RelativeLocations.Worn); + Move(GetObject("palantine/entrails"), GetObject("palantine/soranus"), RelativeLocations.Worn); Active = false; - return RMUD.PerformResult.Continue; + return PerformResult.Continue; }); } } \ No newline at end of file diff --git a/RMUD/database/static/palantine/library.cs b/RMUD/database/static/palantine/library.cs index 63e3045..4788d42 100644 --- a/RMUD/database/static/palantine/library.cs +++ b/RMUD/database/static/palantine/library.cs @@ -1,15 +1,15 @@ -public class library : RMUD.Room +public class library : Room { public override void Initialize() { Short = "Palantine Villa - The Ancient Library of Kuz"; Move(new kuz_shelf(), this); - OpenLink(RMUD.Direction.EAST, "palantine/disambig", GetObject("palantine/disambig_blue_door@outside")); + OpenLink(Direction.EAST, "palantine/disambig", GetObject("palantine/disambig_blue_door@outside")); } } -public class kuz_shelf : RMUD.MudObject +public class kuz_shelf : MudObject { public kuz_shelf() { @@ -17,27 +17,27 @@ public kuz_shelf() Long = "There are so many books, and they all look so interesting and inviting. You could just go right ahead and take one."; Nouns.Add("BOOK", "BOOKS", "SHELF", "DUSTY"); - Perform("describe in locale").Do((actor, item) => + Perform("describe in locale").Do((actor, item) => { SendMessage(actor, "A massive book shelf looms in the center of the room."); - return RMUD.PerformResult.Continue; + return PerformResult.Continue; }); - Check("can take?").Do((a, b) => RMUD.CheckResult.Allow); + Check("can take?").Do((a, b) => CheckResult.Allow); - Perform("taken").Do((actor, target) => + Perform("taken").Do((actor, target) => { var newBook = new kuz_book(); Move(newBook, actor); SendMessage(actor, "You take .", newBook); SendExternalMessage(actor, " takes .", actor, newBook); - return RMUD.PerformResult.Stop; + return PerformResult.Stop; }); } } -public class kuz_book : RMUD.MudObject +public class kuz_book : MudObject { public static System.Collections.Generic.List TitlesA = new System.Collections.Generic.List(new System.String[]{ "Chronicles of", diff --git a/RMUD/database/static/palantine/pit.cs b/RMUD/database/static/palantine/pit.cs index 9293c9a..962ed16 100644 --- a/RMUD/database/static/palantine/pit.cs +++ b/RMUD/database/static/palantine/pit.cs @@ -1,8 +1,8 @@ -public class pit : RMUD.Room +public class pit : Room { public override void Initialize() { - RoomType = RMUD.RoomType.Exterior; + RoomType = RoomType.Exterior; Short = "Palantine Villa - Pit"; OpenLink(RMUD.Direction.NORTH, "palantine/antechamber"); diff --git a/RMUD/database/static/palantine/platos_closet.cs b/RMUD/database/static/palantine/platos_closet.cs index 1f17fb0..a0e42b9 100644 --- a/RMUD/database/static/palantine/platos_closet.cs +++ b/RMUD/database/static/palantine/platos_closet.cs @@ -1,8 +1,8 @@ -public class platos_closet : RMUD.Room +public class platos_closet : Room { public override void Initialize() { - RoomType = RMUD.RoomType.Interior; + RoomType = RoomType.Interior; Short = "Palantine Villa - Plato's Closet"; AddScenery(new lamp()); @@ -11,18 +11,20 @@ public override void Initialize() Move(Clothing.Create("polo shirt", ClothingLayer.Outer, ClothingBodyPart.Torso), this); Move(Clothing.Create("pair of briefs", ClothingLayer.Under, ClothingBodyPart.Legs), this); - OpenLink(RMUD.Direction.WEST, "palantine\\solar"); + OpenLink(Direction.WEST, "palantine\\solar"); } } -public class lamp : RMUD.Scenery +public class lamp : MudObject { public lamp() { Nouns.Add("gas", "lamp"); Long = "This little gas lamp somehow manages to fill the endless closet with light."; - Value("light level").Do(a => RMUD.LightingLevel.Bright); + Value("light level").Do(a => LightingLevel.Bright); + + SetProperty("scenery?", true); } } \ No newline at end of file diff --git a/RMUD/database/static/palantine/skull.cs b/RMUD/database/static/palantine/skull.cs index 15e6807..98d3bcb 100644 --- a/RMUD/database/static/palantine/skull.cs +++ b/RMUD/database/static/palantine/skull.cs @@ -1,6 +1,6 @@ -public class skull : RMUD.MudObject +public class skull : MudObject { - [RMUD.Persist] + [Persist] public int ExamineCount { get; set; } public override void Initialize() @@ -10,12 +10,12 @@ public override void Initialize() Short = "human skull"; Nouns.Add("human", "skull"); - Perform("describe") + Perform("describe") .Do((viewer, thing) => { ExamineCount += 1; SendMessage(viewer, string.Format("How many times? {0} times.", ExamineCount)); - return RMUD.PerformResult.Continue; + return PerformResult.Continue; }); } diff --git a/RMUD/database/static/palantine/solar.cs b/RMUD/database/static/palantine/solar.cs index f584a07..c577d2e 100644 --- a/RMUD/database/static/palantine/solar.cs +++ b/RMUD/database/static/palantine/solar.cs @@ -1,11 +1,11 @@ -public class solar : RMUD.Room +public class solar : Room { int TimesViewed = 0; string Brief; public override void Initialize() { - RoomType = RMUD.RoomType.Exterior; + RoomType = RoomType.Exterior; Short = "Palantine Villa - Solar"; Long = "You are in a gorgeous solar filled with white marble and glowing sun beams. Massive windows above let in copious amounts of light that pick out flecks of minerals in the veins flowing through the marble and make them sparkle like the thousand stars in the firmament."; @@ -14,21 +14,21 @@ public override void Initialize() Move(GetObject("palantine/soranus"), this); - OpenLink(RMUD.Direction.WEST, "palantine\\antechamber"); - OpenLink(RMUD.Direction.EAST, "palantine\\platos_closet"); + OpenLink(Direction.WEST, "palantine\\antechamber"); + OpenLink(Direction.EAST, "palantine\\platos_closet"); - Perform("describe") + Perform("describe") .Do((viewer, item) => { - var auto = RMUD.Core.ExecutingCommand.ValueOrDefault("AUTO", false); + var auto = Core.ExecutingCommand.ValueOrDefault("AUTO", false); if (item.TimesViewed > 0 && auto) - RMUD.MudObject.SendMessage(viewer, item.Brief); + MudObject.SendMessage(viewer, item.Brief); else - RMUD.MudObject.SendMessage(viewer, item.Long); + MudObject.SendMessage(viewer, item.Long); item.TimesViewed += 1; - return RMUD.PerformResult.Stop; + return PerformResult.Stop; }).Name("Choose brief or long description rule."); } diff --git a/RMUD/database/static/palantine/soranus.cs b/RMUD/database/static/palantine/soranus.cs index 2d48cce..bfbb3ba 100644 --- a/RMUD/database/static/palantine/soranus.cs +++ b/RMUD/database/static/palantine/soranus.cs @@ -6,7 +6,7 @@ public override void Initialize() { SendLocaleMessage(actor, "\"I am Soranus,\" says.", this); GlobalRules.ConsiderPerformRule("introduce self", this); - return RMUD.PerformResult.Stop; + return PerformResult.Stop; }); this.Response("the entrails", "\"These things?\" asks. \"Nothing special. They're for the wolves.\""); @@ -18,17 +18,17 @@ public override void Initialize() if (GlobalRules.ConsiderValueRule("quest available?", actor, quest)) { SendMessage(actor, "\"Would you mind feeding them for me?\" asks.", this); - this.OfferQuest(actor as RMUD.Actor, quest); + this.OfferQuest(actor as Actor, quest); } - return RMUD.PerformResult.Stop; + return PerformResult.Stop; }); - Perform("topic response") + Perform("topic response") .When((actor, npc, topic) => topic == null) .Do((actor, npc, topic) => { SendLocaleMessage(actor, "\"This is my default response,\" says, showing his sharp little teeth.", this); - return RMUD.PerformResult.Stop; + return PerformResult.Stop; }); Short = "Soranus"; diff --git a/RMUD/database/static/palantine/wolf.cs b/RMUD/database/static/palantine/wolf.cs index beb6290..1df95fe 100644 --- a/RMUD/database/static/palantine/wolf.cs +++ b/RMUD/database/static/palantine/wolf.cs @@ -1,14 +1,14 @@ -class wolf : RMUD.NPC +class wolf : NPC { public bool IsFed = false; public override void Initialize() { - Perform("topic response") + Perform("topic response") .Do((actor, npc, topic) => { - RMUD.MudObject.SendLocaleMessage(actor, "The wolf snarls and howls, showing its large sharp teeth."); - return RMUD.PerformResult.Stop; + MudObject.SendLocaleMessage(actor, "The wolf snarls and howls, showing its large sharp teeth."); + return PerformResult.Stop; }); Short = "wolf"; @@ -16,27 +16,27 @@ public override void Initialize() Nouns.Add("wolf"); - Perform("handle-entrail-drop").Do((wolf, entrails) => + Perform("handle-entrail-drop").Do((wolf, entrails) => { - RMUD.MudObject.SendLocaleMessage(this, "The wolf snatches up the entrails."); + MudObject.SendLocaleMessage(this, "The wolf snatches up the entrails."); IsFed = true; - RMUD.MudObject.Move(entrails, RMUD.MudObject.GetObject("palantine/soranus"), RMUD.RelativeLocations.Worn); - return RMUD.PerformResult.Stop; + MudObject.Move(entrails, MudObject.GetObject("palantine/soranus"), RelativeLocations.Worn); + return PerformResult.Stop; }); - Value("printed name").First.Do((viewer, item, article) => article + " wolf"); + Value("printed name").First.Do((viewer, item, article) => article + " wolf"); - Value("entrail-quest-is-fed").Do(wolf => IsFed); + Value("entrail-quest-is-fed").Do(wolf => IsFed); - Perform("quest reset") + Perform("quest reset") .When((quest, item) => quest.Path == "palantine/entrail_quest") - .Do((quest, item) => { IsFed = false; return RMUD.PerformResult.Stop; }); + .Do((quest, item) => { IsFed = false; return PerformResult.Stop; }); - RMUD.Core.GlobalRules.Perform("heartbeat").Do(() => + Core.GlobalRules.Perform("heartbeat").Do(() => { if (!IsFed) - RMUD.MudObject.SendLocaleMessage(this, "The wolf whines for food."); - return RMUD.PerformResult.Continue; + MudObject.SendLocaleMessage(this, "The wolf whines for food."); + return PerformResult.Continue; }); } diff --git a/RMUD/database/static/player_base.cs b/RMUD/database/static/player_base.cs index 64f90f8..7427d58 100644 --- a/RMUD/database/static/player_base.cs +++ b/RMUD/database/static/player_base.cs @@ -1,3 +1,3 @@ -public class player_base : RMUD.Player +public class player_base : Player { } diff --git a/RMUD/packages.config b/RMUD/packages.config new file mode 100644 index 0000000..ec6597f --- /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..e2e1393 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 { @@ -17,7 +18,7 @@ public override void Create(CommandParser Parser) MustMatch("Who is being too damn serious?", Object("OBJECT", InScope, (actor, item) => { - if (item is RMUD.Actor) return MatchPreference.Likely; + if (item.GetProperty("actor?")) return MatchPreference.Likely; else return MatchPreference.Unlikely; })))) .Manual("Applies the silly status effect to the target of your choice. Being silly will make it safe for your victim to dance. Sillification is meant as a demonstration of the concepts involved with rule books and status effects, and not as an actual component of the game world.") @@ -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."); @@ -48,7 +49,7 @@ public static void AtStartup(RuleEngine GlobalRules) GlobalRules.DeclareCheckRuleBook("can silly?", "[Actor, Target] : Can the actor make the target silly?", "actor", "item"); GlobalRules.Check("can silly?").First - .When((actor, target) => !(target is Actor)) + .When((actor, target) => !(target.GetProperty("actor?"))) .Do((actor, target) => { MudObject.SendMessage(actor, "That just sounds silly."); @@ -85,7 +86,7 @@ public static void AtStartup(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."); @@ -93,7 +94,7 @@ public static void AtStartup(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()); @@ -105,7 +106,7 @@ public static void AtStartup(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/SillyModule/SillyModule.csproj b/SillyModule/SillyModule.csproj index 52bfce5..9277ce0 100644 --- a/SillyModule/SillyModule.csproj +++ b/SillyModule/SillyModule.csproj @@ -31,6 +31,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\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..ec6597f --- /dev/null +++ b/SillyModule/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Cipher.cs b/SinglePlayer/Akkoteaque/Cipher.cs deleted file mode 100644 index a996c5e..0000000 --- a/SinglePlayer/Akkoteaque/Cipher.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Akkoteaque -{ - public class Cipher - { - static String[] LetterEncodings = new String[] - { - "──┐", "──┘", "──┤", "─┬┐", "─┬┘", "─┬┤", "─┴┐", "─┴┘", "─┴┤", "─┼┐", "─┼┘", "─┼┤", "┬─┐", "┬─┘", "┬─┤", "┬┬┐", "┬┬┘", "┬┬┤", "┬┴┐", "┬┴┘", "┬┴┤", "┬┼┐", "┬┼┘", "┬┼┤", "┴─┐", "┴─┘" - }; - - static String[] PunctuationEncodings = new String[] { "►──", "►┼┤", "►─┐" }; - - static Dictionary Encodings = null; - - static string GetEncodingSequence(char c) - { - if (Encodings == null) - { - Encodings = new Dictionary(); - for (char x = 'a'; x <= 'z'; ++x) - Encodings.Add(x, LetterEncodings[x - 'a']); - Encodings.Add('.', PunctuationEncodings[0]); - Encodings.Add('!', PunctuationEncodings[1]); - Encodings.Add('?', PunctuationEncodings[2]); - } - - if (c >= 'A' && c <= 'Z') - return ExtendLastCharacter(Encodings[(char)((c - 'A') + 'a')]) + "◄"; - else if (!Encodings.ContainsKey(c)) return ""; - return Encodings[c] + " "; - } - - static string ExtendLastCharacter(string s) - { - if (String.IsNullOrEmpty(s)) return s; - if (s.Last() == '┐') - return s.Substring(0, s.Length - 1) + "┬"; - else if (s.Last() == '┤') - return s.Substring(0, s.Length - 1) + "┼"; - else if (s.Last() == '┘') - return s.Substring(0, s.Length - 1) + "┴"; - else - return s; - } - - static string EncodeString(string str) - { - var prevSpace = true; - var nextSpace = true; - var r = ""; - for (int i = 0; i < str.Length; ++i) - { - if (str[i] == ' ') - { - prevSpace = true; - r += " "; - } - else - { - nextSpace = (i == str.Length - 1) || (str[i + 1] == ' '); - if (prevSpace && nextSpace) r += "►"; - else if (prevSpace) r += "┌"; - else if (nextSpace) r += "└"; - else r += "├"; - prevSpace = false; - r += GetEncodingSequence(str[i]); - } - } - return r; - } - - public static string EncodeParagraph(params string[] Segments) - { - var encodedSegments = Segments.Select(s => EncodeString(s)); - var r = ""; - var rows = encodedSegments.Max(s => s.Length); - for (int i = 0; i < rows; i += 5) - { - foreach (var s in encodedSegments) - { - if (s.Length <= i) r += " "; - else r += s.Substring(i, 5) + " "; - } - r += "\n"; - } - return r; - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/Bait.cs b/SinglePlayer/Akkoteaque/Fishing/Bait.cs deleted file mode 100644 index 2e5aee8..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/Bait.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class Bait : MudObject - { - public override void Initialize() - { - Short = "generic fishing bait"; - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/Clam.cs b/SinglePlayer/Akkoteaque/Fishing/Clam.cs deleted file mode 100644 index 7b7a97b..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/Clam.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class Clam : Bait - { - public override void Initialize() - { - SimpleName("clam"); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/FishHead.cs b/SinglePlayer/Akkoteaque/Fishing/FishHead.cs deleted file mode 100644 index b807c1a..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/FishHead.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class FishHead : Bait - { - public override void Initialize() - { - SimpleName("fish head"); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/Hook.cs b/SinglePlayer/Akkoteaque/Fishing/Hook.cs deleted file mode 100644 index afaceab..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/Hook.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class Hook : MudObject - { - public override void Initialize() - { - Short = "generic fishing hook"; - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/Rod.cs b/SinglePlayer/Akkoteaque/Fishing/Rod.cs deleted file mode 100644 index bf5145d..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/Rod.cs +++ /dev/null @@ -1,45 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class Rod : Container - { - public Rod() - : base(RelativeLocations.On, RelativeLocations.On) - { } - - public override void Initialize() - { - Short = "fishing rod"; - Nouns.Add("fishing", "rod"); - Long = "This is a compact, collapsible fishing rod."; - - Check("can put?") - .When((actor, item, container, location) => container == this && !(item is Hook) && !(item is Bait)) - .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; - }); - - Perform("put") - .When((actor, item, container, location) => container == this) - .Do((actor, item, container, location) => - { - if (item is Hook) - this.RemoveAll(o => true); - else if (item is Bait) - this.RemoveAll(o => o is Bait); - - this.Add(item, RelativeLocations.On); - - if (item is Hook) - SendMessage(actor, "You tie to the line.", item); - else - SendMessage(actor, "You put on the hook.", item); - - return PerformResult.Stop; - }); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/RustyHook.cs b/SinglePlayer/Akkoteaque/Fishing/RustyHook.cs deleted file mode 100644 index a932352..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/RustyHook.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class RustyHook : Hook - { - public override void Initialize() - { - SimpleName("rusty hook"); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/ShinyHook.cs b/SinglePlayer/Akkoteaque/Fishing/ShinyHook.cs deleted file mode 100644 index 023e6ca..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/ShinyHook.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class ShinyHook : Hook - { - public override void Initialize() - { - SimpleName("shiny hook"); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/SinkingLure.cs b/SinglePlayer/Akkoteaque/Fishing/SinkingLure.cs deleted file mode 100644 index 29fa2bc..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/SinkingLure.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class SinkingLure : Hook - { - public override void Initialize() - { - SimpleName("sinking lure"); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Fishing/Worm.cs b/SinglePlayer/Akkoteaque/Fishing/Worm.cs deleted file mode 100644 index 58e68c1..0000000 --- a/SinglePlayer/Akkoteaque/Fishing/Worm.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Akkoteaque.Fishing -{ - public class Worm : Bait - { - public override void Initialize() - { - SimpleName("worm"); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Jetty.cs b/SinglePlayer/Akkoteaque/Jetty.cs deleted file mode 100644 index 3a6b466..0000000 --- a/SinglePlayer/Akkoteaque/Jetty.cs +++ /dev/null @@ -1,20 +0,0 @@ -using RMUD; - -namespace Akkoteaque -{ - - public class Jetty : RMUD.Room - { - public override void Initialize() - { - Short = "Stone Jetty"; - Perform("describe") - .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; - }); - - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Akkoteaque/Player.cs b/SinglePlayer/Akkoteaque/Player.cs deleted file mode 100644 index 5c83f46..0000000 --- a/SinglePlayer/Akkoteaque/Player.cs +++ /dev/null @@ -1,13 +0,0 @@ -using RMUD; - -namespace Akkoteaque -{ - public class Player : RMUD.Player - { - public override void Initialize() - { - Short = "you"; - - } - } -} diff --git a/SinglePlayer/Akkoteaque/Settings.cs b/SinglePlayer/Akkoteaque/Settings.cs deleted file mode 100644 index 4065a9a..0000000 --- a/SinglePlayer/Akkoteaque/Settings.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RMUD; - -namespace Akkoteaque -{ - public class settings : RMUD.Settings - { - public static void AtStartup(RuleEngine GlobalRules) - { - - GlobalRules.Perform("singleplayer game started") - .Do((actor) => - { - return PerformResult.Continue; - }); - - GlobalRules.Perform("before command") - .First - .Do((match, actor) => - { - Console.WriteLine(); - return PerformResult.Continue; - }); - - GlobalRules.Perform("after every command") - .Last - .Do((actor) => - { - Console.WriteLine(); - return PerformResult.Continue; - }); - } - - public settings() - { - NewPlayerStartRoom = "Jetty"; - PlayerBaseObject = "Player"; - } - } -} diff --git a/SinglePlayer/CloakOfDarkness/Bar.cs b/SinglePlayer/Bar.cs similarity index 77% rename from SinglePlayer/CloakOfDarkness/Bar.cs rename to SinglePlayer/Bar.cs index 5599d71..3f2f3df 100644 --- a/SinglePlayer/CloakOfDarkness/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. @@ -57,7 +56,7 @@ end the game saying "You have lost". SendMessage(actor, "YOU HAVE WON!"); Core.Shutdown(); } - return PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); /* @@ -66,15 +65,15 @@ end the game saying "You have lost". to the neatness after the neatness of the message; say "In the dark? You could easily disturb something." */ - Perform("before acting") - .When((match, actor) => AmbientLighting == LightingLevel.Dark) + Perform("before acting") + .When((match, actor) => GetProperty("ambient light") == LightingLevel.Dark) .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; }); /* @@ -82,15 +81,15 @@ end the game saying "You have lost". now the message is trampled; say "Blundering around in the dark isn't a good idea!" */ - Perform("before command") - .When((match, actor) => AmbientLighting == LightingLevel.Dark + Perform("before command") + .When((match, actor) => GetProperty("ambient light") == LightingLevel.Dark && match.TypedValue("COMMAND").IsNamed("GO") && (match.ValueOrDefault("DIRECTION") as Direction?).Value != Direction.NORTH) .Do((match, actor) => { 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/Cloak.cs similarity index 75% rename from SinglePlayer/CloakOfDarkness/Cloak.cs rename to SinglePlayer/Cloak.cs index 78b9207..8b885c1 100644 --- a/SinglePlayer/CloakOfDarkness/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 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 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 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." @@ -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/SinglePlayer.csproj b/SinglePlayer/CloakOfDarkness.csproj similarity index 68% rename from SinglePlayer/SinglePlayer.csproj rename to SinglePlayer/CloakOfDarkness.csproj index 800adab..f0b3874 100644 --- a/SinglePlayer/SinglePlayer.csproj +++ b/SinglePlayer/CloakOfDarkness.csproj @@ -33,6 +33,9 @@ 4 + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -42,49 +45,23 @@ - - - - - - - - - - - - - - - Thrad2.cs - - - - Jetty2.cs - - - - - - Player.cs - - - Settings.cs - - - - - - - + + + + + + + + - + Bar2.cs + @@ -108,9 +85,6 @@ StandardActionsModule - - - copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/SinglePlayer/CloakOfDarkness/Outside.cs b/SinglePlayer/CloakOfDarkness/Outside.cs deleted file mode 100644 index 4e7ad01..0000000 --- a/SinglePlayer/CloakOfDarkness/Outside.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace CloakOfDarkness -{ - public class Outside : RMUD.Room - { - public override void Initialize() - { - Short = "Outside the Opera House"; - } - } -} \ No newline at end of file diff --git a/SinglePlayer/CloakOfDarkness/Cloakroom.cs b/SinglePlayer/Cloakroom.cs similarity index 73% rename from SinglePlayer/CloakOfDarkness/Cloakroom.cs rename to SinglePlayer/Cloakroom.cs index 5c552b0..7540202 100644 --- a/SinglePlayer/CloakOfDarkness/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,22 +36,23 @@ 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) => { SendMessage(actor, "It's screwed into the wall."); - return CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; }); } } diff --git a/SinglePlayer/CloakOfDarkness/Foyer.cs b/SinglePlayer/Foyer.cs similarity index 76% rename from SinglePlayer/CloakOfDarkness/Foyer.cs rename to SinglePlayer/Foyer.cs index 0de3f1f..13aef34 100644 --- a/SinglePlayer/CloakOfDarkness/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"); @@ -30,7 +31,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/Game.cs b/SinglePlayer/Game.cs new file mode 100644 index 0000000..3f6fa48 --- /dev/null +++ b/SinglePlayer/Game.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloakOfDarkness +{ + public static class Game + { + public static RMUD.SinglePlayer.Driver Driver { get; set; } + internal static RMUD.MudObject Player { get { return Driver.Player; } } + + public static void SwitchPlayerCharacter(RMUD.MudObject NewCharacter) + { + Driver.SwitchPlayerCharacter(NewCharacter); + } + + public static void AtStartup(RMUD.RuleEngine GlobalRules) + { + GlobalRules.Perform("singleplayer game started") + .First + .Do((actor) => + { + SwitchPlayerCharacter(RMUD.MudObject.GetObject("Player")); + RMUD.MudObject.Move(Player, RMUD.MudObject.GetObject("Foyer")); + RMUD.Core.EnqueuActorCommand(Player, "look"); + + return SharpRuleEngine.PerformResult.Stop; + }); + } + } +} \ No newline at end of file diff --git a/SinglePlayer/GameInfo.cs b/SinglePlayer/GameInfo.cs new file mode 100644 index 0000000..7786d82 --- /dev/null +++ b/SinglePlayer/GameInfo.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Minimum +{ + public class GameInfo : RMUD.SinglePlayer.GameInfo + { + public GameInfo() + { + Title = "Cloak Of Darkness"; + DatabaseNameSpace = "CloakOfDarkness"; + Description = "This game implements the famous CLOAK OF DARKNESS sample that all new Interactive Fiction Authoring Systems are required to implement. By law. The source contains the Inform7 source for the game as comments."; + Modules = new List(new String[] { "StandardActionsModule.dll", "AdminModule.dll", "ClothingModule.dll" }); + } + } +} diff --git a/SinglePlayer/Minimum/Player.cs b/SinglePlayer/Minimum/Player.cs deleted file mode 100644 index 6fd22c5..0000000 --- a/SinglePlayer/Minimum/Player.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Minimum -{ - public class Player : RMUD.Player - { - public override void Initialize() - { - Short = "you"; - } - } -} diff --git a/SinglePlayer/Minimum/Settings.cs b/SinglePlayer/Minimum/Settings.cs deleted file mode 100644 index ef4e3dd..0000000 --- a/SinglePlayer/Minimum/Settings.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RMUD; - -namespace Minimum -{ - public class settings : RMUD.Settings - { - public settings() - { - NewPlayerStartRoom = "Start"; - PlayerBaseObject = "Player"; - } - } -} diff --git a/SinglePlayer/Minimum/Start.cs b/SinglePlayer/Minimum/Start.cs deleted file mode 100644 index 3955001..0000000 --- a/SinglePlayer/Minimum/Start.cs +++ /dev/null @@ -1,14 +0,0 @@ -using RMUD; - -namespace Minimum -{ - - public class Start : RMUD.Room - { - public override void Initialize() - { - Short = "Start Room"; - Long = "This is a game with the minimum possible objects."; - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Outside.cs b/SinglePlayer/Outside.cs new file mode 100644 index 0000000..aef3db0 --- /dev/null +++ b/SinglePlayer/Outside.cs @@ -0,0 +1,14 @@ +using RMUD; + +namespace CloakOfDarkness +{ + public class Outside : RMUD.MudObject + { + public override void Initialize() + { + Room(RoomType.Exterior); + + SetProperty("short", "Outside the Opera House"); + } + } +} \ No newline at end of file diff --git a/SinglePlayer/CloakOfDarkness/Player.cs b/SinglePlayer/Player.cs similarity index 64% rename from SinglePlayer/CloakOfDarkness/Player.cs rename to SinglePlayer/Player.cs index e56b6f1..8df75f8 100644 --- a/SinglePlayer/CloakOfDarkness/Player.cs +++ b/SinglePlayer/Player.cs @@ -2,12 +2,13 @@ namespace CloakOfDarkness { - public class Player : RMUD.Player + public class Player : RMUD.MudObject { public override void Initialize() { - Short = "you"; + Actor(); + SetProperty("short", "you"); Move(GetObject("Cloak"), this, RelativeLocations.Worn); } } diff --git a/SinglePlayer/Program.cs b/SinglePlayer/Program.cs index 09265dc..d1c3030 100644 --- a/SinglePlayer/Program.cs +++ b/SinglePlayer/Program.cs @@ -5,37 +5,15 @@ using System.Threading.Tasks; using System.Threading; -namespace SinglePlayer +class Program { - class Program + static void Main(string[] args) { - static void Main(string[] args) - { - if (args.Length == 0) - { - var demoGames = new List(); - foreach (var type in System.Reflection.Assembly.GetExecutingAssembly().GetTypes()) - if (!demoGames.Contains(type.Namespace)) - demoGames.Add(type.Namespace); - foreach (var name in demoGames.Where(s => System.Reflection.Assembly.GetExecutingAssembly().GetType(s + ".settings", false) != null)) - Console.WriteLine(name); - - - var driver = new RMUD.SinglePlayer.Driver(); - driver.Start(System.Reflection.Assembly.GetExecutingAssembly(), Console.Write); - while (driver.IsRunning) - driver.Input(Console.ReadLine()); - } - else - { - var driver = new RMUD.SinglePlayer.Driver(); - driver.Start(args[0], Console.Write); - while (driver.IsRunning) - driver.Input(Console.ReadLine()); - } - - Console.WriteLine("[Press any key to exit..]"); - Console.ReadKey(); - } + var driver = new RMUD.SinglePlayer.Driver(); + driver.Start(typeof(CloakOfDarkness.Game).Assembly, Console.Write); + while (driver.IsRunning) + driver.Input(Console.ReadLine()); + Console.WriteLine("[Press any key to exit..]"); + Console.ReadKey(); } -} +} \ No newline at end of file diff --git a/SinglePlayer/Wells/Info.txt b/SinglePlayer/Wells/Info.txt deleted file mode 100644 index f525aae..0000000 --- a/SinglePlayer/Wells/Info.txt +++ /dev/null @@ -1 +0,0 @@ -Wells is an example conversation. Engage in a long rambling talk with Thrad, a knight of the northern province, about the many properties of wells, be they deep or shallow. \ No newline at end of file diff --git a/SinglePlayer/Wells/Player.cs b/SinglePlayer/Wells/Player.cs deleted file mode 100644 index 6e1c9ea..0000000 --- a/SinglePlayer/Wells/Player.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RMUD; - -namespace Wells -{ - public class Player : RMUD.Player - { - public override void Initialize() - { - Short = "you"; - } - } -} diff --git a/SinglePlayer/Wells/Settings.cs b/SinglePlayer/Wells/Settings.cs deleted file mode 100644 index 9e679bc..0000000 --- a/SinglePlayer/Wells/Settings.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RMUD; - -namespace Wells -{ - public class settings : RMUD.Settings - { - public settings() - { - NewPlayerStartRoom = "Start"; - PlayerBaseObject = "Player"; - - ConversationModule.Settings.ListDiscussedTopics = false; - } - } -} diff --git a/SinglePlayer/Wells/Start.cs b/SinglePlayer/Wells/Start.cs deleted file mode 100644 index f986c97..0000000 --- a/SinglePlayer/Wells/Start.cs +++ /dev/null @@ -1,16 +0,0 @@ -using RMUD; - -namespace Wells -{ - - public class Start : RMUD.Room - { - public override void Initialize() - { - Short = "Cistern Inn - Mud Room"; - Long = "This is the muddy mud room of the Cistern Inn. It sits between the slightly less muddy common room and the exceptionally muddy front porch. Loose thresh scattered about the floor does a very poor job of soaking up the filth."; - - Move(GetObject("Thrad"), this); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/Wells/Thrad.cs b/SinglePlayer/Wells/Thrad.cs deleted file mode 100644 index ff3f30f..0000000 --- a/SinglePlayer/Wells/Thrad.cs +++ /dev/null @@ -1,54 +0,0 @@ -using RMUD; -using System; -using ConversationModule; -using ClothingModule; - -namespace Wells -{ - public class Thrad : RMUD.NPC - { - //This does, essentially, what the entire IntroductionModule does. - //This is quite tedius to setup for every NPC, but is straightforward for just one. - public bool Introduced = false; - - public override void Initialize() - { - Nouns.Add("THRAD", a => this.Introduced); - Nouns.Add("KNIGHT", "MASSIVE"); - - Short = "Thrad"; - - Perform("describe in locale") //Draw Thrad to the player's attention if they - .When((actor, thrad) => !this.Introduced) //haven't spoken to him yet. - .Do((actor, item) => - { - SendMessage(actor, "A massive knight stands in the middle of the little room."); - return PerformResult.Continue; - }); - - - this.Wear("helmet", ClothingLayer.Outer, ClothingBodyPart.Head); - this.Wear("pauldrons", ClothingLayer.Outer, ClothingBodyPart.Cloak); - - //We want Thrad to be 'a knight' or 'Thrad' depending on if he is introduced. - Value("printed name") - .When((viewer, thrad, article) => !this.Introduced) - .Do((viewer, actor, article) => article + " knight"); - - Value("printed name") - .When((viewer, thrad, article) => this.Introduced) - .Do((viewer, actor, article) => "Thrad"); - - - //The conversation with Thrad - var who_he_is = this.Response("who he is", (actor, npc, topic) => - { - SendMessage(actor, "^ peers at you from within his incredible helmet. \"Thrad\", he says.", this); - this.Introduced = true; - return 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); - } - } -} \ No newline at end of file diff --git a/SinglePlayer/packages.config b/SinglePlayer/packages.config new file mode 100644 index 0000000..ec6597f --- /dev/null +++ b/SinglePlayer/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SinglePlayer/CloakOfDarkness/settings.cs b/SinglePlayer/settings.cs similarity index 70% rename from SinglePlayer/CloakOfDarkness/settings.cs rename to SinglePlayer/settings.cs index 3b21bf3..ac9b22b 100644 --- a/SinglePlayer/CloakOfDarkness/settings.cs +++ b/SinglePlayer/settings.cs @@ -10,27 +10,27 @@ public class settings : RMUD.Settings { public static void AtStartup(RuleEngine GlobalRules) { - GlobalRules.Perform("singleplayer game started") + GlobalRules.Perform("singleplayer game started") .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") + GlobalRules.Perform("before command") .First .Do((match, actor) => { Console.WriteLine(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); - GlobalRules.Perform("after every command") + GlobalRules.Perform("after every command") .Last .Do((actor) => { Console.WriteLine(); - return PerformResult.Continue; + return SharpRuleEngine.PerformResult.Continue; }); } diff --git a/SinglePlayerMinimumGame/Game.cs b/SinglePlayerMinimumGame/Game.cs new file mode 100644 index 0000000..189e09f --- /dev/null +++ b/SinglePlayerMinimumGame/Game.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Minimum +{ + public static class Game + { + public static RMUD.SinglePlayer.Driver Driver { get; set; } + internal static RMUD.MudObject Player { get { return Driver.Player; } } + + public static void SwitchPlayerCharacter(RMUD.MudObject NewCharacter) + { + Driver.SwitchPlayerCharacter(NewCharacter); + } + + public static void AtStartup(RMUD.RuleEngine GlobalRules) + { + GlobalRules.Perform("singleplayer game started") + .First + .Do((actor) => + { + SwitchPlayerCharacter(RMUD.MudObject.GetObject("Player")); + RMUD.MudObject.Move(Player, RMUD.MudObject.GetObject("Start")); + RMUD.Core.EnqueuActorCommand(Player, "look"); + + return SharpRuleEngine.PerformResult.Stop; + }); + } + } +} \ No newline at end of file diff --git a/SinglePlayerMinimumGame/Player.cs b/SinglePlayerMinimumGame/Player.cs index 6fd22c5..47d3664 100644 --- a/SinglePlayerMinimumGame/Player.cs +++ b/SinglePlayerMinimumGame/Player.cs @@ -2,11 +2,13 @@ namespace Minimum { - public class Player : RMUD.Player + public class Player : RMUD.MudObject { public override void Initialize() { - Short = "you"; + Actor(); + + SetProperty("short", "you"); } } } diff --git a/SinglePlayerMinimumGame/Program.cs b/SinglePlayerMinimumGame/Program.cs new file mode 100644 index 0000000..d305d4e --- /dev/null +++ b/SinglePlayerMinimumGame/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; + +class Program +{ + static void Main(string[] args) + { + var driver = new RMUD.SinglePlayer.Driver(); + driver.Start(typeof(Minimum.settings).Assembly, Console.Write); + while (driver.IsRunning) + driver.Input(Console.ReadLine()); + Console.WriteLine("[Press any key to exit..]"); + Console.ReadKey(); + } +} \ No newline at end of file diff --git a/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj b/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj index 2641222..5c91254 100644 --- a/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj +++ b/SinglePlayerMinimumGame/SinglePlayerMinimumGame.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {68D0E431-5DCA-4A25-A1B2-2F5B857821B1} - Library + Exe Properties SinglePlayerMinimumGame SinglePlayerMinimumGame @@ -30,7 +30,13 @@ prompt 4 + + + + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -40,8 +46,10 @@ + + @@ -52,6 +60,9 @@ Core + + + copy "$(TargetPath)" "$(SolutionDir)Out\$(TargetFileName)" diff --git a/SinglePlayerMinimumGame/Start.cs b/SinglePlayerMinimumGame/Start.cs index 3955001..dd4592d 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/SinglePlayerMinimumGame/packages.config b/SinglePlayerMinimumGame/packages.config new file mode 100644 index 0000000..ec6597f --- /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..e3a31de 100644 --- a/Space/Cargo.cs +++ b/Space/Cargo.cs @@ -20,6 +20,8 @@ public override void Initialize() Move(locker, this); Move(GetObject("Wrench"), locker); Move(GetObject("DuctTape"), locker); + + } } @@ -36,7 +38,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..fc85081 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."); @@ -61,10 +61,18 @@ public static void AtStartup(RMUD.RuleEngine GlobalRules) //RMUD.MudObject.SendMessage(actor, "Sal? Sal? Can you hear me?"); //actor.SetProperty("interlocutor", RMUD.MudObject.GetObject("DanConversation0")); //RMUD.Core.EnqueuActorCommand(actor, "topics"); + + GlobalRules.Perform("after acting").Do((match, _a) => + { + var x = 5; + x += 1; + + return SharpRuleEngine.PerformResult.Continue; + }); RMUD.MudObject.Move(actor, RMUD.MudObject.GetObject("Start")); RMUD.Core.EnqueuActorCommand(actor, "look"); - return RMUD.PerformResult.Stop; + return SharpRuleEngine.PerformResult.Stop; }); } } diff --git a/SinglePlayer/Minimum/GameInfo.cs b/Space/GameInfo.cs similarity index 74% rename from SinglePlayer/Minimum/GameInfo.cs rename to Space/GameInfo.cs index 5782296..3c809eb 100644 --- a/SinglePlayer/Minimum/GameInfo.cs +++ b/Space/GameInfo.cs @@ -10,10 +10,10 @@ public class GameInfo : RMUD.SinglePlayer.GameInfo { public GameInfo() { - Title = "Minimum"; - DatabaseNameSpace = "Minimum"; + Title = "Space!"; + DatabaseNameSpace = "Space"; Description = "This is a game with the absolute minimum required to run."; - Modules = new List(new String[] { "StandardActionsModule.dll", "AdminModule.dll" }); + Modules = new List(new String[] { "StandardActionsModule.dll", "AdminModule.dll", "ConversationModule.dll" }); } } } diff --git a/Space/Hatch.cs b/Space/Hatch.cs index c61e21c..67db207 100644 --- a/Space/Hatch.cs +++ b/Space/Hatch.cs @@ -13,22 +13,22 @@ 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 CheckResult.Disallow; + return SharpRuleEngine.CheckResult.Disallow; } - return CheckResult.Allow; + return SharpRuleEngine.CheckResult.Allow; }) .Name("Can open doors rule."); @@ -36,12 +36,12 @@ public Hatch() .Last .Do((a, b) => { - if (!GetBooleanProperty("open?")) + if (!GetPropertyOrDefault("open?", false)) { 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..aaa939b 100644 --- a/Space/Locker.cs +++ b/Space/Locker.cs @@ -1,4 +1,5 @@ using RMUD; +using SharpRuleEngine; namespace Space { @@ -34,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; @@ -47,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/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/Program.cs b/Space/Program.cs new file mode 100644 index 0000000..56db1b8 --- /dev/null +++ b/Space/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; + +class Program +{ + static void Main(string[] args) + { + var driver = new RMUD.SinglePlayer.Driver(); + driver.Start(typeof(Space.Game).Assembly, Console.Write); + while (driver.IsRunning) + driver.Input(Console.ReadLine()); + Console.WriteLine("[Press any key to exit..]"); + Console.ReadKey(); + } +} \ No newline at end of file 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..eb6a8e1 100644 --- a/Space/Space.csproj +++ b/Space/Space.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {75D0C5C6-EFB9-4B45-86FF-F83ABC943D78} - Library + Exe Properties Space Space @@ -30,7 +30,13 @@ prompt 4 + + + + + ..\packages\SharpRuleEngine.1.0.5\lib\SharpRuleEngine.dll + @@ -43,8 +49,10 @@ + + @@ -83,6 +91,9 @@ + + +