MudEngine:
- Sending messages to the client from the server is now an added feature. Use Game.SendMessage() - Added Load and Save commands for players. - Added Missing SaveDataPaths struct file.
This commit is contained in:
parent
4be5a831b1
commit
607bd673a5
7 changed files with 122 additions and 1 deletions
29
MudEngine/Commands/CommandLoad.cs
Normal file
29
MudEngine/Commands/CommandLoad.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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 bool Override { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public CommandResults Execute(string command, BaseCharacter player)
|
||||||
|
{
|
||||||
|
string path = player.ActiveGame.DataPaths.Players;
|
||||||
|
string filename = Path.Combine(path, player.Filename);
|
||||||
|
|
||||||
|
player.Load(filename);
|
||||||
|
|
||||||
|
return new CommandResults();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
MudEngine/Commands/CommandLogin.cs
Normal file
31
MudEngine/Commands/CommandLogin.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using MudEngine.GameObjects.Characters;
|
||||||
|
using MudEngine.GameManagement;
|
||||||
|
using MudEngine.Commands;
|
||||||
|
using MudEngine.GameObjects.Environment;
|
||||||
|
|
||||||
|
namespace MudEngine.Commands
|
||||||
|
{
|
||||||
|
public class CommandLogin : IGameCommand
|
||||||
|
{
|
||||||
|
public bool Override { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public CommandResults Execute(string command, BaseCharacter player)
|
||||||
|
{
|
||||||
|
player.ActiveGame.SendMessage(player.ActiveGame.GameTitle, player);
|
||||||
|
player.ActiveGame.SendMessage(player.ActiveGame.Version, player);
|
||||||
|
player.ActiveGame.SendMessage(player.ActiveGame.Story, player);
|
||||||
|
player.ActiveGame.SendMessage("", player);
|
||||||
|
player.ActiveGame.SendMessage("Enter Character Name: ", player, false);
|
||||||
|
|
||||||
|
//TODO: Read user input...
|
||||||
|
|
||||||
|
return new CommandResults();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
MudEngine/Commands/CommandSave.cs
Normal file
29
MudEngine/Commands/CommandSave.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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 bool Override { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public CommandResults Execute(string command, BaseCharacter player)
|
||||||
|
{
|
||||||
|
string path = player.ActiveGame.DataPaths.Players;
|
||||||
|
string filename = Path.Combine(path, player.Filename);
|
||||||
|
|
||||||
|
player.Save(filename);
|
||||||
|
|
||||||
|
return new CommandResults();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
MudEngine/FileSystem/SaveDataPaths.cs
Normal file
13
MudEngine/FileSystem/SaveDataPaths.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MudEngine.FileSystem
|
||||||
|
{
|
||||||
|
public struct SaveDataPaths
|
||||||
|
{
|
||||||
|
public string Players { get; set; }
|
||||||
|
public string Environment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -197,6 +197,8 @@ namespace MudEngine.GameManagement
|
||||||
BaseCurrencyAmount = 1;
|
BaseCurrencyAmount = 1;
|
||||||
BaseCurrencyName = "Copper";
|
BaseCurrencyName = "Copper";
|
||||||
IsMultiplayer = true; //default.
|
IsMultiplayer = true; //default.
|
||||||
|
Version = "1.0";
|
||||||
|
Story = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -341,5 +343,19 @@ namespace MudEngine.GameManagement
|
||||||
Server.Initialize(ServerPort, ref PlayerCollection);
|
Server.Initialize(ServerPort, ref PlayerCollection);
|
||||||
Server.Start();
|
Server.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendMessage(string message, BaseCharacter player)
|
||||||
|
{
|
||||||
|
SendMessage(message, player, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendMessage(string message, BaseCharacter player, bool newLine)
|
||||||
|
{
|
||||||
|
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
||||||
|
|
||||||
|
if (newLine)
|
||||||
|
message += "\n\r";
|
||||||
|
player.Send(encoding.GetBytes(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,8 +140,10 @@ namespace MudEngine.GameObjects.Characters
|
||||||
|
|
||||||
internal void Initialize()
|
internal void Initialize()
|
||||||
{
|
{
|
||||||
CurrentRoom = ActiveGame.InitialRealm.InitialZone.InitialRoom;
|
string result = ExecuteCommand("Login");
|
||||||
|
|
||||||
|
|
||||||
|
CurrentRoom = ActiveGame.InitialRealm.InitialZone.InitialRoom;
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
}
|
}
|
||||||
internal void Receive(byte[] data)
|
internal void Receive(byte[] data)
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<Compile Include="Commands\CommandSave.cs" />
|
<Compile Include="Commands\CommandSave.cs" />
|
||||||
<Compile Include="Commands\CommandWalk.cs" />
|
<Compile Include="Commands\CommandWalk.cs" />
|
||||||
<Compile Include="Commands\CommandLoad.cs" />
|
<Compile Include="Commands\CommandLoad.cs" />
|
||||||
|
<Compile Include="Commands\CommandLogin.cs" />
|
||||||
<Compile Include="FileSystem\SaveDataPaths.cs" />
|
<Compile Include="FileSystem\SaveDataPaths.cs" />
|
||||||
<Compile Include="GameManagement\CommandEngine.cs" />
|
<Compile Include="GameManagement\CommandEngine.cs" />
|
||||||
<Compile Include="GameManagement\CommandResults.cs" />
|
<Compile Include="GameManagement\CommandResults.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue