From b439f889f26cb4d2921bf1aef0e1f16929b27678 Mon Sep 17 00:00:00 2001 From: zegis Date: Sat, 18 Nov 2023 01:34:19 +0100 Subject: [PATCH] Added command to load next level on final location --- Kaeshi/Commands/AdvanceCommand.cs | 29 +++++++++++++++++++++++++++++ Kaeshi/Modules/CommandParser.cs | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 Kaeshi/Commands/AdvanceCommand.cs diff --git a/Kaeshi/Commands/AdvanceCommand.cs b/Kaeshi/Commands/AdvanceCommand.cs new file mode 100644 index 0000000..4d2f519 --- /dev/null +++ b/Kaeshi/Commands/AdvanceCommand.cs @@ -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; + } + } +} diff --git a/Kaeshi/Modules/CommandParser.cs b/Kaeshi/Modules/CommandParser.cs index 53d9aac..8c542ca 100644 --- a/Kaeshi/Modules/CommandParser.cs +++ b/Kaeshi/Modules/CommandParser.cs @@ -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(); }