コード例 #1
0
        public List <Loot> AssertLootFromEnemies(LootKind[] expectedKinds, bool lootKindMustMach = true)
        {
            var res     = new List <Loot>();
            var enemies = game.GameManager.EnemiesManager.AllEntities;

            Assert.GreaterOrEqual(enemies.Count, 5);
            var li = new LootInfo(game, null);

            KillAllEnemies();

            var lootItems            = li.GetDiff();
            int expectedKindsCounter = 0;

            foreach (var loot in lootItems)
            {
                var exp = expectedKinds.Contains(loot.LootKind);
                //Assert.True(exp || loot is Equipment);//Bosses and Chemp throws Equipment -> fixed by ForEach(i => i.PowerKind = EnemyPowerKind.Plain)
                if (exp)
                {
                    expectedKindsCounter++;
                    res.Add(loot);
                }
                else if (lootKindMustMach && loot.LootKind != LootKind.Food)//enemies might thow meat
                {
                    var en = loot.Source as Enemy;
                    Assert.True(en.PowerKind != EnemyPowerKind.Plain);
                }
                Assert.True(!string.IsNullOrEmpty(loot.tag1));
            }

            Assert.Greater(expectedKindsCounter, 0);

            return(res);
        }
コード例 #2
0
        public LootInfo TestInteractive <T>(Action <Roguelike.Tiles.Interactive.InteractiveTile> init,
                                            int tilesToCreateCount   = 50,
                                            int maxExpectedLootCount = 15,
                                            int maxExpectedUniqCount = 2)
            where T : Roguelike.Tiles.Interactive.InteractiveTile, new()
        {
            var lootInfo = new LootInfo(game, null);

            AddThenDestroyInteractive <T>(tilesToCreateCount, init);
            var newLootItems = lootInfo.GetDiff();

            Assert.Greater(newLootItems.Count, 0);

            Assert.LessOrEqual(newLootItems.Count, maxExpectedLootCount);
            var eqs = newLootItems.Where(i => i is Equipment).Cast <Equipment>().ToList();

            var uniq = eqs.Where(i => i.Class == EquipmentClass.Unique).ToList();

            Assert.LessOrEqual(uniq.Count, maxExpectedUniqCount);
            //Assert.AreEqual(eq.First().Class, EquipmentClass.Unique);

            return(lootInfo);
        }