MudEngine:
- Deleted the following commands from the engine: Exit, GetTime, LinkRoom, Load, Look, Save and Walk. These are now part of the MudGame script library. - Revised all of the Commands prior to moving them to the Script Library. They are now very well commented. - Optimized the player login code. - All commands now support the Help command. - Game now has a MinimumPasswordSize property for setting the required minimum characters for a players password. - System.Linq and System.Text using statements added to scripts when they are compiled. Script writers no longer need to type out the fully qualified name of a Type within those namespaces. MudGame: - Added the following commands to the script library: Exit, GetTime, LinkRoom, Load, Look, Save, Walk. - Added 76 lines of comments to WorldCalifornia to better help new users understand how to create their game worlds via script. - The Clear, Help, Say and Create commands have been given better commenting. - Existing scripts have been given some better optimizations.
This commit is contained in:
parent
cc2213a7b3
commit
7e31a78f72
27 changed files with 1251 additions and 881 deletions
|
@ -1,88 +0,0 @@
|
|||
//Microsoft.NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
//Mud Designer Game Engine
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.Commands;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// The Exit command is used to exit the MUD game.
|
||||
/// Using this command while connected to a MUD server will perform a disconnect from the server.
|
||||
/// Using the command while running the game in offline mode will simply shut down the game.
|
||||
/// </summary>
|
||||
public class CommandExit : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandExit()
|
||||
{
|
||||
//Instance the help collection and add our help information to it.
|
||||
//Typically the Help content is placed within the constructor, but this particular help document
|
||||
//needs to access information from the player, so we will build our Help collection in the Execute command.
|
||||
Help = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// This method is called from the Command Engine, it is not recommended that you call this method directly.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="player"></param>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Check if the game is multiplayer.
|
||||
//Multiplayer games require disconnecting from the server and letting other players in the same Room know
|
||||
//that this player has left.
|
||||
if (player.ActiveGame.IsMultiplayer)
|
||||
{
|
||||
//Query the Active Games Player collection so that we can build a collection of Players that need to be
|
||||
//informed of the Player disconnecting from the Server.
|
||||
var playerQuery =
|
||||
from p in player.ActiveGame.GetPlayerCollection()
|
||||
where !p.Name.StartsWith("New") && p.Name != player.Name && p.CurrentWorldLocation == player.CurrentWorldLocation
|
||||
select p;
|
||||
|
||||
//Inform each player found in our LINQ query that the player has disconnected from the Server.
|
||||
foreach (BaseCharacter p in playerQuery)
|
||||
p.Send(player.Name + " has left."); ;
|
||||
|
||||
//TODO: If a player is in a Group then s/he needs to be removed upon disconnecting.
|
||||
player.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Call the game's shutdown method which will save all objects and exit the game gracefully.
|
||||
player.ActiveGame.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
//Microsoft.NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
//Mud Designer Game Engine
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameManagement;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// The GetTime command is used to print the current in-game time to the player.
|
||||
/// This command will print the day, month and year along with hour, minute and seconds.
|
||||
/// </summary>
|
||||
public class CommandGetTime : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandGetTime()
|
||||
{
|
||||
//Instance the help collection and add our help information to it.
|
||||
Help = new List<string>();
|
||||
Help.Add("Gives you the current time and date in the game world.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the Command.
|
||||
/// This method is called from the Command Engine, it is not recommended that you call this method directly.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="player"></param>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Send the returned String containing the World Time to the player.
|
||||
player.Send(player.ActiveGame.WorldTime.GetCurrentWorldTime());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,401 +0,0 @@
|
|||
//Microsoft.NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
//Mud Designer Game Engine
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// The LinkRoom command is used to Link two previously created Rooms together.
|
||||
/// Rooms linked together can be traversed by players.
|
||||
/// This command is used to link Rooms dynamically during run-time by Admins, allowing environments to be created
|
||||
/// and traversed on-the-fly without the need to modify scripts and re-start the server.
|
||||
/// </summary>
|
||||
public class CommandLinkRoom : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandLinkRoom()
|
||||
{
|
||||
//Instance the help collection and add our help information to it.
|
||||
Help = new List<string>();
|
||||
Help.Add("Use this to link two previously created Rooms together.");
|
||||
//Incase Admins try to use the command, they will know that it's broken.
|
||||
//Don't convert this class into a Script until it is fully completed.
|
||||
Help.Add("NOTE: This command is not fully implemented and does not work.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// This method is called from the Command Engine, it is not recommended that you call this method directly.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="player"></param>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Check if the Player has the correct privileges to Link Rooms together.
|
||||
//If they are not a Admin or GM then the command will bail.
|
||||
//This creates the illusion that this command possibly doesn't exist.
|
||||
if ((player.Role != SecurityRoles.Admin) && (player.Role != SecurityRoles.GM))
|
||||
{
|
||||
player.Send("Invalid Command.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Build the Menu system that will be displayed to Admins.
|
||||
player.Send("Room linkage tool");
|
||||
player.Send("Please select an option.");
|
||||
player.Send("1: Link Room");
|
||||
player.Send("2: Exit");
|
||||
|
||||
//Read the input from the Admin.
|
||||
string input = player.ReadInput();
|
||||
Int32 value = 0;
|
||||
|
||||
//Attempt to convert their input from a String into a numerical value.
|
||||
//If they entered a non-numerical value, then the method will exit
|
||||
try
|
||||
{
|
||||
value = Convert.ToInt32(input);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
player.Send("Invalid selection. Please use numeric values.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Ask what Room the Admin wants to use as the Departing Room.
|
||||
//Departing Rooms will be where the travel direction originates from.
|
||||
//meaning if the Admin selects West as the traveling direction, then traveling West will exit the
|
||||
//Departing Room and enter the Arrival Room.
|
||||
player.Send("");
|
||||
player.Send("Please select which Realm your departing Room resides within:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Realm that we can use to reference an existing Realm so that we can find the
|
||||
//Rooms within it that the Admin is looking for.
|
||||
Boolean isValidRealm = false;
|
||||
Realm realm = new Realm(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Realm, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Realm name.
|
||||
while (!isValidRealm)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidRealm to true, as we will assume that
|
||||
//the user will enter a valid Realm name on the first shot. If we can't find a matching
|
||||
//Realm, then this will get set to false once iterating through Realms is completed.
|
||||
isValidRealm = true;
|
||||
|
||||
//Print each Realm out to the Admin so they may see a complete list to choose from.
|
||||
//This is the Realm that their first Room will reside within.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
player.Send(r.Filename + " | ", false);
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Realm they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the Active Games world collection, finding Realms that match the filename entered by the Admin
|
||||
var realmQuery =
|
||||
from r in player.ActiveGame.World.RealmCollection
|
||||
where r.Filename.ToLower() == input.ToLower()
|
||||
select r;
|
||||
|
||||
//Check if the query contains a Realm.
|
||||
if (realmQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Realm. Assign it to our realm field for use later.
|
||||
realm = realmQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidRealm = true;
|
||||
}
|
||||
//If the query does not contain a Realm, then we ensure that the loop will continue by forcing
|
||||
//isValidRealm back to false.
|
||||
else
|
||||
{
|
||||
isValidRealm = false;
|
||||
//Let the Admin know that they entered an invalid Realm name and that they need to try again.
|
||||
player.Send("That Realm does not exist! Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Let the Admin know that they need to now select which Zone the Room they are wanting to link resides within.
|
||||
player.Send("");
|
||||
player.Send("Please select which Zone your departing Room resides within:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Zone that we can use to reference an existing Zone so that we can find the
|
||||
//Rooms within it that the Admin is looking for.
|
||||
Boolean isValidZone = false;
|
||||
Zone zone = new Zone(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Zone, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Zone name.
|
||||
while (!isValidZone)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidZone to true, as we will assume that
|
||||
//the user will enter a valid Zone name on the first shot. If we can't find a matching
|
||||
//Zone, then this will get set to false once iterating through Zone is completed.
|
||||
isValidZone = true;
|
||||
|
||||
//Print each Zone out to the Admin so they may see a complete list to choose from.
|
||||
//This is the Zone that their first Room will reside within.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Zone z in realm.ZoneCollection)
|
||||
{
|
||||
player.Send(z.Filename + " | ", false);
|
||||
}
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Zone they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the stored Realm's Zone collection, finding Zones that match the filename entered by the Admin
|
||||
var zoneQuery =
|
||||
from z in realm.ZoneCollection
|
||||
where z.Filename.ToLower() == input.ToLower()
|
||||
select z;
|
||||
|
||||
//Check if the query contains a Zone.
|
||||
if (zoneQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Zone. Assign it to our zone field for use later.
|
||||
zone = zoneQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidZone = true;
|
||||
}
|
||||
//If the query does not contain a Zone, then we ensure that the loop will continue by forcing
|
||||
//isValidZone back to false.
|
||||
else
|
||||
{
|
||||
isValidZone = false;
|
||||
//Let the Admin know that they entered an invalid Zone name and that they need to try again.
|
||||
player.Send("That Zone does not exist! Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Let the Admin know that they need to now select Room they are wanting to link as the departure Room
|
||||
player.Send("");
|
||||
player.Send("Please select which Room that you wish to be the departing Room:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Room that we can store a reference to a existing Room.
|
||||
//We will use this reference to link the departure and arrival Rooms together.
|
||||
Boolean isValidRoom = false;
|
||||
Room departingRoom = new Room(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Room, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Room name.
|
||||
while (!isValidRoom)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidRoom to true, as we will assume that
|
||||
//the user will enter a valid Room name on the first shot. If we can't find a matching
|
||||
//Room, then this will get set to false once iterating through Room is completed.
|
||||
isValidRoom = true;
|
||||
|
||||
//Print each Room out to the Admin so they may see a complete list to choose from.
|
||||
//This will be their departing Room.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Room they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the referenced zone's Room collection, finding Rooms that match the filename entered by the Admin
|
||||
var roomQuery =
|
||||
from r in zone.RoomCollection
|
||||
where r.Filename.ToLower() == input.ToLower()
|
||||
select r;
|
||||
|
||||
//Check if the query contains a Room.
|
||||
if (roomQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Room. Assign it to our departingRoom field for use later.
|
||||
departingRoom = roomQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidRoom = true;
|
||||
}
|
||||
//If the query does not contain a Room, then we ensure that the loop will continue by forcing
|
||||
//isValidRoom back to false.
|
||||
else
|
||||
{
|
||||
isValidRoom = false;
|
||||
//Let the Admin know that they entered an invalid Room name and that they need to try again.
|
||||
player.Send("That Room does not exist! Please try again.");
|
||||
}
|
||||
|
||||
//Ensure it's a valid name, if not then loop back and try again.
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
if (r.Filename.ToLower() == input.ToLower())
|
||||
{
|
||||
isValidRoom = true;
|
||||
departingRoom = r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValidRoom = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidRoom)
|
||||
player.Send("That Room does not exist! Please try again.");
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Please select which Room that you wish to be the Arrival Room:");
|
||||
player.Send("");
|
||||
|
||||
isValidRoom = false;
|
||||
Room arrivalRoom = new Room(player.ActiveGame);
|
||||
|
||||
while (!isValidRoom)
|
||||
{
|
||||
isValidRoom = true;//Default to true, assume the user entered a valid name.
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
input = player.ReadInput();
|
||||
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Ensure it's a valid name, if not then loop back and try again.
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
if (r.Filename.ToLower() == input.ToLower())
|
||||
{
|
||||
isValidRoom = true;
|
||||
departingRoom = r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValidRoom = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidRoom)
|
||||
player.Send("That Room does not exist! Please try again.");
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Please select which Room that you wish to be the departing Room:");
|
||||
player.Send("");
|
||||
|
||||
player.Send("Please select which direction you would like to travel while departing the departure Room.");
|
||||
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
|
||||
foreach (Int32 v in values)
|
||||
{
|
||||
//Since enum values are not strings, we can't simply just assign the String to the enum
|
||||
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
|
||||
player.Send(displayName + " | ");
|
||||
}
|
||||
|
||||
player.Send("Enter Selection: ", false);
|
||||
input = player.ReadInput();
|
||||
|
||||
AvailableTravelDirections direction = new AvailableTravelDirections();
|
||||
Boolean isValidDirection = false;
|
||||
|
||||
foreach (Int32 v in values)
|
||||
{
|
||||
//Since enum values are not strings, we can't simply just assign the String to the enum
|
||||
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
|
||||
|
||||
//If the value = the String saved, then perform the needed conversion to get our data back
|
||||
if (displayName.ToLower() == input.ToLower())
|
||||
{
|
||||
direction = (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);
|
||||
isValidDirection = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidDirection)
|
||||
{
|
||||
player.Send("Invalid direction supplied!");
|
||||
}
|
||||
else
|
||||
{
|
||||
zone.LinkRooms(direction, arrivalRoom, departingRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
public class CommandLoad : IGameCommand
|
||||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
String path = player.ActiveGame.DataPaths.Players;
|
||||
String filename = Path.Combine(path, player.Filename);
|
||||
|
||||
player.Load(filename);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,119 +12,183 @@ using MudEngine.GameObjects.Environment;
|
|||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// The Login command is used internally by the game engine.
|
||||
/// This command will not be available as a Script due to the engine requiring that it exists.
|
||||
/// Any changes needing to be made to this command to customize it in some manor will need to be done
|
||||
/// by modifying the source.
|
||||
/// TODO: Update the engine to dynamically look for a Login script rather than relying on CommandLogin.
|
||||
/// </summary>
|
||||
public class CommandLogin : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Class constructor
|
||||
/// </summary>
|
||||
public CommandLogin()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Logs the player into their respective account.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Print the basic Active Game's information to the connecting player.
|
||||
player.Send(player.ActiveGame.GameTitle);
|
||||
player.Send(player.ActiveGame.Version);
|
||||
player.Send(player.ActiveGame.Story);
|
||||
player.Send("");
|
||||
|
||||
//Setup some fields that we'll need.
|
||||
Boolean playerFound = false;
|
||||
Boolean playerLegal = false;
|
||||
String savedFile = "";
|
||||
String playerName = "";
|
||||
|
||||
while (!playerLegal)
|
||||
//Loop until we have a valid player name entered.
|
||||
while (String.IsNullOrEmpty(playerName))
|
||||
{
|
||||
player.Send("Enter Character Name: ", false);
|
||||
playerName = player.ReadInput();
|
||||
|
||||
if (!String.IsNullOrEmpty(playerName))
|
||||
playerLegal = true;
|
||||
}
|
||||
|
||||
//See if this character already exists.
|
||||
//Check to make sure the saved players directory actually exists. If not, create it.
|
||||
if (!Directory.Exists(player.ActiveGame.DataPaths.Players))
|
||||
Directory.CreateDirectory(player.ActiveGame.DataPaths.Players);
|
||||
|
||||
//Setup some password fields we'll need
|
||||
Boolean passwordLegal = false;
|
||||
String playerPwrd = "";
|
||||
|
||||
//Loop through the password creation/entering process until we have a legal password
|
||||
//entered by the player logging in.
|
||||
while (!passwordLegal)
|
||||
{
|
||||
//Acquire a password from the player.
|
||||
player.Send("Enter Password: ", false);
|
||||
playerPwrd = player.ReadInput();
|
||||
|
||||
if (!String.IsNullOrEmpty(playerPwrd))
|
||||
passwordLegal = true;
|
||||
|
||||
if (playerPwrd.Length < 6)
|
||||
//Check if we have a legal password, meaning it's not empty and it's at least as long as the
|
||||
//current Active Game's minimum PasswordSize property has been set to.
|
||||
if ((!String.IsNullOrEmpty(playerPwrd)) && (playerPwrd.Length >= player.ActiveGame.MinimumPasswordSize))
|
||||
{
|
||||
passwordLegal = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Let the user know that their password was invalid and they need to make sure that it conforms to the
|
||||
//current Active Game's minumum password size requirement.
|
||||
passwordLegal = false;
|
||||
player.Send("Invalid Password, minimum password length is 6 characters");
|
||||
player.Send("Invalid Password, minimum password length is " + player.ActiveGame.MinimumPasswordSize + " characters");
|
||||
}
|
||||
|
||||
//Check if the password is legal. If so, we need to find the file associated with this player.
|
||||
//If no file is found, then we will create a new one.
|
||||
if (passwordLegal)
|
||||
{
|
||||
//Iterate through the saved players directory.
|
||||
foreach (String filename in Directory.GetFiles(player.ActiveGame.DataPaths.Players))
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(filename).ToLower() == playerName.ToLower())
|
||||
{
|
||||
//We found a file that matched the supplied user name. We set savedFile to the filename
|
||||
//found so that we can later varify the password before loading.
|
||||
savedFile = filename;
|
||||
playerFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Loop through all the players currently logged in and disconnect anyone that is currently logged
|
||||
//in with this account.
|
||||
//Load the player from the saved file, if the password is legal. Once loaded
|
||||
//we need to look for any other player that might be logged in with this account. If found,
|
||||
//disconnect them from the server. Multiple log-ins of the same account is not permitted.
|
||||
if (playerFound)
|
||||
{
|
||||
if (player.ActiveGame.IsMultiplayer)
|
||||
//Load the player from file using a temporary character reference.
|
||||
//If we load the real player now, he will get disconnected when we check to see
|
||||
//if any player exists on the server already with this name.
|
||||
BaseCharacter p = new BaseCharacter(player.ActiveGame);
|
||||
p.Load(savedFile);
|
||||
|
||||
//Varify their password. If their password is matching the one on file, and the
|
||||
//current Active Game is a multiplayer game, then scan for other other currently
|
||||
//logged in with this account.
|
||||
if ((p.VarifyPassword(playerPwrd)) && (p.ActiveGame.IsMultiplayer))
|
||||
{
|
||||
for (Int32 i = 0; i <= player.ActiveGame.GetPlayerCollection().Length - 1; i++)
|
||||
{
|
||||
if (player.ActiveGame.GetPlayerCollection()[i].Name.ToLower() == playerName.ToLower())
|
||||
//Check if the current player in the iteration has a matching name as the player that
|
||||
//just logged in with his credentials.
|
||||
if (player.ActiveGame.GetPlayerCollection()[i].Name.ToLower() == p.Name.ToLower())
|
||||
{
|
||||
//If we found a match then we need to disconnect the
|
||||
//previously logged in player from the server.
|
||||
player.ActiveGame.GetPlayerCollection()[i].Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now assign this name to this player if this is a new toon or load the player if the file exists.
|
||||
if (!playerFound)
|
||||
{
|
||||
player.Create(playerName, playerPwrd);
|
||||
player.Send("Welcome " + player.Name + "!");
|
||||
//Now that we have no duplicate connections, load the real player.
|
||||
//no need to re-varify password as we have already done this above.
|
||||
player.Load(savedFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCharacter p = new BaseCharacter(player.ActiveGame);
|
||||
p.Load(savedFile);
|
||||
if (p.VarifyPassword(playerPwrd))
|
||||
{
|
||||
player.Load(savedFile);
|
||||
if (player.VarifyPassword(playerPwrd))
|
||||
{
|
||||
player.Send("Welcome back " + player.Name + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
passwordLegal = false;
|
||||
player.Send("Invalid password.");
|
||||
//Don't keep a reference to the already loaded character. The player will need to
|
||||
//re-enter their credentials.
|
||||
player = new BaseCharacter(player.ActiveGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Look to see if there are players in the Room
|
||||
//Let other players know that the user walked in.
|
||||
//Look to see if there are players in the Room, if there are then we need to let
|
||||
//other players know that the user walked/logged in.
|
||||
if (player.ActiveGame.IsMultiplayer)
|
||||
{
|
||||
for (Int32 i = 0; i != player.ActiveGame.GetPlayerCollection().Length; i++)
|
||||
{
|
||||
//Check if the current player in the iteration is the currently logging in player
|
||||
//or a un-used player slot. If it is we will skip them as the logging in player
|
||||
//doesn't need to be told that he has just logged in, and un-used players slots
|
||||
//in the collection array does not need to have anything broadcasted to them.
|
||||
if (player.ActiveGame.GetPlayerCollection()[i].Name == player.Name)
|
||||
continue;
|
||||
else if (player.ActiveGame.GetPlayerCollection()[i].Name == "New BaseCharacter")
|
||||
continue;
|
||||
|
||||
String room = player.ActiveGame.GetPlayerCollection()[i].CurrentRoom.Name;
|
||||
String realm = player.ActiveGame.GetPlayerCollection()[i].CurrentRoom.Realm;
|
||||
String zone = player.ActiveGame.GetPlayerCollection()[i].CurrentRoom.Zone;
|
||||
|
||||
if ((room == player.CurrentRoom.Name) && (realm == player.CurrentRoom.Realm) && (zone == player.CurrentRoom.Zone))
|
||||
//If the current player in the iteration is within the same location as the player logging in
|
||||
//we can broadcast to them that the newly logged in player has entered the same Room.
|
||||
if (player.ActiveGame.GetPlayerCollection()[i].CurrentWorldLocation == player.CurrentWorldLocation)
|
||||
{
|
||||
player.ActiveGame.GetPlayerCollection()[i].Send(player.Name + " arrived.");
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.Commands;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
using MudEngine.GameObjects.Items;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
public class CommandLook : IGameCommand
|
||||
{
|
||||
public String Name { get; set; }
|
||||
public Boolean Override { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if (player.CurrentRoom == null)
|
||||
{
|
||||
player.Send("You are not within any Room.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.CurrentRoom.DetailedDescription.Count == 0)
|
||||
player.Send(player.CurrentRoom.Description);
|
||||
else
|
||||
{
|
||||
foreach(String entry in player.CurrentRoom.DetailedDescription)
|
||||
{
|
||||
player.Send(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,13 @@ namespace MudEngine.Commands
|
|||
public String Name { get; set; }
|
||||
public Boolean Override { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public CommandRestart()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Restarts the game server.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if (player.Role == SecurityRoles.Admin)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
public class CommandSave : IGameCommand
|
||||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
player.Save(player.ActiveGame.DataPaths.Players);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,13 @@ namespace MudEngine.Commands
|
|||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public CommandSaveWorld()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Saves the game world.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.FileSystem;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
public class CommandWalk : IGameCommand
|
||||
{
|
||||
public String Name { get; set; }
|
||||
public Boolean Override { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
String[] words = command.Split(' ');
|
||||
List<String> directions = new List<String>();
|
||||
|
||||
if (words.Length == 1)
|
||||
{
|
||||
player.Send("No direction provided!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Door door in player.CurrentRoom.Doorways)
|
||||
{
|
||||
if (door.TravelDirection == TravelDirections.GetTravelDirectionValue(words[1]))
|
||||
{
|
||||
//Move the player into their new room
|
||||
player.Move(door.TravelDirection);
|
||||
|
||||
player.CommandSystem.ExecuteCommand("Look", player);
|
||||
|
||||
if (player.ActiveGame.AutoSave)
|
||||
player.Save(player.ActiveGame.DataPaths.Players);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.Send("Unable to travel in that direction.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -131,6 +131,12 @@ namespace MudEngine.GameManagement
|
|||
/// </summary>
|
||||
public Int32 AutoSaveInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the minimum number of characters required to create a 'legal' password.
|
||||
/// Default value is 6 characters required for a password during character creation.
|
||||
/// </summary>
|
||||
public Int32 MinimumPasswordSize { get; set; }
|
||||
|
||||
[Category("Project Settings")]
|
||||
[Description("Hide Room names from being outputted to the console.")]
|
||||
/// <summary>
|
||||
|
@ -214,6 +220,8 @@ namespace MudEngine.GameManagement
|
|||
|
||||
AutoSave = true;
|
||||
AutoSaveInterval = 30;
|
||||
|
||||
MinimumPasswordSize = 6;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -50,16 +50,9 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Commands\CommandExit.cs" />
|
||||
<Compile Include="Commands\CommandGetTime.cs" />
|
||||
<Compile Include="Commands\CommandLook.cs" />
|
||||
<Compile Include="Commands\CommandRestart.cs" />
|
||||
<Compile Include="Commands\CommandSave.cs" />
|
||||
<Compile Include="Commands\CommandWalk.cs" />
|
||||
<Compile Include="Commands\CommandLoad.cs" />
|
||||
<Compile Include="Commands\CommandLogin.cs" />
|
||||
<Compile Include="Commands\CommandSaveWorld.cs" />
|
||||
<Compile Include="Commands\CommandLinkRoom.cs" />
|
||||
<Compile Include="FileSystem\SaveDataPaths.cs" />
|
||||
<Compile Include="GameManagement\CommandEngine.cs" />
|
||||
<Compile Include="GameManagement\CommandResults.cs" />
|
||||
|
@ -77,7 +70,6 @@
|
|||
<Compile Include="GameObjects\Characters\BaseCharacter.cs" />
|
||||
<Compile Include="GameObjects\Characters\BaseStats.cs" />
|
||||
<Compile Include="GameObjects\Environment\Door.cs" />
|
||||
<Compile Include="GameObjects\Environment\MyRealm.cs" />
|
||||
<Compile Include="GameObjects\Environment\Realm.cs" />
|
||||
<Compile Include="GameObjects\Environment\Room.cs" />
|
||||
<Compile Include="GameObjects\Environment\StartingLocation.cs" />
|
||||
|
|
|
@ -142,7 +142,20 @@ namespace MudEngine.Scripting
|
|||
Directory.CreateDirectory("temp");
|
||||
|
||||
//Setup the additional sourcecode that's needed in the script.
|
||||
String[] usingStatements = new String[] { "using System;", "using System.Collections.Generic;", "using MudEngine.GameObjects;", "using MudEngine.GameObjects.Characters;", "using MudEngine.GameObjects.Environment;", "using MudEngine.GameObjects.Items;", "using MudEngine.GameManagement;", "using MudEngine.FileSystem;", "using MudEngine.Scripting;" };
|
||||
String[] usingStatements = new String[]
|
||||
{
|
||||
"using System;",
|
||||
"using System.Collections.Generic;",
|
||||
"using System.Text;",
|
||||
"using System.Linq;",
|
||||
"using MudEngine.GameObjects;",
|
||||
"using MudEngine.GameObjects.Characters;",
|
||||
"using MudEngine.GameObjects.Environment;",
|
||||
"using MudEngine.GameObjects.Items;",
|
||||
"using MudEngine.GameManagement;",
|
||||
"using MudEngine.FileSystem;",
|
||||
"using MudEngine.Scripting;"
|
||||
};
|
||||
|
||||
foreach (String script in scripts)
|
||||
{
|
||||
|
@ -171,7 +184,15 @@ namespace MudEngine.Scripting
|
|||
Dictionary<String, String> providerOptions = new Dictionary<String,String>();
|
||||
providerOptions.Add("CompilerVersion", "v4.0");
|
||||
|
||||
CompilerParameters param = new CompilerParameters(new String[] {"mscorlib.dll", "System.dll", "MudEngine.dll"});
|
||||
String[] referencedAssemblies = new String[]
|
||||
{
|
||||
"mscorlib.dll",
|
||||
"System.dll",
|
||||
"System.Core.dll",
|
||||
"MudEngine.dll"
|
||||
};
|
||||
|
||||
CompilerParameters param = new CompilerParameters(referencedAssemblies);
|
||||
param.GenerateExecutable = false;
|
||||
param.GenerateInMemory = true;
|
||||
if (!param.GenerateInMemory)
|
||||
|
|
|
@ -45,11 +45,29 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="Scripts\CommandExit.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandGetTime.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandLinkRoom.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandLook.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandSave.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandWalk.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandHelp.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandCreate.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandSay.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
|
|
@ -1,10 +1,42 @@
|
|||
/// <summary>
|
||||
/// The Clear command is used to clear the players terminal screen of all text.
|
||||
/// </summary>
|
||||
public class CommandClear : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandClear()
|
||||
{
|
||||
Help = new List<String>();
|
||||
Help.Add("The Clear command is used to clear the screen of all text.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Call the flush method to clear the players console screen of all text.
|
||||
player.FlushConsole();
|
||||
}
|
||||
}
|
|
@ -1,15 +1,40 @@
|
|||
public class CommandCreate : IGameCommand
|
||||
/// <summary>
|
||||
/// The Create command is used to dynamically create content within the game world.
|
||||
/// Content is created at run-time while the server/game is running and players are connected.
|
||||
/// Newly created content will be available for players to use/traverse immediately after creation is completed.
|
||||
/// Rooms that are created may be linked together using the LinkRoom command.
|
||||
/// </summary>
|
||||
public class CommandCreate : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandCreate()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Allows for the creation of environment objects.");
|
||||
Help.Add("Linking of Rooms are not supported yet.");
|
||||
//Help.Add("In order to link Rooms together use the LinkRoom command.");
|
||||
Help.Add("Provides Admins the ability to create content dynamically within the game world.");
|
||||
Help.Add("Content is created at run-time while the server/game is running and players are connected.");
|
||||
Help.Add("Newly created content will be available for players to use/traverse immediately after creation is completed.");
|
||||
Help.Add("Rooms that are created may be linked together using the LinkRoom command.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
|
|
72
MudGame/Scripts/CommandExit.cs
Normal file
72
MudGame/Scripts/CommandExit.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
/// <summary>
|
||||
/// The Exit command is used to exit the MUD game.
|
||||
/// Using this command while connected to a MUD server will perform a disconnect from the server.
|
||||
/// Using the command while running the game in offline mode will simply shut down the game.
|
||||
/// </summary>
|
||||
public class CommandExit : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandExit()
|
||||
{
|
||||
//Instance the help collection and add our help information to it.
|
||||
//Typically the Help content is placed within the constructor, but this particular help document
|
||||
//needs to access information from the player, so we will build our Help collection in the Execute command.
|
||||
Help = new List<string>();
|
||||
Help.Add("Exits the game.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// This method is called from the Command Engine, it is not recommended that you call this method directly.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="player"></param>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Check if the game is multiplayer.
|
||||
//Multiplayer games require disconnecting from the server and letting other players in the same Room know
|
||||
//that this player has left.
|
||||
if (player.ActiveGame.IsMultiplayer)
|
||||
{
|
||||
//Query the Active Games Player collection so that we can build a collection of Players that need to be
|
||||
//informed of the Player disconnecting from the Server.
|
||||
var playerQuery =
|
||||
from p in player.ActiveGame.GetPlayerCollection()
|
||||
where !p.Name.StartsWith("New") && p.Name != player.Name && p.CurrentWorldLocation == player.CurrentWorldLocation
|
||||
select p;
|
||||
|
||||
//Inform each player found in our LINQ query that the player has disconnected from the Server.
|
||||
foreach (BaseCharacter p in playerQuery)
|
||||
p.Send(player.Name + " has left."); ;
|
||||
|
||||
//TODO: If a player is in a Group then s/he needs to be removed upon disconnecting.
|
||||
player.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Call the game's shutdown method which will save all objects and exit the game gracefully.
|
||||
player.ActiveGame.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
47
MudGame/Scripts/CommandGetTime.cs
Normal file
47
MudGame/Scripts/CommandGetTime.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
/// <summary>
|
||||
/// The GetTime command is used to print the current in-game time to the player.
|
||||
/// This command will print the day, month and year along with hour, minute and seconds.
|
||||
/// </summary>
|
||||
public class CommandGetTime : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandGetTime()
|
||||
{
|
||||
//Instance the help collection and add our help information to it.
|
||||
Help = new List<string>();
|
||||
Help.Add("Gives you the current time and date in the game world.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the Command.
|
||||
/// This method is called from the Command Engine, it is not recommended that you call this method directly.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="player"></param>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Send the returned String containing the World Time to the player.
|
||||
player.Send(player.ActiveGame.WorldTime.GetCurrentWorldTime());
|
||||
}
|
||||
}
|
|
@ -1,35 +1,81 @@
|
|||
public class CommandHelp : IGameCommand
|
||||
/// <summary>
|
||||
/// Help command provides information on all the existing game commands, including script based commands.
|
||||
/// </summary>
|
||||
public class CommandHelp : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandHelp()
|
||||
{
|
||||
Help = new List<String>();
|
||||
Help.Add("Provides help on various topics.");
|
||||
Help.Add("You may ask for help on any game command.");
|
||||
Help.Add("Usage: Help");
|
||||
Help.Add("Usage: Help 'command' where command = a game command");
|
||||
Help.Add("Example: Help Look");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Check if we have a topic that the player wants help with. If there is nothing after the Help word
|
||||
//in the command, then the user didn't supply us with a topic.
|
||||
string topic = command.Substring("Help".Length);
|
||||
|
||||
//TODO: Help command should display a complete list of available commands and should have self contained help topics.
|
||||
//if the user did not supply us with a topic, we will print every command currently loaded in the engine
|
||||
//and tell the user how they can access help information regarding that command.
|
||||
//TODO: Help command should have self contained help topics.
|
||||
if (topic.Length == 0)
|
||||
{
|
||||
player.Send("Available commands: ", false);
|
||||
|
||||
//Print each command found within the command engine.
|
||||
foreach (String cmd in CommandEngine.GetCommands())
|
||||
{
|
||||
//We will get a reference to the current command in the iteration
|
||||
IGameCommand g = CommandEngine.GetCommand(cmd);
|
||||
//Print the name of the command to the user, place a comma after the command
|
||||
//so that the next command can be placed afterwards.
|
||||
player.Send(CommandEngine.GetCommandName(g) + ", ", false);
|
||||
}
|
||||
|
||||
//Let the player know how to use the help command to access help regarding any of the aformentioned commands.
|
||||
player.Send("");
|
||||
player.Send("Usage: Help 'Command'");
|
||||
return;
|
||||
}
|
||||
//The player supplied a topic, lets trip out all the white spaces from it caused by the Substring method
|
||||
else
|
||||
topic = topic.Trim();
|
||||
|
||||
//Get a reference to the command the player wants help with. We must insert the 'Command' string into the topic,
|
||||
//as all Commands start with the word Command, however the player never sees the word Command. It's internal only.
|
||||
IGameCommand gc = CommandEngine.GetCommand("Command" + topic);
|
||||
|
||||
//Iterate through each entry in the commands help collection and print it to the player.
|
||||
foreach (String help in gc.Help)
|
||||
{
|
||||
player.Send(help);
|
||||
}
|
||||
}
|
||||
}
|
419
MudGame/Scripts/CommandLinkRoom.cs
Normal file
419
MudGame/Scripts/CommandLinkRoom.cs
Normal file
|
@ -0,0 +1,419 @@
|
|||
/// <summary>
|
||||
/// The LinkRoom command is used to Link two previously created Rooms together.
|
||||
/// Rooms linked together can be traversed by players.
|
||||
/// This command is used to link Rooms dynamically during run-time by Admins, allowing environments to be created
|
||||
/// and traversed on-the-fly without the need to modify scripts and re-start the server.
|
||||
/// </summary>
|
||||
public class CommandLinkRoom : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandLinkRoom()
|
||||
{
|
||||
//Instance the help collection and add our help information to it.
|
||||
Help = new List<string>();
|
||||
Help.Add("Use this to link two previously created Rooms together.");
|
||||
//Incase Admins try to use the command, they will know that it's broken.
|
||||
//Don't convert this class into a Script until it is fully completed.
|
||||
Help.Add("NOTE: This command is not fully implemented. You may link two Rooms together provided they exist within the same Zone.");
|
||||
Help.Add("You may experience some Rooms not being traversable even after linking.");
|
||||
Help.Add("This command is a work-in-progress and will contain bugs.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// This method is called from the Command Engine, it is not recommended that you call this method directly.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="player"></param>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Check if the Player has the correct privileges to Link Rooms together.
|
||||
//If they are not a Admin or GM then the command will bail.
|
||||
//This creates the illusion that this command possibly doesn't exist.
|
||||
if ((player.Role != SecurityRoles.Admin) && (player.Role != SecurityRoles.GM))
|
||||
{
|
||||
player.Send("Invalid Command.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Build the Menu system that will be displayed to Admins.
|
||||
player.Send("Room linkage tool");
|
||||
player.Send("Please select an option.");
|
||||
player.Send("1: Link Room");
|
||||
player.Send("2: Exit");
|
||||
|
||||
//Read the input from the Admin.
|
||||
string input = player.ReadInput();
|
||||
Int32 value = 0;
|
||||
|
||||
//Attempt to convert their input from a String into a numerical value.
|
||||
//If they entered a non-numerical value, then the method will exit
|
||||
try
|
||||
{
|
||||
value = Convert.ToInt32(input);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
player.Send("Invalid selection. Please use numeric values.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Ask what Room the Admin wants to use as the Departing Room.
|
||||
//Departing Rooms will be where the travel direction originates from.
|
||||
//meaning if the Admin selects West as the traveling direction, then traveling West will exit the
|
||||
//Departing Room and enter the Arrival Room.
|
||||
player.Send("");
|
||||
player.Send("Please select which Realm your departing Room resides within:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Realm that we can use to reference an existing Realm so that we can find the
|
||||
//Rooms within it that the Admin is looking for.
|
||||
Boolean isValidRealm = false;
|
||||
Realm realm = new Realm(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Realm, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Realm name.
|
||||
while (!isValidRealm)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidRealm to true, as we will assume that
|
||||
//the user will enter a valid Realm name on the first shot. If we can't find a matching
|
||||
//Realm, then this will get set to false once iterating through Realms is completed.
|
||||
isValidRealm = true;
|
||||
|
||||
//Print each Realm out to the Admin so they may see a complete list to choose from.
|
||||
//This is the Realm that their first Room will reside within.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
player.Send(r.Filename + " | ", false);
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Realm they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the Active Games world collection, finding Realms that match the filename entered by the Admin
|
||||
var realmQuery =
|
||||
from r in player.ActiveGame.World.RealmCollection
|
||||
where r.Filename.ToLower() == input.ToLower()
|
||||
select r;
|
||||
|
||||
//Check if the query contains a Realm.
|
||||
if (realmQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Realm. Assign it to our realm field for use later.
|
||||
realm = realmQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidRealm = true;
|
||||
}
|
||||
//If the query does not contain a Realm, then we ensure that the loop will continue by forcing
|
||||
//isValidRealm back to false.
|
||||
else
|
||||
{
|
||||
isValidRealm = false;
|
||||
//Let the Admin know that they entered an invalid Realm name and that they need to try again.
|
||||
player.Send("That Realm does not exist! Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Let the Admin know that they need to now select which Zone the Room they are wanting to link resides within.
|
||||
player.Send("");
|
||||
player.Send("Please select which Zone your departing Room resides within:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Zone that we can use to reference an existing Zone so that we can find the
|
||||
//Rooms within it that the Admin is looking for.
|
||||
Boolean isValidZone = false;
|
||||
Zone zone = new Zone(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Zone, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Zone name.
|
||||
while (!isValidZone)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidZone to true, as we will assume that
|
||||
//the user will enter a valid Zone name on the first shot. If we can't find a matching
|
||||
//Zone, then this will get set to false once iterating through Zone is completed.
|
||||
isValidZone = true;
|
||||
|
||||
//Print each Zone out to the Admin so they may see a complete list to choose from.
|
||||
//This is the Zone that their first Room will reside within.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Zone z in realm.ZoneCollection)
|
||||
{
|
||||
player.Send(z.Filename + " | ", false);
|
||||
}
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Zone they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the stored Realm's Zone collection, finding Zones that match the filename entered by the Admin
|
||||
var zoneQuery =
|
||||
from z in realm.ZoneCollection
|
||||
where z.Filename.ToLower() == input.ToLower()
|
||||
select z;
|
||||
|
||||
//Check if the query contains a Zone.
|
||||
if (zoneQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Zone. Assign it to our zone field for use later.
|
||||
zone = zoneQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidZone = true;
|
||||
}
|
||||
//If the query does not contain a Zone, then we ensure that the loop will continue by forcing
|
||||
//isValidZone back to false.
|
||||
else
|
||||
{
|
||||
isValidZone = false;
|
||||
//Let the Admin know that they entered an invalid Zone name and that they need to try again.
|
||||
player.Send("That Zone does not exist! Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Let the Admin know that they need to now select Room they are wanting to link as the departure Room
|
||||
player.Send("");
|
||||
player.Send("Please select which Room that you wish to be the departing Room:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Room that we can store a reference to a existing Room.
|
||||
//We will use this reference to link the departure and arrival Rooms together.
|
||||
Boolean isValidRoom = false;
|
||||
Room departingRoom = new Room(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Room, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Room name.
|
||||
while (!isValidRoom)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidRoom to true, as we will assume that
|
||||
//the user will enter a valid Room name on the first shot. If we can't find a matching
|
||||
//Room, then this will get set to false once iterating through Room is completed.
|
||||
isValidRoom = true;
|
||||
|
||||
//Print each Room out to the Admin so they may see a complete list to choose from.
|
||||
//This will be their departing Room.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Room they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the referenced zone's Room collection, finding Rooms that match the filename entered by the Admin
|
||||
var roomQuery =
|
||||
from r in zone.RoomCollection
|
||||
where r.Filename.ToLower() == input.ToLower()
|
||||
select r;
|
||||
|
||||
//Check if the query contains a Room.
|
||||
if (roomQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Room. Assign it to our departingRoom field for use later.
|
||||
departingRoom = roomQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidRoom = true;
|
||||
}
|
||||
//If the query does not contain a Room, then we ensure that the loop will continue by forcing
|
||||
//isValidRoom back to false.
|
||||
else
|
||||
{
|
||||
isValidRoom = false;
|
||||
//Let the Admin know that they entered an invalid Room name and that they need to try again.
|
||||
player.Send("That Room does not exist! Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Let the Admin know that they need to now select Room they are wanting to link as the Arrival Room
|
||||
player.Send("");
|
||||
player.Send("Please select which Room that you wish to be the Arrival Room:");
|
||||
player.Send("");
|
||||
|
||||
//Instance a new Room that we can store a reference to a existing Room.
|
||||
//We will use this reference to link the departure and arrival Rooms together.
|
||||
isValidRoom = false;
|
||||
Room arrivalRoom = new Room(player.ActiveGame);
|
||||
|
||||
//Create a Loop incase the Admin enters an invalid Room, we can just loop
|
||||
//back and re-ask the Admin the enter a valid Room name.
|
||||
while (!isValidRoom)
|
||||
{
|
||||
//Now that we are in the loop, set the isValidRoom to true, as we will assume that
|
||||
//the user will enter a valid Room name on the first shot. If we can't find a matching
|
||||
//Room, then this will get set to false once iterating through Room is completed.
|
||||
isValidRoom = true;
|
||||
|
||||
//Print each Room out to the Admin so they may see a complete list to choose from.
|
||||
//This will be their departing Room.
|
||||
//TODO: Currently only linking Rooms within the same Realm/Zone is supported. Need to fix that.
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
//Get the Admins input that should specify what Room they are wanting.
|
||||
input = player.ReadInput();
|
||||
|
||||
//Check if the Admin entered 'Cancel'. If so, then cancel the Link process.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room Linking aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Query the referenced zone's Room collection, finding Rooms that match the filename entered by the Admin
|
||||
var roomQuery =
|
||||
from r in zone.RoomCollection
|
||||
where r.Filename.ToLower() == input.ToLower()
|
||||
select r;
|
||||
|
||||
//Check if the query contains a Room.
|
||||
if (roomQuery.FirstOrDefault() != null)
|
||||
{
|
||||
//The query does in-fact contain a valid Room. Assign it to our departingRoom field for use later.
|
||||
departingRoom = roomQuery.FirstOrDefault();
|
||||
//We can set this to true, allowing us to exit out of the loop.
|
||||
isValidRoom = true;
|
||||
}
|
||||
//If the query does not contain a Room, then we ensure that the loop will continue by forcing
|
||||
//isValidRoom back to false.
|
||||
else
|
||||
{
|
||||
isValidRoom = false;
|
||||
//Let the Admin know that they entered an invalid Room name and that they need to try again.
|
||||
player.Send("That Room does not exist! Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Let the Admin select the direction of travel required for a player to traverse from the
|
||||
//departing Room into the arriving Room.
|
||||
player.Send("Please select which direction you would like to travel while departing the departure Room.");
|
||||
|
||||
//Store a array of existing values within the AvailableTravelDirection enum.
|
||||
//These values are the legal travel directions that are supported by the game.
|
||||
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
|
||||
|
||||
//Create a reference to the AvailableTravelDirections enum that we can use to assign a travel
|
||||
//when we pass the Room linking off to the Rooms owning Zone.
|
||||
AvailableTravelDirections direction = new AvailableTravelDirections();
|
||||
Boolean isValidDirection = false;
|
||||
|
||||
//Perform the direction corrections within a while loop, incase the Admin enteres
|
||||
//a invalid traveling direction and we need to re-acquire input from the Admin.
|
||||
while (!isValidDirection)
|
||||
{
|
||||
//Loop through the array, printing each travel direction we found in the enum array collection
|
||||
//to the screen for the user to see and select from.
|
||||
foreach (Int32 v in values)
|
||||
{
|
||||
//Since enum values are not strings, we can't simply assign a string value to the enum.
|
||||
//The enum needs to be queried to retrieve a value that matches that of 'v' and convert it to a String
|
||||
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
|
||||
|
||||
//Print this current iterations value to the screen for the player.
|
||||
player.Send(displayName + " | ");
|
||||
}
|
||||
|
||||
//As for the Admins selection, we will place the Admins input on the same line
|
||||
//as the last message sent to the Admin by setting the newLine parameter to false.
|
||||
player.Send("Enter Selection: ", false);
|
||||
input = player.ReadInput();
|
||||
|
||||
//Loop through each value found in our original array or values acquired from the AvailableTravelDirections enum.
|
||||
foreach (Int32 v in values)
|
||||
{
|
||||
//Since enum values are not strings, we can't simply assign a string value to the enum.
|
||||
//The enum needs to be queried to retrieve a value that matches that of 'v' and convert it to a String
|
||||
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
|
||||
|
||||
//Check if the Admins selected travel direction matches that of the current travel direction value found
|
||||
//within our array of values harvested from the AvailableTravelDirections enum
|
||||
if (displayName.ToLower() == input.ToLower())
|
||||
{
|
||||
//The two match up. Now you have to convert the String version of the travel direction, back into
|
||||
//an enum equivilant for use by the Rooms owning Zone during linking.
|
||||
direction = (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);
|
||||
|
||||
//We found a legal Travel Direction. Setting this to true will exit the while loop.
|
||||
isValidDirection = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
isValidDirection = false;
|
||||
}
|
||||
|
||||
//Check if we haven't found a valid direction yet. This will print to the Admin that the entered
|
||||
//direction was invalid, and then loop back to the top of the current loop.
|
||||
if (!isValidDirection)
|
||||
{
|
||||
player.Send("Invalid direction supplied!");
|
||||
}
|
||||
//The direction supplied by the Admin matched up and was concidered legal, so we shoud
|
||||
//have a converted AvailableTravelDirection now with the value matching that of the Admins.
|
||||
//Link the two rooms together, with the travel direction of the Admins choice.
|
||||
else
|
||||
{
|
||||
zone.LinkRooms(direction, arrivalRoom, departingRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
MudGame/Scripts/CommandLook.cs
Normal file
64
MudGame/Scripts/CommandLook.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
/// <summary>
|
||||
/// The Look command is used to print the contents of the players current Room to the screen.
|
||||
/// The Room.Description property is printed to the players screen if it contains content.
|
||||
/// If the Room.DetailedDescription collection property contains content, it will be printed to the screen
|
||||
/// after the Room.Description property is printed (provided Room.Description is not empty.)
|
||||
/// </summary>
|
||||
public class CommandLook : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandLook()
|
||||
{
|
||||
Help = new List<String>();
|
||||
Help.Add("Prints a description of the current Room and the objects that reside within it.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//If the players Room is null, then we need to let them know that they are
|
||||
//currently not residing within a Room. If this occures for some reason, the player will
|
||||
//need to be moved into an existing Room by an Admin.
|
||||
//TODO: Allow Admins to move Characters from one Room to another.
|
||||
if (player.CurrentRoom == null)
|
||||
{
|
||||
player.Send("You are not within any Room.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if the players current Room has a blank Description. If not, we print it for the player to read.
|
||||
if (!String.IsNullOrEmpty(player.CurrentRoom.Description))
|
||||
player.Send(player.CurrentRoom.Description);
|
||||
|
||||
//Check if the players current Room has a detailed description.
|
||||
//If the collection contains content, it will loop through each entry and print it to the screen as a new line.
|
||||
if (player.CurrentRoom.DetailedDescription.Count != 0)
|
||||
{
|
||||
foreach (String entry in player.CurrentRoom.DetailedDescription)
|
||||
player.Send(entry);
|
||||
}
|
||||
}
|
||||
}
|
42
MudGame/Scripts/CommandSave.cs
Normal file
42
MudGame/Scripts/CommandSave.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
/// <summary>
|
||||
/// The Save command will save the current player to a hard-disk file.
|
||||
/// </summary>
|
||||
public class CommandSave : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandSave()
|
||||
{
|
||||
Help = new List<String>();
|
||||
Help.Add("Saves your character immediately.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Save the player to the hard-disk.
|
||||
player.Save(player.ActiveGame.DataPaths.Players);
|
||||
}
|
||||
}
|
|
@ -1,25 +1,66 @@
|
|||
/// <summary>
|
||||
/// The Say command provides the player with the ability to chat with other players within the game world.
|
||||
/// Players using the Say command can only talk to players that are currently within the same Room.
|
||||
/// </summary>
|
||||
public class CommandSay : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandSay()
|
||||
{
|
||||
Help = new List<String>();
|
||||
Help.Add("Allows you to Chat with with players around you.");
|
||||
Help.Add("Note that you can only chat with players that reside within the same Room as yourself.");
|
||||
Help.Add("Usage: Say Hello everyone!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if (command.Length <= 4) //user only sent 'Say' or 'Say '
|
||||
//Check if the user only said 'Say ' or 'Say' with no message content.
|
||||
if (command.Length <= 4)
|
||||
{
|
||||
//If no message content, print the help for the command to the player.
|
||||
player.ExecuteCommand("Help Say");
|
||||
return; //nothing to say, don't say anything at all.
|
||||
}
|
||||
|
||||
//Get the message out of the command string.
|
||||
String message = command.Substring("Say ".Length);
|
||||
|
||||
foreach (BaseCharacter p in player.ActiveGame.GetPlayerCollection())
|
||||
{
|
||||
if ((p.CurrentRoom.Realm == player.CurrentRoom.Realm) && (p.CurrentRoom.Zone == player.CurrentRoom.Zone) && (p.CurrentRoom.Filename == player.CurrentRoom.Filename))
|
||||
{
|
||||
p.Send(player.Name + " says: " + message);
|
||||
}
|
||||
}
|
||||
//Query the game world and find what players are within the same location as the chatting player.
|
||||
var playerQuery =
|
||||
from p in player.ActiveGame.GetPlayerCollection()
|
||||
where p.CurrentWorldLocation == player.CurrentWorldLocation
|
||||
select p;
|
||||
|
||||
//Send the message to each player found within our player query.
|
||||
foreach (var p in playerQuery)
|
||||
p.Send(player.Name + " says: " + message);
|
||||
|
||||
//Print the same message but in a alternate format to the player that sent the message originally.
|
||||
player.Send("You say: " + message);
|
||||
|
||||
}
|
||||
|
|
113
MudGame/Scripts/CommandWalk.cs
Normal file
113
MudGame/Scripts/CommandWalk.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
/// <summary>
|
||||
/// The Walk command allows players to walk from Room to Room, traversing the Mud world.
|
||||
/// The command supports all of the available travel directions found within the
|
||||
/// MudEngine.GameObjects.Environment.AvailableTravelDirections enum.
|
||||
/// </summary>
|
||||
public class CommandWalk : IGameCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
|
||||
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
|
||||
/// </summary>
|
||||
public Boolean Override { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the command.
|
||||
/// If Override is set to true, this command will override any other command that contains the same name.
|
||||
/// </summary>
|
||||
public String Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of strings that contains helpfull information for this Command.
|
||||
/// When the user enteres 'Help Exit' the game will print the content of this collection.
|
||||
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
|
||||
/// </summary>
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public CommandWalk()
|
||||
{
|
||||
Help = new List<String>();
|
||||
Help.Add("Allows you to traverse through the world.");
|
||||
Help.Add("You may walk in any direction available within the current Room.");
|
||||
Help.Add("You may use the Look command to see a description of the current Room, and decide where you would like to walk.");
|
||||
Help.Add("Usage: Walk 'Direction' where Direction may equal one of the following:");
|
||||
|
||||
//We will construct a string that contains all of the available travel directions for the player.
|
||||
StringBuilder directions = new StringBuilder();
|
||||
|
||||
//Store a array of existing values within the AvailableTravelDirection enum.
|
||||
//These values are the legal travel directions that are supported by the game.
|
||||
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
|
||||
|
||||
//Loop through the array, printing each travel direction we found in the enum array collection
|
||||
//to the screen for the user to see and select from.
|
||||
foreach (Int32 v in values)
|
||||
{
|
||||
//Since enum values are not strings, we can't simply assign a string value to the enum.
|
||||
//The enum needs to be queried to retrieve a value that matches that of 'v' and convert it to a String
|
||||
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
|
||||
|
||||
//Add the current travel direction to our string for later use.
|
||||
directions.Append(displayName + ", ");
|
||||
}
|
||||
|
||||
//Place the newly constructed String with all of our available travel directions into the help collection.
|
||||
Help.Add(directions.ToString());
|
||||
|
||||
//Note that you could have placed each direction in manually "Help.Add("West")" etc. however this would
|
||||
//prove an issue with maintanence if directions were changed within the engine, new ones added or old ones removed.
|
||||
//Getting the travel directions the way we did always ensures that the help command will always every
|
||||
//available travel direction contained within the engine, regardless if we add or remove directions internally or not.
|
||||
//It's a dynamic way of storing our directions.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class.
|
||||
/// </summary>
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
//Since the walk command requires a second word (ex: walk north)
|
||||
//we split the words into an array so they are seperate.
|
||||
String[] words = command.Split(' ');
|
||||
List<String> directions = new List<String>();
|
||||
|
||||
//We only 1 word was found within the array, then the user failed to provide a second word
|
||||
//which would be the travel direction they are wanting to go.
|
||||
if (words.Length == 1)
|
||||
{
|
||||
player.Send("No direction provided!");
|
||||
return;
|
||||
}
|
||||
//The user supplied a traveling direction for us, lets ensure it's a valid one.
|
||||
else
|
||||
{
|
||||
//iterate through each door within the current Room and see if we have a Door that
|
||||
//contains a exit in the direction that the player supplied.
|
||||
foreach (Door door in player.CurrentRoom.Doorways)
|
||||
{
|
||||
//See if the current door has the same travel direction value as that of the users entered direction.
|
||||
if (door.TravelDirection == TravelDirections.GetTravelDirectionValue(words[1]))
|
||||
{
|
||||
//The matches the users direction, so move the player in the direction supplied by the user.
|
||||
player.Move(door.TravelDirection);
|
||||
|
||||
//Use the Look command to print the contents of the new Room to the Player.
|
||||
player.CommandSystem.ExecuteCommand("Look", player);
|
||||
|
||||
//If the current Active Game has Auto-Save enabled, we will save the player.
|
||||
if (player.ActiveGame.AutoSave)
|
||||
player.Save(player.ActiveGame.DataPaths.Players);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If the user entered a travel direction that does not exist within the current Room, they will be told so
|
||||
//and no moving will be performed.
|
||||
player.Send("Unable to travel in that direction.");
|
||||
}
|
||||
}
|
|
@ -1,10 +1,31 @@
|
|||
/// <summary>
|
||||
/// The EarthGame script extends from the Mud Designer Game Engine internal Game class.
|
||||
/// In order for the script to be used as the new default Game class within the engine, it MUST
|
||||
/// inherit from Game by using a colon followed by Game after the script name.
|
||||
///
|
||||
/// Ex: EarthGame : Game
|
||||
///
|
||||
/// This allows developers to extend on or modify how the Game will act during runtime.
|
||||
/// </summary>
|
||||
public class EarthGame : Game
|
||||
{
|
||||
//Our custom California Realm script.
|
||||
public WorldCalifornia Cali;
|
||||
|
||||
public EarthGame()
|
||||
: base()
|
||||
/// <summary>
|
||||
/// The Constructor for the Game.
|
||||
/// If you wish to have the internal engine Game class execute it's constructor code before your code
|
||||
/// is called, you must call the base class by using a colon followed by base() on the same line as your constructor.
|
||||
///
|
||||
/// Ex: EarthGame() : base()
|
||||
///
|
||||
/// This will ensure that all of the engine properties are setup correctly, incase you miss anything.
|
||||
/// Any code placed within your constructor is executed after the internal Game class constructor is executed,
|
||||
/// allowing you to override of the engines properties and set things up how your game needs things set.
|
||||
/// </summary>
|
||||
public EarthGame() : base()
|
||||
{
|
||||
//The following are Properties this script inherits from the internal Game class.
|
||||
GameTitle = "Planet Earth MUD";
|
||||
Story = "The planet Earth reproduced in a MUD for your playing enjoyment!";
|
||||
IsMultiplayer = true;
|
||||
|
@ -12,9 +33,15 @@ public class EarthGame : Game
|
|||
CompanyName = "Mud Designer Team";
|
||||
Website = "Visit Http://MudDesigner.Codeplex.com for the latest News, Documentation and Releases.";
|
||||
Version = "Example Game Version 1.0";
|
||||
MaximumPlayers = 5000;
|
||||
|
||||
//Maximum number of players allowed to play on the server at any given time.
|
||||
MaximumPlayers = 1000;
|
||||
|
||||
//Create a new instance of our California realm script, we must pass a reference to our EarthGame
|
||||
//to the script so that it may add the Realm to our Game world. That is done by using the 'this' keyword.
|
||||
Cali = new WorldCalifornia(this);
|
||||
|
||||
//Calling the create method within the california script.
|
||||
Cali.Create();
|
||||
}
|
||||
}
|
|
@ -1,50 +1,116 @@
|
|||
/// <summary>
|
||||
/// The WorldCalifornia script is used to construct the Game world.
|
||||
/// </summary>
|
||||
public class WorldCalifornia
|
||||
{
|
||||
//Our current Active Game. Allows us to add content to the game.
|
||||
private Game _Game;
|
||||
|
||||
/// <summary>
|
||||
/// Our Constructor.
|
||||
/// </summary>
|
||||
/// <param name="game"></param>
|
||||
public WorldCalifornia(Game game)
|
||||
{
|
||||
//Set _Game to reference the current Active Game.
|
||||
_Game = game;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the world the player will interact with.
|
||||
/// The WorldCalifornia is used soley for creating the California Realm.
|
||||
/// It is recommended that the creation of other Realms be done in their own respective classes mimicking this one.
|
||||
/// </summary>
|
||||
public void Create()
|
||||
{
|
||||
//Instance our Realm
|
||||
//Get a new Instance of a Realm.
|
||||
Realm myRealm = new Realm(_Game);
|
||||
|
||||
//Setup the Realm properties.
|
||||
myRealm.Name = "California";
|
||||
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
|
||||
|
||||
//Setting the Realms IsInitialRealm to true will let the current Active Game know where to place newly created players.
|
||||
myRealm.IsInitialRealm = true;
|
||||
|
||||
//Add the Realm to the current Active Game World.
|
||||
_Game.World.AddObject(myRealm);
|
||||
|
||||
//Get a new Instance of a Zone.
|
||||
Zone myZone = new Zone(_Game);
|
||||
|
||||
//Setup the Zone properties
|
||||
myZone.Name = "San Diego";
|
||||
myZone.Realm = myRealm.Name;
|
||||
myZone.Description = "San Diego has many attractions, including Sea World!";
|
||||
|
||||
//Place this Zone within our previously created Realm
|
||||
myZone.Realm = myRealm.Filename;
|
||||
|
||||
//Setting the Zones IsInitialZone to true will let the current Active Game know where to place newly created players.
|
||||
myZone.IsInitialZone = true;
|
||||
|
||||
//Add the Zone to the current Active Game World
|
||||
myRealm.AddZone(myZone);
|
||||
|
||||
//Create our HotelRoom
|
||||
//Get a new Instance of a Room.
|
||||
Room myRoom = new Room(_Game);
|
||||
|
||||
//Setup the Room properties
|
||||
myRoom.Name = "Hotel Room B33";
|
||||
myRoom.IsInitialRoom = true;
|
||||
myZone.AddRoom(myRoom);
|
||||
myRoom.DetailedDescription.Add("Your Hotel Room is pretty clean, it is small but not to far off from the beach so you can't complain.");
|
||||
myRoom.DetailedDescription.Add("You can exit your Hotel Room by walking West");
|
||||
|
||||
//Setting the Rooms IsInitialRoom to true will let the current Active Game know where to place newly created players.
|
||||
myRoom.IsInitialRoom = true;
|
||||
|
||||
//Add the Room to the previously created Zone.
|
||||
//TODO: The engine needs to provide World.AddObject() support to Rooms, so that Rooms may be added in the same
|
||||
//manor as Realms and Zones.
|
||||
myZone.AddRoom(myRoom);
|
||||
|
||||
//Get a new Instance of a Room
|
||||
Room myHallway = new Room(_Game);
|
||||
|
||||
//Setup the Room properties
|
||||
myHallway.Name = "Hotel Hallway";
|
||||
myHallway.DetailedDescription.Add("The Hotel Hallway is fairly narrow, but there is plenty of room for people to traverse through it.");
|
||||
myHallway.DetailedDescription.Add("Your Hotel Room B33 is to the East.");
|
||||
myHallway.DetailedDescription.Add("Hotel Room B34 is to your West.");
|
||||
|
||||
//Since more than one 'Hotel hallway' may exist, we will differentiate them by setting a custom filename.
|
||||
//Note that assigning a new Filename must be done AFTER assigning the objects Name property a value.
|
||||
//Each time a objects Name property is assigned a value, it automatically generates a filename.
|
||||
//If a Filename is assigned prior to assigning the Name property, your previous Filename will be over-wrote.
|
||||
myHallway.Filename = myHallway.Name + "1.Zone";
|
||||
|
||||
//Add the Room to the previously created Zone.
|
||||
myZone.AddRoom(myHallway);
|
||||
|
||||
//Link the two previously created Rooms together.
|
||||
//Player must walk 'West' to exit myRoom and enter myHallway.
|
||||
//Zone Linking automatically places a reverse doorway in the myHallway Room,
|
||||
//allowing players to walk 'East' to exit myHallway and enter myRoom once again.
|
||||
myZone.LinkRooms(AvailableTravelDirections.West, myHallway, myRoom);
|
||||
|
||||
//Get a new Instance of a Room
|
||||
Room nextRoom = new Room(_Game);
|
||||
|
||||
//Setup the Room properties
|
||||
nextRoom.Name = "Hotel Room B34";
|
||||
nextRoom.DetailedDescription.Add("This Hotel Room is pretty dirty, they must not have cleaned it yet.");
|
||||
nextRoom.DetailedDescription.Add("You can exit this room by walking East");
|
||||
|
||||
//Add the Room to the previously created Zone
|
||||
myZone.AddRoom(nextRoom);
|
||||
//Link
|
||||
|
||||
//Link the new Room to the previously created myHallway.
|
||||
//Players must walk West out of the hallway to enter this room.
|
||||
myZone.LinkRooms(AvailableTravelDirections.East, myHallway, nextRoom);
|
||||
|
||||
/* Current Room layout is as shown.
|
||||
*
|
||||
* Room B33 -> Hallway <- Room B34
|
||||
*
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
public class WorldCalifornia
|
||||
{
|
||||
private Game _Game;
|
||||
|
||||
public WorldCalifornia(Game game)
|
||||
{
|
||||
_Game = game;
|
||||
}
|
||||
|
||||
public void Create()
|
||||
{
|
||||
//Instance our Realm
|
||||
Realm myRealm = new Realm(_Game);
|
||||
myRealm.Name = "California";
|
||||
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
|
||||
myRealm.IsInitialRealm = true;
|
||||
_Game.World.AddObject(myRealm);
|
||||
|
||||
Zone myZone = new Zone(_Game);
|
||||
myZone.Name = "San Diego";
|
||||
myZone.Realm = myRealm.Name;
|
||||
myZone.Description = "San Diego has many attractions, including Sea World!";
|
||||
myZone.IsInitialZone = true;
|
||||
myRealm.AddZone(myZone);
|
||||
|
||||
//Create our HotelRoom
|
||||
Room myRoom = new Room(_Game);
|
||||
myRoom.Name = "Hotel Room B33";
|
||||
myRoom.IsInitialRoom = true;
|
||||
myZone.AddRoom(myRoom);
|
||||
myRoom.DetailedDescription.Add("Your Hotel Room is pretty clean, it is small but not to far off from the beach so you can't complain.");
|
||||
myRoom.DetailedDescription.Add("You can exit your Hotel Room by walking West");
|
||||
|
||||
Room myHallway = new Room(_Game);
|
||||
myHallway.Name = "Hotel Hallway";
|
||||
myHallway.DetailedDescription.Add("The Hotel Hallway is fairly narrow, but there is plenty of room for people to traverse through it.");
|
||||
myHallway.DetailedDescription.Add("Your Hotel Room B33 is to the East.");
|
||||
myHallway.DetailedDescription.Add("Hotel Room B34 is to your West.");
|
||||
myZone.AddRoom(myHallway);
|
||||
myZone.LinkRooms(AvailableTravelDirections.West, myHallway, myRoom);
|
||||
|
||||
Room nextRoom = new Room(_Game);
|
||||
nextRoom.Name = "Hotel Room B34";
|
||||
nextRoom.DetailedDescription.Add("This Hotel Room is pretty dirty, they must not have cleaned it yet.");
|
||||
nextRoom.DetailedDescription.Add("You can exit this room by walking East");
|
||||
myZone.AddRoom(nextRoom);
|
||||
//Link
|
||||
myZone.LinkRooms(AvailableTravelDirections.East, myHallway, nextRoom);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue