public void KilledEnemyGivesFoodOfAllKinds() { var env = CreateTestEnv(numEnemies: 100); env.LootGenerator.Probability = new Roguelike.Probability.Looting(); env.LootGenerator.Probability.SetLootingChance(LootSourceKind.Enemy, LootKind.Food, 1); var enemies = env.Enemies; Assert.AreEqual(enemies.Count, 100); var li = new LootInfo(game, null); env.KillAllEnemies(); var lootItems = li.GetDiff(); Assert.Greater(lootItems.Count, 0); var foods = li.Get <Food>().ToList(); Assert.Greater(foods.Count, 40); var kinds = Enum.GetValues(typeof(FoodKind)).Cast <FoodKind>().Where(i => i != FoodKind.Unset).ToList(); foreach (var kind in kinds) { Assert.IsTrue(foods.Any(i => i.Kind == kind)); } }
public void LotsOfPotionsTest() { var des = EquipmentKind.Weapon.ToDescription(); var env = CreateTestEnv(); //GenerationInfo.DebugInfo.EachEnemyGivesPotion = true; try { var lootInfo = new LootInfo(game, null); ILootSource lootSrc = ActivePlainEnemies.First();//env.Game.Hero for (int i = 0; i < 10; i++) { var pot = env.LootGenerator.GetRandomLoot(LootKind.Potion, 1); var added = game.GameManager.AddLootReward(pot, lootSrc, false); Assert.True(added); var dist = pot.DistanceFrom(lootSrc.GetPoint()); Assert.Less(dist, 5); Assert.True(dist < 4 || i > 5); } var newLootItems = lootInfo.GetDiff(); Assert.AreEqual(newLootItems.Count, 10); } catch (System.Exception) { //GenerationInfo.DebugInfo.EachEnemyGivesPotion = false; } }
public void KilledEnemyGivesPotionFromTimeToTime() { for (int i = 0; i < loopCount; i++) { var env = CreateTestEnv(numEnemies: 100); var li = new LootInfo(game, null); env.KillAllEnemies(); var lootItems = li.GetDiff(); Assert.Greater(lootItems.Count, 10); var potions = li.Get <Potion>(); Assert.Greater(potions.Count, 2); Assert.Less(potions.Count, 10); } }
private LootInfo KillEnemies(int enemiesCount) { var env = CreateTestEnv(numEnemies: enemiesCount); var enemies = env.Enemies; Assert.AreEqual(enemies.Count, enemiesCount); var li = new LootInfo(game, null); env.KillAllEnemies(); var lootItems = li.GetDiff(); Assert.Greater(lootItems.Count, 0); return(li); }
public void LotsOfEqTest() { var env = CreateTestEnv(); var lootInfo = new LootInfo(game, null); for (int i = 0; i < 10; i++) { var pot = env.LootGenerator.GetRandomLoot(LootKind.Equipment, 1); var closeEmp = env.Game.Level.GetClosestEmpty(env.Game.Hero, true, true); var set = env.Game.Level.SetTile(pot, closeEmp.point); Assert.True(set); } var newLootItems = lootInfo.GetDiff(); Assert.AreEqual(newLootItems.Count, 10); }
///////////////////////////////////////////////////////// public void KilledEnemyLevelAffectsEnchanter(LootKind kind, int enemyLevel, EnchanterSize[] expectedSizes) { var env = CreateTestEnv(true, 10, 2); env.LootGenerator.Probability = new Roguelike.Probability.Looting(); env.LootGenerator.Probability.SetLootingChance(LootSourceKind.Enemy, kind, 1); var enemies = AllEnemies; Assert.GreaterOrEqual(enemies.Count, 5); enemies.ForEach(i => { SetEnemyLevel(i, enemyLevel); }); var li = new LootInfo(game, null); env.KillAllEnemies(); var res = new List <LootKind>(); var lootItems = li.GetDiff(); int expectedKindsCounter = 0; { foreach (var loot in lootItems) { var expected = kind == loot.LootKind; if (expected) { var ench = loot as Enchanter; Assert.True(expectedSizes.Contains(ench.EnchanterSize)); expectedKindsCounter++; } res.Add(loot.LootKind); } } Assert.Greater(expectedKindsCounter, 0); }
public void KilledEnemyAtSamePlace() { var env = CreateTestEnv(true, 20); env.LootGenerator.Probability = new Roguelike.Probability.Looting(); env.LootGenerator.Probability.SetLootingChance(LootSourceKind.Enemy, LootKind.Equipment, 1f); var enemies = game.GameManager.EnemiesManager.GetEnemies().Where(i => i.PowerKind == EnemyPowerKind.Plain).ToList(); var en = enemies[0]; env.KillEnemy(en); var loot = env.Game.Level.GetTile(en.point);//loot shall be at enemy point Assert.NotNull(loot as Loot); var en1 = enemies[1]; Assert.True(env.Game.Level.SetTile(en1, en.point)); Debug.WriteLine("Killing en1..."); var li = new LootInfo(game, null); var prevCountLevel = env.Game.Level.Loot.Count; var prevCount = li.Prev.Count; var prevCopy = li.Prev.ToList(); env.KillEnemy(en1); var lootItems = li.GetDiff(); if (lootItems.Count == 0) { int k = 0; k++; } Assert.GreaterOrEqual(lootItems.Count, 1); Assert.True(lootItems[0].DistanceFrom(loot) < 2); }