Ejemplo n.º 1
0
        public void ContainsTest()
        {
            var subCol = new ShopEntry[]
            {
                new ShopEntry()
                {
                    Id = 111
                },
                new ShopEntry()
                {
                    Id = 222
                },
                new ShopEntry()
                {
                    Id = 333
                }
            };

            var collection = GetCollectionSample(
                Enumerable.Range(0, 10)
                .Select(x => new ShopEntry()
            {
                Id = x
            })
                .Concat(subCol)
                );

            collection.Remove(subCol[1]);
            CheckIndices(collection);

            Assert.IsTrue(collection.Contains(subCol[0]));
            Assert.IsFalse(collection.Contains(subCol[1]));
            Assert.IsTrue(collection.Contains(subCol[2]));
        }
Ejemplo n.º 2
0
            public async Task ShopAdd(Role _, int price, [Remainder] IRole role)
            {
                var entry = new ShopEntry()
                {
                    Name     = "-",
                    Price    = price,
                    Type     = ShopEntryType.Role,
                    AuthorId = Context.User.Id,
                    RoleId   = role.Id,
                    RoleName = role.Name
                };

                using (var uow = _db.UnitOfWork)
                {
                    var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.For(Context.Guild.Id,
                                                                                         set => set.Include(x => x.ShopEntries)
                                                                                         .ThenInclude(x => x.Items)).ShopEntries)
                    {
                        entry
                    };
                    uow.GuildConfigs.For(Context.Guild.Id, set => set).ShopEntries = entries;
                    uow.Complete();
                }
                await Context.Channel.EmbedAsync(EntryToEmbed(entry)
                                                 .WithTitle(GetText("shop_item_add")));
            }
Ejemplo n.º 3
0
            public async Task ShopAdd(Role _, int price, [Leftover] IRole role)
            {
                var entry = new ShopEntry()
                {
                    Name     = "-",
                    Price    = price,
                    Type     = ShopEntryType.Role,
                    AuthorId = ctx.User.Id,
                    RoleId   = role.Id,
                    RoleName = role.Name
                };

                using (var uow = _db.GetDbContext())
                {
                    var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.ForId(ctx.Guild.Id,
                                                                                           set => set.Include(x => x.ShopEntries)
                                                                                           .ThenInclude(x => x.Items)).ShopEntries)
                    {
                        entry
                    };
                    uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries;
                    uow.SaveChanges();
                    List <ulong> roleForSales = JsonConvert.DeserializeObject <List <ulong> >(_bc.BotConfig.RoleForSale);
                    if (!roleForSales.Contains(role.Id))
                    {
                        roleForSales.Add(role.Id);
                        _bc.Edit(BotConfigEditType.RoleForSale, JsonConvert.SerializeObject(roleForSales));
                    }
                }
                await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
                                             .WithTitle(GetText("shop_item_add"))).ConfigureAwait(false);
            }
Ejemplo n.º 4
0
            public async Task ShopAdd(Role _, int price, [Leftover] IRole role)
            {
                var entry = new ShopEntry()
                {
                    Name     = "-",
                    Price    = price,
                    Type     = ShopEntryType.Role,
                    AuthorId = ctx.User.Id,
                    RoleId   = role.Id,
                    RoleName = role.Name
                };

                using (var uow = _db.GetDbContext())
                {
                    var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.ForId(ctx.Guild.Id,
                                                                                           set => set.Include(x => x.ShopEntries)
                                                                                           .ThenInclude(x => x.Items)).ShopEntries)
                    {
                        entry
                    };
                    uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries;
                    uow.SaveChanges();
                }
                await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
                                             .WithTitle(GetText("shop_item_add"))).ConfigureAwait(false);
            }
Ejemplo n.º 5
0
            public async Task ShopAdd(List _, int price, [Remainder] string name)
            {
                var entry = new ShopEntry()
                {
                    Name     = name.TrimTo(100),
                    Price    = price,
                    Type     = ShopEntryType.List,
                    AuthorId = Context.User.Id,
                    Items    = new HashSet <ShopEntryItem>(),
                };

                using (var uow = _db.UnitOfWork)
                {
                    var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.For(Context.Guild.Id,
                                                                                         set => set.Include(x => x.ShopEntries)
                                                                                         .ThenInclude(x => x.Items)).ShopEntries)
                    {
                        entry
                    };
                    uow.GuildConfigs.For(Context.Guild.Id, set => set).ShopEntries = entries;
                    uow.Complete();
                }
                await Context.Channel.EmbedAsync(EntryToEmbed(entry)
                                                 .WithTitle(GetText("shop_item_add")));
            }
Ejemplo n.º 6
0
        private void addShopCellToList(ShopEntry shopEntry, ShopEntryInstance shopEntryInstance, RectTransform parentTm)
        {
            ShopPurchaseController controller = this.createShopPurchaseController(shopEntry, shopEntryInstance);
            string str = StringExtensions.ToUpperLoca(_.L(ConfigLoca.VENDOR_SOLD_OUT, null, false));

            Card.Content content2 = new Card.Content();
            content2.Obj          = controller;
            content2.Text         = StringExtensions.ToUpperLoca(controller.getTitle());
            content2.Sprite       = controller.getSprite();
            content2.Interactable = controller.isPurchaseable();
            content2.Grayscale    = !controller.isPurchaseable();
            content2.PriceText    = controller.getPriceText(1);
            content2.PriceIcon    = controller.getPriceIcon();
            content2.SoldText     = !controller.isSold() ? null : str;
            content2.StickerText  = controller.getStickerText();
            Card.Content content = content2;
            if (controller.payWithAd() && !Service.Binder.AdsSystem.initialized())
            {
                content.SoldText = str;
            }
            Card item = PlayerView.Binder.CardButtonPool.getObject();

            item.transform.SetParent(parentTm, false);
            item.initialize(content, new Action <Card>(this.onCardClicked));
            this.m_vendorCards.Add(item);
            item.gameObject.SetActive(true);
        }
Ejemplo n.º 7
0
 private void onShopPurchaseCompleted(ShopEntry shopEntry, PurchaseResult purchaseResult)
 {
     if (ConfigShops.IsIapShopEntry(shopEntry))
     {
         PlayerView.Binder.MenuSystem.waitAndTransitionToNewMenu(MenuType.StackedPopupMenu, MenuContentType.VendorPopupContent, null);
     }
 }
Ejemplo n.º 8
0
            public async Task ShopAdd(List _, int price, [Leftover] string name)
            {
                var entry = new ShopEntry()
                {
                    Name     = name.TrimTo(100),
                    Price    = price,
                    Type     = ShopEntryType.List,
                    AuthorId = ctx.User.Id,
                    Items    = new HashSet <ShopEntryItem>(),
                };

                using (var uow = _db.GetDbContext())
                {
                    var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.ForId(ctx.Guild.Id,
                                                                                           set => set.Include(x => x.ShopEntries)
                                                                                           .ThenInclude(x => x.Items)).ShopEntries)
                    {
                        entry
                    };
                    uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries;
                    uow.SaveChanges();
                }
                await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
                                             .WithTitle(GetText("shop_item_add"))).ConfigureAwait(false);
            }
Ejemplo n.º 9
0
 private void onPurchaseComplete(ShopEntry entry, PurchaseResult result)
 {
     if (result == PurchaseResult.Success)
     {
         PlayerView.Binder.MenuSystem.closeAllMenusAndTransitionToNewMenu(MenuType.NONE, MenuContentType.NONE, null);
     }
 }
Ejemplo n.º 10
0
        public SKBitmap DrawEntry(ShopEntry entry)
        {
            if (IsInCache(entry.CacheId))
            {
                return(LoadFromCache(entry.CacheId));
            }

            var item = entry.Items[0];

            using (var icon = new BaseIcon
            {
                DisplayName = entry.IsBundle ? entry.Bundle.Name.ToLowerAndUpper() : item.Name,
                ShortDescription = "",//(entry.IsBundle ? entry.Bundle.Info : ""/*item.Type.DisplayValue*/).ToUpper(),
                BundleInfo = entry.IsBundle ? entry.Bundle.Info.ToUpper() : "",
                Banner = entry.HasBanner ? entry.Banner.Value.ToUpper() : "",
                Price = entry.FinalPrice,
                IconImage = GetBitmapFromUrl(entry.IsBundle ? entry.Bundle.Image : item.Image, $"{item.Id}{(entry.IsBundle ? "_Bundle" : "")}"),
                RarityBackgroundImage = item.HasSeries && item.Series.Image != null ? GetBitmapFromUrl(item.Series.Image, item.Series.BackendValue) : null,
                Width = EntryWidth,
                Height = EntryHeight
            })
            {
                ChicRarity.GetRarityColors(icon, item.Rarity.BackendValue);
                var bmp = ChicIcon.GenerateIcon(icon);
                SaveToCache(bmp, entry.CacheId, false);
                return(bmp);
            }
        }
Ejemplo n.º 11
0
            public EmbedBuilder EntryToEmbed(ShopEntry entry)
            {
                var embed = new EmbedBuilder().WithOkColor();

                if (entry.Type == ShopEntryType.Role)
                {
                    return(embed.AddField(efb => efb.WithName(GetText("name")).WithValue(GetText("shop_role", Format.Bold(Context.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE"))).WithIsInline(true))
                           .AddField(efb => efb.WithName(GetText("price")).WithValue(entry.Price.ToString()).WithIsInline(true))
                           .AddField(efb => efb.WithName(GetText("type")).WithValue(entry.Type.ToString()).WithIsInline(true)));
                }
                else if (entry.Type == ShopEntryType.List)
                {
                    return(embed.AddField(efb => efb.WithName(GetText("name")).WithValue(entry.Name).WithIsInline(true))
                           .AddField(efb => efb.WithName(GetText("price")).WithValue(entry.Price.ToString()).WithIsInline(true))
                           .AddField(efb => efb.WithName(GetText("type")).WithValue(GetText("random_unique_item")).WithIsInline(true)));
                }
                //else if (entry.Type == ShopEntryType.Infinite_List)
                //    return embed.AddField(efb => efb.WithName(GetText("name")).WithValue(GetText("shop_role", Format.Bold(entry.RoleName))).WithIsInline(true))
                //            .AddField(efb => efb.WithName(GetText("price")).WithValue(entry.Price.ToString()).WithIsInline(true))
                //            .AddField(efb => efb.WithName(GetText("type")).WithValue(entry.Type.ToString()).WithIsInline(true));
                else
                {
                    return(null);
                }
            }
Ejemplo n.º 12
0
 private ShopPurchaseController createShopPurchaseController(ShopEntry shopEntry, ShopEntryInstance shopEntryInstance)
 {
     if (this.m_params.HasValue)
     {
         return(new ShopPurchaseController(shopEntry, shopEntryInstance, this.m_params.Value.PathToShop, this.m_params.Value.CloseCallback, this.m_params.Value.PurchaseCallback));
     }
     return(new ShopPurchaseController(shopEntry, shopEntryInstance, PathToShopType.Vendor, new System.Action(this.onShopClosed), new Action <ShopEntry, PurchaseResult>(this.onShopPurchaseCompleted)));
 }
 private void onPurchaseComplete(ShopEntry entry, PurchaseResult result)
 {
     if (result == PurchaseResult.Success)
     {
         Service.Binder.PromotionManager.ConsumePromotion(this.m_inputParameters.Promotion, true);
         Service.Binder.EventBus.PromotionAction(this.m_inputParameters.Promotion.promotionid, "purchase");
     }
 }
Ejemplo n.º 14
0
        public static Item GetRandomMysteryItem(Player player, string shopEntryId)
        {
            ShopEntry shopEntry = GetShopEntry(shopEntryId);
            int       floor     = player.getLastCompletedFloor(false) + 1;
            int       rarity    = player.clampItemRarityToMaxAllowed(UnityEngine.Random.Range(1, 3), floor, false);

            return(GameLogic.Binder.ItemResources.getRandomItemOfRarity(rarity, shopEntry.ItemType));
        }
 private void setShopEntryStackExhausted()
 {
     if (this.m_shopPurchaseController != null)
     {
         Player    player = GameLogic.Binder.GameState.Player;
         ShopEntry entry  = this.m_shopPurchaseController.getRefShopEntry();
         player.setStackExhausted(entry.Id);
     }
 }
Ejemplo n.º 16
0
        private void onShopPurchaseCompleted(ShopEntry shopEntry, PurchaseResult purchaseResult)
        {
            InputParameters parameters2 = new InputParameters();

            parameters2.ItemInstance = this.ItemInstance;
            InputParameters parameter = parameters2;

            PlayerView.Binder.MenuSystem.waitAndTransitionToNewMenu(MenuType.ThinPopupMenu, MenuContentType.ItemInfoContent, parameter);
        }
Ejemplo n.º 17
0
 public void SelectPiece(string entryName)
 {
     player.Deselect();
     selectedEntry = gameObject.transform.Find("ShopEntries").transform.Find(entryName).GetComponent <ShopEntry>();
     if (gold >= selectedEntry.GetCost())
     {
         player.SetMode(NameSpaces.Mode.PLACE);
         selectedEntry.gameObject.GetComponent <Button>().Select();
     }
 }
 private void onShopPurchaseCompleted(ShopEntry shopEntry, PurchaseResult purchaseResult)
 {
     if (ConfigShops.IsIapShopEntry(shopEntry))
     {
         MiniPopupMenu.InputParameters parameters2 = new MiniPopupMenu.InputParameters();
         parameters2.MenuContentParams = this.m_param;
         MiniPopupMenu.InputParameters parameter = parameters2;
         PlayerView.Binder.MenuSystem.waitAndTransitionToNewMenu(MenuType.MiniPopupMenu, MenuContentType.VendorMiniPopupContent, parameter);
     }
 }
Ejemplo n.º 19
0
 private void initEntries()
 {
     foreach (AShopItem item in this.items)
     {
         GameObject g  = Object.Instantiate(shopEntryPrefab);
         ShopEntry  se = g.GetComponent <ShopEntry>();
         se.transform.SetParent(this.transform);
         se.setItem(item);
         this.entries.Add(se);
     }
 }
Ejemplo n.º 20
0
        private void addShopCellToList(ShopEntry shopEntry)
        {
            ShopCell item = PlayerView.Binder.ShopCellPool.getObject();

            item.transform.SetParent(this.VerticalGroup, false);
            bool flag = (this.VerticalGroup.childCount % 2) == 0;

            item.initialize(shopEntry, null, PathToShopType.Vendor, !flag ? ConfigUi.LIST_CELL_REGULAR_COLOR : ConfigUi.LIST_CELL_STRIPED_COLOR, null, null);
            this.m_shopCells.Add(item);
            item.gameObject.SetActive(true);
        }
Ejemplo n.º 21
0
            public string EntryToString(ShopEntry entry)
            {
                switch (entry.Type)
                {
                case ShopEntryType.Role:
                    return(GetText("shop_role", Format.Bold(entry.RoleName)));

                case ShopEntryType.List:
                    return(GetText("unique_items_left", entry.Items.Count) + "\n" + entry.Name);
                }
                return("");
            }
Ejemplo n.º 22
0
 private void SetupUI()
 {
     if (entrys.Count == 0)
     {
         for (int i = 0; i < gm.allPlanets.Count; i++)
         {
             ShopEntry entry = Instantiate(entryTemplate, contentParent);
             entrys.Add(entry);
             entry.gameObject.SetActive(true);
             entrys[i].SetupEntry(gm.allPlanets[i]);
         }
     }
 }
Ejemplo n.º 23
0
        private void addPromotionCellToList(ShopEntry shopEntry, RemotePromotion promotion, RectTransform parentTm)
        {
            PromotionCard.Content content2 = new PromotionCard.Content();
            content2.Promotion     = promotion;
            content2.RemoteTexture = promotion.ParsedCustomParams.ShopBannerImage;
            PromotionCard.Content content = content2;
            PromotionCard         item    = PlayerView.Binder.PromotionCardAugmentationPool.getObject();

            item.transform.SetParent(parentTm, false);
            item.initialize(content, new Action <Card>(this.onCardClicked));
            this.m_promotionCards.Add(item);
            item.gameObject.SetActive(true);
        }
Ejemplo n.º 24
0
        protected override void onPreShow([Optional, DefaultParameterValue(null)] object param)
        {
            ShopEntry shopEntryBySlot = Service.Binder.ShopManager.GetShopEntryBySlot(ShopManager.ValidBundleSlots[0]);

            this.m_starterBundleSpc      = new ShopPurchaseController(shopEntryBySlot, null, PathToShopType.Vendor, null, new Action <ShopEntry, PurchaseResult>(this.onPurchaseComplete));
            this.PurchaseButtonText.text = this.m_starterBundleSpc.getPriceText(1);
            this.CritterName.text        = StringExtensions.ToUpperLoca(_.L(ConfigLoca.IAP_STARTERBUNDLE_CRITTER_NAME, null, false));
            double v = this.m_starterBundleSpc.ShopEntry.BuyResourceAmounts[ResourceType.Token];

            this.TokenAmount.text = StringExtensions.ToUpperLoca(_.L(ConfigLoca.RESOURCES_TOKENS_MULTILINE, new < > __AnonType9 <string>(MenuHelpers.BigValueToString(v)), false));
            double num2 = this.m_starterBundleSpc.ShopEntry.BuyResourceAmounts[ResourceType.Diamond];

            this.GemAmount.text = StringExtensions.ToUpperLoca(_.L(ConfigLoca.RESOURCES_DIAMONDS_MULTILINE, new < > __AnonType9 <string>(MenuHelpers.BigValueToString(num2)), false));
        }
Ejemplo n.º 25
0
        public static ShopEntry GetShopEntry(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }
            ShopEntry vendorShopEntry = GetVendorShopEntry(id);

            if (vendorShopEntry != null)
            {
                return(vendorShopEntry);
            }
            return(GetIapShopEntry(id));
        }
Ejemplo n.º 26
0
            public string EntryToString(ShopEntry entry)
            {
                if (entry.Type == ShopEntryType.Role)
                {
                    return(GetText("shop_role", Format.Bold(entry.RoleName)));
                }
                else if (entry.Type == ShopEntryType.List)
                {
                    return(GetText("unique_items_left", entry.Items.Count) + "\n" + entry.Name);
                }
                //else if (entry.Type == ShopEntryType.Infinite_List)
                //{

                //}
                return("");
            }
Ejemplo n.º 27
0
        private void FillShop()
        {
            //using standard random here at the moment, in future could do something like stages with weighted pools.

            //get the unit pool and choose a random unit type from it until the shop capacity is reached.
            Type[] unitPool = UnitPool.GetUnitPool();
            Random rand     = new Random();

            for (int i = 0; i < capacity; i++)
            {
                Type unitType = unitPool[rand.Next(0, unitPool.Length)];

                //create a respective shop entry.
                unitsForSale[i] = new ShopEntry(unitType);
            }
        }
Ejemplo n.º 28
0
            public string EntryToString(ShopEntry entry)
            {
                if (entry.Type == ShopEntryType.Role)
                {
                    return(GetText("shop_role", Format.Bold(Context.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")));
                }
                else if (entry.Type == ShopEntryType.List)
                {
                    return(GetText("unique_items_left", entry.Items.Count) + "\n" + entry.Name);
                }
                //else if (entry.Type == ShopEntryType.Infinite_List)
                //{

                //}
                return("");
            }
Ejemplo n.º 29
0
        public void CopyToTest()
        {
            var collection = GetCollectionSample <ShopEntry>();
            var fullCopy   = new ShopEntry[10];

            collection.CopyTo(fullCopy, 0);

            // Evaluate copy
            for (var index = 0; index < fullCopy.Length; index++)
            {
                Assert.AreEqual(index, fullCopy[index].Index);
            }

            Assert.Throws <ArgumentException>(() => collection.CopyTo(new ShopEntry[10], 4));
            Assert.Throws <ArgumentException>(() => collection.CopyTo(new ShopEntry[6], 0));
        }
Ejemplo n.º 30
0
        public void IndexTest()
        {
            var collection = GetCollectionSample <ShopEntry>();

            collection[4] = new ShopEntry()
            {
                Id = 444
            };
            collection[7] = new ShopEntry()
            {
                Id = 777
            };
            CheckIndices(collection);

            Assert.AreEqual(444, collection[4].Id);
            Assert.AreEqual(777, collection[7].Id);
        }