MudEngine:
- Created PlayerAdmin class. All admins will be instances of this class; allows for segregating admin code into a different class for easier management and maintenance. - CommandRestart now checks to make sure the player is of Type PlayerAdmin instead of player.admin - Added ExecuteCommand to BaseCharacter. All Characters (NPC & Players) can execute commands now. Allows for AI to roam the world at some point in the future by invoking the available move commands. MUDGame: - Updated the command execution from CommandEngine.Execute to user.ExecuteCommand to use the BaseCharacter version. - Changed PlayerBasic to PlayerAdmin for testing purposes. TODO: Remove command execution from game loop, server should sit and wait for telnet data to be transmitted to it within the loop. That will be the command and passed off to the BaseCharacter/Player/NPC ect ExecuteCommand
This commit is contained in:
parent
1baa067044
commit
e9e3bb8033
5 changed files with 20 additions and 11 deletions
|
@ -14,7 +14,7 @@ namespace MUDGame
|
|||
//Setup our Fields
|
||||
static MudEngine.GameManagement.Game game;
|
||||
static MudEngine.GameManagement.CommandEngine commands;
|
||||
static MudEngine.GameObjects.Characters.Controlled.PlayerBasic admin = new MudEngine.GameObjects.Characters.Controlled.PlayerBasic(true);
|
||||
static MudEngine.GameObjects.Characters.Controlled.PlayerAdmin user;
|
||||
|
||||
static List<MudEngine.GameObjects.Environment.Realm> realmCollection;
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace MUDGame
|
|||
game = new MudEngine.GameManagement.Game();
|
||||
commands = new MudEngine.GameManagement.CommandEngine();
|
||||
realmCollection = new List<MudEngine.GameObjects.Environment.Realm>();
|
||||
user = new MudEngine.GameObjects.Characters.Controlled.PlayerAdmin();
|
||||
|
||||
//Setup the game
|
||||
game.AutoSave = true;
|
||||
|
@ -73,7 +74,7 @@ namespace MUDGame
|
|||
Console.Write("Command: ");
|
||||
string command = Console.ReadLine();
|
||||
|
||||
MudEngine.GameManagement.CommandEngine.ExecuteCommand(command, admin, game, null);
|
||||
user.ExecuteCommand(command, user, game, null);
|
||||
}
|
||||
|
||||
Console.WriteLine("Press Enter to exit.");
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
using System;
|
||||
//Microsoft.NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
//MUD Engine
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Characters.Controlled;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.FileSystem;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace MudEngine.Commands
|
||||
{
|
||||
|
@ -21,7 +24,7 @@ namespace MudEngine.Commands
|
|||
|
||||
public CommandResults Execute(string command, BaseCharacter player, Game project, Room room)
|
||||
{
|
||||
/*if (player.admin)
|
||||
if (player is PlayerAdmin)
|
||||
{
|
||||
for (int i = 0; i < project.player.Length; i++)
|
||||
project.player[i].Save(project.player[i].Name + ".dat");
|
||||
|
@ -31,7 +34,7 @@ namespace MudEngine.Commands
|
|||
else
|
||||
project.server.InitializeUDP(555, ref project.player);
|
||||
return new CommandResults("Server Restarted.");
|
||||
}*/
|
||||
}
|
||||
return new CommandResults("Access Denied.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,5 +26,12 @@ namespace MudEngine.GameObjects.Characters
|
|||
CurrentRoom = (Room)CurrentRoom.Load(connectedRoom);
|
||||
}
|
||||
}
|
||||
|
||||
public CommandResults ExecuteCommand(string command, BaseCharacter character, Game game, Room room)
|
||||
{
|
||||
//TODO: Character class can handle a lot of the command management here, checking various things prior to sending
|
||||
//the command off to the command engine for execution.
|
||||
return CommandEngine.ExecuteCommand(command, character, game, room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,8 @@ namespace MudEngine.GameObjects.Characters.Controlled
|
|||
{
|
||||
public class PlayerBasic : BaseCharacter
|
||||
{
|
||||
public bool admin {get; private set;}
|
||||
|
||||
public PlayerBasic(bool a = false)
|
||||
public PlayerBasic()
|
||||
{
|
||||
admin = a;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
<Compile Include="GameObjects\Bag.cs" />
|
||||
<Compile Include="GameObjects\BaseObject.cs" />
|
||||
<Compile Include="GameObjects\Characters\BaseCharacter.cs" />
|
||||
<Compile Include="GameObjects\Characters\Controlled\PlayerAdmin.cs" />
|
||||
<Compile Include="GameObjects\Characters\Controlled\PlayerBasic.cs" />
|
||||
<Compile Include="GameObjects\Environment\Door.cs" />
|
||||
<Compile Include="GameObjects\Environment\Realm.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue