MudGame:
- Display Game Information at game startup now. - Checks to make sure the returned Object from Player.ExecuteCommand() is not null before attempting to iterate through the array. The Exit command no loner causes an error due to this fix.
This commit is contained in:
parent
da42864a85
commit
19e3ec0936
1 changed files with 16 additions and 6 deletions
|
@ -60,6 +60,13 @@ namespace MUDGame
|
|||
game.IsRunning = true;
|
||||
|
||||
game.PlayerCollection.Add(player);
|
||||
|
||||
//Send game info to player
|
||||
Console.WriteLine(game.GameTitle);
|
||||
Console.WriteLine(game.Version);
|
||||
Console.WriteLine(game.Website);
|
||||
Console.WriteLine(game.Story);
|
||||
Console.WriteLine();
|
||||
|
||||
while (game.IsRunning)
|
||||
{
|
||||
|
@ -68,13 +75,16 @@ namespace MUDGame
|
|||
|
||||
//TODO: Does the CommandResult really need to return an array of Objects?
|
||||
//All object management should be dealt with by the Game and Player so this should just be an array of strings.
|
||||
object[] result = player.ExecuteCommand(command).Result;
|
||||
|
||||
//Search through each object in the array returned to us from the command execution and print the strings.
|
||||
foreach (object o in result)
|
||||
Object[] result = player.ExecuteCommand(command).Result;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (o is string)
|
||||
Console.WriteLine(o.ToString());
|
||||
//Search through each object in the array returned to us from the command execution and print the strings.
|
||||
foreach (object o in result)
|
||||
{
|
||||
if (o is string)
|
||||
Console.WriteLine(o.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue