예제 #1
0
        private void PurchasePoolIdShard(int slotIndex, int quantity, Action <object> callback, object cookie, CostVO cost)
        {
            Dictionary <string, int> dictionary = this.CurrentShopData.Purchases[slotIndex];
            string shardSlotId = GameUtils.GetShardSlotId(slotIndex);

            CostUtils.DeductCost(Service.CurrentPlayer, cost);
            CrateSupplyVO crateSupplyVO = this.CurrentShopData.ShardOffers[shardSlotId];

            Service.InventoryCrateRewardController.GrantShopSupply(crateSupplyVO, quantity);
            string uid = crateSupplyVO.Uid;

            if (dictionary.ContainsKey(uid))
            {
                dictionary[uid] += quantity;
            }
            else
            {
                dictionary.Add(uid, quantity);
            }
            BuyShardRequest request         = new BuyShardRequest(shardSlotId, quantity);
            BuyShardCommand buyShardCommand = new BuyShardCommand(request);

            buyShardCommand.Context = new KeyValuePair <object, object>(callback, cookie);
            buyShardCommand.AddSuccessCallback(new AbstractCommand <BuyShardRequest, GetShardOfferingResponse> .OnSuccessCallback(this.OnBuyShardSuccess));
            Service.ServerAPI.Sync(buyShardCommand);
        }
예제 #2
0
        public bool BuyShards(int slotIndex, int quantity, Action <int, bool> deferredSuccess, Action <object> serverCallback)
        {
            CostVO costVO = ShardShopController.CalculateCost(slotIndex, quantity, this.CurrentShopData);
            MissingCurrencyTypes missingCurrencyTypes = CostUtils.CheckForMissingCurrency(Service.CurrentPlayer, costVO);

            if (missingCurrencyTypes != MissingCurrencyTypes.Hard)
            {
                if (missingCurrencyTypes != MissingCurrencyTypes.MultipleSoft)
                {
                    if (missingCurrencyTypes == MissingCurrencyTypes.Soft)
                    {
                        ShardShopPurchaseCookie purchaseCookie = new ShardShopPurchaseCookie(slotIndex, quantity, deferredSuccess, serverCallback, this.ClientPredictionId, costVO);
                        PayMeScreen.ShowIfNotEnoughCurrency(costVO.Credits, costVO.Materials, costVO.Contraband, "shard", purchaseCookie, new OnScreenModalResult(this.OnPurchaseMissingSoftCurrency));
                    }
                }
                else
                {
                    ShardShopPurchaseCookie purchaseCookie2 = new ShardShopPurchaseCookie(slotIndex, quantity, deferredSuccess, serverCallback, this.ClientPredictionId, costVO);
                    MultiResourcePayMeScreen.ShowIfNotEnoughMultipleCurrencies(costVO, "shard", purchaseCookie2, new OnScreenModalResult(this.OnPurchaseMissingSoftCurrency));
                }
            }
            else
            {
                GameUtils.PromptToBuyCrystals();
            }
            if (missingCurrencyTypes != MissingCurrencyTypes.None)
            {
                return(false);
            }
            this.ClientPredictionId++;
            this.PurchasePoolIdShard(slotIndex, quantity, serverCallback, this.ClientPredictionId, costVO);
            return(true);
        }
예제 #3
0
        private void PopulateCosts()
        {
            StaticDataController staticDataController = Service.StaticDataController;

            this.costs = new CostVO[this.CostStrings.Length];
            for (int i = 0; i < this.costs.Length; i++)
            {
                this.costs[i] = CostUtils.CombineCurrenciesForShards(staticDataController.Get <CostVO>(this.CostStrings[i]));
            }
        }
예제 #4
0
        public void GetCostOfTheVisitAfterDiscount_ShouldReturnCostAfterDiscountTheSameAsCostIfNoDiscount()
        {
            // Arrange
            decimal cost     = 150;
            decimal discount = 0;

            // Act
            decimal result = CostUtils.GetCostOfTheVisitAfterDiscount(cost, discount);

            // Assert
            Assert.AreEqual(cost, result);
        }
예제 #5
0
        public static CostVO CalculateCost(int slotIndex, int quantity, ShardShopData data)
        {
            Dictionary <string, int> dictionary = data.Purchases[slotIndex];
            ShardShopPoolVO          pool       = data.ActiveSeries.GetPool(slotIndex);
            int num = 0;

            foreach (int current in dictionary.Values)
            {
                num += current;
            }
            CostVO costVO = pool.GetCost(num);

            if (quantity > 1)
            {
                for (int i = 1; i < quantity; i++)
                {
                    CostVO cost = pool.GetCost(num + i);
                    costVO = CostUtils.Combine(costVO, cost);
                }
            }
            return(CostUtils.CombineCurrenciesForShards(costVO));
        }
예제 #6
0
        public ShardShopViewTO GenerateViewTO(int index, CurrentPlayer player, ShardShopData data)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            int             playerHQLevel             = player.Map.FindHighestHqLevel();
            ShardShopViewTO shardShopViewTO           = new ShardShopViewTO();
            string          shardSlotId = GameUtils.GetShardSlotId(index);
            int             num         = 0;

            foreach (int current in data.Purchases[index].Values)
            {
                num += current;
            }
            int num2 = this.adjustedOfferQuantity[index] - num;

            shardShopViewTO.SlotIndex = index;
            shardShopViewTO.SupplyVO  = data.ShardOffers[shardSlotId];
            shardShopViewTO.RemainingShardsForSale = num2;
            if (num2 > 0)
            {
                shardShopViewTO.CostOfNextShard = ShardShopController.CalculateCost(index, 1, data);
                shardShopViewTO.CostOfAllShards = ShardShopController.CalculateCost(index, num2, data);
            }
            shardShopViewTO.CanAffordSingle       = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfNextShard);
            shardShopViewTO.CanAffordAll          = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfAllShards);
            shardShopViewTO.PlayerHQLevel         = playerHQLevel;
            shardShopViewTO.ItemName              = GameUtils.GetShardShopNameWithoutQuantity(shardShopViewTO.SupplyVO, staticDataController);
            shardShopViewTO.Quality               = GameUtils.GetShardQualityNumeric(shardShopViewTO.SupplyVO);
            shardShopViewTO.UpgradeShardsEarned   = GameUtils.GetUpgradeShardsOwned(shardShopViewTO.SupplyVO, player);
            shardShopViewTO.UpgradeShardsRequired = GameUtils.GetUpgradeShardsRequired(shardShopViewTO.SupplyVO, player, staticDataController);
            shardShopViewTO.State = "unlocked";
            SupplyType type = shardShopViewTO.SupplyVO.Type;

            if (this.adjustedOfferQuantity[index] < 1)
            {
                shardShopViewTO.State = "maxedOut";
            }
            else if (num2 < 1)
            {
                shardShopViewTO.State = "soldOut";
            }
            else if (type == SupplyType.Shard && !ArmoryUtils.PlayerHasArmory())
            {
                shardShopViewTO.State = "requiresArmory";
            }
            else if (type == SupplyType.ShardTroop)
            {
                ShardVO             shardVO             = staticDataController.Get <ShardVO>(shardShopViewTO.SupplyVO.RewardUid);
                TroopUpgradeCatalog troopUpgradeCatalog = Service.TroopUpgradeCatalog;
                TroopTypeVO         byLevel             = troopUpgradeCatalog.GetByLevel(shardVO.TargetGroupId, 1);
                if (byLevel != null && byLevel.Type == TroopType.Mercenary && !Service.BuildingLookupController.HasCantina())
                {
                    shardShopViewTO.State = "requiresCantina";
                }
            }
            if (type == SupplyType.Shard)
            {
                EquipmentUpgradeCatalog equipmentUpgradeCatalog  = Service.EquipmentUpgradeCatalog;
                EquipmentVO             currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(shardShopViewTO.SupplyVO.RewardUid);
                int shards = player.GetShards(shardShopViewTO.SupplyVO.RewardUid);
                int shardsRequiredForNextUpgrade = ArmoryUtils.GetShardsRequiredForNextUpgrade(player, equipmentUpgradeCatalog, currentEquipmentDataByID);
                shardShopViewTO.Upgradeable = (shards >= shardsRequiredForNextUpgrade && shardsRequiredForNextUpgrade > 0);
            }
            else if (type == SupplyType.ShardTroop || type == SupplyType.ShardSpecialAttack)
            {
                shardShopViewTO.Upgradeable = Service.DeployableShardUnlockController.IsShardDeployableReadyToUpgrade(shardShopViewTO.SupplyVO.RewardUid);
            }
            return(shardShopViewTO);
        }