예제 #1
0
        /**
         * Retrieves the current upgrade for the given virtual good.
         *
         * @param good the virtual good to retrieve upgrade for
         * @return the current upgrade for the given virtual good
         */
        public UpgradeVG getCurrentUpgrade(VirtualGood good)
        {
            SoomlaUtils.LogDebug(mTag, "Fetching upgrade to virtual good: " + good.getName());

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

            String upItemId = KeyValueStorage.GetValue(key);

            if (upItemId == null)
            {
                SoomlaUtils.LogDebug(mTag, "You tried to fetch the current upgrade of " + good.getName()
                                     + " but there's not upgrade to it.");
                return(null);
            }

            try {
                return((UpgradeVG)StoreInfo.getVirtualItem(upItemId));
            } catch (VirtualItemNotFoundException e) {
                SoomlaUtils.LogError(mTag,
                                     "The current upgrade's itemId from the DB is not found in StoreInfo." + " " + e.Message);
            } catch (InvalidCastException e) {
                SoomlaUtils.LogError(mTag,
                                     "The current upgrade's itemId from the DB is not an UpgradeVG." + " " + e.Message);
            }

            return(null);
        }
예제 #2
0
        /**
         * Removes any upgrade associated with the given VirtualGood.
         *
         * @param good the virtual good to remove the upgrade from
         * @param notify if true post event to bus
         */
        public void removeUpgrades(VirtualGood good, bool notify)
        {
            SoomlaUtils.LogDebug(mTag, "Removing upgrade information from virtual good: " +
                                 good.getName());

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

            KeyValueStorage.DeleteKeyValue(key);

            if (notify)
            {
                BusProvider.Instance.Post(new GoodUpgradeEvent(good, null));
            }
        }
예제 #3
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));
            }
        }