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); }
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); }