Example #1
0
 private void ModifyItems(ItemModifier modify)
 {
     var odd = true;
     foreach (var current in Items) {
         modify(current, odd);
         odd = !odd;
     }
 }
Example #2
0
        public override object VisitItemLine([NotNull] classlist_langParser.ItemLineContext context)
        {
            //add item modif

            ItemModifier modif = new ItemModifier();

            modif.ItemName   = context.item().GetText();
            modif.ItemNumber = 1;

            if (context.item_number() != null)
            {
                modif.ItemNumber = int.Parse(context.item_number().GetText());
            }

            currentClass.Modifiers.Add(modif);

            return(base.VisitItemLine(context));
        }
        public void Save()
        {
            var databaseUri = DatabaseUri;
            var fields      = new List <Tuple <FieldUri, string> >();

            foreach (var dataTable in DataTables)
            {
                foreach (ResultDataRow dataRow in dataTable.Rows)
                {
                    if (dataRow.RowState == DataRowState.Unchanged)
                    {
                        continue;
                    }

                    for (var index = 0; index < dataRow.ItemArray.Length; index++)
                    {
                        var fieldUri = dataRow.FieldArray[index];
                        if (fieldUri == null)
                        {
                            continue;
                        }

                        var value = dataRow.ItemArray[index];
                        if (value == null)
                        {
                            continue;
                        }

                        var v = value.ToString();

                        if (v == "\b")
                        {
                            v = string.Empty;
                        }

                        var field = new Tuple <FieldUri, string>(fieldUri, v);

                        fields.Add(field);
                    }
                }
            }

            ItemModifier.Edit(databaseUri, fields);
        }
Example #4
0
    private static void GenerateValues(Sword sword)
    {
        Vector2Int requirementsMinMax    = new Vector2Int(0, 10);
        Vector2    modifiersValueMinMax  = new Vector2(0, 25);
        Vector2Int modifiersAmountMinMax = new Vector2Int(3, 5);
        Vector2Int valueMinMax           = new Vector2Int(0, 10000);
        Vector2Int damageMinMax          = new Vector2Int(2, 50);


        sword.name = Random.Range(0, int.MaxValue).ToString();

        System.Random rng = new System.Random();

        sword.requirements              = new EquippableItem.Requirements();
        sword.requirements.dexterity    = Random.Range(requirementsMinMax.x, requirementsMinMax.y + 1);
        sword.requirements.strength     = Random.Range(requirementsMinMax.x, requirementsMinMax.y + 1);
        sword.requirements.intelligence = Random.Range(requirementsMinMax.x, requirementsMinMax.y + 1);

        /*
         * sword.requirements.dexterity = Mathf.RoundToInt(requirementsDistribution.Evaluate((float)rng.NextDouble()));
         * sword.requirements.strength = Mathf.RoundToInt(requirementsDistribution.Evaluate((float)rng.NextDouble()));
         * sword.requirements.intelligence = Mathf.RoundToInt(requirementsDistribution.Evaluate((float)rng.NextDouble()));
         */

        // level req and value should be dependend on the other requirements
        sword.requirements.level = 0;
        sword.value  = Random.Range(valueMinMax.x, valueMinMax.y + 1);
        sword.damage = Random.Range(damageMinMax.x, damageMinMax.y + 1);

        int modAmount = Random.Range(modifiersAmountMinMax.x, modifiersAmountMinMax.y + 1);

        ItemModifier[] modArr = new ItemModifier[modAmount];

        for (int i = 0; i < modAmount; i++)
        {
            modArr[i] = new ItemModifier(Random.Range(modifiersValueMinMax.x, modifiersValueMinMax.y));

            // gets the enum as an array
            ItemModifiers.Types[] types = (ItemModifiers.Types[])System.Enum.GetValues(typeof(ItemModifiers.Types));
            modArr[i].type = types[Random.Range(0, types.Length)];
        }

        sword.Modifiers = modArr;
    }
        private void MoveNextTo([NotNull] DragMovePipeline pipeline)
        {
            Debug.ArgumentNotNull(pipeline, nameof(pipeline));

            int sortOrder;
            int sortOrderDelta;

            ItemTreeViewItem parent;
            ItemTreeViewItem anchor;

            SortOrderHelper.GetSortOrder(pipeline.Target, pipeline.Position, pipeline.Items.Count(), out sortOrder, out sortOrderDelta, out parent, out anchor);
            if (parent == null)
            {
                AppHost.MessageBox(Resources.MoveItems_MoveNextTo_Parent_is_not_an_item, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                pipeline.Abort();
                return;
            }

            pipeline.Owner  = parent;
            pipeline.Anchor = anchor;

            var fieldId = IdManager.GetFieldId("/sitecore/templates/System/Templates/Sections/Appearance/Appearance/__Sortorder");

            foreach (var item in pipeline.Items)
            {
                if (!Move(item.ItemUri, parent.ItemUri))
                {
                    AppHost.MessageBox(string.Format(Resources.MoveItems_MoveNextTo_Failed_to_move___0_, item.Name), Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    break;
                }

                ItemModifier.Edit(item.ItemUri, fieldId, sortOrder.ToString());

                var itemTreeViewItem = item as ItemTreeViewItem;
                if (itemTreeViewItem != null)
                {
                    itemTreeViewItem.Item.SortOrder = sortOrder;
                }

                sortOrder += sortOrderDelta;

                pipeline.MovedItems.Add(item);
            }
        }
        private static void Postfix(SmeltingVM __instance, ItemRoster ____playerItemRoster)
        {
            // This appears to be how the game works out if an item is locked
            // From TaleWorlds.CampaignSystem.ViewModelCollection.SPInventoryVM.InitializeInventory()
            IEnumerable <ItemRosterElement> locks = Campaign.Current.GetCampaignBehavior <TaleWorlds.CampaignSystem.SandBox.CampaignBehaviors.IInventoryLockTracker>().GetLocks();

            ItemRosterElement[] locked_items = (locks != null) ? locks.ToArray <ItemRosterElement>() : null;

            bool isLocked(ItemRosterElement test_item)
            {
                return(locked_items != null && locked_items.Count(delegate(ItemRosterElement x)
                {
                    ItemObject lock_item = x.EquipmentElement.Item;
                    if (lock_item.StringId == test_item.EquipmentElement.Item.StringId)
                    {
                        ItemModifier itemModifier = x.EquipmentElement.ItemModifier;
                        string a = (itemModifier != null) ? itemModifier.StringId : null;
                        ItemModifier itemModifier2 = test_item.EquipmentElement.ItemModifier;
                        return a == ((itemModifier2 != null) ? itemModifier2.StringId : null);
                    }
                    return false;
                }) > 0);
            }

            MBBindingList <SmeltingItemVM> filteredList = new MBBindingList <SmeltingItemVM>();

            foreach (SmeltingItemVM sItem in __instance.SmeltableItemList)
            {
                if (!____playerItemRoster.Any(rItem =>
                                              sItem.Item == rItem.EquipmentElement.Item && isLocked(rItem)
                                              ))
                {
                    filteredList.Add(sItem);
                }
            }

            __instance.SmeltableItemList = filteredList;

            if (__instance.SmeltableItemList.Count == 0)
            {
                __instance.CurrentSelectedItem = null;
            }
        }
        public override void Execute(object parameter)
        {
            var context = parameter as IItemSelectionContext;

            if (context == null)
            {
                return;
            }

            foreach (var field in Fields)
            {
                foreach (var item in context.Items)
                {
                    var itemVersionUri = new ItemVersionUri(item.ItemUri, Language.Current, Data.Version.Latest);

                    ItemModifier.Edit(itemVersionUri, field.Item1.Name, field.Item2);
                }
            }
        }
        protected override void UpdateFields(NewItemWizardPipeline pipeline, ProjectItem projectItem, ItemUri itemUri)
        {
            Debug.ArgumentNotNull(pipeline, nameof(pipeline));
            Debug.ArgumentNotNull(projectItem, nameof(projectItem));
            Debug.ArgumentNotNull(itemUri, nameof(itemUri));

            var fileName = GetFileName(pipeline, projectItem);

            var pathFieldId = IdManager.GetFieldId("/sitecore/templates/System/Layout/Layout/Data/Path");

            var fieldValues = new List <Tuple <FieldId, string> >
            {
                new Tuple <FieldId, string>(pathFieldId, fileName),
            };

            ItemModifier.Edit(itemUri, fieldValues);

            projectItem.Project.LinkItemAndFile(itemUri, fileName);
        }
Example #9
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            var itemTreeViewItem = context.SelectedItems.FirstOrDefault() as ItemTreeViewItem;

            if (itemTreeViewItem == null)
            {
                return;
            }

            var fieldId = IdManager.GetFieldId("/sitecore/templates/System/Templates/Template/Data/__Base template");

            GetValueCompleted <Item> completed = delegate(Item item)
            {
                var field         = item.Fields.FirstOrDefault(f => f.Name == "__Base template");
                var selectedItems = field != null?field.Value.Split('|').Where(v => !string.IsNullOrWhiteSpace(v)).Select(id => new ItemId(new Guid(id))) : Enumerable.Empty <ItemId>();

                var d = new SelectTemplatesDialog
                {
                    HelpText = "Each data template inherits from zero or more base data templates, which in turn specify base templates.",
                    Label    = "Select the Base Templates:"
                };

                d.Initialize(Resources.SetBaseTemplates_Execute_Base_Templates, item.ItemUri.DatabaseUri, selectedItems);

                if (AppHost.Shell.ShowDialog(d) != true)
                {
                    return;
                }

                var baseTemplates = string.Join("|", d.SelectedTemplates.Select(i => i.ToString()));

                ItemModifier.Edit(item.ItemUri, fieldId, baseTemplates);
            };

            itemTreeViewItem.ItemUri.Site.DataService.GetItemFieldsAsync(new ItemVersionUri(itemTreeViewItem.ItemUri, Language.Current, Data.Version.Latest), completed);
        }
Example #10
0
        protected override void Process(SaveItemPipeline pipeline)
        {
            Debug.ArgumentNotNull(pipeline, nameof(pipeline));

            var itemUri = pipeline.ContentModel.FirstItem.Uri.ItemUri;

            ExecuteCompleted callback = delegate(string response, ExecuteResult executeResult)
            {
                if (!DataService.HandleExecute(response, executeResult))
                {
                    return;
                }

                pipeline.Resume();
            };

            pipeline.Suspend();

            ItemModifier.Edit(itemUri.DatabaseUri, pipeline.ContentModel.Fields, true, callback);
        }
Example #11
0
        public void UpdateItems([NotNull] List <Tuple <FieldUri, string> > fieldValues)
        {
            Assert.ArgumentNotNull(fieldValues, nameof(fieldValues));

            var fieldValue = fieldValues.FirstOrDefault();

            if (fieldValue == null)
            {
                return;
            }

            if (!fieldValues.AllHasValue(f => f.Item1.DatabaseUri))
            {
                throw new InvalidOperationException("All items must have the same site and database.");
            }

            var databaseUri = fieldValue.Item1.ItemVersionUri.DatabaseUri;

            ItemModifier.Edit(databaseUri, fieldValues);
        }
Example #12
0
        /// <summary>
        /// Returns value for horse using its properties and filter settings
        /// </summary>
        /// <param name="sourceItem">Horse item</param>
        /// <returns>calculated value for horse</returns>
        public float CalculateHorseValue(EquipmentElement sourceItem, FilterMountSettings filterMount)
        {
            HorseComponent horseComponentItem = sourceItem.Item.HorseComponent;

            float sum =
                Math.Abs(filterMount.ChargeDamage) +
                Math.Abs(filterMount.HitPoints) +
                Math.Abs(filterMount.Maneuver) +
                Math.Abs(filterMount.Speed);

            int ChargeDamage = horseComponentItem.ChargeDamage,
                HitPoints    = horseComponentItem.HitPoints,
                Maneuver     = horseComponentItem.Maneuver,
                Speed        = horseComponentItem.Speed;

            ItemModifier mod = sourceItem.ItemModifier;

            if (mod != null)
            {
                ChargeDamage = mod.ModifyMountCharge(ChargeDamage);
                Maneuver     = mod.ModifyMountManeuver(Maneuver);
                Speed        = mod.ModifyMountSpeed(Speed);
            }

            var   weights = filterMount;
            float value   = (
                ChargeDamage * weights.ChargeDamage +
                HitPoints * weights.HitPoints +
                Maneuver * weights.Maneuver +
                Speed * weights.Speed
                ) / sum;

#if DEBUG
            InformationManager.DisplayMessage(new InformationMessage(String.Format("{0}: CD {1}, HP {2}, MR {3}, SD {4}",
                                                                                   sourceItem.Item.Name, ChargeDamage, HitPoints, Maneuver, Speed)));

            InformationManager.DisplayMessage(new InformationMessage("Total score: " + value));
#endif

            return(value);
        }
        public async Task <ItemModifierDTO> AddNewItemModifier(int itemId, ItemModifier itemModifier)
        {
            var newIM = new ItemModifier
            {
                ItemId         = itemId,
                ModifierId     = itemModifier.ModifierId,
                AdditionalCost = itemModifier.AdditionalCost
            };

            _context.itemModifier.Add(newIM);
            await _context.SaveChangesAsync();


            var newIMDTO = new ItemModifierDTO
            {
                ModifierName   = "new",
                AdditionalCost = itemModifier.AdditionalCost
            };

            return(newIMDTO);
        }
Example #14
0
        public override void Execute(object parameter)
        {
            var context = parameter as IItemSelectionContext;

            if (context == null)
            {
                return;
            }

            if (AppHost.MessageBox("Are you sure you want to reset the layout to the standard value?", "Confirmation", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
            {
                return;
            }

            var databaseUri   = DatabaseUri.Empty;
            var fields        = new List <Field>();
            var layoutFieldId = IdManager.GetFieldId("/sitecore/templates/System/Templates/Sections/Layout/Layout/__Renderings");

            foreach (var item in context.Items)
            {
                var field = new Field
                {
                    ResetOnSave = true,
                    HasValue    = true,
                    Value       = string.Empty
                };

                field.FieldUris.Add(new FieldUri(new ItemVersionUri(item.ItemUri, Language.Current, Version.Latest), layoutFieldId));

                fields.Add(field);

                if (databaseUri == DatabaseUri.Empty)
                {
                    databaseUri = item.ItemUri.DatabaseUri;
                }
            }

            ItemModifier.Edit(databaseUri, fields, false);
        }
        private static bool SaveItemLockStates(SPInventoryVM __instance)
        {
            if (!CommonSetting.Instance.LockNoMiss)
            {
                return(true);
            }



            Func <EquipmentElement, ItemRosterElement, bool> func = delegate(EquipmentElement x, ItemRosterElement itemRosterElement)
            {
                if (x.Item.StringId == itemRosterElement.EquipmentElement.Item.StringId)
                {
                    ItemModifier itemModifier  = x.ItemModifier;
                    string       a             = (itemModifier != null) ? itemModifier.StringId : null;
                    ItemModifier itemModifier2 = itemRosterElement.EquipmentElement.ItemModifier;
                    return(a == ((itemModifier2 != null) ? itemModifier2.StringId : null));
                }
                return(false);
            };


            List <EquipmentElement> list = Campaign.Current.GetCampaignBehavior <IInventoryLockTracker>().GetLocks().ToList();

            foreach (SPItemVM spitemVM in __instance.RightItemListVM)
            {
                if (spitemVM.IsLocked && !list.Exists(a => func(a, spitemVM.ItemRosterElement)))
                {
                    list.Add(spitemVM.ItemRosterElement.EquipmentElement);
                }
                if (!spitemVM.IsLocked && list.Exists(a => func(a, spitemVM.ItemRosterElement)))
                {
                    list.RemoveAll(a => func(a, spitemVM.ItemRosterElement));
                }
            }
            Campaign.Current.GetCampaignBehavior <IInventoryLockTracker>().SetLocks(list);

            return(false);
        }
Example #16
0
        public static ItemInstance ReadItemInstance602(Packet packet, params object[] indexes)
        {
            ItemInstance instance = new ItemInstance();

            instance.ItemID = packet.ReadInt32 <ItemId>("ItemID", indexes);
            instance.RandomPropertiesSeed = packet.ReadUInt32("RandomPropertiesSeed", indexes);
            instance.RandomPropertiesID   = packet.ReadUInt32("RandomPropertiesID", indexes);

            packet.ResetBitReader();

            var hasBonuses       = packet.ReadBit("HasItemBonus", indexes);
            var hasModifications = packet.ReadBit("HasModifications", indexes);

            if (hasBonuses)
            {
                instance.Context = packet.ReadByte("Context", indexes);

                var bonusCount = packet.ReadUInt32();
                instance.BonusListIDs = new uint[bonusCount];
                for (var j = 0; j < bonusCount; ++j)
                {
                    instance.BonusListIDs[j] = packet.ReadUInt32("BonusListID", indexes, j);
                }
            }

            if (hasModifications)
            {
                var mask = packet.ReadUInt32();
                for (var j = 0; mask != 0; mask >>= 1, ++j)
                {
                    if ((mask & 1) != 0)
                    {
                        ItemModifier mod = (ItemModifier)j;
                        instance.ItemModifier[mod] = packet.ReadInt32(mod.ToString(), indexes);
                    }
                }
            }
            return(instance);
        }
Example #17
0
        public static EquipmentElement GetEquipmentWithModifier(ItemObject item, float prosperityFactor)
        {
            ItemModifierGroup itemModifierGroup;
            ArmorComponent    armorComponent = item.ArmorComponent;

            if (armorComponent != null)
            {
                itemModifierGroup = armorComponent.ItemModifierGroup;
            }
            else
            {
                itemModifierGroup = null;
            }
            ItemModifierGroup itemModifierGroup1     = itemModifierGroup ?? Campaign.Current.ItemModifierGroupss.FirstOrDefault <ItemModifierGroup>((ItemModifierGroup x) => x.ItemTypeEnum == item.ItemType);
            ItemModifier      itemModifierWithTarget = null;

            if (itemModifierGroup1 != null)
            {
                float prosperityVariance = 1f;
                if (prosperityFactor < 1f)
                {
                    prosperityVariance = MBRandom.RandomFloatRanged(prosperityFactor, 1f);
                }
                else
                {
                    prosperityVariance = MBRandom.RandomFloatRanged(1f, prosperityFactor);
                }

                itemModifierWithTarget = itemModifierGroup1.GetRandomModifierWithTarget(prosperityVariance, 1f);
            }
            //Toss out the bad ones - they suck as prizes
            if (itemModifierWithTarget.PriceMultiplier < 1)
            {
                itemModifierWithTarget = null;
            }
            return(new EquipmentElement(item, itemModifierWithTarget));
        }
Example #18
0
        public static ItemInstance ReadItemInstance251(Packet packet, params object[] indexes)
        {
            ItemInstance instance = new ItemInstance();

            instance.ItemID = packet.ReadInt32 <ItemId>("ItemID", indexes);
            instance.RandomPropertiesSeed = packet.ReadUInt32("RandomPropertiesSeed", indexes);
            instance.RandomPropertiesID   = packet.ReadUInt32("RandomPropertiesID", indexes);

            packet.ResetBitReader();
            var hasBonuses = packet.ReadBit("HasItemBonus", indexes);

            {
                packet.ResetBitReader();
                var modificationCount = packet.ReadBits(6);
                for (var j = 0u; j < modificationCount; ++j)
                {
                    var          value = packet.ReadInt32();
                    ItemModifier mod   = packet.ReadByteE <ItemModifier>();
                    packet.AddValue(mod.ToString(), value, indexes);
                    instance.ItemModifier[mod] = value;
                }
            }

            if (hasBonuses)
            {
                instance.Context = packet.ReadByte("Context", indexes);

                var bonusCount = packet.ReadUInt32();
                instance.BonusListIDs = new uint[bonusCount];
                for (var j = 0; j < bonusCount; ++j)
                {
                    instance.BonusListIDs[j] = packet.ReadUInt32("BonusListID", indexes, j);
                }
            }

            return(instance);
        }
Example #19
0
        protected void SetHelp(ItemVersionUri itemUri)
        {
            var item = itemUri.Site.DataService.GetItemFields(itemUri);

            var shortHelpField = item.Fields.FirstOrDefault(f => f != null && f.Name == "__Short description");
            var longHelpField  = item.Fields.FirstOrDefault(f => f != null && f.Name == "__Long description");

            var shortHelp = shortHelpField != null ? shortHelpField.Value : string.Empty;
            var longHelp  = longHelpField != null ? longHelpField.Value : string.Empty;

            var d = new SetHelpDialog();

            d.Initialize(shortHelp, longHelp);
            if (AppHost.Shell.ShowDialog(d) != true)
            {
                return;
            }

            var shortProperty    = d.GetType().GetField("ShortHelp", BindingFlags.NonPublic | BindingFlags.Instance);
            var shortHelpTextBox = shortProperty.GetValue(d) as TextBox;

            if (shortHelpTextBox != null)
            {
                shortHelp = shortHelpTextBox.Text ?? string.Empty;
            }

            var longProperty    = d.GetType().GetField("LongHelp", BindingFlags.NonPublic | BindingFlags.Instance);
            var longHelpTextBox = longProperty.GetValue(d) as TextBox;

            if (longHelpTextBox != null)
            {
                longHelp = longHelpTextBox.Text ?? string.Empty;
            }

            ItemModifier.Edit(itemUri, "__Short description", shortHelp);
            ItemModifier.Edit(itemUri, "__Long description", longHelp);
        }
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            var fieldId = IdManager.GetFieldId("/sitecore/templates/System/Templates/Sections/Appearance/Appearance/__Sortorder");

            foreach (var i in context.SelectedItems)
            {
                var item = i as ItemTreeViewItem;
                if (item == null)
                {
                    continue;
                }

                var sortOrder = 0;

                foreach (var obj in item.Items)
                {
                    var child = obj as ItemTreeViewItem;
                    if (child == null)
                    {
                        continue;
                    }

                    ItemModifier.Edit(child.Item.ItemUri, fieldId, sortOrder.ToString());
                    child.Item.SortOrder = sortOrder;

                    sortOrder += 100;
                }
            }
        }
Example #21
0
        protected override void UpdateSelf(GameTime gameTime)
        {
            Vector2      mousePosition  = Main.MouseScreen;
            ItemModifier instance       = ModContent.GetInstance <ItemModifier>();
            TriggersSet  oldTriggersSet = PlayerInput.Triggers.Old;
            bool         leftDown;
            bool         wasLeftDown = oldTriggersSet.MouseLeft;
            bool         rightDown;
            bool         wasRightDown = oldTriggersSet.MouseRight;
            bool         middleDown;
            bool         wasMiddleDown = oldTriggersSet.MouseMiddle;
            bool         backDown;
            bool         wasBackDown = oldTriggersSet.MouseXButton1;
            bool         forwardDown;
            bool         wasForwardDown = oldTriggersSet.MouseXButton2;
            UIElement    target;

            if (Main.hasFocus)
            {
                leftDown    = Main.mouseLeft;
                rightDown   = Main.mouseRight;
                middleDown  = Main.mouseMiddle;
                backDown    = Main.mouseXButton1;
                forwardDown = Main.mouseXButton2;
                target      = GetElementAt(mousePosition);
                // Prevent UILayer from always blocking mouse input
                if (target == this)
                {
                    target = null;
                }
            }
            else
            {
                leftDown    = false;
                rightDown   = false;
                middleDown  = false;
                backDown    = false;
                forwardDown = false;
                target      = null;
                if (lastFocused != null)
                {
                    lastFocused.Unfocus();
                    lastFocused = null;
                }
            }
            if (target == null)
            {
                instance.MouseWheelDisabled   = false;
                instance.ItemAtCursorDisabled = false;
            }
            else
            {
                Main.LocalPlayer.mouseInterface = true;
                instance.MouseWheelDisabled     = true;
                instance.ItemAtCursorDisabled   = true;
            }
            if (target != lastHover)
            {
                lastHover?.MouseOut(new UIMouseEventArgs(lastHover, mousePosition));
                target?.MouseOver(new UIMouseEventArgs(target, mousePosition));
                lastHover = target;
            }
            target?.MouseHover(new UIMouseEventArgs(target, mousePosition));
            if (leftDown && !wasLeftDown || rightDown && !wasRightDown || middleDown && !wasMiddleDown || backDown && !wasBackDown || forwardDown && !wasForwardDown)
            {
                if (lastFocused != target)
                {
                    lastFocused?.Unfocus();
                    lastFocused = target;
                    target?.Focus();
                }
            }
            if (leftDown && !wasLeftDown && target != null)
            {
                lastLeftDown = target;
                target.LeftMouseDown(new UIMouseEventArgs(target, mousePosition));
                if (lastLeftClick == target && gameTime.TotalGameTime.TotalMilliseconds - lastLeftClickTime < DOUBLE_CLICK_MAX_GAP)
                {
                    target.LeftDoubleClick(new UIMouseEventArgs(target, mousePosition));
                    lastLeftClick = null;
                }
                lastLeftClickTime = gameTime.TotalGameTime.TotalMilliseconds;
            }
            else if (!leftDown && wasLeftDown && lastLeftDown != null)
            {
                if (lastLeftDown.ContainsPoint(mousePosition))
                {
                    lastLeftDown.LeftClick(new UIMouseEventArgs(lastLeftDown, mousePosition));
                    lastLeftClick = lastLeftDown;
                }
                lastLeftDown.LeftMouseUp(new UIMouseEventArgs(lastLeftDown, mousePosition));
                lastLeftDown = null;
            }
            if (rightDown && !wasRightDown && target != null)
            {
                lastRightDown = target;
                target.RightMouseDown(new UIMouseEventArgs(target, mousePosition));
                if (lastRightClick == target && gameTime.TotalGameTime.TotalMilliseconds - lastRightClickTime < DOUBLE_CLICK_MAX_GAP)
                {
                    target.RightDoubleClick(new UIMouseEventArgs(target, mousePosition));
                    lastRightClick = null;
                }
                lastRightClickTime = gameTime.TotalGameTime.TotalMilliseconds;
            }
            else if (!rightDown && wasRightDown && lastRightDown != null)
            {
                if (lastRightDown.ContainsPoint(mousePosition))
                {
                    lastRightDown.RightClick(new UIMouseEventArgs(lastRightDown, mousePosition));
                    lastRightClick = lastRightDown;
                }
                lastRightDown.RightMouseUp(new UIMouseEventArgs(lastRightDown, mousePosition));
                lastRightDown = null;
            }
            if (middleDown && !wasMiddleDown && target != null)
            {
                lastMiddleDown = target;
                target.MiddleMouseDown(new UIMouseEventArgs(target, mousePosition));
                if (lastMiddleClick == target && gameTime.TotalGameTime.TotalMilliseconds - lastMiddleClickTime < DOUBLE_CLICK_MAX_GAP)
                {
                    target.MiddleDoubleClick(new UIMouseEventArgs(target, mousePosition));
                    lastMiddleClick = null;
                }
                lastMiddleClickTime = gameTime.TotalGameTime.TotalMilliseconds;
            }
            else if (!middleDown && wasMiddleDown && lastMiddleDown != null)
            {
                if (lastMiddleDown.ContainsPoint(mousePosition))
                {
                    lastMiddleDown.MiddleClick(new UIMouseEventArgs(lastMiddleDown, mousePosition));
                    lastMiddleClick = lastMiddleDown;
                }
                lastMiddleDown.MiddleMouseUp(new UIMouseEventArgs(lastMiddleDown, mousePosition));
                lastMiddleDown = null;
            }
            if (backDown && !wasBackDown && target != null)
            {
                lastBackDown = target;
                target.BackDown(new UIMouseEventArgs(target, mousePosition));
                if (lastBackClick == target && gameTime.TotalGameTime.TotalMilliseconds - lastBackClickTime < DOUBLE_CLICK_MAX_GAP)
                {
                    target.BackDoubleClick(new UIMouseEventArgs(target, mousePosition));
                    lastBackClick = null;
                }
                lastBackClickTime = gameTime.TotalGameTime.TotalMilliseconds;
            }
            else if (!backDown && wasBackDown && lastBackDown != null)
            {
                if (lastBackDown.ContainsPoint(mousePosition))
                {
                    lastBackDown.BackClick(new UIMouseEventArgs(lastBackDown, mousePosition));
                    lastBackClick = lastBackDown;
                }
                lastBackDown.BackUp(new UIMouseEventArgs(lastBackDown, mousePosition));
                lastBackDown = null;
            }
            if (forwardDown && !wasForwardDown && target != null)
            {
                lastForwardDown = target;
                target.ForwardDown(new UIMouseEventArgs(target, mousePosition));
                if (lastForwardClick == target && gameTime.TotalGameTime.TotalMilliseconds - lastForwardClickTime < DOUBLE_CLICK_MAX_GAP)
                {
                    target.ForwardDoubleClick(new UIMouseEventArgs(target, mousePosition));
                    lastForwardClick = null;
                }
                lastForwardClickTime = gameTime.TotalGameTime.TotalMilliseconds;
            }
            else if (!forwardDown && wasForwardDown && lastForwardDown != null)
            {
                if (lastForwardDown.ContainsPoint(mousePosition))
                {
                    lastForwardDown.ForwardClick(new UIMouseEventArgs(lastForwardDown, mousePosition));
                    lastForwardClick = lastForwardDown;
                }
                lastForwardDown.ForwardUp(new UIMouseEventArgs(lastForwardDown, mousePosition));
                lastForwardDown = null;
            }
            if (PlayerInput.ScrollWheelDeltaForUI != 0)
            {
                target?.ScrollWheel(new UIScrollWheelEventArgs(target, mousePosition, PlayerInput.ScrollWheelDeltaForUI));
            }

            base.UpdateSelf(gameTime);
        }
Example #22
0
        /// <summary>
        /// Returns value for weapon using its properties and filter settings
        /// </summary>
        /// <param name="sourceItem">Weapon item</param>
        /// <param name="slot">Weapon equipment slot</param>
        /// <returns>calculated value for weapon</returns>
        public float CalculateWeaponValue(EquipmentElement sourceItem, FilterWeaponSettings filterWeapon)
        {
            WeaponComponentData  primaryWeaponItem = sourceItem.Item.PrimaryWeapon;
            FilterWeaponSettings weights           = filterWeapon;

            // Fetch direct values from the weapon item
            int   accuracy     = primaryWeaponItem.Accuracy;
            int   bodyArmor    = primaryWeaponItem.BodyArmor;
            int   handling     = primaryWeaponItem.Handling;
            int   maxDataValue = primaryWeaponItem.MaxDataValue;
            int   missileSpeed = primaryWeaponItem.MissileSpeed;
            int   swingDamage  = primaryWeaponItem.SwingDamage;
            int   swingSpeed   = primaryWeaponItem.SwingSpeed;
            int   thrustDamage = primaryWeaponItem.ThrustDamage;
            int   thrustSpeed  = primaryWeaponItem.ThrustSpeed;
            int   weaponLength = primaryWeaponItem.WeaponLength;
            float weaponWeight = sourceItem.Weight;

            // Modification calculation
            ItemModifier mod = sourceItem.ItemModifier;

            if (mod != null)
            {
                if (bodyArmor > 0f)
                {
                    bodyArmor = mod.ModifyArmor(bodyArmor);
                }
                if (missileSpeed > 0f)
                {
                    missileSpeed = mod.ModifyMissileSpeed(missileSpeed);
                }
                if (swingDamage > 0f)
                {
                    swingDamage = mod.ModifyDamage(swingDamage);
                }
                if (swingSpeed > 0f)
                {
                    swingSpeed = mod.ModifySpeed(swingSpeed);
                }
                if (thrustDamage > 0f)
                {
                    thrustDamage = mod.ModifyDamage(thrustDamage);
                }
                if (thrustDamage > 0f)
                {
                    thrustSpeed = mod.ModifySpeed(thrustSpeed);
                }
                if (maxDataValue > 0f)
                {
                    maxDataValue = mod.ModifyHitPoints((short)maxDataValue);
                }
                //WeaponWeight *= mod.WeightMultiplier;

                bodyArmor    = bodyArmor < 0 ? 0 : bodyArmor;
                missileSpeed = missileSpeed < 0 ? 0 : missileSpeed;
                swingDamage  = swingDamage < 0 ? 0 : swingDamage;
                swingSpeed   = swingSpeed < 0 ? 0 : swingSpeed;
                thrustDamage = thrustDamage < 0 ? 0 : thrustDamage;
                thrustSpeed  = thrustSpeed < 0 ? 0 : thrustSpeed;
                maxDataValue = maxDataValue < 0 ? 0 : maxDataValue;
            }

            // Weighted value
            float weightAccuracy     = accuracy * weights.Accuracy;
            float weightBodyArmor    = bodyArmor * weights.WeaponBodyArmor;
            float weightHandling     = handling * weights.Handling;
            float weightMaxDataValue = maxDataValue * weights.MaxDataValue;
            float weightMissileSpeed = missileSpeed * weights.MissileSpeed;
            float weightSwingDamage  = swingDamage * weights.SwingDamage;
            float weightSwingSpeed   = swingSpeed * weights.SwingSpeed;
            float weightThrustDamage = thrustDamage * weights.ThrustDamage; // It is also missile damage for bows and crossbows
            float weightThrustSpeed  = thrustSpeed * weights.ThrustSpeed;
            float weightWeaponLength = weaponLength * weights.WeaponLength;
            float weightWeaponWeight = weaponWeight * weights.WeaponWeight;

            float sum   = 0.0f;
            float value = 0.0f;

            switch (primaryWeaponItem.WeaponClass)
            {
            case WeaponClass.SmallShield:
            case WeaponClass.LargeShield:
                // Weight, HitPoints
                sum   = Math.Abs(filterWeapon.MaxDataValue) + Math.Abs(filterWeapon.WeaponWeight);
                value = weightMaxDataValue + weightWeaponWeight;

#if DEBUG
                InformationManager.DisplayMessage(new InformationMessage("Shield"));
#endif
                break;

            case WeaponClass.Crossbow:
            case WeaponClass.Bow:
                // Weight, Thrust Damage, Accuracy, Missile Speed
                sum = Math.Abs(filterWeapon.WeaponWeight) +
                      Math.Abs(filterWeapon.ThrustDamage) +
                      Math.Abs(filterWeapon.Accuracy) +
                      Math.Abs(filterWeapon.MissileSpeed);
                value = weightWeaponWeight + weightThrustDamage + weightAccuracy + weightMissileSpeed;

#if DEBUG
                InformationManager.DisplayMessage(new InformationMessage("Shield"));
#endif
                break;

            case WeaponClass.Javelin:
            case WeaponClass.ThrowingAxe:
            case WeaponClass.ThrowingKnife:
                // Weight, Length, Thrust Damage, Missile Speed, Accuracy, MaxDataValue (Stack Amount)
                sum = Math.Abs(filterWeapon.WeaponWeight) +
                      Math.Abs(filterWeapon.WeaponLength) +
                      Math.Abs(filterWeapon.ThrustDamage) +
                      Math.Abs(filterWeapon.MissileSpeed) +
                      Math.Abs(filterWeapon.Accuracy) +
                      Math.Abs(filterWeapon.MaxDataValue);
                value = weightWeaponWeight +
                        weightWeaponLength +
                        weightThrustDamage +
                        weightMissileSpeed +
                        weightAccuracy +
                        weightMaxDataValue;

#if DEBUG
                InformationManager.DisplayMessage(new InformationMessage("Javelin/Throwing Axe/Throwing Knife"));
#endif
                break;

            case WeaponClass.OneHandedSword:
            case WeaponClass.TwoHandedSword:
            case WeaponClass.LowGripPolearm:
            case WeaponClass.OneHandedPolearm:
            case WeaponClass.TwoHandedPolearm:
                // Weight, Length, Handling, Swing Speed, Swing Damage, Thrust Speed, Thrust Damage
                sum = Math.Abs(filterWeapon.WeaponWeight) +
                      Math.Abs(filterWeapon.WeaponLength) +
                      Math.Abs(filterWeapon.Handling) +
                      Math.Abs(filterWeapon.SwingSpeed) +
                      Math.Abs(filterWeapon.SwingDamage) +
                      Math.Abs(filterWeapon.ThrustSpeed) +
                      Math.Abs(filterWeapon.ThrustDamage);
                value = weightWeaponWeight +
                        weightWeaponLength +
                        weightHandling +
                        weightSwingSpeed +
                        weightSwingDamage +
                        weightThrustSpeed +
                        weightThrustDamage;

#if DEBUG
                if (primaryWeaponItem.WeaponClass >= WeaponClass.OneHandedPolearm &&
                    primaryWeaponItem.WeaponClass <= WeaponClass.LowGripPolearm)
                {
                    InformationManager.DisplayMessage(new InformationMessage("Low Grip/One Handed/Two Handed Polearm"));
                }
                else
                {
                    InformationManager.DisplayMessage(new InformationMessage("One Handed/Two Handed Sword"));
                }
#endif
                break;

            case WeaponClass.OneHandedAxe:
            case WeaponClass.TwoHandedAxe:
            case WeaponClass.Mace:
            case WeaponClass.TwoHandedMace:
                // Weight, Swing Speed, Swing Damage, Length, Handling
                sum = Math.Abs(filterWeapon.WeaponWeight) +
                      Math.Abs(filterWeapon.SwingSpeed) +
                      Math.Abs(filterWeapon.SwingDamage) +
                      Math.Abs(filterWeapon.WeaponLength) +
                      Math.Abs(filterWeapon.Handling);
                value = weightWeaponWeight +
                        weightSwingSpeed +
                        weightSwingDamage +
                        weightWeaponLength +
                        weightHandling;
#if DEBUG
                if (primaryWeaponItem.WeaponClass >= WeaponClass.OneHandedAxe &&
                    primaryWeaponItem.WeaponClass <= WeaponClass.TwoHandedAxe)
                {
                    InformationManager.DisplayMessage(new InformationMessage("One Handed/Two Handed Axe"));
                }
                else
                {
                    InformationManager.DisplayMessage(new InformationMessage("One Handed/Two Handed Mace"));
                }
#endif
                break;

            case WeaponClass.Arrow:
            case WeaponClass.Bolt:
                // Weight, Accuracy, Missile (Thrust) Damage, Stack Amount (MaxDataPoints)
                sum = Math.Abs(filterWeapon.WeaponWeight) +
                      Math.Abs(filterWeapon.Accuracy) +
                      Math.Abs(filterWeapon.ThrustDamage) +
                      Math.Abs(filterWeapon.MaxDataValue);
                value = weightWeaponWeight +
                        weightAccuracy +
                        weightThrustDamage +
                        weightMaxDataValue;
#if DEBUG
                InformationManager.DisplayMessage(new InformationMessage("Arrows/Bolts"));
#endif
                break;

            default:
                sum =
                    Math.Abs(filterWeapon.Accuracy) +
                    Math.Abs(filterWeapon.WeaponBodyArmor) +
                    Math.Abs(filterWeapon.Handling) +
                    Math.Abs(filterWeapon.MaxDataValue) +
                    Math.Abs(filterWeapon.MissileSpeed) +
                    Math.Abs(filterWeapon.SwingDamage) +
                    Math.Abs(filterWeapon.SwingSpeed) +
                    Math.Abs(filterWeapon.ThrustDamage) +
                    Math.Abs(filterWeapon.ThrustSpeed) +
                    Math.Abs(filterWeapon.WeaponLength) +
                    Math.Abs(filterWeapon.WeaponWeight);
                value = weightAccuracy +
                        weightBodyArmor +
                        weightHandling +
                        weightMaxDataValue +
                        weightMissileSpeed +
                        weightSwingDamage +
                        weightSwingSpeed +
                        weightThrustDamage +
                        weightThrustSpeed +
                        weightWeaponLength +
                        weightWeaponWeight;
#if DEBUG
                InformationManager.DisplayMessage(new InformationMessage("Other"));
#endif
                break;
            }

            float finalValue = value / sum;

#if DEBUG
            InformationManager.DisplayMessage(new InformationMessage(String.Format("{0}: Acc {1}, BA {2}, HL {3}, HP {4}, MS {5}, SD {6}, SS {7}, TD {8}, TS {9}, WL {10}, W {11}",
                                                                                   sourceItem.Item.Name, accuracy, bodyArmor, handling, maxDataValue, missileSpeed, swingDamage, swingSpeed, thrustDamage, thrustSpeed, weaponLength, weaponWeight)));

            InformationManager.DisplayMessage(new InformationMessage("Total score: " + finalValue));
#endif

            return(finalValue);
        }
Example #23
0
 public void Read(WorldPacket data)
 {
     Value = data.ReadUInt32();
     Type  = (ItemModifier)data.ReadUInt8();
 }
Example #24
0
        /// <summary>
        /// Returns value for armor using its properties and filter settings
        /// </summary>
        /// <param name="sourceItem">Armor item</param>
        /// <param name="slot">Armor equipment slot</param>
        /// <returns>calculated value for armor</returns>
        public float CalculateArmorValue(EquipmentElement sourceItem, FilterArmorSettings filterArmor)
        {
            ArmorComponent armorComponentItem = sourceItem.Item.ArmorComponent;

            float sum =
                Math.Abs(filterArmor.HeadArmor) +
                Math.Abs(filterArmor.ArmArmor) +
                Math.Abs(filterArmor.ArmorBodyArmor) +
                Math.Abs(filterArmor.ArmorWeight) +
                Math.Abs(filterArmor.LegArmor);

            ItemModifier mod = sourceItem.ItemModifier;

            int HeadArmor = armorComponentItem.HeadArmor,
                BodyArmor = armorComponentItem.BodyArmor,
                LegArmor  = armorComponentItem.LegArmor,
                ArmArmor  = armorComponentItem.ArmArmor;
            float Weight  = sourceItem.Weight;

            if (mod != null)
            {
                // Since armor values are positive numbers, we need to check
                // if the given values have positive number before we apply
                // any modifiers to it.
                if (HeadArmor > 0f)
                {
                    HeadArmor = mod.ModifyArmor(HeadArmor);
                }
                if (BodyArmor > 0f)
                {
                    BodyArmor = mod.ModifyArmor(BodyArmor);
                }
                if (LegArmor > 0f)
                {
                    LegArmor = mod.ModifyArmor(LegArmor);
                }
                if (ArmArmor > 0f)
                {
                    ArmArmor = mod.ModifyArmor(ArmArmor);
                }
                //Weight *= mod.WeightMultiplier;

                HeadArmor = HeadArmor < 0 ? 0 : HeadArmor;
                BodyArmor = BodyArmor < 0 ? 0 : BodyArmor;
                LegArmor  = LegArmor < 0 ? 0 : LegArmor;
                ArmArmor  = ArmArmor < 0 ? 0 : ArmArmor;
            }

            float value = (
                HeadArmor * filterArmor.HeadArmor +
                BodyArmor * filterArmor.ArmorBodyArmor +
                LegArmor * filterArmor.LegArmor +
                ArmArmor * filterArmor.ArmArmor +
                Weight * filterArmor.ArmorWeight
                ) / sum;

#if DEBUG
            InformationManager.DisplayMessage(new InformationMessage(String.Format("{0}: HA {1}, BA {2}, LA {3}, AA {4}, W {5}",
                                                                                   sourceItem.Item.Name, HeadArmor, BodyArmor, LegArmor, ArmArmor, Weight)));

            InformationManager.DisplayMessage(new InformationMessage("Total score: " + value));
#endif
            return(value);
        }
Example #25
0
 public ItemMod()
 {
     Type = ItemModifier.Max;
 }
Example #26
0
 public ItemMod(uint value, ItemModifier type)
 {
     Value = value;
     Type  = type;
 }
Example #27
0
        public async Task <ActionResult <ItemModifierDTO> > AddNewItemModifier(int storeId, int itemId, ItemModifier itemModifier)
        {
            var result = await itemRepository.AddNewItemModifier(itemId, itemModifier);

            return(result);
        }
Example #28
0
 public SummoningMastery(MasteryData data, ItemModifier modifier) : base(data, modifier)
 {
 }
Example #29
0
        public static ItemObject GenerateTournamentPrize(TournamentGame tournamentGame, TournamentPrizePool currentPool = null, bool keepTownPrize = true)
        {
            var  numItemsToGet   = TournamentXPSettings.Instance.NumberOfPrizeOptions;
            bool bRegenAllPrizes = false;

            if (currentPool == null)
            {
                bRegenAllPrizes = true;
                currentPool     = GetTournamentPrizePool(tournamentGame.Town.Settlement);
            }
            var allitems = GetItemStringsRevised(tournamentGame, TournamentPrizePoolBehavior.GetActivePrizeTypes());

            //Add any existing items if we are filling in missing ones from an already generated pool
            var pickeditems = new List <string>();

            if (keepTownPrize && !string.IsNullOrWhiteSpace((tournamentGame.Prize.StringId)))
            {
                pickeditems.Add(tournamentGame.Prize.StringId);
                currentPool.SelectedPrizeStringId = tournamentGame.Prize.StringId;
            }
            try
            {
                if (!bRegenAllPrizes)
                {
                    foreach (ItemRosterElement existingPrize in currentPool.Prizes)
                    {
                        if (!pickeditems.Contains(existingPrize.EquipmentElement.Item.StringId))
                        {
                            pickeditems.Add(existingPrize.EquipmentElement.Item.StringId);
                        }

                        if (allitems.Contains(existingPrize.EquipmentElement.Item.StringId))
                        {
                            allitems.Remove(existingPrize.EquipmentElement.Item.StringId);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Log("ERROR: GetTournamentPrize existingprizes\n" + ex.ToStringFull());
            }

            //If the totoal pool of unique items is less than our desired number, reduce our pool size.
            if (allitems.Count() < numItemsToGet)
            {
                numItemsToGet = allitems.Count();
            }

            while (pickeditems.Count < numItemsToGet && allitems.Count() > 0)
            {
                var randomId = allitems.GetRandomElement <string>();

                if (!pickeditems.Contains(randomId))
                {
                    pickeditems.Add(randomId);
                    allitems.Remove(randomId);
                }
            }
            currentPool.Prizes = new ItemRoster();
            foreach (var id in pickeditems)
            {
                ItemModifier itemModifier = null;
                var          pickedPrize  = Game.Current.ObjectManager.GetObject <ItemObject>(id);
#if VERSION120
                if (TournamentXPSettings.Instance.EnableItemModifiersForPrizes)
                {
                    //var ee = GetEquipmentWithModifier(pickedPrize, TournamentPrizePoolBehavior.GetProsperityModifier(tournamentGame.Town.Settlement));
                    if (MBRandom.RandomFloatRanged(100f) < 50f)
                    {
                        var ee = GetEquipmentWithModifier(pickedPrize, 1.3f);
                        itemModifier = ee.ItemModifier;
                    }
                }
#endif
                currentPool.Prizes.Add(new ItemRosterElement(pickedPrize, 1, itemModifier));
                // currentPool.Prizes.Add(new ItemRosterElement(pickedPrize, 1, null)); //Turn off random item mods for now;
            }

            if (!keepTownPrize)
            {
                var selected = currentPool.Prizes.GetRandomElement <ItemRosterElement>();
                currentPool.SelectedPrizeStringId = selected.EquipmentElement.Item.StringId;
                SetTournamentSelectedPrize(tournamentGame, selected.EquipmentElement.Item);
            }
            return(currentPool.SelectPrizeItemRosterElement.EquipmentElement.Item);
        }
Example #30
0
 public WeaponMastery(MasteryData data, ItemModifier modifier) : base(data, modifier)
 {
 }
Example #31
0
        public static ItemObject GenerateTournamentPrize(TournamentGame tournamentGame, TournamentPrizePool currentPool = null, bool keepTownPrize = true)
        {
            var  numItemsToGet   = TournamentXPSettings.Instance.NumberOfPrizeOptions;
            bool bRegenAllPrizes = false;

            if (currentPool == null)
            {
                bRegenAllPrizes = true;
                currentPool     = GetTournamentPrizePool(tournamentGame.Town.Settlement);
            }
            var allitems = GetItemStringsRevised(tournamentGame, TournamentPrizePoolBehavior.GetActivePrizeTypes());

            if (allitems.Count == 0)
            {
                MessageBox.Show("TournamentsXPanded Error:\nAlert, your prize generation filters have resulted in no valid prizes.  Consider widening your prize value range and if you are using a custom list make sure it's loaded correctly.");
                return(null);
            }

            //Add any existing items if we are filling in missing ones from an already generated pool
            var pickeditems = new List <string>();

            if (keepTownPrize && !string.IsNullOrWhiteSpace((tournamentGame.Prize.StringId)))
            {
                pickeditems.Add(tournamentGame.Prize.StringId);
                currentPool.SelectedPrizeStringId = tournamentGame.Prize.StringId;
            }
            try
            {
                if (!bRegenAllPrizes)
                {
                    foreach (ItemRosterElement existingPrize in currentPool.Prizes)
                    {
                        if (!pickeditems.Contains(existingPrize.EquipmentElement.Item.StringId))
                        {
                            pickeditems.Add(existingPrize.EquipmentElement.Item.StringId);
                        }

                        if (allitems.Contains(existingPrize.EquipmentElement.Item.StringId))
                        {
                            allitems.Remove(existingPrize.EquipmentElement.Item.StringId);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Log("ERROR: GetTournamentPrize existingprizes\n" + ex.ToStringFull());
            }

            //If the totoal pool of unique items is less than our desired number, reduce our pool size.
            if (allitems.Count() < numItemsToGet)
            {
                numItemsToGet = allitems.Count();
            }

            while (pickeditems.Count < numItemsToGet && allitems.Count() > 0)
            {
                var randomId = allitems.GetRandomElement <string>();

                if (!pickeditems.Contains(randomId))
                {
                    pickeditems.Add(randomId);
                    allitems.Remove(randomId);
                }
            }
            currentPool.Prizes = new ItemRoster();
            foreach (var id in pickeditems)
            {
                ItemModifier itemModifier = null;
                ItemObject   pickedPrize  = null;
                try
                {
                    pickedPrize = Game.Current.ObjectManager.GetObject <ItemObject>(id);
                }
                catch (Exception ex)
                {
                    ErrorLog.Log("Error getting object StringId: " + id + "\n" + ex.ToStringFull());
                }

                if (pickedPrize != null)
                {
#if VERSION120 || VERSION130
                    if (TournamentXPSettings.Instance.EnableItemModifiersForPrizes && pickedPrize.ItemType != ItemObject.ItemTypeEnum.Thrown && pickedPrize.ItemType != ItemObject.ItemTypeEnum.Arrows)
                    {
                        try
                        {
                            if (MBRandom.RandomFloatRanged(100f) < 50f)
                            {
                                var ee = GetEquipmentWithModifier(pickedPrize, TournamentPrizePoolBehavior.GetProsperityModifier(tournamentGame.Town.Settlement));
                                itemModifier = ee.ItemModifier;
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorLog.Log("Error in GetEquipmentWithModifier\nItem:" + pickedPrize.StringId + "\n" + ex.ToStringFull());
                        }
                    }
#endif
                    try
                    {
                        currentPool.Prizes.Add(new ItemRosterElement(pickedPrize, 1, itemModifier));
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Log("Error adding equipment to prizepool.\n" + ex.ToStringFull());
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Item detected.  Please remove: " + id + " from your list of custom items. Ignoring this item and continuing.");
                }
            }

            if (!keepTownPrize)
            {
                var selected = currentPool.Prizes.GetRandomElement <ItemRosterElement>();
                currentPool.SelectedPrizeStringId = selected.EquipmentElement.Item.StringId;
                SetTournamentSelectedPrize(tournamentGame, selected.EquipmentElement.Item);
            }
            return(currentPool.SelectPrizeItemRosterElement.EquipmentElement.Item);
        }