示例#1
0
        public void TestAllSlotsHoldsEverySlot()
        {
            ISlotContentObserver observer = new FakeSlotContentObserver();
            SlotContentHistory   history  = new SlotContentHistory(observer);
            AllSlots             sut      = new AllSlots(history);

            List <SlotContent> blueSlots = new List <SlotContent>()
            {
                SlotContent.Empty, SlotContent.Empty, SlotContent.Bot, SlotContent.Player, SlotContent.Empty,
                SlotContent.Empty
            };
            List <SlotContent> redSlots = new List <SlotContent>()
            {
                SlotContent.Bot, SlotContent.Bot, SlotContent.Bot, SlotContent.Player, SlotContent.Player, SlotContent.Empty
            };

            history.Update();

            List <int> blueResult = sut.Slots(Team.Blue);
            List <int> redResult  = sut.Slots(Team.Red);

            List <int> blueExpectation = new List <int>()
            {
                0, 1, 2, 3, 4, 5
            };
            List <int> redExpectation = new List <int>()
            {
                6, 7, 8, 9, 10, 11
            };

            Assert.IsTrue(blueResult.SequenceEqual(blueExpectation));
            Assert.IsTrue(redResult.SequenceEqual((redExpectation)));
        }
示例#2
0
        public void TestAllContentInAllSlots()
        {
            AllSlots sut = new AllSlots(new FakeEmptyContentHistory());

            Assert.IsTrue(sut.SlotContentIsInCategory(SlotContent.Player));
            Assert.IsTrue(sut.SlotContentIsInCategory(SlotContent.Bot));
            Assert.IsTrue(sut.SlotContentIsInCategory(SlotContent.Empty));
        }
示例#3
0
 public SlotManager(ISlotContentHistory history)
 {
     Bots    = new BotSlots(history);
     All     = new AllSlots(history);
     Filled  = new FilledSlots(history);
     Empty   = new EmptySlots(history);
     Players = new PlayerSlots(history);
 }
        public void TestAllSlotsContainsAll()
        {
            foreach (var slotObj in Enum.GetValues(typeof(Slots)))
            {
                var slot = (Slots)slotObj;

                if (slot == Slots.NONE || slot == Slots.LAST)
                {
                    // Not real slots, skip these.
                    continue;
                }

                Assert.That(AllSlots.Contains(slot));
            }
        }
示例#5
0
        /// <summary>
        /// Invites a player to the game via battletag.
        /// </summary>
        /// <param name="playerName">Battletag of the player to invite. Is case sensitive. Ex: Tracer#1818</param>
        /// <param name="slot">Slot that the invited player will join.</param>
        /// <returns>Returns true if <paramref name="playerName"/> is a valid battletag.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="playerName"/> is null.</exception>
        public bool InvitePlayer(string playerName, int slot)
        {
            using (LockHandler.Interactive)
            {
                if (playerName == null)
                {
                    throw new ArgumentNullException(nameof(playerName));
                }

                if (!IsSlotValid(slot))
                {
                    throw new InvalidSlotException(slot);
                }

                if (IsSlotInQueue(slot))
                {
                    throw new InvalidSlotException("slot cannot be in queue.");
                }

                if (AllSlots.Contains(slot))
                {
                    return(false);
                }

                LeftClick(Interact.FindSlotLocation(slot));

                LeftClick(Points.INVITE_VIA_BATTLETAG, 100); // click via battletag

                TextInput(playerName);

                Thread.Sleep(200);

                UpdateScreen();

                if (Capture.CompareColor(Points.INVITE_INVITE, Colors.CONFIRM, Fades.CONFIRM))
                {
                    LeftClick(Points.INVITE_INVITE); // invite player
                    //ResetMouse();
                    return(true);
                }
                else
                {
                    LeftClick(Points.INVITE_BACK); // click back
                    //ResetMouse();
                    return(false);
                }
            }
        }
 public AppointmentsForDay(LocalDate date, AppointmentConfig config, List <AppointmentAggregate> slots)
 {
     PrevDateAvailable = config.AvailableIntervalStart == null || config.AvailableIntervalStart < date;
     NextDateAvailable = config.AvailableIntervalEnd == null || date < config.AvailableIntervalEnd;
     Date     = date;
     AllSlots = slots.OrderBy(a => a.From).ToList();
     if (((config.AvailableIntervalStart == null || config.AvailableIntervalStart <= date) &&
          (config.AvailableIntervalEnd == null || date <= config.AvailableIntervalEnd)))
     {
         AvailableSlots = AllSlots.Where(a => a.CanCreateAppointment).ToList();
     }
     else
     {
         AvailableSlots = new List <AppointmentAggregate>();
     }
 }
示例#7
0
 public int GetItemCount(Item item)
 {
     return(AllSlots.Where(slot => slot.CurrentItem.Equals(item)).Sum(slot => slot.Items.Count));
 }
示例#8
0
 public bool ContainItem(Item item)
 {
     return(AllSlots.FirstOrDefault(slot => slot.CurrentItem.Equals(item)));
 }
示例#9
0
        private SlotIdentity GetSlotIdentity(int slot)
        {
            using (LockHandler.Passive)
            {
                if (!AllSlots.Contains(slot))
                {
                    return(null);
                }

                if (slot == 5 && OpenChatIsDefault)
                {
                    Chat.CloseChat();
                }
                if (slot == 0)
                {
                    ResetMouse();
                }

                Point origin = Point.Empty;
                int   width  = 0;
                int   height = 0;

                if (IsSlotBlueOrRed(slot))
                {
                    width  = 158;
                    height = Distances.LOBBY_SLOT_HEIGHT;

                    int comp = slot;
                    if (IsSlotBlue(slot))
                    {
                        origin = new Point(145, 239);
                    }
                    else if (IsSlotRed(slot))
                    {
                        origin = new Point(372, 239);
                        comp  -= 6;
                    }
                    origin.Y += Distances.LOBBY_SLOT_DISTANCE * comp;
                }
                else if (IsSlotSpectatorOrQueue(slot))
                {
                    width  = 158;
                    height = Distances.LOBBY_SPECTATOR_SLOT_HEIGHT;
                    origin = new Point(666, 245);

                    int comp = slot;
                    if (IsSlotSpectator(slot))
                    {
                        origin.Y += FindSpectatorOffset(true);
                        comp     -= SpectatorID;
                    }
                    else if (IsSlotInQueue(slot))
                    {
                        origin.Y -= Distances.LOBBY_QUEUE_OFFSET;
                        comp     -= QueueID;
                    }
                    origin.Y += Distances.LOBBY_SPECTATOR_SLOT_DISTANCE * comp;
                }

                UpdateScreen();
                DirectBitmap identity = Capture.Clone(origin.X, origin.Y, width, height);

                if (slot == 5 && OpenChatIsDefault)
                {
                    Chat.OpenChat();
                }

                return(new SlotIdentity(identity, slot));
            }
        }
示例#10
0
 private InventorySlot GetSlot(Vector2Int position)
 {
     return(AllSlots.FirstOrDefault(s => s.Position.Equals(position)));
 }
示例#11
0
 private IEnumerable <InventorySlot> FindSlots(Item item)
 {
     return(AllSlots.Where(s => s.Item == item));
 }