Beispiel #1
0
        private IList <GetItemQueryResponse> OrderItems()
        {
            var items = this.Items;

            var euquipetItems = items.Where(x => x.ItemType != "Empty").Count();

            if (euquipetItems == 0)
            {
                return(items.Where(x => x.ItemType != "Empty").ToList());
            }

            var emptyItem = new GetItemQueryResponse();

            if (euquipetItems != 0 && items.Count > 9)
            {
                emptyItem = items.FirstOrDefault(x => x.ItemType == "Empty");

                items.Remove(emptyItem);
            }
            else
            {
                for (var i = 0; i < 9 - euquipetItems; i++)
                {
                    if (items.Count == 9)
                    {
                        break;
                    }

                    items.Add(emptyItem);
                }
            }

            var gearItemsPosition = new List <string>()
            {
                "Empty", "Head", "Empty",
                "Sword", "Chest", "Shield",
                "Empty", "Boots", "Empty",
            };

            for (var i = 0; i < 9; i++)
            {
                var temp = items.FirstOrDefault(x => x.ItemType == gearItemsPosition[i]);

                if (temp == null)
                {
                    continue;
                }

                var currItem = items.IndexOf(temp);
                items[currItem] = items[i];
                items[i]        = temp;
            }

            return(items);
        }
Beispiel #2
0
        public GetItemQueryResponse AddItem(GetItemQueryResponse item)
        {
            var existsSecondItem = this.Gear.FirstOrDefault(x => x.ItemType == item.ItemType && x.Id != item.Id);

            this.Gear.Add(item);
            if (existsSecondItem != null)
            {
                this.Gear.Remove(existsSecondItem);

                return(existsSecondItem);
            }
            // TODO: Repair default
            return(default);