public Hero useBed(Hero hero) { HeroBusiness hb = new HeroBusiness(); Console.WriteLine("You are in an inn"); Console.WriteLine($"You are currently at {hero.CurrentHealthPoints} out of {hero.HealthPoints}"); Console.WriteLine("Do you wish to sleep and regenerate your Health Points for 5 gold? (Y) or (N)"); String command = Console.ReadLine().ToLower(); if (command == "y" && hero.Money >= 5 && hero.CurrentHealthPoints == hero.HealthPoints) { Console.WriteLine("You don't need to sleep yet!"); } else if (command == "y" && hero.Money >= 5 && hero.CurrentHealthPoints != hero.HealthPoints) { hero.CurrentHealthPoints = hero.HealthPoints; hero.Money -= 5; Console.WriteLine("You now have " + hero.HealthPoints + " health points"); hb.Update(hero); } else if (command == "y" && hero.Money < 5) { Console.WriteLine("You don't have enough money for this action"); } return(hero); }
public static Hero enemyAttack(Hero hero, Enemy enemy, Random rand) { int enemyAttackChance = rand.Next(0, enemy.Accuracy * 2); int heroDodgeChance = rand.Next(0, (int)Math.Round((double)hero.Dexterity / 2)); if (enemyAttackChance > heroDodgeChance) { EquipmentBusiness eq = new EquipmentBusiness(); HeroBusiness hb = new HeroBusiness(); int heroDefencePoints = 0; if (eq.GetEquipedByIdAndType(hero.Id, "Armor") != null) { heroDefencePoints = (int)eq.GetEquipedByIdAndType(hero.Id, "Armor").Points; } if (enemy.Strength * 2 - heroDefencePoints > 0) { hero.CurrentHealthPoints -= enemy.Strength * 2 - heroDefencePoints; Console.WriteLine(enemy.Name.Trim() + " deals " + (enemy.Strength * 2 - heroDefencePoints) + " damage to " + hero.Name.Trim() + "!"); hb.Update(hero); } else { Console.WriteLine(enemy.Name.Trim() + " can't penetrade " + hero.Name.Trim() + "'s armor!"); } } else { Console.WriteLine(enemy.Name.Trim() + " misses!"); } return(hero); }
public static Hero startFight(Hero hero, Enemy enemy) { HeroBusiness hb = new HeroBusiness(); Console.WriteLine("you fight!"); Random rand = new Random(); while (hero.CurrentHealthPoints >= 0 && enemy.CurrentHealthPoints >= 0) { enemy = heroAttack(enemy, hero, rand); if (enemy.CurrentHealthPoints <= 0) { hero = hero.enemyDied(enemy, hero); break; } hero = enemyAttack(hero, enemy, rand); if (hero.CurrentHealthPoints <= 0) { hero = hero.heroDied(hero); break; } hb.Update(hero); } return(hero); }
public int CharacterSelectMenu() { HeroBusiness heroBusiness = new HeroBusiness(); EquipmentBusiness equipmentBusiness = new EquipmentBusiness(); List <HeroModel> heros = heroBusiness.GetAll(); int i = 1; foreach (HeroModel hero in heros) { Console.WriteLine($"{i}: {hero.Name} / {hero.Char_level} level"); i++; } Console.WriteLine("Please enter hero number to continue or (D)elete to delete hero"); string command = Console.ReadLine(); if (command == "d") { while (command == "d") { Console.WriteLine("Which hero do you wish to delete? Input number."); int deleteNumber = int.Parse(Console.ReadLine()); if (Utils.inArrayRange(heros.Count, (deleteNumber - 1))) { List <Equipment> itemsToDelete = equipmentBusiness.GetAllByOwnerId(heros[deleteNumber - 1].Id); heroBusiness.Delete(heros[deleteNumber - 1].Id); for (int j = 0; j < itemsToDelete.Count; j++) { equipmentBusiness.Delete(itemsToDelete[j].Id); } } Console.WriteLine("Please enter hero number to continue or (D)elete to delete hero"); command = Console.ReadLine().ToLower(); } } return(int.Parse(command)); }
public Forge() { eb = new EquipmentBusiness(); hb = new HeroBusiness(); }