muddesigner/MudEngine/Commands/CommandLogin.cs
Scionwest_cp 29cdae3b1a MudEngine:
- Corrected CommandLogin to support the Player.Send/Receive methods.
 - Re-organized the Game class source code and added additional commenting.
 - Began adding code to remove un-wanted characters in the received byte stream in Player.Receive()
2010-08-01 17:34:59 -07:00

57 lines
1.6 KiB
C#

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.Send(player.ActiveGame.GameTitle);
player.Send(player.ActiveGame.Version);
player.Send(player.ActiveGame.Story);
player.Send("");
bool isLegal = false;
while (!isLegal)
{
player.Send("Enter Character Name: ", false);
string input = player.ReadInput();
bool foundName = false;
foreach (BaseCharacter bc in player.ActiveGame.PlayerCollection)
{
if (bc.Name == input)
{
player.Send("Character name already taken.");
foundName = true;
break;
}
}
if (!foundName)
{
isLegal = true;
player.Name = input;
}
}
player.Send("Welcome " + player.Name + "!");
//string playerName = player.Receive();
//TODO: Read user input...
return new CommandResults();
}
}
}