/// <summary> /// Constructs a random enemy based on the given difficulty level /// </summary> /// <param name="difficulty">The current game difficulty</param> /// <returns>A random enemy</returns> public static Enemy RandomEnemy(int difficulty) { Enemy enemy = null; int encounterValue = Utils.Random.Next(difficulty); foreach (DataRow row in EnemyDao.GetTable().Rows) { if (encounterValue <= (int)row[nameof(Difficulty)]) { enemy = new Enemy((EnemyType)Enum.Parse(typeof(EnemyType), row[nameof(EnemyType)].ToString())); break; } } if (enemy == null) { if (Game.MinotaurIsAlive) { enemy = new Enemy(EnemyType.Minotaur); } else { enemy = new Enemy(EnemyType.Dragon); } } return(enemy); }
/// <summary> /// Constructs an <see cref="Enemy"/> of the given type /// </summary> /// <param name="type">The type of <see cref="Enemy"/> to construct</param> public Enemy(EnemyType type) { EnemyDataEntry enemyData = EnemyDao.GetData()[type]; EnemyType = type; Description = enemyData.Description; Power = enemyData.Power; Defense = 0; MaxHP = enemyData.MaxHP; CurrentHP = MaxHP; XP = enemyData.XP; Difficulty = enemyData.Difficulty; if (Utils.Roll(CHANCE_FOR_LOOT)) { Item loot = Item.RandomItem(Items); Items.Add(loot); } }