public IMessageService SelectMessageService(string serviceType) { IMessageService service; switch (serviceType) { case "ConsoleMessageService": service = new ConsoleMessageService(); break; case "InMemoryMessageService": service = new InMemoryMessageService(); break; case "MobileMessageService": service = new MobileMessageService(); break; default: service = new InMemoryMessageService(); break; } return(service); }
public void ShowEnemies() { var i = 1; foreach (var enemy in Enemies) { mMessageService.ShowMessage(new Message(i + ")" + enemy.Name, ConsoleColor.Yellow)); mMessageService.ShowMessage(new Message(enemy.AsciiArt, ConsoleColor.Cyan)); ConsoleMessageService.ShowConsoleBoxedInfo(enemy.Stats.ToDictionary(x => x.Key, x => x.Value.ToString())); i++; } }
public void ConsoleMessageServiceShouldReturnHelloWorld() { // Arrange var sut = new ConsoleMessageService(); string expected = "Hello World"; // Act var actual = sut.GetMessage(); // Assert Assert.That(expected, Is.EqualTo(actual)); }
static void Main(string[] args) { Console.WriteLine(" *******Welcom to GuessNumberGame!*******\n"); var playerRepository = new PlayerRepository(); var messageService = new ConsoleMessageService(); var service = new GameServices(playerRepository, messageService); service.Play(); Console.ReadLine(); }
public void ShowPlayerDeathScreen(Player player, Enemy killerEnemy) { mMessageService.ClearTextField(); mMessageService.ShowMessage(new Message("В следующий раз вам повезет больше!", ConsoleColor.Cyan)); Thread.Sleep(2000); mMessageService.ShowMessage(new Message($"Вы дошли до {player.CurrentLevel.Number} уровня!", ConsoleColor.Cyan)); Thread.Sleep(2000); mMessageService.ShowMessage(new Message($"Вы набрали {player.Points} очков!", ConsoleColor.Yellow)); Thread.Sleep(2000); mMessageService.ShowMessage(new Message($"Вы погибли от:", ConsoleColor.Cyan)); mMessageService.ShowMessage(new Message(killerEnemy.Name, ConsoleColor.Red)); ConsoleMessageService.ShowConsoleBoxedInfo(killerEnemy.BaseStats.ToDictionary(x => x.Key, x => x.Value.ToString())); Thread.Sleep(1000); Interface.ShowConsolePlayerUi(player, new InterfaceBuilder().AddPart(InterfacePartType.Name) .AddPart(InterfacePartType.Gold) .AddPart(InterfacePartType.Inventory) .AddPart(InterfacePartType.Talents) .BuildInterface()); }
public static void ShowConsoleItemInfo(Item item, bool abilityOnly = false) { if (!abilityOnly) { Program.MessageService.ShowMessage(new Message($"Тип:{Game.EnumToString(item.Type)}", ConsoleColor.DarkCyan)); var isWeapon = item.Type < (ItemType)2; if (isWeapon) { ShowWeaponType((Weapon)item); } Program.MessageService.ShowMessage(new Message($"Характеристики:", ConsoleColor.Cyan)); ConsoleMessageService.ShowConsoleBoxedInfo(item.Stats.ToDictionary(x => x.Key, x => x.Value.ToString())); } if (item.ItemAbility != null) { Program.MessageService.ShowMessage(new Message($"Способность({(item.ItemAbility.IsActiveType ? "Активная" : "Пассивная")}):", ConsoleColor.DarkCyan)); if (item.ItemAbility.IsActiveType) { var activeAbility = item.ItemAbility as ActiveAbility; Program.MessageService.ShowMessage(new Message("Ходы:", ConsoleColor.DarkCyan)); ConsoleMessageService.ShowConsoleBoxedInfo(new Dictionary <string, string>() { { "Дейсвует", $"{activeAbility.TurnDuration.ToString()}({activeAbility.CurrentDuration})" }, { "Перезарядка", $"{activeAbility.Cooldown.ToString()}({activeAbility.CurrentCooldown})" } }); } ConsoleMessageService.ShowConsoleBoxedInfo(new Dictionary <string, string>() { { item.ItemAbility.Name, item.ItemAbility.Description } }); ConsoleMessageService.ShowConsoleBoxedInfo(item.ItemAbility.ValueIncreases.ToDictionary(x => x.Key, x => x.Value.ToString())); if (item.ItemAbility.PercentIncreases.Count > 0) { Program.MessageService.ShowMessage(new Message("Усиления в процентах:", ConsoleColor.DarkCyan)); ConsoleMessageService.ShowConsoleBoxedInfo(item.ItemAbility.PercentIncreases.ToDictionary(x => x.Key, x => (x.Value * 100).ToString())); } } }
public static void ShowStats(Dictionary <string, int> stats) { Program.MessageService.ShowMessage(new Message($"Характеристики:", ConsoleColor.Blue)); ConsoleMessageService.ShowConsoleBoxedInfo(stats.ToDictionary(x => x.Key, x => x.Value.ToString())); }
private static void ShowTalents(IEnumerable <Ability> abilities) { Program.MessageService.ShowMessage(new Message($"Таланты:", ConsoleColor.Blue)); ConsoleMessageService.ShowConsoleBoxedInfo(abilities.ToDictionary(x => x.Name, x => x.Description)); }