Skip to content

Commit

Permalink
Remove unnecessary split of command and response in dungeon/location.
Browse files Browse the repository at this point in the history
  • Loading branch information
nightblade9 committed Dec 17, 2024
1 parent 3b31099 commit abc4be4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
6 changes: 0 additions & 6 deletions source/TextBlade.ConsoleRunner/IO/InputProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ public ICommand PromptForAction(Location currentLocation)

// It's some special command that the location handles. That doesn't change location.
var command = currentLocation.GetCommandFor(_console, rawResponse);
var response = currentLocation.GetResponseFor(rawResponse);

if (response != string.Empty)
{
_console.WriteLine(response);
}

if (!(command is DoNothingCommand))
{
return command;
Expand Down
23 changes: 2 additions & 21 deletions source/TextBlade.Core/Locations/Dungeon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ override public ICommand GetCommandFor(IConsole console, string input)
{
if (currentFloorData.Any())
{
// Monsters here
console.WriteLine("You can't descend while monsters are around!");
return new DoNothingCommand();
}
else if (_currentFloorNumber == _floorMonsters.Count - 1)
{
// Already at the bottom
console.WriteLine("You're already at the bottom of the dungeon!");
return new DoNothingCommand();
}
else
Expand All @@ -181,25 +181,6 @@ override public ICommand GetCommandFor(IConsole console, string input)
return new DoNothingCommand();
}

public string GetResponseFor(string input)
{
var currentFloorData = _floorMonsters[_currentFloorNumber];

if (input == "d" || input == "down" || input == "descend" || input == ">")
{
if (currentFloorData.Any())
{
return "You can't descend while monsters are around!";
}
else if (_currentFloorNumber == _floorMonsters.Count - 1)
{
return "You're already at the bottom of the dungeon!";
}
}

return string.Empty;
}

public bool IsCurrentFloorClear()
{
return _floorMonsters[_currentFloorNumber].Count == 0;
Expand Down
6 changes: 0 additions & 6 deletions source/TextBlade.Core/Locations/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ public Location(string name, string description, string? locationClass = null)
this.LocationClass = locationClass;
}

public virtual string GetResponseFor(string input)
{
// The sibling of GetcommandFor. Returns the message.
return string.Empty;
}

public virtual ICommand GetCommandFor(IConsole console, string input)
{
// Leave it up to sub-types, like inn, to handle their own input and return a command.
Expand Down

0 comments on commit abc4be4

Please sign in to comment.