コード例 #1
0
        private void KillShops(ShopType shopType, ShopKillMode mode, ShopKillFactor factor, bool excludeConeria)
        {
            if (mode == ShopKillMode.Random)
            {
                mode = (ShopKillMode)Math.Max(rng.Between(-3, 4), 0);
            }
            if (factor == ShopKillFactor.KillRandom)
            {
                factor = (ShopKillFactor)rng.Between(0, 4);
            }

            switch (mode)
            {
            case ShopKillMode.WholeShops:
                KillWholeShops(shopType, factor, excludeConeria);
                break;

            case ShopKillMode.AllItemsOfAKind:
                KillAllItemsOfAKind(shopType, factor, excludeConeria);
                break;

            case ShopKillMode.Spread:
                KillSpreads(shopType, factor, excludeConeria);
                break;

            case ShopKillMode.Chaos:
                KillChaos(shopType, factor, excludeConeria);
                break;

            default:
                break;
            }
        }
コード例 #2
0
        private void KillSpreads(ShopType shopType, ShopKillFactor factor, bool excludeConeria)
        {
            var shops = ShopData.Shops.Where(s => s.Type == shopType).ToList();

            if (excludeConeria)
            {
                shops = shops.Where(s => s.Location != MapLocation.Coneria).ToList();
            }

            foreach (var shop in shops)
            {
                var entries = shop.Entries.Where(e => !QuestItems.Contains(e)).ToList();

                entries.Shuffle(rng);

                var cnt = (int)Math.Round(shop.Entries.Count * GetKillFactor(factor) / 100.0f, 0);

                var entriesToRemove = entries.Take(cnt).ToList();

                foreach (var e in entriesToRemove)
                {
                    shop.Entries.Remove(e);
                }

                if (shop.Entries.Count == 0)
                {
                    shop.Entries.Add(GetDefaultItem(shopType));
                    RemoveShopFromMap(shop);
                }
            }
        }
コード例 #3
0
        private void KillChaos(ShopType shopType, ShopKillFactor factor, bool excludeConeria)
        {
            var shops = ShopData.Shops.Where(s => s.Type == shopType).ToList();

            if (excludeConeria)
            {
                shops = shops.Where(s => s.Location != MapLocation.Coneria).ToList();
            }

            var allEntries = shops.Select(s => s.Entries.Select(e => (s, e))).SelectMany(x => x).Where(e => !QuestItems.Contains(e.e)).ToList();

            allEntries.Shuffle(rng);

            var cnt = (int)Math.Round(allEntries.Count * GetKillFactor(factor) / 100.0f, 0);

            var entriesToRemove = allEntries.Take(cnt).ToList();

            foreach (var entry in entriesToRemove)
            {
                entry.s.Entries.Remove(entry.e);

                if (entry.s.Entries.Count == 0)
                {
                    entry.s.Entries.Add(GetDefaultItem(shopType));
                    RemoveShopFromMap(entry.s);
                }
            }
        }
コード例 #4
0
        private void KillAllItemsOfAKind(ShopType shopType, ShopKillFactor factor, bool excludeConeria)
        {
            var shops = ShopData.Shops.Where(s => s.Type == shopType).ToList();

            if (excludeConeria)
            {
                shops = shops.Where(s => s.Location != MapLocation.Coneria).ToList();
            }

            var dinstinctEntries = shops.SelectMany(s => s.Entries).Distinct().Where(e => !QuestItems.Contains(e)).ToList();

            dinstinctEntries.Shuffle(rng);

            var cnt = (int)Math.Round(dinstinctEntries.Count * GetKillFactor(factor) / 100.0f, 0);

            var dinstinctToRemove = new HashSet <Item>(dinstinctEntries.Take(cnt));

            foreach (var shop in shops)
            {
                shop.Entries = shop.Entries.Where(e => !dinstinctToRemove.Contains(e)).ToList();

                if (shop.Entries.Count == 0)
                {
                    shop.Entries.Add(GetDefaultItem(shopType));
                    RemoveShopFromMap(shop);
                }
            }
        }
コード例 #5
0
        private int GetKillFactor(ShopKillFactor factor)
        {
            switch (factor)
            {
            case ShopKillFactor.Kill20Percent: return(20);

            case ShopKillFactor.Kill40Percent: return(40);

            case ShopKillFactor.Kill60Percent: return(60);

            case ShopKillFactor.Kill80Percent: return(80);

            case ShopKillFactor.KillAll: return(100);

            default: return(0);
            }
        }