MudEngine:
- All commands are now required to have a Help property. MudGame: - Finished the Create command. Now allows for creating Realms, Zones and Rooms - Added LinkRoom command for linking Rooms. Not finished. - Added Help command. Typing Help prints all of the currently available commands. Typing Help 'CommandName' prints that Commands help property. Default commands print a help document.
This commit is contained in:
parent
f51e17af7b
commit
386d90df19
22 changed files with 678 additions and 114 deletions
|
@ -16,6 +16,13 @@ namespace MudEngine.Commands
|
|||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public CommandExit()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Exits the game cleanly.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace MudEngine.Commands
|
|||
public String Name { get; set; }
|
||||
|
||||
public Boolean Override { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public CommandGetTime()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Gives you the current time and date in the game world.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
|
|
271
MudEngine/Commands/CommandLinkRoom.cs
Normal file
271
MudEngine/Commands/CommandLinkRoom.cs
Normal file
|
@ -0,0 +1,271 @@
|
|||
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;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
public class CommandLinkRoom : IGameCommand
|
||||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public CommandLinkRoom()
|
||||
{
|
||||
Help = new List<string>();
|
||||
Help.Add("Use this to link two previously created Rooms together");
|
||||
Help.Add("Note that this command is not fully implemented and does not work.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
player.Send("Room linkage tool");
|
||||
player.Send("Please select an option.");
|
||||
player.Send("1: Link Room");
|
||||
player.Send("2: Exit");
|
||||
|
||||
string input = player.ReadInput();
|
||||
Int32 value = 0;
|
||||
|
||||
try
|
||||
{
|
||||
value = Convert.ToInt32(input);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
player.Send("Invalid selection. Please use numeric values.");
|
||||
return;
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Please select which Realm your departing Room resides within:");
|
||||
player.Send("");
|
||||
|
||||
Boolean isValidRealm = false;
|
||||
Realm realm = new Realm(player.ActiveGame);
|
||||
|
||||
while (!isValidRealm)
|
||||
{
|
||||
isValidRealm = true;//Default to true, assume the user entered a valid name.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
{
|
||||
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 (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
{
|
||||
if (r.Filename.ToLower() == input.ToLower())
|
||||
{
|
||||
isValidRealm = true;
|
||||
realm = r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValidRealm = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidRealm)
|
||||
player.Send("That Realm does not exist! Please try again.");
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Please select which Zone your departing Room resides within:");
|
||||
player.Send("");
|
||||
|
||||
Boolean isValidZone = false;
|
||||
Zone zone = new Zone(player.ActiveGame);
|
||||
|
||||
while (!isValidZone)
|
||||
{
|
||||
isValidZone = true;//Default to true, assume the user entered a valid name.
|
||||
foreach (Zone z in realm.ZoneCollection)
|
||||
{
|
||||
player.Send(z.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 (Zone z in realm.ZoneCollection)
|
||||
{
|
||||
if (z.Filename.ToLower() == input.ToLower())
|
||||
{
|
||||
isValidZone = true;
|
||||
zone = z;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValidZone = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidZone)
|
||||
player.Send("That Zone does not exist! Please try again.");
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Please select which Room that you wish to be the departing Room:");
|
||||
player.Send("");
|
||||
|
||||
Boolean isValidRoom = false;
|
||||
Room departingRoom = 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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public List<String> Help { get; set; }
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
player.Send(player.ActiveGame.GameTitle);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
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)
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
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.Role == SecurityRoles.Admin)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
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);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public List<String> Help { get; set; }
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace MudEngine.Commands
|
|||
{
|
||||
public String Name { get; set; }
|
||||
public Boolean Override { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
|
|
|
@ -57,6 +57,11 @@ namespace MudEngine.GameManagement
|
|||
return null;
|
||||
}
|
||||
|
||||
public static String GetCommandName(IGameCommand command)
|
||||
{
|
||||
return command.Name.Substring("Command".Length);
|
||||
}
|
||||
|
||||
public static Boolean IsValidCommand(String Name)
|
||||
{
|
||||
if (CommandCollection.ContainsKey(Name.ToLower()))
|
||||
|
|
|
@ -142,11 +142,11 @@ namespace MudEngine.GameManagement
|
|||
|
||||
DayTransitions = TimeOfDayOptions.Transition;
|
||||
|
||||
SecondsPerMinute = 5;
|
||||
MinutesPerHour = 5;
|
||||
HoursPerDay = 5;
|
||||
DaysPerMonth = 31;
|
||||
MonthsPerYear = 12;
|
||||
SecondsPerMinute = 1;
|
||||
MinutesPerHour = 1;
|
||||
HoursPerDay = 1;
|
||||
DaysPerMonth = 3;
|
||||
MonthsPerYear = 3;
|
||||
|
||||
CurrentWorldTime = InitialGameTime;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ namespace MudEngine.GameManagement
|
|||
CurrentSystemTime = DateTime.Now;
|
||||
Int32 amount = Math.Abs(ts.Seconds);
|
||||
IncrementSecond(amount);
|
||||
Log.Write(GetCurrentWorldTime());
|
||||
//Log.Write(GetCurrentWorldTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,5 +311,51 @@ namespace MudEngine.GameManagement
|
|||
|
||||
return day + ", " + month + " " + CurrentWorldTime.Day + ", " + CurrentWorldTime.Year + ": " + CurrentWorldTime.Hour + ":" + CurrentWorldTime.Minute + ":" + CurrentWorldTime.Second;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentSecond()
|
||||
{
|
||||
return CurrentWorldTime.Second;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentMinute()
|
||||
{
|
||||
return CurrentWorldTime.Minute;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentHour()
|
||||
{
|
||||
return CurrentWorldTime.Hour;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentDayNumber()
|
||||
{
|
||||
return CurrentWorldTime.Day;
|
||||
}
|
||||
|
||||
public String GetCurrentDayName()
|
||||
{
|
||||
if (DayNames.Count > CurrentWorldTime.Day)
|
||||
return "No Day Name available for the current Date.";
|
||||
else
|
||||
return DayNames[CurrentWorldTime.Day - 1];//Days start at 1, array index starts at 0
|
||||
}
|
||||
|
||||
public Int32 GetCurrentMonthNumber()
|
||||
{
|
||||
return CurrentWorldTime.Month;
|
||||
}
|
||||
|
||||
public String GetCurrentMonthName()
|
||||
{
|
||||
if (MonthNames.Count > CurrentWorldTime.Month)
|
||||
return "No Month Name available for the current Date.";
|
||||
else
|
||||
return MonthNames[CurrentWorldTime.Month - 1]; //Day starts at 1, array index starts at 0.
|
||||
}
|
||||
|
||||
public Int32 GetCurrentYear()
|
||||
{
|
||||
return CurrentWorldTime.Year;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ namespace MudEngine.GameManagement
|
|||
String Name { get; set; }
|
||||
//Used to override commands with the same name
|
||||
Boolean Override { get; set; }
|
||||
|
||||
//Used when the player enters the help command
|
||||
List<String> Help { get; set; }
|
||||
|
||||
//Executes the command.
|
||||
void Execute(String command, BaseCharacter player);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace MudEngine.GameManagement
|
|||
|
||||
//Add to the cache so consoles can get these messages if they want to.
|
||||
//If Pushmessage=true then we skip caching and dump it straight to the console
|
||||
//TODO: Allow for enabling critical error messages being forced into the console, regardless if !IsMultiplayer
|
||||
if ((pushMessage) && (!IsVerbose))
|
||||
Console.WriteLine(message);
|
||||
else
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<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" />
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace MudEngine.Scripting
|
|||
Directory.CreateDirectory("temp");
|
||||
|
||||
//Setup the additional sourcecode that's needed in the script.
|
||||
String[] usingStatements = new String[] { "using System;", "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 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)
|
||||
{
|
||||
|
|
|
@ -45,8 +45,11 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="Scripts\CommandHelp.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandCreate.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Scripts\CommandSay.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
@ -60,6 +63,9 @@
|
|||
<None Include="Scripts\EarthGame.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Settings.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MudEngine\MudEngine.csproj">
|
||||
|
|
|
@ -130,8 +130,9 @@ namespace MudGame
|
|||
{
|
||||
Log.Write("Critical Error! " + ex.Message);
|
||||
}
|
||||
//Save the game on shut-down.
|
||||
game.Save();
|
||||
//The Game should save itself during shutdown, requiring to save it on the runtime end will
|
||||
//present possible issues with 3rd party runtimes not saving if they don't know better to do so.
|
||||
//game.Save();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ public class CommandClear : 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.FlushConsole();
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
public List<String> Help { get; set; }
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
|
@ -19,9 +28,31 @@
|
|||
player.Send("2: Zone");
|
||||
player.Send("3: Room");
|
||||
player.Send("4: Exit Tool");
|
||||
player.Send("At point during creation, you may type 'Cancel' to exit with no changes saved.");
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
Int32 selection = Convert.ToInt32(player.ReadInput());
|
||||
|
||||
Int32 selection = 0;
|
||||
String input = player.ReadInput();
|
||||
|
||||
//Allows for aborting the creation tool if the user wants too.
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
selection = Convert.ToInt32(input);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.Write("Invalid selection!");
|
||||
player.Send("Invalid selection!");
|
||||
player.Send("Creation aborted.");
|
||||
return;
|
||||
}
|
||||
//Fire off what ever Method we need to, according to the users input.
|
||||
switch (selection)
|
||||
{
|
||||
|
@ -31,6 +62,11 @@
|
|||
case 2:
|
||||
CreateZone(player);
|
||||
break;
|
||||
case 3:
|
||||
CreateRoom(player);
|
||||
break;
|
||||
case 4:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +84,13 @@
|
|||
player.Send("Realm Name: ", false);
|
||||
realm.Name = player.ReadInput();
|
||||
|
||||
//Check for canceling
|
||||
if (realm.Name.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if a Realm with this name already exists.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
{
|
||||
|
@ -79,8 +122,17 @@
|
|||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
input = player.ReadInput();
|
||||
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Zone creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Ensure it's a valid name, if not then loop back and try again.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
{
|
||||
|
@ -101,9 +153,10 @@
|
|||
}
|
||||
|
||||
Zone zone = new Zone(player.ActiveGame);
|
||||
realm.AddZone(zone);
|
||||
//realm.AddZone(zone);
|
||||
|
||||
Boolean isValidZone = false;
|
||||
player.Send(""); //blank line
|
||||
|
||||
while (!isValidZone)
|
||||
{
|
||||
|
@ -131,5 +184,131 @@
|
|||
|
||||
Log.Write(player.Name + " has created a Zone called " + zone.Name + " within the Realm " + realm.Name);
|
||||
player.Send(zone.Name + " has been created and added to Realm " + realm.Name + ".");
|
||||
realm.AddZone(zone);
|
||||
}
|
||||
|
||||
public void CreateRoom(BaseCharacter player)
|
||||
{
|
||||
player.Send("Select which Realm this Zone will belong to.");
|
||||
Boolean isValidRealm = false;
|
||||
String input = "";
|
||||
Realm realm = new Realm(player.ActiveGame);
|
||||
|
||||
while (!isValidRealm)
|
||||
{
|
||||
isValidRealm = true;//Default to true, assume the user entered a valid name.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
{
|
||||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
input = player.ReadInput();
|
||||
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Zone creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Ensure it's a valid name, if not then loop back and try again.
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
{
|
||||
if (r.Filename.ToLower() == input.ToLower())
|
||||
{
|
||||
isValidRealm = true;
|
||||
realm = r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValidRealm = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidRealm)
|
||||
player.Send("That Realm does not exist! Please try again.");
|
||||
}
|
||||
|
||||
Zone zone = new Zone(player.ActiveGame);
|
||||
//realm.AddZone(zone);
|
||||
|
||||
Boolean isValidZone = false;
|
||||
player.Send(""); //blank line
|
||||
|
||||
while (!isValidZone)
|
||||
{
|
||||
isValidZone = true;//Default to true, assume the user entered a valid name.
|
||||
foreach (Zone z in realm.ZoneCollection)
|
||||
{
|
||||
player.Send(z.Filename + " | ", false);
|
||||
}
|
||||
|
||||
player.Send("");
|
||||
player.Send("Selection: ", false);
|
||||
|
||||
input = player.ReadInput();
|
||||
|
||||
if (input.ToLower() == "cancel")
|
||||
{
|
||||
player.Send("Room creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Ensure it's a valid name, if not then loop back and try again.
|
||||
foreach (Zone z in realm.ZoneCollection)
|
||||
{
|
||||
if (z.Filename.ToLower() == input.ToLower())
|
||||
{
|
||||
isValidZone = true;
|
||||
zone = z;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
isValidZone = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidZone)
|
||||
player.Send("That Zone does not exist! Please try again.");
|
||||
}
|
||||
|
||||
//Create the Room.
|
||||
Room room = new Room(player.ActiveGame);
|
||||
|
||||
Boolean isValidRoom = false;
|
||||
player.Send(""); //blank line
|
||||
|
||||
while (!isValidRoom)
|
||||
{
|
||||
isValidRoom = true; //assume the user will enter a correct value.
|
||||
player.Send("Enter a name for this Room: ", false);
|
||||
String name = player.ReadInput();
|
||||
|
||||
if (String.IsNullOrEmpty(name))
|
||||
continue;
|
||||
|
||||
foreach (Room r in zone.RoomCollection)
|
||||
{
|
||||
if (r.Name == name)
|
||||
{
|
||||
isValidRoom = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValidRoom)
|
||||
{
|
||||
room.Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Log.Write(player.Name + " has created a Room called " + zone.Name + " within the Zone " + realm.Name + "->" + zone.Name);
|
||||
player.Send(room.Name + " has been created and added to " + realm.Name + "->" + zone.Name + ".");
|
||||
zone.AddRoom(room);
|
||||
}
|
||||
}
|
35
MudGame/Scripts/CommandHelp.cs
Normal file
35
MudGame/Scripts/CommandHelp.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
public class CommandHelp : 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 topic = command.Substring("Help".Length);
|
||||
|
||||
//TODO: Help command should display a complete list of available commands and should have self contained help topics.
|
||||
if (topic.Length == 0)
|
||||
{
|
||||
player.Send("Available commands: ", false);
|
||||
foreach (String cmd in CommandEngine.GetCommands())
|
||||
{
|
||||
IGameCommand g = CommandEngine.GetCommand(cmd);
|
||||
player.Send(CommandEngine.GetCommandName(g) + ", ", false);
|
||||
}
|
||||
player.Send("");
|
||||
player.Send("Usage: Help 'Command'");
|
||||
return;
|
||||
}
|
||||
else
|
||||
topic = topic.Trim();
|
||||
|
||||
IGameCommand gc = CommandEngine.GetCommand("Command" + topic);
|
||||
|
||||
foreach (String help in gc.Help)
|
||||
{
|
||||
player.Send(help);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ public class CommandSay : IGameCommand
|
|||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public List<String> Help { get; set; }
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if (command.Length <= 4) //user only sent 'Say' or 'Say '
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue