コード例 #1
0
ファイル: ExportArgs.cs プロジェクト: ewin66/Arya
        public IEnumerable <Sku> GetFilteredSkuList(IEnumerable <Sku> skus)
        {
            var skuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions);

            foreach (var filter in skuInclusions)
            {
                var attribute = filter.Key;

                skus = filter.Value.Count == 0
                    ? skus.Where(sku => sku.HasAttribute(attribute))
                    : filter.Value.Aggregate(skus,
                                             (current, value) => current.Where(sku => sku.HasValue(attribute, value)));
            }

            var skuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions);

            foreach (var exclusion in skuExclusions)
            {
                var attribute = exclusion.Key;

                skus = exclusion.Value.Count == 0
                    ? skus.Where(sku => !sku.HasAttribute(attribute))
                    : exclusion.Value.Aggregate(skus,
                                                (current, value) => current.Where(sku => !sku.HasValue(attribute, value)));
            }

            if (ItemIds != null && ItemIds.Length > 0)
            {
                skus = skus.Where(sku => ItemIds.Contains(sku.ItemID));
            }
            return(skus);
        }
コード例 #2
0
ファイル: Model.cs プロジェクト: kenta-suzuki/okaeri
 /// <summary>
 /// アイテムを削除する処理
 /// </summary>
 public void RemoveItemId(int itemId)
 {
     if (ItemIds.Contains(itemId))
     {
         return;
     }
     ItemIds.Remove(itemId);
 }
コード例 #3
0
ファイル: Model.cs プロジェクト: kenta-suzuki/okaeri
 /// <summary>
 /// アイテムを追加する処理
 /// </summary>
 public void AddItemId(int itemId)
 {
     if (ItemIds.Contains(itemId))
     {
         return;
     }
     ItemIds.Add(itemId);
 }
コード例 #4
0
        public void AskUserItemChoice()
        {
            Console.WriteLine();
            Console.WriteLine("Please write ID to view the item");
            ItemId = GeneralStaticClass.ReadIntNumber();

            while (!ItemIds.Contains(ItemId))
            {
                Console.WriteLine("Invalid choice");
                ItemId = GeneralStaticClass.ReadIntNumber();
            }
        }
コード例 #5
0
        private async Task LowerItemQuality()
        {
            if (_isDone)
            {
                await Coroutine.Yield();

                return;
            }

            List <BagSlot> bagSlots = IgnoreGear ? InventoryManager.FilledSlots.ToList() : InventoryManager.FilledSlots.Where(x => x.Item.StackSize == 999).ToList();

            List <uint> toLower;

            if (AllItems && ForceLower)
            {
                toLower = bagSlots.Where(x => x.IsHighQuality).Select(x => x.RawItemId).ToList();
            }
            else if (AllItems)
            {
                var HQ = bagSlots.Where(x => x.IsHighQuality).Select(x => x.RawItemId).OrderBy(x => x);
                var NQ = bagSlots.Where(x => !x.IsHighQuality).Select(x => x.RawItemId).OrderBy(x => x);
                toLower = NQ.Intersect(HQ).ToList();
            }
            else if (ForceLower)
            {
                toLower = ItemIds.Select(x => (uint)x).ToList();
            }
            else
            {
                var slotsWithId = bagSlots.Where(x => ItemIds.Contains((int)x.RawItemId)).ToList();
                var HQ          = slotsWithId.Where(x => x.IsHighQuality).Select(x => x.RawItemId).OrderBy(x => x);
                var NQ          = slotsWithId.Where(x => !x.IsHighQuality).Select(x => x.RawItemId).OrderBy(x => x);
                toLower = NQ.Intersect(HQ).ToList();
            }

            if (!toLower.Any())
            {
                _isDone = true;
                return;
            }

            await StopBusy(leaveDuty : false, dismount : false);

            foreach (var itemId in toLower)
            {
                await LowerQualityAndCombine((int)itemId);

                await Coroutine.Sleep(200);
            }

            _isDone = true;
        }
コード例 #6
0
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var pages = new PageService(new RockContext()).Queryable().Where(p => ItemIds.Contains(p.Id.ToString()));

            this.SetValues(pages);
        }
コード例 #7
0
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var metricCategories = new MetricCategoryService(new RockContext()).Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(metricCategories);
        }
コード例 #8
0
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var registrationTemplates = new RegistrationTemplateService(new RockContext()).Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(registrationTemplates);
        }
コード例 #9
0
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var workflowTypes = new WorkflowTypeService(new RockContext()).Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(workflowTypes);
        }
コード例 #10
0
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var schedules = new ScheduleService(new RockContext()).Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(schedules);
        }
コード例 #11
0
ファイル: GroupPicker.cs プロジェクト: shelsonjava/Rock
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var groups = new GroupService().Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(groups);
        }
コード例 #12
0
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var reports = new ReportService(new RockContext()).Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(reports);
        }
コード例 #13
0
ファイル: DataViewItemPicker.cs プロジェクト: ewin66/rockrms
        /// <summary>
        /// Sets the values on select.
        /// </summary>
        protected override void SetValuesOnSelect()
        {
            var dataViews = new DataViewService(new RockContext()).Queryable().Where(g => ItemIds.Contains(g.Id.ToString()));

            this.SetValues(dataViews);
        }
コード例 #14
0
ファイル: ItemMessages.cs プロジェクト: indij/KatanaMUD
        public override void Process(Actor actor)
        {
            if (Quantity < 0)
            {
                actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = "Cannot give negative items."
                });
                return;
            }

            IEnumerable <Actor> receivers;

            if (ActorId != null)
            {
                receivers = actor.Room.ActiveActors.Where(x => x.Id == ActorId.Value);
            }
            else
            {
                receivers = actor.Room.ActiveActors.FindActorsByName(ActorName, true).ToList();
            }
            if (!receivers.Any())
            {
                actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = "Cannot find player!"
                });
                return;
            }
            if (receivers.Count() > 1)
            {
                actor.SendMessage(new AmbiguousActorMessage()
                {
                    Actors = receivers.Select(x => new ActorDescription(x)).ToArray()
                });
                return;
            }
            var receiver = receivers.First();

            IEnumerable <IItem> items;

            if (ItemIds != null && ItemIds.Any())
            {
                items = actor.Items.Where(x => ItemIds.Contains(x.Id));
            }
            else
            {
                var availableCurrencies = Game.Data.AllCurrencies.Where(x => Currency.Get(x, actor.Cash) > 0).ToList();
                items = GetItemCommand.FindItems(availableCurrencies, actor.Items.ToList(), ItemName);
            }
            if (items.Count() > 1)
            {
                actor.SendMessage(new AmbiguousItemMessage()
                {
                    Items = items.Select(x => new ItemDescription(x)).ToArray()
                });
                return;
            }
            if (!items.Any())
            {
                actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = "Cannot find item!"
                });
                return;
            }

            // Handle a cash give.
            if (items.First() is Currency)
            {
                var currency = items.First() as Currency;
                if (Quantity == 0)
                {
                    // In the event that no number is specified (ie 0), then we assume the user
                    // wants to drop all currency. So, we oblige them.
                    // TODO: see if this is a correct assumption. Could be dangerous?
                    Quantity = (int)Currency.Get(currency, actor.Cash);
                }

                var action = actor.CanRemoveCash(currency, Quantity);
                if (!action.Allowed)
                {
                    actor.SendMessage(new ActionNotAllowedMessage()
                    {
                        Message = action.FirstPerson
                    });
                    return;
                }
                action = receiver.CanAcceptCash(currency, Quantity);
                if (!action.Allowed)
                {
                    actor.SendMessage(new ActionNotAllowedMessage()
                    {
                        Message = action.ThirdPerson
                    });
                    return;
                }

                var quantity = actor.RemoveCash(currency, Quantity);
                receiver.AcceptCash(currency, quantity);

                var message = new CashTransferMessage()
                {
                    Giver    = new ActorDescription(actor),
                    Taker    = new ActorDescription(receiver),
                    Currency = new CurrencyDescription(currency, quantity)
                };

                actor.Room.ActiveActors.ForEach(x => x.SendMessage(message));
                return;
            }

            // Handle a regular give
            Quantity = Math.Max(Quantity, 1);   // 0 is valid in the event that no number is specified. In that instance, we assume 1 instead.

            IEnumerable <Item> finalItems;

            if (items.First() is ItemGroup)
            {
                finalItems = (items.First() as ItemGroup).Items.Take(Quantity);
            }
            else
            {
                finalItems = items.Cast <Item>();
            }

            List <Item>   successes = new List <Item>();
            List <string> failures  = new List <string>();

            foreach (var item in finalItems)
            {
                var give = actor.CanRemoveItem(item);
                var take = receiver.CanAcceptItem(item);

                if (give.Allowed && take.Allowed)
                {
                    actor.RemoveItem(item);
                    receiver.AcceptItem(item);
                    successes.Add(item);
                }

                if (!give.Allowed)
                {
                    failures.Add(give.FirstPerson);
                }
                if (!take.Allowed)
                {
                    failures.Add(take.ThirdPerson);
                }
            }

            if (successes.Any())
            {
                var message = new ItemOwnershipMessage()
                {
                    Giver = new ActorDescription(actor),
                    Taker = new ActorDescription(receiver),
                    Items = successes.Select(x => new ItemDescription(x)).ToArray(),
                };

                actor.Room.ActiveActors.ForEach(x => x.SendMessage(message));
            }
            if (failures.Any())
            {
                failures.Distinct().ForEach(x => actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = x
                }));
            }
        }
コード例 #15
0
ファイル: ItemMessages.cs プロジェクト: indij/KatanaMUD
        public override void Process(Actor actor)
        {
            if (Quantity < 0)
            {
                actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = "Cannot drop negative items."
                });
                return;
            }

            IEnumerable <IItem> items;

            if (ItemIds != null && ItemIds.Any())
            {
                items = actor.Items.Where(x => ItemIds.Contains(x.Id));
            }
            else
            {
                var availableCurrencies = Game.Data.AllCurrencies.Where(x => Currency.Get(x, actor.Cash) > 0).ToList();
                items = GetItemCommand.FindItems(availableCurrencies, actor.Items.ToList(), ItemName);
            }

            if (items.Count() > 1)
            {
                actor.SendMessage(new AmbiguousItemMessage()
                {
                    Items = items.Select(x => new ItemDescription(x)).ToArray()
                });
                return;
            }

            if (!items.Any())
            {
                actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = "Cannot find item!"
                });
                return;
            }

            // Handle a cash drop.
            if (items.First() is Currency)
            {
                var currency = items.First() as Currency;
                if (Quantity == 0)
                {
                    // In the event that no number is specified (ie 0), then we assume the user
                    // wants to drop all currency. So, we oblige them.
                    // TODO: see if this is a correct assumption. Could be dangerous?
                    Quantity = (int)Currency.Get(currency, actor.Cash);
                }

                var action = actor.CanDropCash(currency, Quantity, Hide);
                if (action.Allowed)
                {
                    actor.DropCash(currency, Quantity, Hide);

                    var message = new CashTransferMessage()
                    {
                        Giver    = new ActorDescription(actor),
                        Currency = new CurrencyDescription(currency, Quantity),
                        Hide     = Hide
                    };

                    if (Hide == false)
                    {
                        // let the actors in the room know, but only if it's not being hidden.
                        actor.Room.ActiveActors.Where(x => x != actor).ForEach(x => x.SendMessage(message));
                    }
                    actor.SendMessage(message);
                }
                else
                {
                    actor.SendMessage(new ActionNotAllowedMessage()
                    {
                        Message = action.FirstPerson
                    });
                }
                return;
            }

            // Handle a regular drop
            Quantity = Math.Max(Quantity, 1);   // 0 is valid in the event that no number is specified. In that instance, we assume 1 instead.

            IEnumerable <Item> finalItems;

            if (items.First() is ItemGroup)
            {
                finalItems = (items.First() as ItemGroup).Items.Take(Quantity);
            }
            else
            {
                finalItems = items.Cast <Item>();
            }

            List <Item>   successes = new List <Item>();
            List <string> failures  = new List <string>();

            foreach (var item in finalItems)
            {
                var action = actor.CanDropItem(item, Hide);

                if (action.Allowed)
                {
                    actor.DropItem(item, Hide);
                    successes.Add(item);
                }
                else
                {
                    failures.Add(action.FirstPerson);
                }
            }

            if (successes.Any())
            {
                var message = new ItemOwnershipMessage()
                {
                    Giver = new ActorDescription(actor),
                    Items = successes.Select(x => new ItemDescription(x)).ToArray(),
                    Hide  = Hide
                };

                if (Hide == false)
                {
                    actor.Room.ActiveActors.ForEach(x => x.SendMessage(message));
                }
                else
                {
                    actor.SendMessage(message);
                }
            }
            if (failures.Any())
            {
                failures.Distinct().ForEach(x => actor.SendMessage(new ActionNotAllowedMessage()
                {
                    Message = x
                }));
            }
        }