Ejemplo n.º 1
0
        private bool DoesSingleItemBreakFloor(IRTG item, List <IRTG> floor)
        {
            bool broken = false;

            if (item.GetType() == typeof(RTGChip))
            {
                if (FloorContainsReactor(floor))
                {
                    List <RTG> reactors = floor.Where(r => r.GetType() == typeof(RTG)).Select(x => (RTG)x).ToList();

                    //if any reactor has a matching element we're fine
                    if (reactors.Any(x => x.element == item.GetElement()))
                    {
                        broken = false;
                    }
                    else
                    {
                        broken = true;
                    }
                }
                else
                {
                    broken = false;
                }
            }
            else if (item.GetType() == typeof(RTG))
            {
                if (FloorContainsChip(floor))
                {
                    List <RTGChip> chips = floor.Where(r => r.GetType() == typeof(RTGChip)).Select(x => (RTGChip)x).ToList();

                    //if any chip has a matching element we're fine
                    if (chips.Any(x => x.element == item.GetElement()))
                    {
                        broken = false;
                    }
                    else
                    {
                        broken = true;
                    }
                }
                else
                {
                    broken = false;
                }
            }

            return(!broken);
        }
Ejemplo n.º 2
0
        private IRTG[] GetFloorItems(int floorNumber, int destinationFloor)
        {
            List <IRTG> floor = GetFloor(floorNumber);

            IRTG[] items = null;

            //attempt to take a reactor chip combo up
            List <string> elements = floor.Select(x => x.element).Distinct().ToList();

            foreach (string element in elements)
            {
                var possibleitems = floor.Where(x => x.element == element);

                if (possibleitems.Count() > 1)
                {
                    items = possibleitems.ToArray();
                    break;
                }
            }

            if (items == null)
            {
                //if none available, take 2 things
                List <IRTG> remaining = floor.Where(item => floor.Count(x => x.element == item.element) < 2).ToList();

                IRTG firstItem = floor.FirstOrDefault();

                if (firstItem != null)
                {
                    Type itemType = firstItem.GetType();

                    if (remaining.Any(x => x.GetType() == itemType))
                    {
                        items = new IRTG[] { firstItem, remaining.Where(x => x.GetType() == itemType).First() };
                    }

                    if (items == null)
                    {
                        //if we can't take 1 thing
                        items = new IRTG[] { firstItem };
                    }
                }
            }
            return(items);
        }