private void equipItem(Equipment item) { Console.WriteLine(); Equipment oldItem = eb.GetEquipedByIdAndType(Id, item.Type); if (oldItem != null) { oldItem.Is_equiped = false; eb.Update(oldItem); } item.Is_equiped = true; eb.Update(item); if (item.Type == "Weapon") { this.Weapon = item.Id; } else if (item.Type == "Armor") { this.Armor = item.Id; } hb.Update(this); }
private static Enemy heroAttack(Enemy enemy, Hero hero, Random rand) { int heroAttackChance = rand.Next(0, hero.Accuracy * 2); int enemyDodgeChance = rand.Next(0, (int)Math.Ceiling((double)enemy.Dexterity / 2)); if (heroAttackChance > enemyDodgeChance) { EquipmentBusiness eq = new EquipmentBusiness(); int heroAttackPoints = hero.Strength; if (eq.GetEquipedByIdAndType(hero.Id, "Weapon") != null) { heroAttackPoints += (int)eq.GetEquipedByIdAndType(hero.Id, "Weapon").Points; } enemy.CurrentHealthPoints -= heroAttackPoints; Console.WriteLine(hero.Name.Trim() + " deals " + heroAttackPoints + " damage to " + enemy.Name.Trim() + "!"); } else { Console.WriteLine(hero.Name.Trim() + " misses!"); } return(enemy); }