public NegativeArgumentException(IConsoleLogger logger) : base() { logger.Write(GlobalMessages.PositiveMessage); }
public async Task Handle(EventAB @event) { log.Write($"Handle message, Type: {this.GetType().FullName} - Message: {@event.ValueAB}"); await Task.FromResult(0); }
public void PrintMageFightMesssage(IHero hero, IEnemy enemy, IConsoleLogger logger) { var message = "You engage a " + enemy.GetType().Name + "!!!"; while (hero.Hp > 0 && enemy.Hp > 0) { logger.Clear(); logger.Write(message); logger.Write("Hero Hp:" + hero.Hp + ", " + "Hero Mana:" + hero.SpecialEnergy); logger.Write("Enemy Hp:" + enemy.Hp + ", " + "Enemy Energy:" + enemy.Energy); logger.Write("Enter 1 for hit with " + hero.Weapon.GetType().Name); logger.Write("Enter 2 to Run for your Life"); logger.Write("Enter 3 for CastSpell"); logger.Write("Enter 4 to Stab with your " + hero.WeaponSecond.GetType().Name); var a = logger.Read(); switch (a) { case "1": enemy.Hp -= hero.Weapon.Dmg; logger.Write($"The monster loses {hero.Weapon.Dmg} HP!"); break; case "2": hero.Hp -= 5; logger.Write($"It is too late to run!"); break; case "3": if (hero.SpecialEnergy < 35) { logger.Write($"Not enough mana for CastSpell!"); System.Threading.Thread.Sleep(1000); break; } else { int score = hero.SpecialAttack(); enemy.Hp -= hero.Weapon.Dmg + score; logger.Write($"The monster loses {hero.Weapon.Dmg + score} HP!"); break; } case "4": enemy.Hp -= hero.WeaponSecond.Dmg; logger.Write($"The monster loses {hero.WeaponSecond.Dmg} HP!"); break; default: break; } logger.Write("WAIT FOR ENEMY TURN"); System.Threading.Thread.Sleep(1000); if (enemy.Energy < 5) { logger.Write($"You lose {enemy.Dmg} HP!"); System.Threading.Thread.Sleep(2000); hero.Hp -= enemy.Dmg; } else { int score = enemy.Roar(); logger.Write($"The Monster Roars!"); logger.Write($"You lose {enemy.Dmg + score} HP!"); System.Threading.Thread.Sleep(2000); hero.Hp -= enemy.Dmg + score; } } }
public void ReadCommands(IHero hero, IMap map, IGameFactory factory, IConsoleLogger logger, IHeroPrinter heroprint, IFightMode mode, ICollisionDetector detect, IHeroCoordinates coord) { bool happyend = false; string currentLine = ""; string message = GlobalMessages.JourneyMessage; IEnemy enemy; while (hero.Hp > 0 && !happyend) { logger.Clear(); Console.BackgroundColor = (ConsoleColor)hero.HeroColor; logger.Write(message); Console.ResetColor(); logger.Write(hero.ToString()); logger.Write(coord.ToString()); logger.Write(GlobalMessages.ChooseMessage); logger.Write(" 1 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map))); logger.Write(" 2 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map))); logger.Write(" 3 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map))); logger.Write(" 4 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map))); logger.Write(GlobalMessages.EnterMessage); currentLine = logger.Read(); switch (currentLine) { case "1": if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == 'x') { message = GlobalMessages.EscapeMessage; break; } else if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == '@') { message = GlobalMessages.ClimbRockMessage; hero.Hp -= 1; } else if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == '1') { enemy = factory.CreateMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(1); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == '2') { enemy = factory.CreateBossMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(1); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else { hero.Move(1); message = GlobalMessages.LeftMessage; } break; case "2": if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == 'x') { message = GlobalMessages.EscapeMessage; break; } else if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == '@') { message = GlobalMessages.ClimbRockMessage; hero.Hp -= 1; } else if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == '1') { enemy = factory.CreateMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(2); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == '2') { enemy = factory.CreateBossMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(2); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else { hero.Move(2); message = GlobalMessages.RightMessage; } break; case "3": if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == 'x') { message = GlobalMessages.EscapeMessage; break; } else if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == '@') { message = GlobalMessages.ClimbRockMessage; hero.Hp -= 1; } else if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == '1') { enemy = factory.CreateMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(3); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == '2') { enemy = factory.CreateBossMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(3); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else { hero.Move(3); message = GlobalMessages.UpMessage; } break; case "4": if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == 'x') { message = GlobalMessages.EscapeMessage; happyend = true; break; } else if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == '@') { message = GlobalMessages.ClimbRockMessage; hero.Hp -= 1; } else if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == '1') { enemy = factory.CreateMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(4); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == '2') { enemy = factory.CreateBossMonster(); mode.Fight(hero, enemy, logger, heroprint); message = GlobalMessages.DeadMonsterMessage; hero.Move(4); map.FirstMap[hero.PositionX, hero.PositionY] = '-'; } else { hero.Move(4); message = GlobalMessages.DownMessage; } break; default: message = GlobalMessages.WrongInputMessage; break; } } logger.Clear(); if (happyend) { logger.Write(GlobalMessages.EscapeMessage); System.Threading.Thread.Sleep(1000); logger.Write(GlobalMessages.EscapeMessageFun); } else { logger.Write(GlobalMessages.DeadGameMessage); System.Threading.Thread.Sleep(1000); logger.Write(GlobalMessages.DeadGameMessageFun); } logger.Write(GlobalMessages.GameOverMessage); }
public void PrintHunterFightMesssage(IHero hero, IEnemy enemy, IConsoleLogger logger) { var message = "You engage a " + enemy.GetType().Name + "!!!"; var ammo = 5; while (hero.Hp > 0 && enemy.Hp > 0) { logger.Clear(); logger.Write(message); logger.Write("Hero Hp:" + hero.Hp + ", " + "Hero Energy:" + hero.SpecialEnergy + ", " + "Bow Ammo:" + ammo); logger.Write("Enemy Hp:" + enemy.Hp + ", " + "Enemy Energy:" + enemy.Energy); logger.Write("Enter 1 to Shoot with your " + hero.Weapon.GetType().Name); logger.Write("Enter 2 to Run for your Life"); logger.Write("Enter 3 for FocusShot"); logger.Write("Enter 4 to Stab with your " + hero.WeaponSecond.GetType().Name); var a = logger.Read(); switch (a) { case "1": if (ammo == 0) { logger.Write($"No more ammo, try something else!"); break; } else { enemy.Hp -= hero.Weapon.Dmg; if (ammo > 0) { ammo -= 1; } logger.Write($"The monster loses {hero.Weapon.Dmg} HP!"); break; } case "2": hero.Hp -= 5; logger.Write($"It is too late to run!"); break; case "3": if (hero.SpecialEnergy < 44) { logger.Write($"Not enough energy for FocusShot!"); System.Threading.Thread.Sleep(1000); break; } else { int score = hero.SpecialAttack(); enemy.Hp -= hero.Weapon.Dmg + score; logger.Write($"The monster loses {hero.Weapon.Dmg + score} HP!"); break; } case "4": enemy.Hp -= hero.WeaponSecond.Dmg; logger.Write($"The monster loses {hero.WeaponSecond.Dmg} HP!"); break; default: break; } logger.Write("WAIT FOR ENEMY TURN"); System.Threading.Thread.Sleep(1000); if (enemy.Energy < 5) { logger.Write($"You lose {enemy.Dmg} HP!"); System.Threading.Thread.Sleep(2000); hero.Hp -= enemy.Dmg; } else { int score = enemy.Roar(); logger.Write($"The Monster Roars!"); logger.Write($"You lose {enemy.Dmg + score} HP!"); System.Threading.Thread.Sleep(2000); hero.Hp -= enemy.Dmg + score; } } }