public void TestRemoveHalfStack()
        {
            const long oid = 456499611;
            long       id;
            {
                var item = new PlayerItem {
                    BaseRecord       = "for-testing-item-halfstack-removal",
                    Mod              = string.Empty,
                    MinimumLevel     = 200,
                    LevelRequirement = 200,
                    StackCount       = 30,
                    OnlineId         = oid
                };
                dao.Save(item);


                item.Id.Should().Be.GreaterThan(0);
                id = item.Id;
            }


            // Reduce to 15
            {
                var reloaded = dao.GetByOnlineId(oid);
                reloaded.Id.Should().Be.EqualTo(id);
                reloaded.StackCount = 15;
                dao.Update(new List <PlayerItem> {
                    reloaded
                }, true);
            }


            // Ensure the online ID has been cleared
            {
                var reloaded = dao.GetByOnlineId(oid);
                reloaded.Should().Be.Null();
            }

            // Ensure the item still exists
            {
                var reloaded = dao.GetById(id);
                reloaded.Should().Not.Be.Null();
                reloaded.Count.Should().Be.EqualTo(15);
            }

            // Ensure the old OID is marked for removal
            var deletionEntry = dao.GetItemsMarkedForOnlineDeletion().FirstOrDefault(m => m.OID == oid);

            deletionEntry.Should().Not.Be.Null();
        }
Exemple #2
0
        List <PlayerItem> GetItemsForTransfer(StashTransferEventArgs args)
        {
            List <PlayerItem> items = new List <PlayerItem>();

            // Detect the record type (long or string) and add the item(s)
            if (args.HasValidId)
            {
                var pid = args.PlayerItemId;
                if (pid.HasValue)
                {
                    var item = _dao.GetById(pid.Value);
                    items.Add(item);
                }
                else
                {
                    IList <PlayerItem> tmp = _dao.GetByRecord(args.Prefix, args.BaseRecord, args.Suffix, args.Materia, args.Mod, args.IsHardcore);
                    if (tmp.Count > 0)
                    {
                        if (!args.TransferAll)
                        {
                            Logger.Warn("Error transferring item, transfer all was false, but no player item id was located.");
                        }
                        else
                        {
                            items.AddRange(tmp);
                        }
                    }
                }
            }

            if (items.Contains(null))
            {
                Logger.Warn("Attempted to transfer NULL item.");

                var message = RuntimeSettings.Language.GetTag("iatag_feedback_item_does_not_exist");
                _setFeedback(message);
                _browser.ShowMessage(message, UserFeedbackLevel.Danger);

                return(null);
            }

            return(items);
        }
Exemple #3
0
        List <PlayerItem> GetItemsForTransfer(StashTransferEventArgs args)
        {
            List <PlayerItem> items = new List <PlayerItem>();

            // Detect the record type (long or string) and add the item(s)
            if (args.Id != null && args.Id > 0)
            {
                items.Add(_dao.GetById(args.Id.Value));
            }
            else if (args.HasValidId)
            {
                IList <PlayerItem> tmp = _dao.GetByRecord(args.Prefix, args.BaseRecord, args.Suffix, args.Materia);
                if (tmp.Count > 0)
                {
                    if (args.Count == 1)
                    {
                        items.Add(tmp[0]);
                    }
                    else
                    {
                        items.AddRange(tmp);
                    }
                }
            }


            if (items.Contains(null))
            {
                Logger.Warn("Attempted to transfer NULL item.");

                var message = GlobalSettings.Language.GetTag("iatag_feedback_item_does_not_exist");
                _setFeedback(GlobalSettings.Language.GetTag("iatag_feedback_item_does_not_exist"));
                //
                //
                _browser.ShowMessage(message, "Error");

                return(null);
            }

            return(items);
        }