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:
Scionwest_cp 2010-07-22 16:18:53 -07:00
parent 1baa067044
commit e9e3bb8033
5 changed files with 20 additions and 11 deletions

View file

@ -14,7 +14,7 @@ namespace MUDGame
//Setup our Fields //Setup our Fields
static MudEngine.GameManagement.Game game; static MudEngine.GameManagement.Game game;
static MudEngine.GameManagement.CommandEngine commands; 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; static List<MudEngine.GameObjects.Environment.Realm> realmCollection;
@ -24,6 +24,7 @@ namespace MUDGame
game = new MudEngine.GameManagement.Game(); game = new MudEngine.GameManagement.Game();
commands = new MudEngine.GameManagement.CommandEngine(); commands = new MudEngine.GameManagement.CommandEngine();
realmCollection = new List<MudEngine.GameObjects.Environment.Realm>(); realmCollection = new List<MudEngine.GameObjects.Environment.Realm>();
user = new MudEngine.GameObjects.Characters.Controlled.PlayerAdmin();
//Setup the game //Setup the game
game.AutoSave = true; game.AutoSave = true;
@ -73,7 +74,7 @@ namespace MUDGame
Console.Write("Command: "); Console.Write("Command: ");
string command = Console.ReadLine(); string command = Console.ReadLine();
MudEngine.GameManagement.CommandEngine.ExecuteCommand(command, admin, game, null); user.ExecuteCommand(command, user, game, null);
} }
Console.WriteLine("Press Enter to exit."); Console.WriteLine("Press Enter to exit.");

View file

@ -1,16 +1,19 @@
using System; //Microsoft.NET Framework
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Net;
using System.Net.Sockets;
//MUD Engine
using MudEngine.GameObjects.Characters; using MudEngine.GameObjects.Characters;
using MudEngine.GameObjects.Characters.Controlled;
using MudEngine.GameManagement; using MudEngine.GameManagement;
using MudEngine.GameObjects.Environment; using MudEngine.GameObjects.Environment;
using MudEngine.GameObjects; using MudEngine.GameObjects;
using MudEngine.FileSystem; using MudEngine.FileSystem;
using System.Net;
using System.Net.Sockets;
namespace MudEngine.Commands namespace MudEngine.Commands
{ {
@ -21,7 +24,7 @@ namespace MudEngine.Commands
public CommandResults Execute(string command, BaseCharacter player, Game project, Room room) 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++) for (int i = 0; i < project.player.Length; i++)
project.player[i].Save(project.player[i].Name + ".dat"); project.player[i].Save(project.player[i].Name + ".dat");
@ -31,7 +34,7 @@ namespace MudEngine.Commands
else else
project.server.InitializeUDP(555, ref project.player); project.server.InitializeUDP(555, ref project.player);
return new CommandResults("Server Restarted."); return new CommandResults("Server Restarted.");
}*/ }
return new CommandResults("Access Denied."); return new CommandResults("Access Denied.");
} }
} }

View file

@ -26,5 +26,12 @@ namespace MudEngine.GameObjects.Characters
CurrentRoom = (Room)CurrentRoom.Load(connectedRoom); 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);
}
} }
} }

View file

@ -11,11 +11,8 @@ namespace MudEngine.GameObjects.Characters.Controlled
{ {
public class PlayerBasic : BaseCharacter public class PlayerBasic : BaseCharacter
{ {
public bool admin {get; private set;} public PlayerBasic()
public PlayerBasic(bool a = false)
{ {
admin = a;
} }
} }

View file

@ -63,6 +63,7 @@
<Compile Include="GameObjects\Bag.cs" /> <Compile Include="GameObjects\Bag.cs" />
<Compile Include="GameObjects\BaseObject.cs" /> <Compile Include="GameObjects\BaseObject.cs" />
<Compile Include="GameObjects\Characters\BaseCharacter.cs" /> <Compile Include="GameObjects\Characters\BaseCharacter.cs" />
<Compile Include="GameObjects\Characters\Controlled\PlayerAdmin.cs" />
<Compile Include="GameObjects\Characters\Controlled\PlayerBasic.cs" /> <Compile Include="GameObjects\Characters\Controlled\PlayerBasic.cs" />
<Compile Include="GameObjects\Environment\Door.cs" /> <Compile Include="GameObjects\Environment\Door.cs" />
<Compile Include="GameObjects\Environment\Realm.cs" /> <Compile Include="GameObjects\Environment\Realm.cs" />