示例#1
0
        /**
         * Retrieves the itemId of the current upgrade of the virtual good with the given
         * <code>goodItemId</code>.
         *
         * @param goodItemId id of the virtual good whose upgrade id we want to know
         * @return upgrade id if exists, or empty string otherwise
         * @throws VirtualItemNotFoundException
         */
        public static String getGoodCurrentUpgrade(String goodItemId)
        {
            VirtualGood good      = (VirtualGood)StoreInfo.getVirtualItem(goodItemId);
            UpgradeVG   upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good);

            if (upgradeVG == null)
            {
                return("");
            }
            return(upgradeVG.getItemId());
        }
示例#2
0
        /**
         * Assigns a specific upgrade to the given virtual good.
         *
         * @param good the VirtualGood to upgrade
         * @param upgradeVG the upgrade to assign
         * @param notify if true post event to bus
         */
        public void assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify)
        {
            if (getCurrentUpgrade(good) != null && getCurrentUpgrade(good).getItemId() == upgradeVG.getItemId())
            {
                return;
            }

            SoomlaUtils.LogDebug(mTag, "Assigning upgrade " + upgradeVG.getName() + " to virtual good: "
                                 + good.getName());

            String itemId   = good.getItemId();
            String key      = keyGoodUpgrade(itemId);
            String upItemId = upgradeVG.getItemId();

            KeyValueStorage.SetValue(key, upItemId);

            if (notify)
            {
                BusProvider.Instance.Post(new GoodUpgradeEvent(good, upgradeVG));
            }
        }