Skip to content

Commit

Permalink
Added command to load next level on final location
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegis committed Nov 18, 2023
1 parent a3ee8cd commit b439f88
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Kaeshi/Commands/AdvanceCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Kaeshi.Entity;
using Kaeshi.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;

namespace Kaeshi.Commands
{
public class AdvanceCommand : ICommand
{
private readonly IMap _map;

public AdvanceCommand(IMap map) {
_map = map;
}

public GameState Execute()
{
if (!_map.GetCurrentLocation().final)
Console.WriteLine("There's no way to next floor here");
else {
Console.WriteLine("You reached next floor!");
_map.Advance();
}

return GameState.Play;
}
}
}
2 changes: 2 additions & 0 deletions Kaeshi/Modules/CommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public ICommand Parse(string rawCommand)
return new EquipCommand(entityManager.GetHero(), equippableItem);
case "unequip":
return new UnequipCommand(entityManager.GetHero(), (EquippableType)Enum.Parse(typeof(EquippableType),rawTarget,true));
case "advance":
return new AdvanceCommand(entityManager.GetMap());
case "exit": return new ExitCommand();
default: return new NotFoundCommand();
}
Expand Down

0 comments on commit b439f88

Please sign in to comment.