private void RequiredItemChange(IStorage storage, CraftingRequiredItemLink i, bool success)
        {
            MixResult mr = success ? i.ItemRequirement.SuccessResult : i.ItemRequirement.FailResult;

            switch (mr)
            {
            case MixResult.Disappear:
                i.StoredItem.ForEach(storage.RemoveItem);
                //// TODO: Delete item?
                //// TODO: Send ItemDisappear?
                break;

            case MixResult.DowngradedRandom:
                i.StoredItem.ForEach(item => item.Level = (byte)Rand.NextInt(0, item.Level));

                // TODO: Send item updated
                break;

            case MixResult.DowngradedTo0:
                i.StoredItem.ForEach(item => item.Level = 0);

                // TODO: Send item updated
                break;
            }
        }
示例#2
0
        private void RequiredItemChange(Player player, CraftingRequiredItemLink i, bool success)
        {
            MixResult mr = success ? i.ItemRequirement.SuccessResult : i.ItemRequirement.FailResult;

            switch (mr)
            {
            case MixResult.Disappear:
                var point = player.GameContext.PlugInManager.GetPlugInPoint <IItemDestroyedPlugIn>();
                foreach (var item in i.StoredItem)
                {
                    player.TemporaryStorage.RemoveItem(item);
                    player.PersistenceContext.Delete(item);
                    point.ItemDestroyed(item);
                }

                //// TODO: Send ItemDisappear?
                break;

            case MixResult.DowngradedRandom:
                i.StoredItem.ForEach(item => item.Level = (byte)Rand.NextInt(0, item.Level));

                // TODO: Send item updated
                break;

            case MixResult.DowngradedTo0:
                i.StoredItem.ForEach(item => item.Level = 0);

                // TODO: Send item updated
                break;

            default:
                // The item stays as is.
                break;
            }
        }
示例#3
0
        /// <summary>
        /// Changes the <see cref="CraftingRequiredItemLink.Items"/> depending on the success.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="itemLink">The item link.</param>
        /// <param name="success"><c>true</c>, if the crafting was successful; Otherwise, <c>false</c>.</param>
        private void RequiredItemChange(Player player, CraftingRequiredItemLink itemLink, bool success)
        {
            var mixResult = success ? itemLink.ItemRequirement.SuccessResult : itemLink.ItemRequirement.FailResult;

            switch (mixResult)
            {
            case MixResult.Disappear:
                var point = player.GameContext.PlugInManager.GetPlugInPoint <IItemDestroyedPlugIn>();
                foreach (var item in itemLink.Items)
                {
                    Log.DebugFormat("Item {0} is getting destroyed.", item);
                    player.TemporaryStorage.RemoveItem(item);
                    player.PersistenceContext.Delete(item);
                    point?.ItemDestroyed(item);
                }

                break;

            case MixResult.DowngradedRandom:
                itemLink.Items.ForEach(item =>
                {
                    var previousLevel = item.Level;
                    item.Level        = (byte)Rand.NextInt(0, item.Level);
                    Log.DebugFormat("Item {0} was downgraded from {1} to {2}.", item, previousLevel, item.Level);
                });

                break;

            case MixResult.DowngradedTo0:
                itemLink.Items.ForEach(item =>
                {
                    Log.DebugFormat("Item {0} is getting downgraded to level 0.", item);
                    item.Level = 0;
                });

                break;

            default:
                if (Log.IsDebugEnabled)
                {
                    itemLink.Items.ForEach(item => Log.DebugFormat("Item {0} stays as-is.", item));
                }

                // The item stays as is.
                break;
            }
        }